@@ -48,10 +48,11 @@ class TestLockscreen(UnityTestCase):
4848 unity_proxy = self.launch_unity()
4949 greeter = self.main_window.get_greeter()
5050
51+
5152 if greeter.narrowMode:
5253 unlock_unity(unity_proxy)
5354 lockscreen = self._wait_for_lockscreen()
54− self._enter_pincode("1234")
55+ self.main_window.enter_pin_code("1234")
5556 self.assertThat(lockscreen.shown, Eventually(Equals(False)))
5657 else:
5758 self._enter_prompt_passphrase("1234")
@@ -81,7 +82,7 @@ class TestLockscreen(UnityTestCase):
8182 if greeter.narrowMode:
8283 unlock_unity(unity_proxy)
8384 lockscreen = self._wait_for_lockscreen()
84− self._enter_pincode("4321")
85+ self.main_window.enter_pin_code("4321")
8586 pinentryField = self.main_window.get_pinentryField()
8687 self.assertThat(pinentryField.text, Eventually(Equals("")))
8788 self.assertThat(lockscreen.shown, Eventually(Equals(True)))
@@ -118,28 +119,6 @@ class TestLockscreen(UnityTestCase):
118119 self.assertThat(lockscreen.shown, Eventually(Equals(True)))
119120 return lockscreen
120121
121− def _enter_pincode(self, code):
122− """Enter code 'code' into the single-pin lightdm pincode entry
123− screen.
124−
125− :param code: must be a string of numeric characters.
126− :raises: TypeError if code is not a string.
127− :raises: ValueError if code contains non-numeric characters.
128−
129− """
130−
131− if not isinstance(code, basestring):
132− raise TypeError(
133− "'code' parameter must be a string, not %r."
134− % type(code)
135− )
136− for num in code:
137− if not num.isdigit():
138− raise ValueError(
139− "'code' parameter contains non-numeric characters."
140− )
141− self.touch.tap_object(self.main_window.get_pinPadButton(int(num)))
142−
143122 def _enter_pin_passphrase(self, passphrase):
144123 """Enter the password specified in 'passphrase' into the password entry
145124 field of the pin lock screen.
@@ -148,18 +127,15 @@ class TestLockscreen(UnityTestCase):
148127 :raises: TypeError if passphrase is not a string.
149128
150129 """
151− if not isinstance(passphrase, basestring):
130+ if not isinstance(passphrase, str):
152131 raise TypeError(
153132 "'passphrase' parameter must be a string, not %r."
154133 % type(passphrase)
155134 )
156135
157− pinentryField = self.main_window.get_pinentryField()
158− self.touch.tap_object(pinentryField)
159− self.assertThat(pinentryField.activeFocus, Eventually(Equals(True)))
160− for character in passphrase:
161− self._type_character(character, pinentryField)
162− logger.debug("Typed passphrase: %s", pinentryField.text)
136+ pin_entry_field = self.main_window.get_pinentryField()
137+ pin_entry_field.write(passphrase)
138+ logger.debug("Typed passphrase: %s", pin_entry_field.text)
163139 self.keyboard.type("\n")
164140
165141 def _enter_prompt_passphrase(self, passphrase):
@@ -177,21 +153,6 @@ class TestLockscreen(UnityTestCase):
177153 )
178154
179155 prompt = self.main_window.get_greeter().get_prompt()
180− self.touch.tap_object(prompt)
181− self.assertThat(prompt.activeFocus, Eventually(Equals(True)))
182− for character in passphrase:
183− self._type_character(character, prompt)
156+ prompt.write(passphrase)
184157 logger.debug("Typed passphrase: %s", prompt.text)
185158 self.keyboard.type("\n")
186−
187− def _type_character(self, character, prompt, retries=5):
188− current_text = prompt.text
189− self.keyboard.type(character)
190− try:
191− self.assertThat(
192− prompt.text, Eventually(Equals(current_text + character)))
193− except AssertionError:
194− if retries > 0:
195− self._type_character(character, prompt, retries-1)
196− else:
197− raise