on xenial help sign in
Added second (desktop only) test.
25e1ab8Thomi Richards
tests/autopilot/unity8/shell/tests/test_lock_screen.py+30−36
@@ -29,6 +29,8 @@ from unity8.shell.tests import Unity8TestCase
29from unity8.shell.tests.helpers import with_lightdm_mock
29from unity8.shell.tests.helpers import with_lightdm_mock
30
30
31from autopilot.matchers import Eventually
31from autopilot.matchers import Eventually
32+from testtools import skipUnless, skipIf
33+from autopilot.platform import model
32from testtools.matchers import Equals
34from testtools.matchers import Equals
33import logging
35import logging
34import time
36import time
@@ -41,26 +43,8 @@ class TestLockscreen(Unity8TestCase):
41
43
42 """Tests for the lock screen."""
44 """Tests for the lock screen."""
43
45
44− # if model() == 'Desktop':
45− # scenarios = [
46− # ('Pinlock', dict(app_width=768, app_height=1280, grid_unit_px=18, lightdm_mock="single-pin")),
47− # ('Keylock', dict(app_width=768, app_height=1280, grid_unit_px=18, lightdm_mock="single-passphrase")),
48− # ]
49− # else:
50− # scenarios = [
51− # ('Pinlock', dict(app_width=0, app_height=0, grid_unit_px=0, lightdm_mock="single-pin")),
52− # ('Keylock', dict(app_width=0, app_height=0, grid_unit_px=0, lightdm_mock="single-key")),
53− # ]
54−
55− # def setUp(self):
56− # super(TestLockscreen, self).setUp()
57−
58−
59− # dash = self.main_window.get_dash()
60− # self.assertThat(dash.showScopeOnLoaded, Eventually(Equals(""), timeout=30))
61−
62 @with_lightdm_mock("single-pin")
46 @with_lightdm_mock("single-pin")
63− def test_can_unlock_screen(self):
47+ def test_can_unlock_pin_screen(self):
64 """Must be able to unlock the PIN entry lock screen."""
48 """Must be able to unlock the PIN entry lock screen."""
65 self.app = self.launch_unity()
49 self.app = self.launch_unity()
66 self._unlock_greeter()
50 self._unlock_greeter()
@@ -70,6 +54,18 @@ class TestLockscreen(Unity8TestCase):
70
54
71 self.assertThat(lockscreen.shown, Eventually(Equals(False)))
55 self.assertThat(lockscreen.shown, Eventually(Equals(False)))
72
56
57+ @skipUnless(model() == 'Desktop', "Passphrase applicable to desktop only.")
58+ @with_lightdm_mock("single-passphrase")
59+ def test_can_unlock_passphrase_screen(self):
60+ """Must be able to unlock the passphrase entry screen."""
61+ self.app = self.launch_unity()
62+ self._unlock_greeter()
63+
64+ lockscreen = self._wait_for_lockscreen()
65+ self._enter_passphrase("password")
66+
67+ self.assertThat(lockscreen.shown, Eventually(Equals(False)))
68+
73 def _unlock_greeter(self):
69 def _unlock_greeter(self):
74 greeter = self.main_window.get_greeter()
70 greeter = self.main_window.get_greeter()
75 self.assertThat(greeter.created, Eventually(Equals(True)))
71 self.assertThat(greeter.created, Eventually(Equals(True)))
@@ -116,25 +112,23 @@ class TestLockscreen(Unity8TestCase):
116 )
112 )
117 self.touch.tap_object(self.main_window.get_pinPadButton(int(num)))
113 self.touch.tap_object(self.main_window.get_pinPadButton(int(num)))
118
114
119− # def test_unlock(self):
115+ def _enter_passphrase(self, passphrase):
120− # self.unlock_greeter()
116+ """Enter the password specified in 'passphrase' into the password entry
117+ field.
118+
119+ :param passphrase: The string you want to enter.
120+ :raises: TypeError if passphrase is not a string.
121+
122+ """
123+ if not isinstance(passphrase, basestring):
124+ raise TypeError("'passphrase' parameter must be a string.")
125+
126+ pinentryField = self.main_window.get_pinentryField()
127+ self.touch.tap_object(pinentryField)
128+ self.keyboard.type(passphrase)
129+ self.keyboard.type("\n")
121
130
122− # pinPadLoader = self.main_window.get_pinPadLoader();
123− # self.assertThat(pinPadLoader.progress, Eventually(Equals(1)))
124− # lockscreen = self.main_window.get_lockscreen();
125− # self.assertThat(lockscreen.shown, Eventually(Equals(True)))
126
131
127− # if self.lightdm_mock == "single-pin":
128− # self.touch.tap_object(self.main_window.get_pinPadButton(1))
129− # self.touch.tap_object(self.main_window.get_pinPadButton(2))
130− # self.touch.tap_object(self.main_window.get_pinPadButton(3))
131− # self.touch.tap_object(self.main_window.get_pinPadButton(4))
132− # self.assertThat(lockscreen.shown, Eventually(Equals(False)))
133− # else:
134− # pinentryField = self.main_window.get_pinentryField()
135− # self.touch.tap_object(pinentryField)
136− # self.keyboard.type("password\n")
137− # self.assertThat(lockscreen.shown, Eventually(Equals(False)))
138
132
139 # def test_unlock_wrong(self):
133 # def test_unlock_wrong(self):
140 # self.unlock_greeter()
134 # self.unlock_greeter()