Lomiri
Loading...
Searching...
No Matches
test_lock_screen.py
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Lomiri Autopilot Test Suite
4# Copyright (C) 2012, 2013, 2014, 2015 Canonical Ltd.
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19
20import logging
21
22from autopilot.matchers import Eventually
23from testtools.matchers import Equals
24from lomiriuitoolkit import lomiri_scenarios
25
26from lomiri.shell.tests import LomiriTestCase
27
28
29logger = logging.getLogger(__name__)
30
31
33
34 """Tests for the lock screen."""
35
36 scenarios = lomiri_scenarios.get_device_simulation_scenarios()
37
39 """Must be able to unlock the PIN entry lock screen."""
40
41 self._environment['LIBLIGHTDM_MOCK_MODE'] = "single-pin"
42 self.launch_lomiri()
43 greeter = self.main_window.get_greeter()
44
45 if not greeter.tabletMode:
46 greeter.swipe()
48 self.main_window.enter_pin_code("1234")
49 else:
50 self._enter_prompt_passphrase("1234\n")
51 self.assertThat(greeter.shown, Eventually(Equals(False)))
52
54 """Must be able to unlock the passphrase entry screen."""
55
56 self._environment['LIBLIGHTDM_MOCK_MODE'] = "single-passphrase"
57 self.launch_lomiri()
58 greeter = self.main_window.get_greeter()
59
60 if not greeter.tabletMode:
61 greeter.swipe()
63 self._enter_pin_passphrase("password")
64 else:
65 self._enter_prompt_passphrase("password")
66 self.assertThat(greeter.shown, Eventually(Equals(False)))
67
69 """Entering the wrong pin code must not dismiss the lock screen."""
70 self._environment['LIBLIGHTDM_MOCK_MODE'] = "single-pin"
71 self.launch_lomiri()
72 greeter = self.main_window.get_greeter()
73
74 if not greeter.tabletMode:
75 greeter.swipe()
77 self.main_window.enter_pin_code("4321")
78 pinentryField = self.main_window.get_pinentryField()
79 self.assertThat(pinentryField.text, Eventually(Equals("")))
80 else:
81 self._enter_prompt_passphrase("4231\n")
82 prompt = self.main_window.get_greeter().get_prompt()
83 self.assertThat(prompt.text, Eventually(Equals("")))
84 self.assertThat(greeter.shown, Eventually(Equals(True)))
85
87 """Entering the wrong password must not dismiss the lock screen."""
88 self._environment['LIBLIGHTDM_MOCK_MODE'] = "single-passphrase"
89 self.launch_lomiri()
90 greeter = self.main_window.get_greeter()
91
92 if not greeter.tabletMode:
93 greeter.swipe()
95 self._enter_pin_passphrase("foobar")
96 pinentryField = self.main_window.get_pinentryField()
97 self.assertThat(pinentryField.text, Eventually(Equals("")))
98 else:
99 self._enter_prompt_passphrase("foobar")
100 prompt = self.main_window.get_greeter().get_prompt()
101 self.assertThat(prompt.text, Eventually(Equals("")))
102 self.assertThat(greeter.shown, Eventually(Equals(True)))
103
105 """Wait for the lock screen to load, and return it."""
106 pinPadLoader = self.main_window.get_pinPadLoader()
107 self.assertThat(pinPadLoader.progress, Eventually(Equals(1)))
108 lockscreen = self.main_window.get_lockscreen()
109 self.assertThat(lockscreen.shown, Eventually(Equals(True)))
110 return lockscreen
111
112 def _enter_pin_passphrase(self, passphrase):
113 """Enter the password specified in 'passphrase' into the password entry
114 field of the pin lock screen.
115
116 :param passphrase: The string you want to enter.
117 :raises: TypeError if passphrase is not a string.
118
119 """
120 if not isinstance(passphrase, str):
121 raise TypeError(
122 "'passphrase' parameter must be a string, not %r."
123 % type(passphrase)
124 )
125
126 pin_entry_field = self.main_window.get_pinentryField()
127 # pinentryField should automatically have focus
128 self.keyboard.type(passphrase)
129 logger.debug("Typed passphrase: %s", pin_entry_field.text)
130 self.assertEqual(pin_entry_field.text, passphrase)
131 self.keyboard.type("\n")
132
133 def _enter_prompt_passphrase(self, passphrase):
134 """Enter the password specified in 'passphrase' into the password entry
135 field of the main user list's prompt.
136
137 :param passphrase: The string you want to enter.
138 :raises: TypeError if passphrase is not a string.
139
140 """
141 if not isinstance(passphrase, str):
142 raise TypeError(
143 "'passphrase' parameter must be a string, not %r."
144 % type(passphrase)
145 )
146
147 prompt = self.main_window.get_greeter().get_prompt()
148 prompt.write(passphrase)
149 logger.debug("Typed passphrase: %s", prompt.text)
150 self.keyboard.type("\n")
launch_lomiri(self, mode="full-greeter", *args)
Definition __init__.py:183