on xenial help sign in
Added second (desktop only) test.
commit25e1ab81a655efc87267cf8b3788cfd4ed83a5d0 authorThomi Richards <thomi.richards@canonical.com> dateMon 15 Jul 2013, 12:23 (13 years ago) parentd341616
1 file changed+30−36
tests/autopilot/unity8/shell/tests/test_lock_screen.py+30−36
tests/autopilot/unity8/shell/tests/test_lock_screen.py+30−36
@@ -29,6 +29,8 @@ from unity8.shell.tests import Unity8TestCase
2929from unity8.shell.tests.helpers import with_lightdm_mock
3030
3131from autopilot.matchers import Eventually
32+from testtools import skipUnless, skipIf
33+from autopilot.platform import model
3234from testtools.matchers import Equals
3335import logging
3436import time
@@ -41,26 +43,8 @@ class TestLockscreen(Unity8TestCase):
4143
4244 """Tests for the lock screen."""
4345
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−
6246 @with_lightdm_mock("single-pin")
63− def test_can_unlock_screen(self):
47+ def test_can_unlock_pin_screen(self):
6448 """Must be able to unlock the PIN entry lock screen."""
6549 self.app = self.launch_unity()
6650 self._unlock_greeter()
@@ -70,6 +54,18 @@ class TestLockscreen(Unity8TestCase):
7054
7155 self.assertThat(lockscreen.shown, Eventually(Equals(False)))
7256
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+
7369 def _unlock_greeter(self):
7470 greeter = self.main_window.get_greeter()
7571 self.assertThat(greeter.created, Eventually(Equals(True)))
@@ -116,25 +112,23 @@ class TestLockscreen(Unity8TestCase):
116112 )
117113 self.touch.tap_object(self.main_window.get_pinPadButton(int(num)))
118114
119− # def test_unlock(self):
120− # self.unlock_greeter()
115+ def _enter_passphrase(self, passphrase):
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")
121130
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)))
126131
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)))
138132
139133 # def test_unlock_wrong(self):
140134 # self.unlock_greeter()