本文整理汇总了Python中gaiatest.apps.clock.app.Clock类的典型用法代码示例。如果您正苦于以下问题:Python Clock类的具体用法?Python Clock怎么用?Python Clock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Clock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestClockSetAlarm
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()
示例2: TestClockRunStopWatch
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')
示例3: TestClockTestAllItemsPresentNewAlarm
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)
示例4: TestClockAddAlarmMultipleTimes
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))
示例5: tap_done
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
示例6: TestClockTurnOnOffAlarm
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.')
示例7: TestClockAlarmInLockscreen
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)
示例8: setUp
def setUp(self):
GaiaTestCase.setUp(self)
self.clock = Clock(self.marionette)
self.clock.launch()
# delete any existing alarms
self.data_layer.delete_all_alarms()
示例9: TestCardsView
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()
示例10: TestClockDeleteAlarm
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.")
示例11: TestClockSetAlarmSound
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()
示例12: setUp
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()
示例13: TestClockSetAlarm
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()
示例14: setUp
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()
示例15: setUp
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()