21 from __future__
import absolute_import
27 from autopilot.matchers
import Eventually
28 from autopilot.platform
import model
30 from testtools
import skipUnless
31 from testtools.matchers
import Equals
34 logger = logging.getLogger(__name__)
37 if sys.version >=
'3':
43 """Tests for the lock screen."""
45 scenarios = _get_device_emulation_scenarios()
47 @with_lightdm_mock(
"single-pin")
49 """Must be able to unlock the PIN entry lock screen."""
51 greeter = self.main_window.get_greeter()
53 if greeter.narrowMode:
54 unlock_unity(unity_proxy)
57 self.assertThat(lockscreen.shown, Eventually(Equals(
False)))
60 self.assertThat(greeter.shown, Eventually(Equals(
False)))
62 @with_lightdm_mock(
"single-passphrase")
64 """Must be able to unlock the passphrase entry screen."""
66 greeter = self.main_window.get_greeter()
68 if greeter.narrowMode:
69 unlock_unity(unity_proxy)
72 self.assertThat(lockscreen.shown, Eventually(Equals(
False)))
75 self.assertThat(greeter.shown, Eventually(Equals(
False)))
77 @with_lightdm_mock(
"single-pin")
79 """Entering the wrong pin code must not dismiss the lock screen."""
81 greeter = self.main_window.get_greeter()
83 if greeter.narrowMode:
84 unlock_unity(unity_proxy)
87 pinentryField = self.main_window.get_pinentryField()
88 self.assertThat(pinentryField.text, Eventually(Equals(
"")))
89 self.assertThat(lockscreen.shown, Eventually(Equals(
True)))
92 prompt = self.main_window.get_greeter().get_prompt()
93 self.assertThat(prompt.text, Eventually(Equals(
"")))
94 self.assertThat(greeter.shown, Eventually(Equals(
True)))
96 @with_lightdm_mock(
"single-passphrase")
98 """Entering the wrong password must not dismiss the lock screen."""
100 greeter = self.main_window.get_greeter()
102 if greeter.narrowMode:
103 unlock_unity(unity_proxy)
106 pinentryField = self.main_window.get_pinentryField()
107 self.assertThat(pinentryField.text, Eventually(Equals(
"")))
108 self.assertThat(lockscreen.shown, Eventually(Equals(
True)))
111 prompt = self.main_window.get_greeter().get_prompt()
112 self.assertThat(prompt.text, Eventually(Equals(
"")))
113 self.assertThat(greeter.shown, Eventually(Equals(
True)))
115 def _wait_for_lockscreen(self):
116 """Wait for the lock screen to load, and return it."""
117 pinPadLoader = self.main_window.get_pinPadLoader()
118 self.assertThat(pinPadLoader.progress, Eventually(Equals(1)))
119 lockscreen = self.main_window.get_lockscreen()
120 self.assertThat(lockscreen.shown, Eventually(Equals(
True)))
123 def _enter_pincode(self, code):
124 """Enter code 'code' into the single-pin lightdm pincode entry
127 :param code: must be a string of numeric characters.
128 :raises: TypeError if code is not a string.
129 :raises: ValueError if code contains non-numeric characters.
133 if not isinstance(code, basestring):
135 "'code' parameter must be a string, not %r."
139 if not num.isdigit():
141 "'code' parameter contains non-numeric characters."
143 self.touch.tap_object(self.main_window.get_pinPadButton(int(num)))
145 def _enter_pin_passphrase(self, passphrase):
146 """Enter the password specified in 'passphrase' into the password entry
147 field of the pin lock screen.
149 :param passphrase: The string you want to enter.
150 :raises: TypeError if passphrase is not a string.
153 if not isinstance(passphrase, basestring):
155 "'passphrase' parameter must be a string, not %r."
159 pinentryField = self.main_window.get_pinentryField()
160 self.touch.tap_object(pinentryField)
161 self.assertThat(pinentryField.activeFocus, Eventually(Equals(
True)))
162 for character
in passphrase:
164 logger.debug(
"Typed passphrase: %s", pinentryField.text)
165 self.keyboard.type(
"\n")
167 def _enter_prompt_passphrase(self, passphrase):
168 """Enter the password specified in 'passphrase' into the password entry
169 field of the main user list's prompt.
171 :param passphrase: The string you want to enter.
172 :raises: TypeError if passphrase is not a string.
175 if not isinstance(passphrase, basestring):
177 "'passphrase' parameter must be a string, not %r."
181 prompt = self.main_window.get_greeter().get_prompt()
182 self.touch.tap_object(prompt)
183 self.assertThat(prompt.activeFocus, Eventually(Equals(
True)))
184 for character
in passphrase:
186 logger.debug(
"Typed passphrase: %s", prompt.text)
187 self.keyboard.type(
"\n")
189 def _type_character(self, character, prompt, retries=5):
190 current_text = prompt.text
191 self.keyboard.type(character)
193 self.assertThat(prompt.text, Eventually(Equals(current_text + character)))
194 except AssertionError:
def test_can_unlock_pin_screen
def test_can_unlock_passphrase_screen
def _enter_pin_passphrase
def test_passphrase_screen_wrong_password
def test_pin_screen_wrong_code
def _enter_prompt_passphrase