当前位置: 首页>>代码示例>>Python>>正文


Python Clock.switch_view方法代码示例

本文整理汇总了Python中gaiatest.apps.clock.app.Clock.switch_view方法的典型用法代码示例。如果您正苦于以下问题:Python Clock.switch_view方法的具体用法?Python Clock.switch_view怎么用?Python Clock.switch_view使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gaiatest.apps.clock.app.Clock的用法示例。


在下文中一共展示了Clock.switch_view方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestClockRunStopWatch

# 需要导入模块: from gaiatest.apps.clock.app import Clock [as 别名]
# 或者: from gaiatest.apps.clock.app.Clock import switch_view [as 别名]
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')
开发者ID:Archaeopteryx,项目名称:gaia,代码行数:30,代码来源:test_clock_run_stopwatch_then_reset.py

示例2: TestClockSetAlarm

# 需要导入模块: from gaiatest.apps.clock.app import Clock [as 别名]
# 或者: from gaiatest.apps.clock.app.Clock import switch_view [as 别名]
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()
开发者ID:Cwiiis,项目名称:gaia,代码行数:62,代码来源:test_clock_set_alarm.py

示例3: TestClockAlarmInLockscreen

# 需要导入模块: from gaiatest.apps.clock.app import Clock [as 别名]
# 或者: from gaiatest.apps.clock.app.Clock import switch_view [as 别名]
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)
开发者ID:Cwiiis,项目名称:gaia,代码行数:52,代码来源:test_clock_alarm_in_lockscreen.py

示例4: TestClockRunStopWatch

# 需要导入模块: from gaiatest.apps.clock.app import Clock [as 别名]
# 或者: from gaiatest.apps.clock.app.Clock import switch_view [as 别名]
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')
开发者ID:Cwiiis,项目名称:gaia,代码行数:42,代码来源:test_clock_run_stopwatch_laps.py

示例5: TestClockCreateNewAlarm

# 需要导入模块: from gaiatest.apps.clock.app import Clock [as 别名]
# 或者: from gaiatest.apps.clock.app.Clock import switch_view [as 别名]
class TestClockCreateNewAlarm(GaiaTestCase):

    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)

    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_view = self.clock.switch_view("alarm")
        _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();""")

        alarm_label_text = "test4321"

        initial_alarms_count = len(alarm_view.alarm_items)

        # Set the time on the device
        self.data_layer.set_time(_seconds_since_epoch)

        # create a new alarm with the default values that are available
        new_alarm = alarm_view.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)
        alarm_view = new_alarm.tap_done()

        # verify the banner-countdown message appears
        alarm_msg = alarm_view.banner_notification
        self.assertTrue('The alarm is set for' in alarm_msg, 'Actual banner message was: "' + alarm_msg + '"')
        alarm_view.dismiss_banner()

        # ensure the new alarm has been added and it is displayed
        self.assertTrue(initial_alarms_count < len(alarm_view.alarm_items),
                        'Alarms count did not increment')

        # verify the label of alarm
        self.assertEqual(len(alarm_view.alarm_items), 1)
        self.assertEqual(alarm_view.alarm_items[0].label, alarm_label_text)

        alarm_time = alarm_view.alarm_items[0].time

        # tap to Edit alarm
        edit_alarm = alarm_view.alarm_items[0].tap()

        # Set the alarm time to 1 min more than the current time
        time_picker = edit_alarm.tap_time()
        time_picker.add_minute()
        time_picker.tap_done()

        edit_alarm.tap_done()
        alarm_view.dismiss_banner()

        self.assertNotEqual(alarm_view.alarm_items[0].time, alarm_time)

        # turn off the alarm
        alarm_view.alarm_items[0].tap_checkbox()
        alarm_view.alarm_items[0].wait_for_checkbox_to_change_state(False)
        self.assertFalse(alarm_view.alarm_items[0].is_alarm_active, 'user should be able to turn on the alarm.')

        # turn on the alarm
        alarm_view.alarm_items[0].tap_checkbox()
        alarm_view.alarm_items[0].wait_for_checkbox_to_change_state(True)
        alarm_view.dismiss_banner()
        self.assertTrue(alarm_view.alarm_items[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
        Homescreen(self.marionette).wait_to_be_displayed()
开发者ID:Archaeopteryx,项目名称:gaia,代码行数:92,代码来源:test_clock_create_new_alarm.py


注:本文中的gaiatest.apps.clock.app.Clock.switch_view方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。