def test_lockscreen_time_check(self): """ https: // bugzilla.mozilla.org / show_bug.cgi?id = 1118054 Due to the Bug 1133803, test requires active sim with data connection """ self.settings = Settings(self.marionette) self.settings.launch() datetime_setting = self.settings.open_date_and_time() old_time = datetime_setting.get_current_time_datetime # Auto time update is by default set to true, turn it off to make region change datetime_setting.toggle_automatic_time_update() self.assertFalse(datetime_setting.is_autotime_enabled, 'Autotime still enabled') # change the region. since no one will be in Atlantic Ocean timezone, change in time # will be guaranteed. datetime_setting.set_region('Atlantic Ocean') # get the displayed time after the region change new_time = datetime_setting.get_current_time_datetime self.assertNotEqual(new_time, old_time) # lock screen and check time on the lockscreen self.marionette.switch_to_frame() self.device.lock() lock_screen = LockScreen(self.marionette) difference = lock_screen.time_in_datetime - new_time self.assertLessEqual(difference.seconds, 60) # configure to set the time automatically (this will revert the timezone change), then lock screen lock_screen.switch_to_frame() lock_screen.unlock() self.apps.switch_to_displayed_app() # Enable the auto time update, so the regions change back and date/time is reverted back datetime_setting.toggle_automatic_time_update() self.assertTrue(datetime_setting.is_autotime_enabled, 'Autotime still disabled') self.marionette.switch_to_frame() self.device.lock() # wait until device is off and turn back on to check that the time is changed Wait(self.marionette, timeout=20).until( lambda m: not self.device.is_screen_enabled) self.device.turn_screen_on() self.marionette.switch_to_frame() # Check it reverted to the correct time, and compare it with the previously shown time # Allow 4 minutes difference max difference = lock_screen.time_in_datetime - old_time self.assertLessEqual(difference.seconds, 240)
def test_unlock_to_homescreen(self): """ https://moztrap.mozilla.org/manage/case/6784/ """ lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() homescreen = lock_screen.unlock() from gaiatest.apps.homescreen.app import Homescreen Homescreen(self.marionette).wait_to_be_displayed()
def test_lockscreen_notification(self): # the lockscreen should display the carrier name Wait(self.marionette, timeout=30).until(lambda m: self.device.has_mobile_connection) lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() self.marionette.execute_script( 'new Notification("%s", {body: "%s"});' % (self._notification_title, self._notification_body)) self.marionette.execute_script( 'new Notification("%s", {body: "%s"});' % (self._notification_title + "_2", self._notification_body + "_2")) self.marionette.execute_script( 'new Notification("%s", {body: "%s"});' % (self._notification_title + "_3", self._notification_body + "_3")) Wait(self.marionette).until( lambda m: len(lock_screen.notifications) == 3) # wait until device is off and turn back on Wait(self.marionette, timeout=20).until(lambda m: not self.device.is_screen_enabled) self.device.turn_screen_on() self.take_screenshot()
def test_unlock_to_emergency_call_screen(self): lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() emergency_call = lock_screen.unlock_to_emergency_call() emergency_call.switch_to_emergency_call_frame() self.assertTrue(emergency_call.is_emergency_dialer_keypad_displayed, 'emergency dialer keypad is not displayed')
def test_lockscreen_unlock_to_homescreen_with_passcode(self): # Need to wait until the carrier is detected, so the lockscreen will display the carrier information Wait(self.marionette, timeout = 30).until(lambda m: self.device.has_mobile_connection) self.data_layer.set_time(self._seconds_since_epoch * 1000) self.data_layer.set_setting('time.timezone', 'Atlantic/Reykjavik') # set passcode-lock self.data_layer.set_setting('lockscreen.passcode-lock.code', self._input_passcode) self.data_layer.set_setting('lockscreen.passcode-lock.enabled', True) # this time we need it locked! self.device.lock() # 1st try lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() lock_screen.unlock_to_passcode_pad() self.take_screenshot() self.device.turn_screen_off() # 2nd try self.device.turn_screen_on() passcode_pad = lock_screen.unlock_to_passcode_pad() homescreen = passcode_pad.type_passcode(self._input_passcode) Wait(self.marionette).until(lambda m: self.apps.displayed_app.name == homescreen.name) self.take_screenshot()
def test_lockscreen_unlock_to_homescreen_with_passcode(self): # Need to wait until the carrier is detected, so the lockscreen will display the carrier information Wait(self.marionette, timeout=30).until(lambda m: self.device.has_mobile_connection) self.data_layer.set_time(self._seconds_since_epoch * 1000) self.data_layer.set_setting('time.timezone', 'Atlantic/Reykjavik') # set passcode-lock self.data_layer.set_setting('lockscreen.passcode-lock.code', self._input_passcode) self.data_layer.set_setting('lockscreen.passcode-lock.enabled', True) # this time we need it locked! self.device.lock() # 1st try lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() lock_screen.unlock_to_passcode_pad() self.take_screenshot() self.device.turn_screen_off() # 2nd try self.device.turn_screen_on() passcode_pad = lock_screen.unlock_to_passcode_pad() homescreen = passcode_pad.type_passcode(self._input_passcode) Wait(self.marionette).until( lambda m: self.apps.displayed_app.name == homescreen.name) self.take_screenshot()
def test_unlock_to_emergency_call_screen(self): lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() emergency_call = lock_screen.unlock_to_emergency_call() emergency_call.switch_to_emergency_call_frame() self.assertTrue(emergency_call.is_emergency_dialer_keypad_displayed, 'emergency dialer keypad is not displayed')
def test_unlock_to_homescreen_with_passcode(self): lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() passcode_pad = lock_screen.unlock_to_passcode_pad() homescreen = passcode_pad.type_passcode(self._input_passcode) self.wait_for_condition(lambda m: self.apps.displayed_app.name == homescreen.name)
def test_unlock_to_homescreen_with_passcode(self): lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() passcode_pad = lock_screen.unlock_to_passcode_pad() homescreen = passcode_pad.type_passcode(self._input_passcode) self.wait_for_condition( lambda m: self.apps.displayed_app.name == homescreen.name)
def test_unlock_to_homescreen(self): lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() homescreen = lock_screen.unlock() Wait(self.marionette).until(lambda m: self.apps.displayed_app.name == homescreen.name) self.take_screenshot()
def test_unlock_to_homescreen(self): """https://moztrap.mozilla.org/manage/case/1296/""" lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() homescreen = lock_screen.unlock() self.wait_for_condition(lambda m: self.apps.displayed_app.name == homescreen.name)
def test_unlock_to_homescreen_with_passcode(self): """ https://moztrap.mozilla.org/manage/case/1296/ """ lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() homescreen = lock_screen.unlock_to_homescreen_using_passcode(self._input_passcode) homescreen.wait_to_be_displayed()
def test_unlock_to_homescreen(self): lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() homescreen = lock_screen.unlock() Wait(self.marionette).until( lambda m: self.apps.displayed_app.name == homescreen.name) self.take_screenshot()
def test_unlock_to_homescreen_with_passcode(self): """ https://moztrap.mozilla.org/manage/case/1296/ """ lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() passcode_pad = lock_screen.unlock_to_passcode_pad() homescreen = passcode_pad.type_passcode(self._input_passcode) self.wait_for_condition(lambda m: self.apps.displayed_app.name == homescreen.name)
def test_unlock_to_homescreen_with_passcode(self): """ https://moztrap.mozilla.org/manage/case/1296/ """ lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() homescreen = lock_screen.unlock_to_homescreen_using_passcode( self._input_passcode) homescreen.wait_to_be_displayed()
def test_lock_screen_notification(self): lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() self.marionette.execute_script('new Notification("%s", {body: "%s"});' % (self._notification_title, self._notification_body)) self.assertEqual(len(lock_screen.notifications), 1) self.assertTrue(lock_screen.notifications[0].is_visible) self.assertEqual(lock_screen.notifications[0].content, self._notification_body) self.assertEqual(lock_screen.notifications[0].title, self._notification_title)
def test_dialer_miss_call_from_known_contact_notification(self): """ https://moztrap.mozilla.org/manage/case/9294/ """ PLIVO_TIMEOUT = 30 self.device.lock() from gaiatest.utils.plivo.plivo_util import PlivoUtil self.plivo = PlivoUtil( self.testvars['plivo']['auth_id'], self.testvars['plivo']['auth_token'], self.testvars['plivo']['phone_number'] ) self.call_uuid = self.plivo.make_call( to_number=self.testvars['local_phone_numbers'][0].replace('+', ''), timeout=PLIVO_TIMEOUT) call_screen = CallScreen(self.marionette) call_screen.wait_for_incoming_call_with_locked_screen() self.plivo.hangup_call(self.call_uuid) Wait(self.plivo, timeout=PLIVO_TIMEOUT).until( lambda p: p.is_call_completed(self.call_uuid), message="Plivo didn't report the call as completed") self.call_uuid = None lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() lock_screen.wait_for_notification() # Check if the screen is turned on self.assertTrue(self.device.is_screen_enabled) # Verify the user sees a missed call notification message # and the known contacts info is shown. self.assertTrue(lock_screen.notifications[0].is_visible) self.assertEqual(lock_screen.notifications[0].title, 'Missed call') self.assertTrue(self.contact.givenName in lock_screen.notifications[0].content) self.device.unlock() system = System(self.marionette) system.wait_for_notification_toaster_not_displayed() # Expand the notification bar system.wait_for_status_bar_displayed() utility_tray = system.open_utility_tray() utility_tray.wait_for_notification_container_displayed() # Verify the user sees the missed call event in the notification center # and the known contacts info is shown. notifications = utility_tray.notifications self.assertEqual(notifications[0].title, 'Missed call') self.assertTrue(self.contact.givenName in notifications[0].content)
def test_unlock_to_homescreen_with_passcode(self): """ https://moztrap.mozilla.org/manage/case/1296/ """ lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() passcode_pad = lock_screen.unlock_to_passcode_pad() homescreen = passcode_pad.type_passcode(self._input_passcode) self.wait_for_condition( lambda m: self.apps.displayed_app.name == homescreen.name)
def test_unlock_to_homescreen(self): """ https://moztrap.mozilla.org/manage/case/6784/ """ lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() homescreen = lock_screen.unlock() from gaiatest.apps.homescreen.app import Homescreen Homescreen(self.marionette).wait_to_be_displayed()
def test_dialer_miss_call_from_known_contact_notification(self): """ https://moztrap.mozilla.org/manage/case/9294/ """ PLIVO_TIMEOUT = 30 self.device.lock() from gaiatest.utils.plivo.plivo_util import PlivoUtil self.plivo = PlivoUtil(self.testvars['plivo']['auth_id'], self.testvars['plivo']['auth_token'], self.testvars['plivo']['phone_number']) self.call_uuid = self.plivo.make_call( to_number=self.testvars['local_phone_numbers'][0].replace('+', ''), timeout=PLIVO_TIMEOUT) call_screen = CallScreen(self.marionette) call_screen.wait_for_incoming_call_with_locked_screen() self.plivo.hangup_call(self.call_uuid) Wait(self.plivo, timeout=PLIVO_TIMEOUT).until( lambda p: p.is_call_completed(self.call_uuid), message="Plivo didn't report the call as completed") self.call_uuid = None lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() lock_screen.wait_for_notification() # Check if the screen is turned on self.assertTrue(self.device.is_screen_enabled) # Verify the user sees a missed call notification message # and the known contacts info is shown. self.assertTrue(lock_screen.notifications[0].is_visible) self.assertEqual(lock_screen.notifications[0].title, 'Missed call') self.assertTrue( self.contact.givenName in lock_screen.notifications[0].content) self.device.unlock() system = System(self.marionette) system.wait_for_notification_toaster_not_displayed() # Expand the notification bar system.wait_for_status_bar_displayed() utility_tray = system.open_utility_tray() utility_tray.wait_for_notification_container_displayed() # Verify the user sees the missed call event in the notification center # and the known contacts info is shown. notifications = utility_tray.notifications self.assertEqual(notifications[0].title, 'Missed call') self.assertTrue(self.contact.givenName in notifications[0].content)
def test_lock_screen_notification(self): lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() prev_notifications_length = len(lock_screen.notifications) self.marionette.execute_script('new Notification("%s", {body: "%s"});' % (self._notification_title, self._notification_body)) self.assertEqual(len(lock_screen.notifications), prev_notifications_length + 1) # The last added notification is the first in the notifications array self.assertTrue(lock_screen.notifications[0].is_visible) self.assertEqual(lock_screen.notifications[0].content, self._notification_body) self.assertEqual(lock_screen.notifications[0].title, self._notification_title)
def test_lockscreen_time_check(self): """ https: // bugzilla.mozilla.org / show_bug.cgi?id = 1118054 Due to the Bug 1133803, test requires active sim with data connection """ self.settings = Settings(self.marionette) self.settings.launch() datetime_setting = self.settings.open_date_and_time_settings() old_time = datetime_setting.get_current_time_datetime # Auto time update is by default set to true, turn it off to make region change datetime_setting.toggle_automatic_time_update() self.assertFalse(datetime_setting.is_autotime_enabled, 'Autotime still enabled') # change the region. since no one will be in Atlantic Ocean timezone, change in time # will be guaranteed. datetime_setting.set_region('Atlantic Ocean') # get the displayed time after the region change new_time = datetime_setting.get_current_time_datetime self.assertNotEqual(new_time, old_time) # lock screen and check time on the lockscreen self.marionette.switch_to_frame() self.device.lock() lock_screen = LockScreen(self.marionette) difference = lock_screen.time_in_datetime - new_time self.assertLessEqual(difference.seconds, 60) # configure to set the time automatically (this will revert the timezone change), then lock screen lock_screen.switch_to_frame() lock_screen.unlock() self.apps.switch_to_displayed_app() # Enable the auto time update, so the regions change back and date/time is reverted back datetime_setting.toggle_automatic_time_update() self.assertTrue(datetime_setting.is_autotime_enabled, 'Autotime still disabled') self.marionette.switch_to_frame() self.device.lock() # wait until device is off and turn back on to check that the time is changed Wait(self.marionette, timeout=20).until(lambda m: not self.device.is_screen_enabled) self.device.turn_screen_on() self.marionette.switch_to_frame() # Check it reverted to the correct time, and compare it with the previously shown time # Allow 4 minutes difference max difference = lock_screen.time_in_datetime - old_time self.assertLessEqual(difference.seconds, 240)
def test_unlock_to_camera(self): """https://moztrap.mozilla.org/manage/case/2460/""" lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() camera = lock_screen.unlock_to_camera() self.wait_for_condition(lambda m: self.apps.displayed_app.name == camera.name) self.assertFalse(self.device.is_locked) # Wait fot the capture button displayed. no need to take a photo. self.apps.switch_to_displayed_app() camera.wait_for_capture_ready()
def test_unlock_to_camera(self): """https://moztrap.mozilla.org/manage/case/2460/""" lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() camera = lock_screen.unlock_to_camera() self.wait_for_condition( lambda m: self.apps.displayed_app.name == camera.name) self.assertFalse(self.device.is_locked) # Wait fot the capture button displayed. no need to take a photo. self.apps.switch_to_displayed_app() camera.wait_for_capture_ready()
def test_does_not_dial_regular_phones(self): """ https://moztrap.mozilla.org/manage/case/15186/ """ lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() passcode_pad = lock_screen.unlock_to_passcode_pad() emergency_call = passcode_pad.tap_emergency_call() emergency_call.switch_to_emergency_call_frame() emergency_call.keypad.dial_phone_number(self.testvars['remote_phone_number']) emergency_call.keypad.tap_call_button(switch_to_call_screen=False) self.assertTrue(emergency_call.is_emergency_call_only_title_displayed)
def test_dialer_miss_call_from_known_contact_notification(self): """ https://moztrap.mozilla.org/manage/case/9294/ """ self.device.lock() from gaiatest.utils.plivo.plivo_util import PlivoUtil self.plivo = PlivoUtil( self.testvars["plivo"]["auth_id"], self.testvars["plivo"]["auth_token"], self.testvars["plivo"]["phone_number"], ) self.call_uuid = self.plivo.make_call(to_number=self.environment.phone_numbers[0].replace("+", "")) call_screen = CallScreen(self.marionette) call_screen.wait_for_incoming_call() self.plivo.hangup_call(self.call_uuid) self.plivo.wait_for_call_completed(self.call_uuid) self.call_uuid = None lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() lock_screen.wait_for_notification() # Check if the screen is turned on self.assertTrue(self.device.is_screen_enabled) # Verify the user sees a missed call notification message # and the known contacts info is shown. self.assertTrue(lock_screen.notifications[0].is_visible) self.assertEqual(lock_screen.notifications[0].title, "Missed call") self.assertTrue(self.contact.givenName in lock_screen.notifications[0].content) self.device.unlock() system = System(self.marionette) system.wait_for_notification_toaster_not_displayed() # Expand the notification bar system.wait_for_status_bar_displayed() utility_tray = system.open_utility_tray() utility_tray.wait_for_notification_container_displayed() # Verify the user sees the missed call event in the notification center # and the known contacts info is shown. notifications = utility_tray.notifications self.assertEqual(notifications[0].title, "Missed call") self.assertTrue(self.contact.givenName in notifications[0].content)
def test_does_not_dial_regular_phones(self): """ https://moztrap.mozilla.org/manage/case/15186/ """ lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() passcode_pad = lock_screen.unlock_to_passcode_pad() emergency_call = passcode_pad.tap_emergency_call() emergency_call.switch_to_emergency_call_frame() emergency_call.keypad.dial_phone_number( self.testvars['remote_phone_number']) emergency_call.keypad.tap_call_button(switch_to_call_screen=False) self.assertTrue(emergency_call.is_emergency_call_only_title_displayed)
def test_lock_screen_wake_with_notification(self): lock_screen = LockScreen(self.marionette) # Check if the screen is turned off self.assertFalse(self.device.is_screen_enabled) self.marionette.execute_script('new Notification("%s", {body: "%s"});' % (self._notification_title, self._notification_body)) lock_screen.switch_to_frame() lock_screen.wait_for_notification() self.marionette.switch_to_frame() # Check if the screen is turned on self.assertTrue(self.device.is_screen_enabled) lock_screen.switch_to_frame() # Check if the notification is displayed on the screen self.assertTrue(lock_screen.notifications[0].is_visible) self.assertEqual(lock_screen.notifications[0].content, self._notification_body)
def test_set_passcode_by_settings(self): settings = Settings(self.marionette) settings.launch() screen_lock_settings = settings.open_screen_lock() screen_lock_settings.enable_lockscreen() screen_lock_settings.enable_passcode_lock() screen_lock_settings.create_passcode(self._input_passcode) passcode_enabled = self.data_layer.get_setting('lockscreen.passcode-lock.enabled') self.assertEqual(passcode_enabled, True, 'Passcode is not enabled.') # test new passcode by locking and unlocking self.device.lock() lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() passcode_pad = lock_screen.unlock_to_passcode_pad() passcode_pad.type_passcode(self._input_passcode) settings.wait_to_be_displayed()
def test_unlock_to_camera_with_passcode(self): """https://moztrap.mozilla.org/manage/case/2460/""" lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() camera = lock_screen.unlock_to_camera() self.assertTrue(self.device.is_locked) camera.switch_to_secure_camera_frame() camera.take_photo() # Check that thumbnail is visible self.assertTrue(camera.is_thumbnail_visible) # Check that picture saved to SD cards self.wait_for_condition(lambda m: len(self.data_layer.picture_files) == 1) self.assertEqual(len(self.data_layer.picture_files), 1) self.assertFalse(camera.is_gallery_button_visible)
def test_set_passcode_by_settings(self): settings = Settings(self.marionette) settings.launch() screen_lock_settings = settings.open_screen_lock() screen_lock_settings.enable_lockscreen() screen_lock_settings.enable_passcode_lock() screen_lock_settings.create_passcode(self._input_passcode) passcode_enabled = self.data_layer.get_setting( 'lockscreen.passcode-lock.enabled') self.assertEqual(passcode_enabled, True, 'Passcode is not enabled.') # test new passcode by locking and unlocking self.device.lock() lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() passcode_pad = lock_screen.unlock_to_passcode_pad() passcode_pad.type_passcode(self._input_passcode) settings.wait_to_be_displayed()
def test_lockscreen_notification(self): # the lockscreen should display the carrier name Wait(self.marionette, timeout=30).until(lambda m: self.device.has_mobile_connection) lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() self.marionette.execute_script('new Notification("%s", {body: "%s"});' % (self._notification_title, self._notification_body)) self.marionette.execute_script('new Notification("%s", {body: "%s"});' % (self._notification_title + "_2", self._notification_body + "_2")) self.marionette.execute_script('new Notification("%s", {body: "%s"});' % (self._notification_title + "_3", self._notification_body + "_3")) Wait(self.marionette).until(lambda m: len(lock_screen.notifications) == 3) # wait until device is off and turn back on Wait(self.marionette, timeout=20).until( lambda m: not self.device.is_screen_enabled) self.device.turn_screen_on() self.take_screenshot()
def test_unlock_to_camera_with_passcode(self): """https://moztrap.mozilla.org/manage/case/2460/""" lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() camera = lock_screen.unlock_to_camera() self.assertTrue(self.device.is_locked) camera.switch_to_secure_camera_frame() camera.take_photo() # Check that thumbnail is visible self.assertTrue(camera.is_thumbnail_visible) # Check that picture saved to SD cards self.wait_for_condition( lambda m: len(self.data_layer.picture_files) == 1) self.assertEqual(len(self.data_layer.picture_files), 1) self.assertFalse(camera.is_gallery_button_visible)
def test_settings_change_time_format(self): """ https://moztrap.mozilla.org/manage/case/14358/ """ status_bar = System(self.marionette).status_bar self.assertEqual('10:00', status_bar.maximized.time) settings = Settings(self.marionette) settings.launch() date_and_time = settings.open_date_and_time() date_and_time.select_time_format('24-hour') self.marionette.switch_to_frame() self.assertEqual('22:00', status_bar.minimized.time) self.device.lock() lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() self.assertEqual('22:00', lock_screen.time)
def test_settings_change_time_format(self): """ https://moztrap.mozilla.org/manage/case/14358/ """ status_bar = System(self.marionette).status_bar self.assertEqual('10:00', status_bar.time) settings = Settings(self.marionette) settings.launch() date_and_time = settings.open_date_and_time() date_and_time.select_time_format('24-hour') self.marionette.switch_to_frame() self.assertEqual('22:00', status_bar.time) self.device.lock() lock_screen = LockScreen(self.marionette) lock_screen.switch_to_frame() self.assertEqual('22:00', lock_screen.time)