def startTest(self): # switch to the all view testView = QAUITestAppLib.UITestView(self.logger) # We need to look at the all view testView.SwitchToAllView() # can't do the next two steps because modal dialogs don't work # with emulate_typing # app_ns().root.NewFlickrCollectionByTag() # User.emulate_typing("oscon2005") # this is what we do instead view = self.app_ns.itsView # get a collection of photos from the oscon2005 tag fc = flickr.PhotoCollection(itsView = view) fc.tag = flickr.Tag.getTag(view, "oscon2005") fc.displayName = uw("oscon2005") self.logger.startAction('Get a flickr collection by tag') try: fc.fillCollectionFromFlickr(view, 10, '831f4f96fa5bf41fb9ed1317174ebbbe') except socket.timeout: self.logger.endAction(True, "Flickr timed out; skipping test") except IOError, e: self.logger.endAction(True, "IOError (%s); skipping test" % str(e))
def startTest(self): def testEnabled(event, calendarBlock): # Test that the detail view does display the timezone event.CheckDisplayedValues(EditTimeZone=(True, )) # Test that the calendar view does display the timezone widget self.logger.startAction( "Test that the calendar view does display the timezone widget") if calendarBlock.widget.tzChoice.IsShown(): self.logger.endAction( True, "Timezone widget found when timezones enabled") else: self.logger.endAction( False, "Timezone widget not found even though timezones are enabled" ) def testDisabled(event, calendarBlock): # Test that the detail view does not display the timezone self.logger.startAction( "Test that timezone hidden when not enabled") event.CheckDisplayedValues(EditTimeZone=(False, )) # Test that the calendar view does not displays the timezone widget if calendarBlock.widget.tzChoice.IsShown(): self.logger.endAction( False, "Timezone widget shown incorrectly when timezones not enabled" ) else: self.logger.endAction( True, "Timezone widget correctly hidden when timezones not enabled" ) # make user collection, since only user # collections can be displayed as a calendar col = QAUITestAppLib.UITestItem("Collection", self.logger) # switch to calendar view testView = QAUITestAppLib.UITestView(self.logger) testView.SwitchToCalView() calendarBlock = getattr(self.app_ns, "MainCalendarControl") # Before timezones are enabled, create an event floatingEvent = QAUITestAppLib.UITestItem("Event", self.logger) testDisabled(floatingEvent, calendarBlock) # Enable timezones self.app_ns.root.EnableTimezones() testEnabled(floatingEvent, calendarBlock) # Disable timezones again self.app_ns.root.EnableTimezones() testDisabled(floatingEvent, calendarBlock)
def startTest(self): QAUITestAppLib.startTestInCalView(self.logger) path = os.path.join(Globals.chandlerDirectory, "tools/cats/DataFiles", "TestRecurrence.ics") # Upcast path to unicode since Sharing requires a unicode path path = unicode(path, sys.getfilesystemencoding()) self.logger.startAction('Importing TestRecurrence.ics') collection = sharing.importFile(self.app_ns.itsView, path) self.app_ns.sidebarCollection.add(collection) # select the collection sidebar = self.app_ns.sidebar QAUITestAppLib.scripting.User.emulate_sidebarClick( sidebar, collection.displayName) scripting.User.idle() self.logger.endAction(True, "Importing calendar") def VerifyEventCreation(title): self.logger.startAction("Verify event titled %s exists" % title) testEvent = self.app_ns.item_named(pim.EventStamp, title) if testEvent is not None: self.logger.endAction(True, " '%s' exists" % title) else: self.logger.endAction(False, "'%s' not created" % title) scripting.User.idle() VerifyEventCreation("Yearly Never End") VerifyEventCreation("Monthly Meeting") VerifyEventCreation("Multi-All Day") VerifyEventCreation("All-day never end") # bug 5593, set an end date for the "Weekly Never End" event sidebar = self.app_ns.sidebar scripting.User.emulate_sidebarClick(sidebar, 'TestRecurrence') view = QAUITestAppLib.UITestView(self.logger) # Need to format date the same way the detail view does uiView = wx.GetApp().UIRepositoryView goto = datetime.date(2006, 5, 1) value = datetime.datetime.combine( goto, datetime.time(0, tzinfo=uiView.tzinfo.default)) dateStr = pim.shortDateFormat.format(uiView, value) view.GoToDate(dateStr) event = QAUITestAppLib.GetOccurrence('Weekly Never End', goto) QAUITestAppLib.UITestItem(event, self.logger).SetAttr(recurrenceEnd=dateStr) # event has been deleted by changing recurrence, get a new one event = QAUITestAppLib.GetOccurrence('Weekly Never End', goto) testItem = QAUITestAppLib.UITestItem(event, self.logger) testItem.SelectItem(catchException=True) # Make sure this occurrence exists and was able to be selected testItem.Check_ItemSelected()
def startTest(self): # make user collection, since only user # collections can be displayed as a calendar col = QAUITestAppLib.UITestItem("Collection", self.logger) QAUITestAppLib.UITestView(self.logger).SwitchToCalView() # creation testView = QAUITestAppLib.UITestView(self.logger) # action # switch to all view testView.SwitchToAllView() # switch to tasks view testView.SwitchToTaskView() # switch to calendar view testView.SwitchToCalView()
def startTest(self): # make user collection, since only user # collections can be displayed as a calendar col = QAUITestAppLib.UITestItem("Collection", self.logger) # switch to calendar view testView = QAUITestAppLib.UITestView(self.logger) testView.SwitchToCalView() calendarBlock = getattr(self.app_ns, "MainCalendarControl") # Find the "canonical timezone" to use in test comparisons view = self.app_ns.itsView info = TimeZoneInfo.get(view) originalTz = info.canonicalTimeZone(view.tzinfo.default).tzid switchTz = "Pacific/Honolulu" # Enable timezones so that we can switch from the UI self.app_ns.root.EnableTimezones() # Create a new event, which should inherit the default tz timezoneEvent = QAUITestAppLib.UITestItem("Event", self.logger) # Test that the new event has indeed inherited the default tz timezoneEvent.CheckDisplayedValues(EditTimeZone=(True, originalTz)) # Change the timezone to Pacific/Honolulu QAUITestAppLib.SetChoice(calendarBlock.widget.tzChoice, switchTz) # Test that the event timezone hasn't changed timezoneEvent.CheckDisplayedValues(EditTimeZone=(True, originalTz)) # Test that the default timezone has switched self.logger.startAction("Verify timezone switched") if view.tzinfo.setDefault(view.tzinfo.getInstance(switchTz)): self.logger.endAction(True, "Timezone switched") else: self.logger.endAction(False, "Timezone failed to switch") # @@@ More interesting tests could be added here # Switch back to original timezone QAUITestAppLib.SetChoice(calendarBlock.widget.tzChoice, originalTz)
def startTest(self): #make sure we start in the calendar view QAUITestAppLib.UITestItem("Collection", self.logger) QAUITestAppLib.UITestView(self.logger).SwitchToCalView() # creation col = QAUITestAppLib.UITestItem("Collection", self.logger) col.SetDisplayName(uw("ToBeDeleted")) # action sb = self.app_ns.sidebar # move focus from collection name text to collection. This # requires 2 clicks scripting.User.emulate_sidebarClick(sb, uw("ToBeDeleted")) scripting.User.emulate_sidebarClick(sb, uw("ToBeDeleted")) col.DeleteCollection() # verification col.Check_CollectionExistence(expectedResult=False)
def startTest(self): today = strftime('%m/%d/%Y', localtime()) view = QAUITestAppLib.UITestView(self.logger) #Create a collection and select it collection = QAUITestAppLib.UITestItem("Collection", self.logger) collection.SetDisplayName(uw("stacked")) sidebar = self.app_ns.sidebar QAUITestAppLib.scripting.User.emulate_sidebarClick( sidebar, uw("stacked")) # Make sure we are in calendar view, need to do this AFTER creating a # collection, or we might be in the dashboard view.SwitchToCalView() #make sure we are on current week view.GoToToday() # creation for i in range(10): eventName = uw('Stacked Event %d' % i) event = QAUITestAppLib.UITestItem("Event", self.logger) #action event.SetAttr(displayName=eventName, startDate=today, startTime="12:00 PM", body=uw("Stacked event test")) #verification event.Check_DetailView({ "displayName": eventName, "startDate": today, "endDate": today, "startTime": "12:00 PM", "body": uw("Stacked event test") })
def startTest(self): # creation testView = QAUITestAppLib.UITestView(self.logger) # make user collection, since only user # collections can be displayed as a calendar col = QAUITestAppLib.UITestItem("Collection", self.logger) #name and then select collection col.SetDisplayName(uw("testCalView")) sb = QAUITestAppLib.App_ns.sidebar User.emulate_sidebarClick(sb, uw('testCalView')) # action # switch to calendar view testView.SwitchToCalView() # double click in the calendar view => event creation or selection ev = testView.DoubleClickInCalView() QAUITestAppLib.scripting.User.emulate_typing(uw("Writing tests")) QAUITestAppLib.scripting.User.emulate_return() # verification # check the detail view of the created event ev.Check_DetailView({"displayName":uw("Writing tests")})
def startTest(self): # test edit on enter for collection names # creation testCollection = QAUITestAppLib.UITestItem("Collection", self.logger) # action 1 test collection name # use enter to shift to edit mode testCollection.SelectItem() QAUITestAppLib.scripting.User.emulate_return() QAUITestAppLib.scripting.User.emulate_typing(uw("NoLongerUntitled")) # use enter to leave edit mode #except it doesn't work, focus somewhere else for the time being #QAUITestAppLib.scripting.User.emulate_return() testCollection.FocusInDetailView() #verification 1 testCollection.Check_CollectionExistence(uw("NoLongerUntitled")) # switch to summary view QAUITestAppLib.UITestView(self.logger).SwitchToAllView() # test edit on enter for summary view rows # creation 2 testEvent = QAUITestAppLib.UITestItem("Event", self.logger) # action 2 testEvent.SelectItem() QAUITestAppLib.scripting.User.emulate_return() #QAUITestAppLib.scripting.User.emulate_return() #until bug 5744 resolved 2 returns needed QAUITestAppLib.scripting.User.emulate_typing(uw("Your title here")) #QAUITestAppLib.scripting.User.emulate_return()#emulate_return doesn't work here either at svn r9900 testCollection.FocusInDetailView() # verification 2 # check the detail view of the created event testEvent.Check_DetailView({"displayName":uw("Your title here")})
def startTest(self): # resize the Chandler window to (1024,720): this test sort of crumble if the window is too small frame = wx.GetApp().mainFrame frame.SetSize((1024, 720)) #Create a collection and select it collection = QAUITestAppLib.UITestItem("Collection", self.logger) collection.SetDisplayName(uw("Delete and Remove")) sidebar = self.app_ns.sidebar QAUITestAppLib.scripting.User.emulate_sidebarClick( sidebar, uw("Delete and Remove")) # creation note = QAUITestAppLib.UITestItem("Note", self.logger) # actions note.SetAttr(displayName=uw("A note to move to Trash"), body=uw("TO MOVE TO TRASH")) # Work around nasty bug in QAUITestAppLib caused by not propagating notificatons correctly application = wx.GetApp() application.propagateAsynchronousNotifications() application.Yield(True) note.RemoveFromCollection() note.Check_ItemInCollection(uw("Delete and Remove"), expectedResult=False) note.Check_ItemInCollection("Trash", expectedResult=False) note.Check_ItemInCollection("Dashboard") note.AddCollection(uw("Delete and Remove")) note.Check_ItemInCollection(uw("Delete and Remove")) note.MoveToTrash() # verification note.Check_ItemInCollection("Trash") note.Check_ItemInCollection("Dashboard", expectedResult=False) today = strftime('%m/%d/%Y', localtime()) view = QAUITestAppLib.UITestView(self.logger) view.SwitchToCalView() view.GoToToday() sidebar = QAUITestAppLib.App_ns.sidebar col = QAUITestAppLib.UITestItem("Collection", self.logger) col.SetDisplayName(uw("Trash testing")) scripting.User.emulate_sidebarClick(sidebar, uw('Trash testing')) event = QAUITestAppLib.UITestItem("Event", self.logger) event.SetAttr(startDate=today, startTime="12:00 PM", displayName=uw("Ephemeral event")) event.SelectItem() event.Check_ItemInCollection("Dashboard", expectedResult=True) event.Check_ItemSelected() event.MoveToTrash() # This is perhaps not necessary for the test, but it used to # be here. It cannot be enabled until bug XXX is fixed. #scripting.User.emulate_sidebarClick(sidebar, 'Dashboard') event.SelectItem(catchException=True) event.Check_ItemInCollection("Trash") event.Check_ItemInCollection("Dashboard", expectedResult=False) event.Check_ItemSelected(expectedResult=False)
def startTest(self): # make user collection, since only user # collections can be displayed as a calendar col = QAUITestAppLib.UITestItem("Collection", self.logger) # creation dailyEvent = QAUITestAppLib.UITestItem("Event", self.logger) # action dailyEvent.SetAttr( displayName=uw("Daily Exercise"), startDate="01/01/2006", startTime="6:00 AM", location=uw("Gym"), status="FYI", body=uw("Resolution: exercise daily for optimal health"), timeZone="America/Chicago", recurrence="Daily", recurrenceEnd="03/01/2006") # verification dailyEvent.Check_DetailView({ "displayName": uw("Daily Exercise"), "startDate": "1/1/2006", "endDate": "1/1/2006", "startTime": "6:00 AM", "endTime": "7:00 AM", "location": uw("Gym"), "status": "FYI", "body": uw("Resolution: exercise daily for optimal health"), "timeZone": "America/Chicago", "recurrence": "Daily", "recurrenceEnd": "3/1/2006" }) dailyEvent.Check_Object({ "displayName": uw("Daily Exercise"), "startDate": "1/1/2006", "endDate": "1/1/2006", "startTime": "6:00 AM", "endTime": "7:00 AM", "location": uw("Gym"), "status": "FYI", "body": uw("Resolution: exercise daily for optimal health"), "timeZone": "America/Chicago" }) # Weekly Event Test # creation weeklyEvent = QAUITestAppLib.UITestItem("Event", self.logger) # action weeklyEvent.SetAttr( displayName=uw("Weekly call home"), startDate="01/07/2006", startTime="5:00 PM", location=uw("Phone"), status="FYI", body=uw("Resolution: call home weekly for good family relations"), timeZone="America/Chicago", recurrence="Weekly", recurrenceEnd="03/25/2006") # verification weeklyEvent.Check_DetailView({ "displayName": uw("Weekly call home"), "startDate": "1/7/2006", "endDate": "1/7/2006", "startTime": "5:00 PM", "endTime": "6:00 PM", "location": uw("Phone"), "status": "FYI", "body": uw("Resolution: call home weekly for good family relations"), "timeZone": "America/Chicago", "recurrence": "Weekly", "recurrenceEnd": "3/25/2006" }) weeklyEvent.Check_Object({ "displayName": uw("Weekly call home"), "startDate": "1/7/2006", "endDate": "1/7/2006", "startTime": "5:00 PM", "endTime": "6:00 PM", "location": uw("Phone"), "status": "FYI", "body": uw("Resolution: call home weekly for good family relations"), "timeZone": "America/Chicago" }) # Monthly Event Test # creation monthlyEvent = QAUITestAppLib.UITestItem("Event", self.logger) # action monthlyEvent.SetAttr( displayName=uw("Monthly book club"), startDate="01/01/2006", startTime="7:00 PM", endTime="9:00 PM", location=uw("My house"), status="CONFIRMED", body=uw("Resolution: host book club once a month"), timeZone="America/Chicago", recurrence="Monthly", recurrenceEnd="12/31/2006") # verification monthlyEvent.Check_DetailView({ "displayName": uw("Monthly book club"), "startDate": "1/1/2006", "endDate": "1/1/2006", "startTime": "7:00 PM", "endTime": "9:00 PM", "location": uw("My house"), "status": "Confirmed", "body": uw("Resolution: host book club once a month"), "timeZone": "America/Chicago", "recurrence": "Monthly", "recurrenceEnd": "12/31/2006" }) monthlyEvent.Check_Object({ "displayName": uw("Monthly book club"), "startDate": "1/1/2006", "endDate": "1/1/2006", "startTime": "7:00 PM", "endTime": "9:00 PM", "location": uw("My house"), "status": "CONFIRMED", "body": uw("Resolution: host book club once a month"), "timeZone": "America/Chicago" }) # Yearly Event Test # creation yearlyEvent = QAUITestAppLib.UITestItem("Event", self.logger) # action yearlyEvent.SetAttr( displayName=uw("Yearly dentist appointment"), startDate="02/06/2004", startTime="10:00 AM", location=uw("Downtown"), status="CONFIRMED", body=uw("Resolution: get teeth cleaned once a year"), timeZone="America/Los_Angeles", recurrence="Yearly", recurrenceEnd="02/07/2050") # verification yearlyEvent.Check_DetailView({ "displayName": uw("Yearly dentist appointment"), "startDate": "2/6/2004", "endDate": "2/6/2004", "startTime": "10:00 AM", "endTime": "11:00 AM", "location": uw("Downtown"), "status": "Confirmed", "body": uw("Resolution: get teeth cleaned once a year"), "timeZone": "America/Los_Angeles", "recurrence": "Yearly", "recurrenceEnd": "2/7/2050" }) yearlyEvent.Check_Object({ "displayName": uw("Yearly dentist appointment"), "startDate": "2/6/2004", "endDate": "2/6/2004", "startTime": "10:00 AM", "endTime": "11:00 AM", "location": uw("Downtown"), "status": "CONFIRMED", "body": uw("Resolution: get teeth cleaned once a year"), "timeZone": "America/Los_Angeles" }) # Test stamping of recurring events # @@@ unstamping eventness on recurring events is hard to define # Test that the communication stamp applies to all yearlyEvent.StampAsMailMessage(True) self.logger.startAction( "Check communication stamp applies to all occurrences") firstOccurrence = pim.EventStamp(yearlyEvent.item).getFirstOccurrence() secondOccurrence = firstOccurrence.getNextOccurrence() if not pim.has_stamp(secondOccurrence, pim.MailStamp): self.logger.endAction( False, "The second occurrence didn't get the MailStamp") yearlyEvent.StampAsMailMessage(False) if pim.has_stamp(secondOccurrence, pim.MailStamp): self.logger.endAction( False, "The second occurrence didn't lose the MailStamp") # switch to the table view, make sure there are appropriate triageStatus # modifications. These tests will fail if run before Feb. 2006 or after # Feb. 2050. view = QAUITestAppLib.UITestView(self.logger) view.SwitchToAllView() dashboardBlock = self.app_ns.DashboardSummaryView def getTriageStatusDict(title): """ Get a dictionary mapping triage status to lists of items with the given title. """ dictionary = dict() for status in pim.TriageEnum.constants: dictionary[status] = [] for item in dashboardBlock.contents: if item.displayName == title: dictionary[item.triageStatus].append(item) return dictionary def checkDictNumbers(done, later, now): statuses = getTriageStatusDict(uw("Yearly dentist appointment")) if len(statuses[pim.TriageEnum.done]) != done: self.logger.endAction( False, 'Wrong number of Done items, %s instead of %s' % (len(statuses[pim.TriageEnum.done]), done)) elif len(statuses[pim.TriageEnum.later]) != later: self.logger.endAction( False, 'Wrong number of Later items, %s instead of %s' % (len(statuses[pim.TriageEnum.later]), later)) elif len(statuses[pim.TriageEnum.now]) != now: self.logger.endAction( False, 'Wrong number of Now items, %s instead of %s' % (len(statuses[pim.TriageEnum.now]), now)) self.logger.startAction("Check initial modification states.") checkDictNumbers(1, 1, 0) self.logger.endAction(True) statuses = getTriageStatusDict(uw("Yearly dentist appointment")) changing_item = statuses[pim.TriageEnum.done][0] self.logger.startAction("Change a Done to Now.") # moved the Done to Now, created a new Done changing_item.setTriageStatus(pim.TriageEnum.now) checkDictNumbers(0, 1, 1) pim.EventStamp(changing_item).updateTriageStatus() # triage changes need to be purged to generate a new Done checkDictNumbers(1, 1, 1) self.logger.endAction(True) self.logger.startAction("Change the now back to Done.") changing_item.setTriageStatus(pim.TriageEnum.done) checkDictNumbers(2, 1, 0) pim.EventStamp(changing_item).updateTriageStatus() checkDictNumbers(1, 1, 0) self.logger.endAction(True)
def startTest(self): view = QAUITestAppLib.UITestView(self.logger) view.SwitchToAllView() self.logger.startAction("Testing reminder processing") repoView = self.app_ns.itsView reminderDialog = wx.FindWindowByName(u'ReminderDialog') if reminderDialog is not None: self.logger.endAction(False, "Reminder dialog presented too soon?!") return self.collection = QAUITestAppLib.UITestItem("Collection", self.logger) colName = uw("TestReminderProcessing") self.collection.SetDisplayName(colName) self.scripting.User.emulate_sidebarClick(self.app_ns.sidebar, colName) # We'll create a few items with interesting times coming up testTime = datetime.now(tz=repoView.tzinfo.default).replace(microsecond=0) \ + timedelta(seconds=1) nearFutureDelta = timedelta(seconds=nearFutureSeconds) nearFutureReminderDelta = timedelta(seconds=nearFutureSeconds / -2) nearFuture = testTime + nearFutureDelta nearFutureReminder = nearFuture + nearFutureReminderDelta logger.critical("testTime=%s, nearFutureReminder=%s, nearFuture=%s", testTime, nearFutureReminder, nearFuture) # An ordinary event with relative and triageStatus reminders simpleEvent = self._makeEvent("Simple Event", nearFuture) simpleEvent.userReminderInterval = nearFutureReminderDelta self._checkRemindersOn(simpleEvent, userTime=nearFutureReminderDelta, userExpired=False, triageStatusTime=nearFuture, triageStatus=pim.TriageEnum.later) # A recurring event that hasn't started yet. We start with # an event with an absolute reminder just before its startTime. futureRecurrerNormal = self._makeEvent("Recurrer: Future", nearFuture) futureRecurrerNormal.itsItem.userReminderTime = nearFutureReminder self._checkRemindersOn(futureRecurrerNormal, userTime=nearFutureReminder, userExpired=False, triageStatusTime=nearFuture) # Making it recur should: convert the absolute reminder to a relative # one, leaving the relative reminder on the master's 'expired' list # but pending on the first occurrence. It should also get rid of the # triageStatus reminder. nextOccurrence = self._makeRecur(futureRecurrerNormal, testTime) # Let the app pick up any reminder firing changes scripting.User.idle() # Individual occurrences don't get their own reminders (unless you # make a change). self.failunless( futureRecurrerNormal.itsItem.reminders is nextOccurrence.itsItem.reminders, "occurrence shouldn't have its own reminders reflist") self._checkRemindersOn(futureRecurrerNormal, userTime=nearFutureReminderDelta, userExpired=False, triageStatusTime=nearFuture) # A recurring event that started in the past, so the second occurrence # is in the near future pastTime = testTime - (timedelta(days=7) - nearFutureDelta) pastRecurrerNormal = self._makeEvent("Recurrer: Past", pastTime) pastRecurrerNormal.userReminderInterval = timedelta(0) scripting.User.idle() self._checkRemindersOn(pastRecurrerNormal, userTime=timedelta(0), userExpired=True, triageStatusTime=None) secondOccurrence = self._makeRecur(pastRecurrerNormal, testTime) firstOccurrence = pastRecurrerNormal.getFirstOccurrence() self.failunlessequal(firstOccurrence.getNextOccurrence(), secondOccurrence, "2nd occurrence isn't the one after first") self._checkRemindersOn(firstOccurrence, userTime=timedelta(0), userExpired=True, triageStatusTime=None) self._checkRemindersOn(secondOccurrence, userTime=timedelta(0), userExpired=False, triageStatusTime=None) # Iterate until all the processing is complete, or we hit our timeout timeOut = nearFuture + timedelta(seconds=nearFutureSeconds * 2) state = "Waiting for reminder dialog" # @@@ [grant] Is this actually right ... ? allFutureReminders = schema.ns('osaf.pim', repoView).allFutureReminders testReminderItems = list( event.itsItem for event in (simpleEvent, futureRecurrerNormal, nextOccurrence, pastRecurrerNormal, firstOccurrence, secondOccurrence)) logger.critical(state) clicked = False while True: now = datetime.now(tz=repoView.tzinfo.default) repoView.dispatchQueuedNotifications() scripting.User.idle() if now > timeOut: self.logger.endAction( False, "Reminder processing didn't complete (%s)" % state) return reminderDialog = wx.FindWindowByName(u'ReminderDialog') if state == "Waiting for reminder dialog": if reminderDialog is not None: state = "Dismissing reminders" logger.critical(state) continue if reminderDialog is not None: # The reminder dialog is up. Hit its dismiss button. dismissWidget = reminderDialog.reminderControls['dismiss'] self.failunless( dismissWidget.IsEnabled(), "Reminder dialog up, but dismiss button disabled? That's just wrong." ) scripting.User.emulate_click(dismissWidget) clicked = True continue # The reminder dialog isn't up. Skip out when none of our items have # pending reminders if clicked and now > nearFuture + timedelta(seconds=1): foundPending = False for pending in pim.PendingReminderEntry.getKind( repoView).iterItems(): if pending.item in testReminderItems: break else: state = "Reminders done" logger.critical(state) break self.failunlessequal(state, "Reminders done", "Reminder-processing timeout") # Check each reminder logger.critical("Checking reminders, post-dismissal") self._checkRemindersOn(simpleEvent, userTime=nearFutureReminderDelta, userExpired=True, triageStatusTime=None, triageStatus=pim.TriageEnum.now) self._checkRemindersOn(firstOccurrence, userTime=timedelta(0), userExpired=True, triageStatusTime=None) self._checkRemindersOn(secondOccurrence, userTime=timedelta(0), userExpired=True, triageStatusTime=None) thirdOccurrence = secondOccurrence.getNextOccurrence() self._checkRemindersOn(thirdOccurrence, userTime=timedelta(0), userExpired=False, triageStatusTime=None) self.logger.endAction(True)
def startTest(self): def mondayPlus(inc=0): """return a m/d/yy date string equal to this Monday plus inc days""" today = datetime.date.today() daysUntilMonday = today.weekday() if daysUntilMonday == 6: daysUntilMonday = -1 #sunday is special case monday = today - datetime.timedelta(days=daysUntilMonday) incDay = monday + datetime.timedelta(days=inc) view = wx.GetApp().UIRepositoryView value = datetime.datetime.combine( incDay, datetime.time(0, tzinfo=view.tzinfo.default)) dateStr = shortDateFormat.format(view, value) return dateStr # resize the Chandler window to (1024,720): this test sort of crumble if the window is too small frame = wx.GetApp().mainFrame frame.SetSize((1024, 720)) # switch to calendar view testView = QAUITestAppLib.UITestView(self.logger) testView.SwitchToCalView() # make user collection, since only user # collections can be displayed as a calendar col = QAUITestAppLib.UITestItem("Collection", self.logger) evtDate = mondayPlus() evtSecondDate = mondayPlus(1) evtThirdDate = mondayPlus(2) evtRecurrenceEnd = mondayPlus(365) evtNextWeek = mondayPlus(7) # Make sure we're not showing timezones now (we'll put it back below) tzPrefs = schema.ns('osaf.pim', QAUITestAppLib.App_ns.itsView).TimezonePrefs oldTZPref = tzPrefs.showUI tzPrefs.showUI = False # Create a vanilla event; leave the timezone alone so we can make sure # it's floating. event = QAUITestAppLib.UITestItem("Event", self.logger) event.SetAttr(displayName=uw("Birthday Party"), startDate=evtDate, startTime="6:00 PM", location=uw("Club101"), status="FYI", body=uw("This is a birthday party invitation")) # Check a few things: that those attributes got set right, plus # a few defaulty things worked (timezone, endtime) event.CheckDisplayedValues( "Checking initial setup", HeadlineBlock=(True, uw("Birthday Party")), EditAllDay=(True, False), EditCalendarStartDate=(True, evtDate), CalendarStartAtLabel=(True, ), EditCalendarStartTime=(True, "6:00 PM"), EditCalendarEndDate=(True, evtDate), CalendarEndAtLabel=(True, ), EditCalendarEndTime=(True, "7:00 PM"), CalendarLocation=(True, uw("Club101")), EditTransparency=(True, "FYI"), NotesBlock=(True, uw("This is a birthday party invitation")), EditTimeZone=(False, "None")) # Not visible with timezones off # Toggle allday, then make sure the right changes happened. event.SetAttr("Setting allDay", allDay=True) event.CheckDisplayedValues( "Checking allday", HeadlineBlock=(True, uw("Birthday Party")), EditAllDay=(True, True), EditCalendarStartDate=(True, evtDate), CalendarStartAtLabel=(False, ), EditCalendarStartTime=(False, ), EditCalendarEndDate=(True, evtDate), CalendarEndAtLabel=(False, ), EditCalendarEndTime=(False, ), ) # Turn on timezones, turn off alldayness, and make sure the popup appears tzPrefs.showUI = True event.SetAttr("Setting explicit timezone", allDay=False, timeZone='America/Denver') event.CheckDisplayedValues( "Changed Timezone", HeadlineBlock=(True, uw("Birthday Party")), EditTimeZone=(True, 'America/Denver'), EditCalendarStartDate=(True, evtDate), EditCalendarEndDate=(True, evtDate), EditCalendarStartTime=( True, ), # could check the time here if I knew the local tz EditCalendarEndTime=(True, ), CalendarStartAtLabel=(True, ), CalendarEndAtLabel=(True, )) # Make it recur event.SetAttr("Making it recur", recurrence="Daily", recurrenceEnd=evtRecurrenceEnd) scripting.User.idle() event.CheckDisplayedValues("Checking recurrence", EditRecurrence=(True, "Daily"), EditRecurrenceEnd=(True, evtRecurrenceEnd)) # Select the second occurrence and delete it masterEvent = EventStamp(event.item) secondEvent = QAUITestAppLib.UITestItem( masterEvent.getFirstOccurrence().getNextOccurrence(), self.logger) secondEvent.SelectItem() secondEvent.CheckDisplayedValues( "Checking 2nd occurrence", EditCalendarStartDate=(True, evtSecondDate), ) secondEvent.MoveToTrash() scripting.User.idle() # Answer the recurrence question with "just this item" self.logger.startAction('Test recurrence dialog') recurrenceDialog = wx.FindWindowByName(u'RecurrenceDialog') if recurrenceDialog is None: self.logger.endAction( False, "Didn't see the recurrence dialog when deleting a recurrence instance" ) else: scripting.User.emulate_click(recurrenceDialog.thisButton) scripting.User.idle() self.logger.endAction(True) # Make sure the new second occurrence starts on the right date thirdEvent = QAUITestAppLib.UITestItem( masterEvent.getFirstOccurrence().getNextOccurrence(), self.logger) thirdEvent.SelectItem() thirdEvent.CheckDisplayedValues( "After deleting second occurrence", HeadlineBlock=(True, uw("Birthday Party")), EditCalendarStartDate=(True, evtThirdDate), ) # Create an event in a future week futureEvent = QAUITestAppLib.UITestItem("Event", self.logger) futureEvent.SetAttr(displayName=uw("Future Weekly"), startDate=evtNextWeek, startTime="6:00 PM", recurrence="Weekly", body=uw("This is an event in the future")) futureEvent.CheckDisplayedValues( "Checking future recurring event", HeadlineBlock=(True, uw("Future Weekly")), EditAllDay=(True, False), EditCalendarStartDate=(True, evtNextWeek), CalendarStartAtLabel=(True, ), EditCalendarStartTime=(True, "6:00 PM"), EditCalendarEndDate=(True, evtNextWeek), CalendarEndAtLabel=(True, ), EditCalendarEndTime=(True, "7:00 PM"), NotesBlock=(True, uw("This is an event in the future"))) #leave Chandler with timezones turned off tzPrefs.showUI = False
def startTest(self): ITEM_COUNT = 12 # create a collection and some test items col = QAUITestAppLib.UITestItem("Collection", self.logger) view = QAUITestAppLib.UITestView(self.logger) col.SetDisplayName("TestTableSelection") self.scripting.User.emulate_sidebarClick(self.app_ns.sidebar, "TestTableSelection") alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" items = [] for i in xrange(ITEM_COUNT): mail = QAUITestAppLib.UITestItem("MailMessage", self.logger) # make sure the sorting is different for To vs. Subject, # and that the sort by Subject will be the order we're adding them. mail.SetAttr(displayName="%s Mail Message" % alpha[i], toAddress="*****@*****.**" % (ITEM_COUNT - i)) items.append(mail.item) # action self.logger.startAction("Test summary view") dashboardBlock = self.app_ns.DashboardSummaryView dashboard = dashboardBlock.widget header_widget = dashboard.GetGridColLabelWindow() # Select the About column aboutMiddle = sum(dashboard.GetColSize(i) for i in range(3)) + \ dashboard.GetColSize(3) / 2 self.scripting.User.emulate_click(header_widget, aboutMiddle, 3) self.scripting.User.idle() rowsToSelect = [1, 3, 4, 9, 11] rowHeight = dashboard.GetDefaultRowSize() rowMiddle = rowHeight / 2 # select the first row self.scripting.User.emulate_click( dashboard, 100, rowsToSelect[0] * rowHeight + rowMiddle) # select 3 more rows, with control key down for multi selection # except for mac which wants the meta key held down if sys.platform == 'darwin': for row in rowsToSelect[1:]: self.scripting.User.idle() self.scripting.User.emulate_click(dashboard, 100, rowHeight * row + rowMiddle, meta=True) else: for row in rowsToSelect[1:]: self.scripting.User.idle() self.scripting.User.emulate_click(dashboard, 100, rowHeight * row + rowMiddle, control=True) self.logger.endAction(True) # verification # check selection indexes expectedIndexes = [(1, 1), (3, 4), (9, 9), (11, 11)] view.Check_Equality(expectedIndexes, list(dashboardBlock.contents.getSelectionRanges()), "Table Selection Ranges") # check selected items by collection indexes expectedItems = [items[row] for row in rowsToSelect] expectedItems.sort(key=lambda x: x.itsUUID) selectionByUUID = list(dashboardBlock.contents.iterSelection()) selectionByUUID.sort(key=lambda x: x.itsUUID) view.Check_Equality(expectedItems, selectionByUUID, "Table Selection by Item") # check the grid widget itself to make sure the right rows are # selected visually. expectedRows = [(i, i) for i in rowsToSelect] topLeft = [i for i, j in dashboard.GetSelectionBlockTopLeft()] bottomRight = [i for i, j in dashboard.GetSelectionBlockBottomRight()] gridSelectedRows = zip(topLeft, bottomRight) view.Check_Equality(expectedRows, gridSelectedRows, "Table grid selection") # # reverse the table, and make sure we're still selecting the same items # self.scripting.User.emulate_click(header_widget, aboutMiddle, 3) self.scripting.User.idle() newSelectedItems = list(dashboardBlock.contents.iterSelection()) newSelectedItems.sort(key=lambda x: x.itsUUID) view.Check_Equality(expectedItems, newSelectedItems, "Selection by item after reversing") # now sort by Who and check again whoMiddle = sum(map(lambda c: c.width, dashboardBlock.columns[0:2])) + \ (dashboardBlock.columns[2].width / 2) self.scripting.User.emulate_click(header_widget, whoMiddle, 3) newSelectedItems = list(dashboardBlock.contents.iterSelection()) newSelectedItems.sort(key=lambda x: x.itsUUID) view.Check_Equality(expectedItems, newSelectedItems, "Selection by item after sorting by Who") # now sort by triage status (which uses sectioning) and check again triageStatusMiddle = sum(map(lambda c: c.width, dashboardBlock.columns)) - \ (dashboardBlock.columns[-1].width / 2) self.scripting.User.emulate_click(header_widget, triageStatusMiddle, 3) newSelectedItems = list(dashboardBlock.contents.iterSelection()) newSelectedItems.sort(key=lambda x: x.itsUUID) view.Check_Equality( expectedItems, newSelectedItems, "Selection by item after sorting by Triage Status")
def startTest(self): # setup # create a collection and select it in the sidebar view = QAUITestAppLib.UITestView(self.logger) view.SwitchToAllView() col = QAUITestAppLib.UITestItem("Collection", self.logger) col.SetDisplayName("TestTriageSectioning") self.scripting.User.emulate_sidebarClick(self.app_ns.sidebar, "TestTriageSectioning") items = [] for status in pim.TriageEnum.constants: item = QAUITestAppLib.UITestItem("Note", self.logger) item.item.setTriageStatus(status) items.append(item) # Let the display catch up to the items self.scripting.User.idle() self.scripting.User.idle() # Get ready to bang on the dashboard dashboardBlock = self.app_ns.DashboardSummaryView dashboard = dashboardBlock.widget rowHeight = dashboard.GetDefaultRowSize() rowMiddle = rowHeight/2 header_widget = dashboard.GetGridColLabelWindow() # sort by triage status (already sorted that way) #self.scripting.User.emulate_click(header_widget, header_widget.GetSize()[0] - 15, 3) self.scripting.User.idle() # Check the data structures: see that we're sectioned properly # for a table with three items of different status: # (The sectioning values are the row index, the number of visible items # in the section, and the total number of items in the section) goodDefaultSectioning = [(0, 1, 1), (2, 1, 1), (4, 1, 1)] sectionRows = getattr(dashboard, 'sectionRows', None) self.logger.startAction('Check Sectioning') if not sectionRows: self.logger.endAction(False, "Dashboard not sectioned") else: self.logger.endAction(True) self.logger.startAction('Check section expansion') if sectionRows != goodDefaultSectioning: self.logger.endAction(False, "Dashboard not sectioned properly: %r != %r" % (sectionRows, goodDefaultSectioning)) else: self.logger.endAction(True) # Check that contraction and expansion work. for row in (4, 2): self.scripting.User.emulate_click(dashboard, 12, row*rowHeight + rowMiddle) self.scripting.User.idle() onlyNowSectioning = [(0, 1, 1), (2, 0, 1), (3, 0, 1)] self.logger.startAction('Check changed section expansion') if dashboard.sectionRows != onlyNowSectioning: self.logger.endAction(False, "Dashboard not sectioned properly: %r != %r" % (sectionRows, onlyNowSectioning)) else: self.logger.endAction(True) # Check that contraction and expansion work. for row in (3, 2, 0): self.scripting.User.emulate_click(dashboard, 12, row*rowHeight + rowMiddle) self.scripting.User.idle() self.logger.startAction('Check toggling') goodToggledSectioning = [(0, 0, 1), (1, 1, 1), (3, 1, 1)] if dashboard.sectionRows != goodToggledSectioning: self.logger.endAction(False, "Dashboard didn't toggle properly: %r != %r" % (sectionRows, goodToggledSectioning)) else: self.logger.endAction(True)