class TestClockTestAllItemsPresentNewAlarm(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() def test_all_items_present_new_alarm(self): # Wait for the new alarm screen to load new_alarm = self.clock.tap_new_alarm() # Ensure label has the default placeholder and text self.assertEquals(new_alarm.alarm_label_placeholder, 'Alarm') self.assertEquals(new_alarm.alarm_label, 'Alarm') # Ensure repeat has the default value self.assertEquals(new_alarm.alarm_repeat, 'Never') # Ensure sound has the default value self.assertEquals(new_alarm.alarm_sound, 'Classic Buzz') # Ensure snooze has the default value self.assertEquals(new_alarm.alarm_snooze, '5 minutes') def tearDown(self): # delete any existing alarms self.data_layer.delete_all_alarms() GaiaTestCase.tearDown(self)
def tap_done(self): self.wait_for_element_displayed(*self._done_locator) self.marionette.find_element(*self._done_locator).tap() clock = Clock(self.marionette) clock.wait_for_banner_displayed() return clock
def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() self.data_layer.set_setting('time.clock.automatic-update.enabled', False)
class TestCardsViewTwoApps(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.cards_view = CardsView(self.marionette) self.clock = Clock(self.marionette) self.clock.launch() self.gallery = Gallery(self.marionette) self.gallery.launch(empty=True) def test_kill_app_from_cards_view(self): """https://moztrap.mozilla.org/manage/case/1917/""" # Pull up the cards view self.device.hold_home_button() self.cards_view.wait_for_cards_view() # Wait for first app ready self.cards_view.cards[1].wait_for_centered() self.assertIn(self.cards_view.cards[1].manifest_url, self.gallery.manifest_url) # Close the current apps from the cards view self.cards_view.cards[1].close() self.cards_view.cards[0].close() # If successfully killed, the apps should no longer appear in the cards view and the "No recent apps" message should be displayed self.assertEqual(len(self.cards_view.cards), 0, 'Should have no cards to display')
class TestClockTurnOnOffAlarm(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() # create a new alarm with the default values that are available new_alarm = self.clock.tap_new_alarm() self.clock = new_alarm.tap_done() self.clock.wait_for_banner_not_visible() def test_clock_turn_on_off_alarm(self): """ Turn on/off the alarm https://moztrap.mozilla.org/manage/case/1779/ """ alarm = self.clock.alarms[0] # turn on the alarm origin_alarm_checked = alarm.is_alarm_active alarm.tap_checkbox() alarm.wait_for_alarm_to_uncheck() self.assertTrue(origin_alarm_checked != alarm.is_alarm_active, 'user should be able to turn on the alarm.') origin_alarm_checked = alarm.is_alarm_active alarm.tap_checkbox() alarm.wait_for_banner_not_displayed() self.assertTrue(origin_alarm_checked != alarm.is_alarm_active, 'user should be able to turn off the alarm.')
class TestClockAddAlarmMultipleTimes(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() def test_clock_add_alarm_multiple_times(self): """ Add multiple alarm https://moztrap.mozilla.org/manage/case/1773/ """ count = 3 for i in range(1, count + 1): # create a new alarm with the default values that are available new_alarm = self.clock.tap_new_alarm() new_alarm.tap_done() # verify the banner-countdown message appears alarm_msg = self.clock.banner_countdown_notification self.assertIn('The alarm is set for', alarm_msg) self.clock.wait_for_banner_not_visible() # Ensure the new alarm has been added and is displayed self.assertEqual(i, len(self.clock.alarms))
class TestClockSetAlarm(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() def test_clock_set_alarm(self): # Added a view switching method to app.py for getting a Clock object. alarm = self.clock.switch_view('alarm') new_alarm = alarm.tap_new_alarm() self.assertEquals(new_alarm.alarm_repeat, 'Never') # Set label new_alarm.type_alarm_label("TestSetAlarmRepeat") # Loop the options and select the ones in match list for option in ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']: new_alarm.select_repeat(option) self.assertEqual('Weekdays', new_alarm.alarm_repeat) new_alarm.select_repeat('Sunday') # In this locale, Sunday is the first day of the week; it appears first. self.assertEqual('Sun, Mon, Tue, Wed, Thu, Fri', new_alarm.alarm_repeat) new_alarm.select_repeat('Sunday') self.assertEqual('Weekdays', new_alarm.alarm_repeat) # Ensure sound has the default value self.assertEquals(new_alarm.alarm_sound, 'Awake') # Set sound new_alarm.select_sound('Digicloud') self.assertEqual('Digicloud', new_alarm.alarm_sound) # Ensure snooze has the default value self.assertEquals(new_alarm.alarm_snooze, '10 minutes') # Set snooze new_alarm.select_snooze('15 minutes') self.assertEqual('15 minutes', new_alarm.alarm_snooze) # Save the alarm alarm_view = new_alarm.tap_done() alarm_view.dismiss_banner() # Tap to Edit alarm edit_alarm = alarm_view.alarm_items[0].tap() # Verify selected options self.assertEqual('Weekdays', edit_alarm.alarm_repeat) self.assertEqual('Digicloud', new_alarm.alarm_sound) self.assertEqual('15 minutes', new_alarm.alarm_snooze) edit_alarm.tap_done() alarm_view.dismiss_banner()
class TestClockSetAlarm(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() def test_clock_set_alarm(self): # Added a view switching method to app.py for getting a Clock object. alarm = self.clock.switch_view('alarm') new_alarm = alarm.tap_new_alarm() self.assertEquals(new_alarm.alarm_repeat, 'never') # Set label new_alarm.type_alarm_label("TestSetAlarmRepeat") # Loop the options and select the ones in match list for option in ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']: new_alarm.select_repeat(option) self.assertEqual(new_alarm.alarm_repeat, 'weekdays') new_alarm.select_repeat('Sunday') # In this locale, Sunday is the first day of the week; it appears first. self.assertEqual(new_alarm.alarm_repeat, 'Sun, Mon, Tue, Wed, Thu, Fri') new_alarm.select_repeat('Sunday') self.assertEqual(new_alarm.alarm_repeat, 'weekdays') # Ensure sound has the default value self.assertEquals(new_alarm.alarm_sound, 'ac_awake_opus') # Set sound new_alarm.select_sound('Digicloud') self.assertEqual(new_alarm.alarm_sound, 'ac_digicloud_opus') # Ensure snooze has the default value self.assertIn('10', new_alarm.alarm_snooze) # Set snooze new_alarm.select_snooze('15 minutes') self.assertIn('15', new_alarm.alarm_snooze) # Save the alarm alarm_view = new_alarm.tap_done() alarm_view.dismiss_banner() # Tap to Edit alarm edit_alarm = alarm_view.alarm_items[0].tap() # Verify selected options self.assertEqual(edit_alarm.alarm_repeat, 'weekdays') self.assertEqual(new_alarm.alarm_sound, 'ac_digicloud_opus') self.assertIn('15', new_alarm.alarm_snooze) edit_alarm.tap_done() alarm_view.dismiss_banner()
class TestClockRunStopWatch(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() def test_click_run_stopwatch_then_reset(self): stopwatch_view = self.clock.switch_view("stopwatch") self.assertEqual(stopwatch_view.current_time, '00:00.00') stopwatch_view.tap_start() time.sleep(0.2) self.assertNotEqual(stopwatch_view.current_time, '00:00.00') stopwatch_view.tap_pause() first_time = stopwatch_view.current_time time.sleep(0.2) self.assertNotEqual(stopwatch_view.current_time, '00:00.00') self.assertNotEqual(first_time, stopwatch_view.current_time) stopwatch_view.tap_reset() self.assertEqual(stopwatch_view.current_time, '00:00.00')
class TestClockRunStopWatch(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() def test_click_run_stopwatch_then_reset(self): stopwatch_view = self.clock.switch_view("stopwatch") self.assertEqual(stopwatch_view.current_time, '00:00.00') stopwatch_view.tap_start() time.sleep(0.2) self.assertNotEqual(stopwatch_view.current_time, '00:00.00') stopwatch_view.tap_pause() first_time = stopwatch_view.current_time stopwatch_view.tap_resume() time.sleep(0.2) self.assertNotEqual(stopwatch_view.current_time, '00:00.00') self.assertNotEqual(first_time, stopwatch_view.current_time) stopwatch_view.tap_pause() stopwatch_view.tap_reset() self.assertEqual(stopwatch_view.current_time, '00:00.00')
class TestClockTestAllItemsPresentNewAlarm(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() def test_all_items_present_new_alarm(self): # Wait for the new alarm screen to load new_alarm = self.clock.tap_new_alarm() # Ensure label has the default placeholder and text self.assertEquals(new_alarm.alarm_label_placeholder, 'Alarm name') # Ensure repeat has the default value self.assertEquals(new_alarm.alarm_repeat, 'Never') # Ensure sound has the default value self.assertEquals(new_alarm.alarm_sound, 'Classic Buzz') # Ensure snooze has the default value self.assertEquals(new_alarm.alarm_snooze, '5 minutes') def tearDown(self): # delete any existing alarms self.data_layer.delete_all_alarms() GaiaTestCase.tearDown(self)
def __init__(self, marionette): Clock.__init__(self, marionette) view = self.marionette.find_element(*self._alarm_view_locator) Wait(self.marionette).until( lambda m: view.location['x'] == 0 and view.is_displayed()) # Bug 1032852 This is to bust intermittents caused by this bug that causes keyboard not to appear upon tap time.sleep(1.5)
class TestClockAddAlarmMultipleTimes(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() def test_clock_add_alarm_multiple_times(self): """ Add multiple alarm https://moztrap.mozilla.org/manage/case/1773/ """ count = 3 for i in range(1, count + 1): # create a new alarm with the default values that are available new_alarm = self.clock.tap_new_alarm() new_alarm.type_alarm_label(' '.join(['alarm', str(i)])) new_alarm.tap_done() # verify the banner-countdown message appears self.assertIn('The alarm is set for', self.clock.banner_notification) self.clock.dismiss_banner() # Ensure the new alarm has been added and is displayed self.assertEqual(i, len(self.clock.alarms))
def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() # delete any existing alarms self.data_layer.delete_all_alarms()
def setUp(self): GaiaTestCase.setUp(self) self.cards_view = CardsView(self.marionette) self.clock = Clock(self.marionette) self.clock.launch() self.gallery = Gallery(self.marionette) self.gallery.launch(empty=True)
def setUp(self): PasscodeTestCase.setUp(self) self.set_passcode_to_1337() self.data_layer.set_setting('lockscreen.passcode-lock.enabled', True) self.clock = Clock(self.marionette) self.clock.launch()
def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() # create a new alarm with the default values that are available new_alarm = self.clock.tap_new_alarm() self.clock = new_alarm.tap_done() self.clock.wait_for_banner_not_visible()
def setUp(self): GaiaTestCase.setUp(self) self.calendar = Calendar(self.marionette) self.calendar.launch() self.clock = Clock(self.marionette) self.clock.launch() # Switch to top level frame before starting the test self.marionette.switch_to_frame()
def setUp(self): GaiaEnduranceTestCase.setUp(self) # Launch the Clock app self.clock = Clock(self.marionette) self.clock.launch() # Bug 864945, UI is not updating unless restart the app self.app_under_test = "clock" self.close_app() time.sleep(2) self.clock.launch() self.initial_alarms_count = len(self.clock.alarms)
class TestClockAlarmInLockscreen(PasscodeTestCase): _input_passcode = '1337' def setUp(self): PasscodeTestCase.setUp(self) self.set_passcode_to_1337() self.data_layer.set_setting('lockscreen.passcode-lock.enabled', True) self.clock = Clock(self.marionette) self.clock.launch() def test_clock_set_alarm_in_lockscreen(self): """ Dismiss alarm in lockscreen https://moztrap.mozilla.org/manage/cases/15805/ """ alarm_label_text = 'Test Alarm' # Set the time on the device so that it starts with 0 seconds _seconds_since_epoch = self.marionette.execute_script(""" var today = new Date(); var yr = today.getFullYear(); var mth = today.getMonth(); var day = today.getDate(); return new Date(yr, mth, day, 1, 0, 0).getTime();""") self.data_layer.set_time(_seconds_since_epoch) alarm = self.clock.switch_view('alarm') new_alarm = alarm.tap_new_alarm() new_alarm.type_alarm_label(alarm_label_text) time_picker = new_alarm.tap_time() time_picker.add_minute() time_picker.tap_done() self.clock = new_alarm.tap_done() self.clock.dismiss_banner() self.assertTrue(alarm.alarm_items[0].is_alarm_active) self.device.lock() self.alarm_alert = AlarmAlertScreen(self.marionette) self.alarm_alert.wait_for_alarm_to_trigger() # Check that the alarm name is the one we set self.assertEqual(self.alarm_alert.alarm_label, alarm_label_text) self.alarm_alert.tap_stop_alarm() self.assertTrue(self.device.is_locked)
def setUp(self): GaiaTestCase.setUp(self) # Set the time on the device _seconds_since_epoch = self.marionette.execute_script(""" var today = new Date(); var yr = today.getFullYear(); var mth = today.getMonth(); var day = today.getDate(); return new Date(yr, mth, day, 1, 0, 0).getTime();""") self.data_layer.set_time(_seconds_since_epoch) self.clock = Clock(self.marionette) self.clock.launch()
def tap_done(self): self.wait_for_element_displayed(*self._done_locator) self.marionette.find_element(*self._done_locator).tap() view = self.marionette.find_element(*self._alarm_view_locator) self.wait_for_condition( lambda m: view.location['x'] == view.size['width']) return Clock(self.marionette)
class TestClockSwitchClockType(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() def test_clock_switch_clock_type(self): """ Switch the clock type https://moztrap.mozilla.org/manage/case/1770 """ # switch to digital clock self.clock.tap_analog_display() self.assertTrue(self.clock.is_digital_clock_displayed, "The digital clock should be displayed.") # switch to analog clock self.clock.tap_digital_display() self.assertTrue(self.clock.is_analog_clock_displayed, "The analog clock should be displayed.") def test_clock_show_time_date(self): """ Show the time, date https://moztrap.mozilla.org/manage/case/1771 """ # check the date, time, state for digital clock self.clock.tap_analog_display() self.assertTrue(self.clock.is_day_and_date_displayed, "The date of digital clock should be displayed.") self.assertTrue(self.clock.is_digital_clock_displayed, "The time of digital clock should be displayed.") self.assertTrue( self.clock.is_24_hour_state_displayed, "The hour24-state of digital clock should be displayed.") # check the date, time for analog clock self.clock.tap_digital_display() self.assertTrue(self.clock.is_day_and_date_displayed, "The date of digital clock should be displayed.") self.assertTrue(self.clock.is_analog_clock_displayed, "The time of digital clock should be displayed.") self.assertFalse( self.clock.is_24_hour_state_displayed, "The hour24-state of digital clock should be displayed.")
class TestClockSetAlarmSound(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() def test_clock_set_alarm_sound(self): """ Modify the alarm sound [Clock][Alarm] Change the alarm sound https://moztrap.mozilla.org/manage/case/1787/ """ new_alarm = self.clock.tap_new_alarm() # set label &sound new_alarm.type_alarm_label("TestSetAlarmSound") new_alarm.select_sound('Gem Echoes') self.assertEqual('Gem Echoes', new_alarm.alarm_sound) # Save the alarm new_alarm.tap_done() self.clock.wait_for_banner_not_visible() # Tap to Edit alarm edit_alarm = self.clock.alarms[0].tap() self.assertEqual('Gem Echoes', new_alarm.alarm_sound) # Close alarm edit_alarm.tap_done() self.clock.wait_for_banner_not_visible()
class TestClockDeleteAlarm(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() # create a new alarm with the default values that are available new_alarm = self.clock.tap_new_alarm() self.clock = new_alarm.tap_done() self.clock.wait_for_banner_not_visible() def test_clock_delete_alarm(self): """ Delete alarm https://moztrap.mozilla.org/manage/case/1783/ """ # find the origin alarms' number initial_alarms_count = len(self.clock.alarms) # edit alarm edit_alarm = self.clock.alarms[0].tap() # delete alarm self.clock = edit_alarm.tap_delete() # wait alarm item not displayed self.clock.wait_for_new_alarm_button() self.wait_for_condition(lambda m: len(self.clock.alarms) != initial_alarms_count) self.assertEqual(len(self.clock.alarms), initial_alarms_count - 1, "delete alarm failed.")
class TestClockSetAlarmSnooze(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() def test_clock_set_alarm_snooze(self): """ Modify the alarm snooze Test that [Clock][Alarm] Change the snooze time https://moztrap.mozilla.org/manage/case/1788/ """ new_alarm = self.clock.tap_new_alarm() # Set label & snooze new_alarm.type_alarm_label("TestSetAlarmSnooze") new_alarm.select_snooze("15 minutes") self.assertEqual("15 minutes", new_alarm.alarm_snooze) # Save the alarm new_alarm.tap_done() self.clock.wait_for_banner_not_visible() # Tap to Edit alarm edit_alarm = self.clock.alarms[0].tap() # to verify the select list. self.assertEqual("15 minutes", new_alarm.alarm_snooze) # Close alarm edit_alarm.tap_done() self.clock.wait_for_banner_not_visible()
class TestClockDeleteAlarm(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() # create a new alarm with the default values that are available new_alarm = self.clock.tap_new_alarm() self.clock = new_alarm.tap_done() self.clock.wait_for_banner_not_visible() def test_clock_delete_alarm(self): """ Delete alarm https://moztrap.mozilla.org/manage/case/1783/ """ # find the origin alarms' number initial_alarms_count = len(self.clock.alarms) # edit alarm edit_alarm = self.clock.alarms[0].tap() # delete alarm self.clock = edit_alarm.tap_delete() # wait alarm item not displayed self.clock.wait_for_new_alarm_button() self.wait_for_condition( lambda m: len(self.clock.alarms) != initial_alarms_count) self.assertEqual(len(self.clock.alarms), initial_alarms_count - 1, "delete alarm failed.")
class TestCardsView(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.calendar = Calendar(self.marionette) self.calendar.launch() self.clock = Clock(self.marionette) self.clock.launch() # Switch to top level frame before starting the test self.marionette.switch_to_frame() def test_that_app_can_be_launched_from_cards_view(self): """ https://moztrap.mozilla.org/manage/case/2462/ """ cards_view = CardsView(self.marionette) self.assertFalse(cards_view.is_displayed, 'Cards view not expected to be visible') # Pull up the cards view self.device.hold_home_button() cards_view.wait_for_cards_view() # Wait for first app ready cards_view.cards[1].wait_for_centered() self.assertIn(cards_view.cards[0].manifest_url, self.calendar.manifest_url) self.assertTrue(cards_view.cards[0].is_displayed, '%s app should be present in cards view' % cards_view.cards[1].title) self.assertIn(cards_view.cards[1].manifest_url, self.clock.manifest_url) self.assertTrue(cards_view.cards[1].is_displayed, '%s app should be present in cards view' % cards_view.cards[1].title) cards_view.swipe_to_previous_app() # Wait for previous app ready cards_view.cards[0].wait_for_centered() cards_view.cards[0].tap() cards_view.wait_for_cards_view_not_displayed() self.calendar.wait_to_be_displayed()
def tap_done(self): done = Wait(self.marionette).until( expected.element_present(*self._done_locator)) Wait(self.marionette).until(expected.element_displayed(done)) done.tap() view = self.marionette.find_element(*self._alarm_view_locator) Wait(self.marionette).until( lambda m: view.location['x'] == view.size['width']) return Clock(self.marionette)
class TestClockSetAlarm(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() def test_clock_set_alarm(self): new_alarm = self.clock.tap_new_alarm() # Ensure repeat has the default value self.assertEquals(new_alarm.alarm_repeat, 'Never') # Set label new_alarm.type_alarm_label("TestSetAlarmRepeat") # Loop the options and select the ones in match list for option in ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']: new_alarm.select_repeat(option) self.assertEqual('Weekdays', new_alarm.alarm_repeat) new_alarm.select_repeat('Sunday') # In this locale, Sunday is the first day of the week; it appears first. self.assertEqual('Sun, Mon, Tue, Wed, Thu, Fri', new_alarm.alarm_repeat) new_alarm.select_repeat('Sunday') self.assertEqual('Weekdays', new_alarm.alarm_repeat) # Ensure sound has the default value self.assertEquals(new_alarm.alarm_sound, 'Classic Buzz') # Set sound new_alarm.select_sound('Gem Echoes') self.assertEqual('Gem Echoes', new_alarm.alarm_sound) # Ensure snooze has the default value self.assertEquals(new_alarm.alarm_snooze, '5 minutes') # Set snooze new_alarm.select_snooze('15 minutes') self.assertEqual('15 minutes', new_alarm.alarm_snooze) # Save the alarm new_alarm.tap_done() self.clock.dismiss_banner() # Tap to Edit alarm edit_alarm = self.clock.alarms[0].tap() # Verify selected options self.assertEqual('Weekdays', edit_alarm.alarm_repeat) self.assertEqual('Gem Echoes', new_alarm.alarm_sound) self.assertEqual('15 minutes', new_alarm.alarm_snooze) edit_alarm.tap_done() self.clock.dismiss_banner()
class TestClockTurnOnOffAlarm(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() # create a new alarm with the default values that are available new_alarm = self.clock.tap_new_alarm() self.clock = new_alarm.tap_done() self.clock.wait_for_banner_not_visible() def test_clock_turn_on_off_alarm(self): """ Turn on/off the alarm https://moztrap.mozilla.org/manage/case/1779/ """ alarm = self.clock.alarms[0] # turn on the alarm origin_alarm_checked = alarm.is_alarm_active alarm.tap_checkbox() time.sleep( 2 ) # TODO: Remove the sleep and add a wait_for_checkbox_state_to_change (one day) self.assertTrue(origin_alarm_checked != alarm.is_alarm_active, 'user should be able to turn on the alarm.') origin_alarm_checked = alarm.is_alarm_active alarm.tap_checkbox() time.sleep( 2 ) # TODO: Remove the sleep and add a wait_for_checkbox_state_to_change (one day) self.assertTrue(origin_alarm_checked != alarm.is_alarm_active, 'user should be able to turn off the alarm.') def tearDown(self): # delete any existing alarms self.data_layer.delete_all_alarms() GaiaTestCase.tearDown(self)
class TestClockCreateNewAlarm(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() def test_clock_create_new_alarm(self): """ Add an alarm and set label of the new alarm https://moztrap.mozilla.org/manage/case/1772/ https://moztrap.mozilla.org/manage/case/1775/ """ alarm_label_text = "test4321" # get the number of alarms set, before adding the new alarm initial_alarms_count = len(self.clock.alarms) # create a new alarm with the default values that are available new_alarm = self.clock.tap_new_alarm() # Ensure label has the default placeholder and text self.assertEquals(new_alarm.alarm_label_placeholder, 'Alarm name') # set label new_alarm.type_alarm_label(alarm_label_text) self.clock = new_alarm.tap_done() # verify the banner-countdown message appears alarm_msg = self.clock.banner_countdown_notification self.assertTrue('The alarm is set for' in alarm_msg, 'Actual banner message was: "' + alarm_msg + '"') # ensure the new alarm has been added and is displayed self.assertTrue(initial_alarms_count < len(self.clock.alarms), 'Alarms count did not increment') # verify the label of alarm self.clock.wait_for_banner_not_visible() alarms = self.clock.alarms self.assertEqual(len(alarms), 1) self.assertEqual(alarms[0].label, alarm_label_text)
class TestEnduranceSetAlarm(GaiaEnduranceTestCase): def setUp(self): GaiaEnduranceTestCase.setUp(self) # Launch the Clock app self.clock = Clock(self.marionette) self.clock.launch() # Bug 864945, UI is not updating unless restart the app self.app_under_test = "clock" self.close_app() time.sleep(2) self.clock.launch() self.initial_alarms_count = len(self.clock.alarms) def test_endurance_set_alarm(self): self.drive(test=self.set_alarm, app='clock') def set_alarm(self): # Set a new alarm and verify; code taken from existing clock tests # Create a new alarm with the default values except unique label new_alarm = self.clock.tap_new_alarm() text = "%d of %d" % (self.iteration, self.iterations) new_alarm.type_alarm_label(text) self.clock = new_alarm.tap_done() # Verify the banner-countdown message appears alarm_msg = self.clock.banner_countdown_notification self.assertTrue('The alarm is set for' in alarm_msg, 'Actual banner message was: "' + alarm_msg + '"') time.sleep(2) # Ensure all of the new alarms were added if self.iteration == self.iterations: alarms = self.clock.alarms self.assertEqual(len(alarms), self.initial_alarms_count + self.iteration, 'Alarms count did not increment') # A bit of sleep between reps time.sleep(3)
class TestClockRunStopWatch(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() def test_click_run_stopwatch_laps(self): stopwatch_view = self.clock.switch_view("stopwatch") self.assertEqual(stopwatch_view.current_time, '00:00.00') stopwatch_view.tap_start() time.sleep(0.2) self.assertNotEqual(stopwatch_view.current_time, '00:00.00') stopwatch_view.tap_lap() time.sleep(0.2) self.assertEqual(len(stopwatch_view.lap_items), 2) self.assertNotEqual(stopwatch_view.lap_items[0].time, '00:00.00') self.assertNotEqual(stopwatch_view.lap_items[1].time, '00:00.00') self.assertNotEqual(stopwatch_view.lap_items[0].time, stopwatch_view.lap_items[1].time) stopwatch_view.tap_pause() recorded_time = stopwatch_view.current_time stopwatch_view.tap_resume() time.sleep(0.2) self.assertNotEqual(stopwatch_view.current_time, recorded_time) stopwatch_view.tap_pause() stopwatch_view.tap_reset() self.assertEqual(len(stopwatch_view.lap_items), 0) self.assertEqual(stopwatch_view.current_time, '00:00.00')
class TestEnduranceSetAlarm(GaiaEnduranceTestCase): def setUp(self): GaiaEnduranceTestCase.setUp(self) # Launch the Clock app self.clock = Clock(self.marionette) self.clock.launch() # Bug 864945, UI is not updating unless restart the app self.app_under_test = "clock" self.close_app() time.sleep(2) self.clock.launch() self.initial_alarms_count = len(self.clock.alarms) def test_endurance_set_alarm(self): self.drive(test=self.set_alarm, app='clock') def set_alarm(self): # Set a new alarm and verify; code taken from existing clock tests # Create a new alarm with the default values except unique label new_alarm = self.clock.tap_new_alarm() text = "%d of %d" %(self.iteration, self.iterations) new_alarm.type_alarm_label(text) self.clock = new_alarm.tap_done() # Verify the banner-countdown message appears alarm_msg = self.clock.banner_countdown_notification self.assertTrue('The alarm is set for' in alarm_msg, 'Actual banner message was: "' + alarm_msg + '"') time.sleep(2) # Ensure all of the new alarms were added if self.iteration == self.iterations: alarms = self.clock.alarms self.assertEqual(len(alarms), self.initial_alarms_count + self.iteration, 'Alarms count did not increment') # A bit of sleep between reps time.sleep(3)
class TestClockSwitchClockType(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() def test_clock_switch_clock_type_and_show_time_date(self): """ Switch the clock type and show time and date https://moztrap.mozilla.org/manage/case/1770 https://moztrap.mozilla.org/manage/case/1771 """ # switch to digital clock and check the date, time, state for digital clock self.clock.tap_analog_display() self.assertTrue(self.clock.is_digital_clock_displayed, "The digital clock should be displayed.") self.assertTrue(self.clock.is_day_and_date_displayed, "The date of digital clock should be displayed.") self.assertTrue(self.clock.is_24_hour_state_displayed, "The hour24-state of digital clock should be displayed.") # switch to analog clock and check the date, time for analog clock self.clock.tap_digital_display() self.assertTrue(self.clock.is_analog_clock_displayed, "The analog clock should be displayed.") self.assertTrue(self.clock.is_day_and_date_displayed, "The date of digital clock should be displayed.") self.assertFalse(self.clock.is_24_hour_state_displayed, "The hour24-state of digital clock should be displayed.")
class TestClockTurnOnOffAlarm(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() # create a new alarm with the default values that are available new_alarm = self.clock.tap_new_alarm() self.clock = new_alarm.tap_done() self.clock.wait_for_banner_not_visible() def test_clock_turn_on_off_alarm(self): """ Turn on/off the alarm https://moztrap.mozilla.org/manage/case/1779/ """ alarm = self.clock.alarms[0] # turn on the alarm origin_alarm_checked = alarm.is_alarm_active alarm.tap_checkbox() time.sleep(2) # TODO: Remove the sleep and add a wait_for_checkbox_state_to_change (one day) self.assertTrue(origin_alarm_checked != alarm.is_alarm_active, 'user should be able to turn on the alarm.') origin_alarm_checked = alarm.is_alarm_active alarm.tap_checkbox() time.sleep(2) # TODO: Remove the sleep and add a wait_for_checkbox_state_to_change (one day) self.assertTrue(origin_alarm_checked != alarm.is_alarm_active, 'user should be able to turn off the alarm.') def tearDown(self): # delete any existing alarms self.data_layer.delete_all_alarms() GaiaTestCase.tearDown(self)
class TestClockSetAlarmTime(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() def test_clock_set_alarm_time(self): """ Modify the alarm time https://moztrap.mozilla.org/manage/case/1784/ """ new_alarm = self.clock.tap_new_alarm() # set label new_alarm.type_alarm_label("TestSetAlarmTime") # Save the alarm new_alarm.tap_done() self.clock.wait_for_banner_not_visible() old_alarm_text = self.clock.alarms[0].time # Tap to Edit alarm edit_alarm = self.clock.alarms[0].tap() # Set alarm time edit_alarm.spin_hour() edit_alarm.spin_minute() edit_alarm.spin_hour24() edit_alarm.tap_done() self.clock.wait_for_banner_not_visible() # Verify Result # Get the number of alarms set after the new alarm was added # Ensure that there is only one alarm self.assertEqual(1, len(self.clock.alarms)) # Verify label self.assertEqual("TestSetAlarmTime", self.clock.alarms[0].label) # Verify that alarm time has been changed new_alarm_text = self.clock.alarms[0].time self.assertNotEqual(old_alarm_text, new_alarm_text) def tearDown(self): # delete any existing alarms self.data_layer.delete_all_alarms() GaiaTestCase.tearDown(self)
class TestClockAddAlarmMultipleTimes(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() # delete any existing alarms self.data_layer.delete_all_alarms() def test_clock_add_alarm_multiple_times(self): """ Add multiple alarm https://moztrap.mozilla.org/manage/case/1773/ """ count = 3 for i in range(1, count + 1): # create a new alarm with the default values that are available new_alarm = self.clock.tap_new_alarm() new_alarm.tap_done() # verify the banner-countdown message appears alarm_msg = self.clock.banner_countdown_notification self.assertIn('The alarm is set for', alarm_msg) self.clock.wait_for_banner_not_visible() # Ensure the new alarm has been added and is displayed self.assertEqual(i, len(self.clock.alarms)) def tearDown(self): # delete any existing alarms self.data_layer.delete_all_alarms() GaiaTestCase.tearDown(self)
class TestClockSetAlarmRepeat(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() def test_clock_set_alarm_repeat(self): """ Modify the alarm repeat https://moztrap.mozilla.org/manage/case/1786/ Test that [Clock][Alarm] Change the repeat state """ new_alarm = self.clock.tap_new_alarm() # Set label new_alarm.type_alarm_label("TestSetAlarmRepeat") # loop the options and select the ones in match list for option in ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']: new_alarm.select_repeat(option) self.assertEqual('Weekdays', new_alarm.alarm_repeat) # check select Sunday twice new_alarm.select_repeat('Sunday') self.assertEqual('Mon, Tue, Wed, Thu, Fri Sun', new_alarm.alarm_repeat) new_alarm.select_repeat('Sunday') self.assertEqual('Weekdays', new_alarm.alarm_repeat) # Save the alarm new_alarm.tap_done() self.clock.wait_for_banner_not_visible() # Tap to Edit alarm edit_alarm = self.clock.alarms[0].tap() # To verify the select list. self.assertEqual('Weekdays', edit_alarm.alarm_repeat) # Close alarm edit_alarm.tap_done() self.clock.wait_for_banner_not_visible() def tearDown(self): # delete any existing alarms self.data_layer.delete_all_alarms() GaiaTestCase.tearDown(self)
class TestClockSetAlarmSnooze(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() def test_clock_set_alarm_snooze(self): """ Modify the alarm snooze Test that [Clock][Alarm] Change the snooze time https://moztrap.mozilla.org/manage/case/1788/ """ new_alarm = self.clock.tap_new_alarm() # Set label & snooze new_alarm.type_alarm_label("TestSetAlarmSnooze") new_alarm.select_snooze("15 minutes") self.assertEqual("15 minutes", new_alarm.alarm_snooze) # Save the alarm new_alarm.tap_done() self.clock.wait_for_banner_not_visible() # Tap to Edit alarm edit_alarm = self.clock.alarms[0].tap() # to verify the select list. self.assertEqual("15 minutes", new_alarm.alarm_snooze) # Close alarm edit_alarm.tap_done() self.clock.wait_for_banner_not_visible() def tearDown(self): # delete any existing alarms self.data_layer.delete_all_alarms() GaiaTestCase.tearDown(self)
def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch()
def __init__(self, marionette): Clock.__init__(self, marionette) view = self.marionette.find_element(*self._alarm_view_locator) Wait(self.marionette).until(lambda m: view.location['x'] == 0 and view.is_displayed()) # Bug 1032852 This is to bust intermittents caused by this bug that causes keyboard not to appear upon tap time.sleep(1.5)
def __init__(self, marionette): Clock.__init__(self, marionette) view = self.marionette.find_element(*self._alarm_view_locator) self.wait_for_condition(lambda m: view.location['x'] == 0 and view.is_displayed())
class TestClockCreateNewAlarm(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.clock = Clock(self.marionette) self.clock.launch() def test_clock_create_new_alarm(self): """ Add an alarm and set label of the new alarm https://moztrap.mozilla.org/manage/case/1772/ https://moztrap.mozilla.org/manage/case/1775/ """ alarm_label_text = "test4321" # get the number of alarms set, before adding the new alarm initial_alarms_count = len(self.clock.alarms) # create a new alarm with the default values that are available new_alarm = self.clock.tap_new_alarm() # Ensure label has the default placeholder and text self.assertEquals(new_alarm.alarm_label_placeholder, 'Alarm name') # set label new_alarm.type_alarm_label(alarm_label_text) self.clock = new_alarm.tap_done() # verify the banner-countdown message appears alarm_msg = self.clock.banner_countdown_notification self.assertTrue('The alarm is set for' in alarm_msg, 'Actual banner message was: "' + alarm_msg + '"') # ensure the new alarm has been added and is displayed self.assertTrue(initial_alarms_count < len(self.clock.alarms), 'Alarms count did not increment') # verify the label of alarm self.clock.wait_for_banner_not_visible() alarms = self.clock.alarms self.assertEqual(len(alarms), 1) self.assertEqual(alarms[0].label, alarm_label_text) # Tap to Edit alarm edit_alarm = alarms[0].tap() # TODO: change alarm time after Bug 946130 is fixed # edit_alarm.tap_time() # self.marionette.switch_to_frame() # edit_alarm.spin_hour() # edit_alarm.spin_minute() # edit_alarm.spin_hour24() edit_alarm.tap_done() self.clock.wait_for_banner_not_visible() # TODO: assert that alarm time has changed after Bug 946130 is fixed # turn off the alarm self.clock.alarms[0].tap_checkbox() self.assertFalse(self.clock.alarms[0].is_alarm_active, 'user should be able to turn on the alarm.') # turn on the alarm self.clock.alarms[0].tap_checkbox() self.clock.wait_for_banner_not_visible() self.assertTrue(self.clock.alarms[0].is_alarm_active, 'user should be able to turn off the alarm.')
class TestClockCreateNewAlarm(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) # Set the time on the device _seconds_since_epoch = self.marionette.execute_script(""" var today = new Date(); var yr = today.getFullYear(); var mth = today.getMonth(); var day = today.getDate(); return new Date(yr, mth, day, 1, 0, 0).getTime();""") self.data_layer.set_time(_seconds_since_epoch) self.clock = Clock(self.marionette) self.clock.launch() def test_clock_create_new_alarm(self): """ Add an alarm and set label of the new alarm https://moztrap.mozilla.org/manage/case/1772/ https://moztrap.mozilla.org/manage/case/1775/ """ alarm_label_text = "test4321" # get the number of alarms set, before adding the new alarm initial_alarms_count = len(self.clock.alarms) # create a new alarm with the default values that are available new_alarm = self.clock.tap_new_alarm() # Ensure label has the default placeholder and text self.assertEquals(new_alarm.alarm_label_placeholder, 'Alarm name') # set label new_alarm.type_alarm_label(alarm_label_text) self.clock = new_alarm.tap_done() # verify the banner-countdown message appears alarm_msg = self.clock.banner_notification self.assertTrue('The alarm is set for' in alarm_msg, 'Actual banner message was: "' + alarm_msg + '"') self.clock.dismiss_banner() # ensure the new alarm has been added and it is displayed self.assertTrue(initial_alarms_count < len(self.clock.alarms), 'Alarms count did not increment') # verify the label of alarm alarms = self.clock.alarms self.assertEqual(len(alarms), 1) self.assertEqual(alarms[0].label, alarm_label_text) alarm_time = self.clock.alarms[0].time() # tap to Edit alarm edit_alarm = alarms[0].tap() # Set the alarm time to 1 min more than the current time time_picker = edit_alarm.tap_time() time_picker.spin_minute() time_picker.tap_done() edit_alarm.tap_done() self.clock.dismiss_banner() self.assertNotEqual(self.clock.alarms[0].time, alarm_time) # turn off the alarm self.clock.alarms[0].tap_checkbox() self.clock.alarms[0].wait_for_checkbox_to_change_state(False) self.assertFalse(self.clock.alarms[0].is_alarm_active, 'user should be able to turn on the alarm.') # turn on the alarm self.clock.alarms[0].tap_checkbox() self.clock.dismiss_banner() self.assertTrue(self.clock.alarms[0].is_alarm_active, 'user should be able to turn off the alarm.') self.device.touch_home_button() self.marionette.switch_to_frame() self.alarm_alert = AlarmAlertScreen(self.marionette) self.alarm_alert.wait_for_alarm_to_trigger() # Check that the alarm name is the one we set self.assertEqual(self.alarm_alert.alarm_label, alarm_label_text) self.alarm_alert.tap_stop_alarm() # Switch back to top level now that Clock app is gone self.wait_for_condition(lambda m: self.apps.displayed_app.name == Homescreen.name)