class TestLockScreen(GaiaTestCase):

    _input_passcode = '7931'

    def setUp(self):
        GaiaTestCase.setUp(self)

        #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.lockscreen.lock()
        self.lock_screen = LockScreen(self.marionette)
        self.lock_screen.wait_for_lockscreen_handle_visible()

    def test_lockscreen_unlock_to_emergency_call_screen(self):
        """Test that emergency call screen can open

        https://github.com/mozilla/gaia-ui-tests/issues/762
        """
        self.lock_screen.swipe_to_unlock()
        self.lock_screen.tap_unlock_button()
        emergency_screen = self.lock_screen.passcode_pad.tap_emergency_call()

        self.assertTrue(emergency_screen.is_emergency_dialer_keypad_displayed,
                        'emergency dialer keypad is not displayed')
class TestLockScreen(GaiaTestCase):

    _input_passcode = '7931'

    def setUp(self):
        GaiaTestCase.setUp(self)

        #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.lockscreen.lock()
        self.lock_screen = LockScreen(self.marionette)
        self.lock_screen.wait_for_lockscreen_handle_visible()

    def test_lockscreen_unlock_to_emergency_call_screen(self):
        """Test that emergency call screen can open

        https://github.com/mozilla/gaia-ui-tests/issues/762
        """
        self.lock_screen.swipe_to_unlock()
        self.lock_screen.tap_unlock_button()
        emergency_screen = self.lock_screen.passcode_pad.tap_emergency_call()

        self.assertTrue(emergency_screen.is_emergency_dialer_keypad_displayed,
                        'emergency dialer keypad is not displayed')
class TestCameraUnlockWithPasscode(GaiaTestCase):

    # Input data
    _input_passcode = '7931'

    def setUp(self):
        GaiaTestCase.setUp(self)

        # Turn off geolocation prompt
        self.apps.set_permission('System', 'geolocation', 'deny')

        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.lockscreen.lock()
        self.lock_screen = LockScreen(self.marionette)
        self.lock_screen.wait_for_lockscreen_handle_visible()

    def test_unlock_to_camera_with_passcode(self):
        # https://github.com/mozilla/gaia-ui-tests/issues/479

        self.lock_screen.swipe_to_unlock()
        camera = self.lock_screen.tap_camera_button()

        self.assertFalse(camera.is_gallery_button_visible)

        camera.tap_switch_source()
        camera.wait_for_capture_ready()

        self.assertFalse(camera.is_gallery_button_visible)
class TestLockScreen(GaiaTestCase):

    # Homescreen locators
    _homescreen_frame_locator = (By.CSS_SELECTOR, 'div.homescreen iframe')
    _homescreen_landing_locator = (By.ID, 'landing-page')

    def setUp(self):
        GaiaTestCase.setUp(self)

        # this time we need it locked!
        self.lockscreen.lock()
        self.lock_screen = LockScreen(self.marionette)
        self.lock_screen.wait_for_lockscreen_handle_visible()

    def test_unlock_swipe_to_homescreen(self):
        # https://moztrap.mozilla.org/manage/case/1296/
        self.lock_screen.swipe_to_unlock()
        self.lock_screen.tap_unlock_button()

        self.lock_screen.wait_for_lockscreen_not_visible()

        hs_frame = self.marionette.find_element(*self._homescreen_frame_locator)
        # TODO I would prefer to check visibility of the the frame at this point but bug 813583
        self.marionette.switch_to_frame(hs_frame)

        # Instead, check the main element of the landing screen
        landing_element = self.marionette.find_element(*self._homescreen_landing_locator)

        self.assertTrue(landing_element.is_displayed(), "Landing element not displayed after unlocking")
class TestLockScreen(GaiaTestCase):

    _input_passcode = '7931'

    # Homescreen locators
    _homescreen_frame_locator = (By.CSS_SELECTOR, 'div.homescreen iframe')
    _homescreen_landing_locator = (By.ID, 'landing-page')

    def setUp(self):
        GaiaTestCase.setUp(self)

        #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.lockscreen.lock()
        self.lock_screen = LockScreen(self.marionette)
        self.lock_screen.wait_for_lockscreen_handle_visible()

    def test_lockscreen_unlock_to_homescreen_with_passcode(self):
        """Unlock device to homescreen when a passcode is set

        https://github.com/mozilla/gaia-ui-tests/issues/478
        """
        self.lock_screen.swipe_to_unlock()
        self.lock_screen.tap_unlock_button()
        self.lock_screen.passcode_pad.type_passcode(self._input_passcode)

        self.lock_screen.wait_for_lockscreen_not_visible()

        hs_frame = self.marionette.find_element(*self._homescreen_frame_locator)
        # TODO I would prefer to check visibility of the the frame at this point but bug 813583
        self.marionette.switch_to_frame(hs_frame)

        # Instead, check the main element of the landing screen
        landing_element = self.marionette.find_element(*self._homescreen_landing_locator)
        self.assertTrue(landing_element.is_displayed(), 'Landing element not displayed after unlocking')
class TestLockScreen(GaiaTestCase):
    _camera_frame_locator = (By.CSS_SELECTOR, 'iframe[src^="app://camera"][src$="index.html"]')

    def setUp(self):
        GaiaTestCase.setUp(self)

        # Turn off geolocation prompt
        self.apps.set_permission('Camera', 'geolocation', 'deny')

        # this time we need it locked!
        self.lockscreen.lock()

        self.lock_screen = LockScreen(self.marionette)
        self.lock_screen.wait_for_lockscreen_handle_visible()

    def test_unlock_swipe_to_camera(self):
        # https://moztrap.mozilla.org/manage/case/2460/

        self.lock_screen.swipe_to_unlock()
        camera = self.lock_screen.tap_camera_button()

        # Wait fot the capture button displayed. no need to take a photo.
        camera.wait_for_camera_ready()
class TestLockScreen(GaiaTestCase):
    _camera_frame_locator = (By.CSS_SELECTOR,
                             'iframe[src^="app://camera"][src$="index.html"]')

    def setUp(self):
        GaiaTestCase.setUp(self)

        # Turn off geolocation prompt
        self.apps.set_permission('Camera', 'geolocation', 'deny')

        # this time we need it locked!
        self.lockscreen.lock()

        self.lock_screen = LockScreen(self.marionette)
        self.lock_screen.wait_for_lockscreen_handle_visible()

    def test_unlock_swipe_to_camera(self):
        # https://moztrap.mozilla.org/manage/case/2460/

        self.lock_screen.swipe_to_unlock()
        camera = self.lock_screen.tap_camera_button()

        # Wait fot the capture button displayed. no need to take a photo.
        camera.wait_for_camera_ready()