@@ -23,25 +23,34 @@ import LightDM 0.1 as LightDM
23import Unity.Test 0.1 as UT
23import Unity.Test 0.1 as UT
25Rectangle {
25Rectangle {
26− width: units.gu(60)
27+ width: units.gu(80)
27 height: units.gu(80)
28 height: units.gu(80)
28 color: "orange"
29 color: "orange"
30 Lockscreen {
31 Lockscreen {
31 id: lockscreen
32 id: lockscreen
32 anchors.fill: parent
33 anchors.fill: parent
33− anchors.rightMargin: units.gu(18)
34+ anchors.rightMargin: units.gu(30)
34 placeholderText: "Please enter your PIN"
35 placeholderText: "Please enter your PIN"
36+ wrongPlaceholderText: "Incorrect PIN"
37+ retryText: retryCountTextField.text
35 alphaNumeric: pinPadCheckBox.checked
38 alphaNumeric: pinPadCheckBox.checked
36− pinLength: pinLengthTextField.text
39+ minPinLength: minPinLengthTextField.text
40+ maxPinLength: maxPinLengthTextField.text
37 username: "Lola"
41 username: "Lola"
42+ background: "../../../qml/graphics/phone_background.jpg"
43+ infoText: infoTextTextField.text
40 Connections {
46 Connections {
41 target: lockscreen
47 target: lockscreen
43 onEmergencyCall: emergencyCheckBox.checked = true
49 onEmergencyCall: emergencyCheckBox.checked = true
44− onEntered: enteredLabel.text = passphrase
51+ enteredLabel.text = passphrase
52+ lockscreen.clear(true)
47 Connections {
56 Connections {
@@ -49,9 +58,9 @@ Rectangle {
50 onShowPrompt: {
59 onShowPrompt: {
51 if (text.indexOf("PIN") >= 0) {
60 if (text.indexOf("PIN") >= 0) {
52− lockscreen.alphaNumeric = false
61+ pinPadCheckBox.checked = false
54− lockscreen.alphaNumeric = true
63+ pinPadCheckBox.checked = true
56 lockscreen.placeholderText = text;
65 lockscreen.placeholderText = text;
@@ -65,6 +74,7 @@ Rectangle {
66 anchors.fill: parent
75 anchors.fill: parent
67 anchors.margins: units.gu(1)
76 anchors.margins: units.gu(1)
70 CheckBox {
80 CheckBox {
@@ -86,12 +96,32 @@ Rectangle {
88 TextField {
98 TextField {
89− id: pinLengthTextField
99+ id: minPinLengthTextField
90 width: units.gu(7)
100 width: units.gu(7)
91 text: "4"
101 text: "4"
104+ text: "Min PIN length"
109+ id: maxPinLengthTextField
94− text: "PIN length"
114+ text: "Max PIN length"
119+ id: retryCountTextField
121+ text: "3 retries left"
124+ text: "Retries left"
@@ -108,12 +138,40 @@ Rectangle {
110 text: "start auth (1234)"
140 text: "start auth (1234)"
111 onClicked: LightDM.Greeter.authenticate("has-pin")
142 onClicked: LightDM.Greeter.authenticate("has-pin")
114 text: "start auth (password)"
145 text: "start auth (password)"
115 onClicked: LightDM.Greeter.authenticate("has-password")
147 onClicked: LightDM.Greeter.authenticate("has-password")
151+ id: infoTextTextField
153+ placeholderText: "Infotext"
154+ text: "+49 179 3253553"
158+ id: infoPopupTitleTextField
160+ placeholderText: "Popup title"
161+ text: "This will be the last attempt"
165+ id: infoPopupTextArea
167+ text: "If the SIM PIN is entered incorrectly, your SIM will be blocked and would require the PUK code to unlock."
171+ text: "open info popup"
173+ onClicked: lockscreen.showInfoPopup(infoPopupTitleTextField.text, infoPopupTextArea.text)
@@ -121,6 +179,16 @@ Rectangle {
121 name: "Lockscreen"
179 name: "Lockscreen"
122 when: windowShown
180 when: windowShown
182+ function cleanup() {
183+ lockscreen.clear(false);
186+ function waitForLockscreenReady() {
187+ var pinPadLoader = findChild(lockscreen, "pinPadLoader");
188+ tryCompare(pinPadLoader, "status", Loader.Ready)
189+ waitForRendering(lockscreen)
124 function test_loading_data() {
192 function test_loading_data() {
126 {tag: "numeric", alphanumeric: false, pinPadAvailable: true },
194 {tag: "numeric", alphanumeric: false, pinPadAvailable: true },
@@ -129,8 +197,8 @@ Rectangle {
131 function test_loading(data) {
199 function test_loading(data) {
132− lockscreen.alphaNumeric = data.alphanumeric
200+ pinPadCheckBox.checked = data.alphanumeric
133− waitForRendering(lockscreen)
201+ waitForLockscreenReady();
134 if (data.pinPadAvailable) {
202 if (data.pinPadAvailable) {
135 compare(findChild(lockscreen, "pinPadButton8").text, "8", "Could not find number 8 on PinPad")
203 compare(findChild(lockscreen, "pinPadButton8").text, "8", "Could not find number 8 on PinPad")
@@ -147,8 +215,8 @@ Rectangle {
148 function test_emergency_call(data) {
216 function test_emergency_call(data) {
149 emergencyCheckBox.checked = false
217 emergencyCheckBox.checked = false
150− lockscreen.alphaNumeric = data.alphanumeric
218+ pinPadCheckBox.checked = data.alphanumeric
151− waitForRendering(lockscreen)
219+ waitForLockscreenReady();
152 var emergencyButton = findChild(lockscreen, "emergencyCallIcon")
220 var emergencyButton = findChild(lockscreen, "emergencyCallIcon")
153 mouseClick(emergencyButton, units.gu(1), units.gu(1))
221 mouseClick(emergencyButton, units.gu(1), units.gu(1))
154 tryCompare(emergencyCheckBox, "checked", true)
222 tryCompare(emergencyCheckBox, "checked", true)
@@ -163,9 +231,9 @@ Rectangle {
165 function test_labels(data) {
233 function test_labels(data) {
166− lockscreen.alphaNumeric = data.alphanumeric
234+ pinPadCheckBox.checked = data.alphanumeric
167 lockscreen.placeholderText = data.placeholderText
235 lockscreen.placeholderText = data.placeholderText
168− waitForRendering(lockscreen)
236+ waitForLockscreenReady();
169 compare(findChild(lockscreen, "pinentryField").placeholderText, data.placeholderText, "Placeholdertext is not what it should be")
237 compare(findChild(lockscreen, "pinentryField").placeholderText, data.placeholderText, "Placeholdertext is not what it should be")
170 if (data.alphanumeric) {
238 if (data.alphanumeric) {
171 compare(findChild(lockscreen, "greeterLabel").text, "Hello " + data.username, "Greeter is not set correctly")
239 compare(findChild(lockscreen, "greeterLabel").text, "Hello " + data.username, "Greeter is not set correctly")
@@ -175,23 +243,25 @@ Rectangle {
176 function test_unlock_data() {
244 function test_unlock_data() {
178− {tag: "numeric", alphanumeric: false, username: "has-pin", password: "1234", pinLength: 4},
246+ {tag: "numeric", alphanumeric: false, username: "has-pin", password: "1234", minPinLength: 4, maxPinLength: 4},
179− {tag: "alphanumeric", alphanumeric: true, username: "has-password", password: "password", pinLength: -1},
247+ {tag: "alphanumeric", alphanumeric: true, username: "has-password", password: "password", minPinLength: -1, maxPinLength: -1},
180− {tag: "numeric (wrong)", alphanumeric: false, username: "has-pin", password: "4321", pinLength: 4},
248+ {tag: "numeric (wrong)", alphanumeric: false, username: "has-pin", password: "4321", minPinLength: 4, maxPinLength: 4},
181− {tag: "alphanumeric (wrong)", alphanumeric: true, username: "has-password", password: "drowssap", pinLength: -1},
249+ {tag: "alphanumeric (wrong)", alphanumeric: true, username: "has-password", password: "drowssap", minPinLength: -1, maxPinLength: -1},
182− {tag: "flexible length", alphanumeric: false, username: "has-pin", password: "1234", pinLength: -1},
250+ {tag: "flexible length", alphanumeric: false, username: "has-pin", password: "1234", minPinLength: -1, maxPinLength: -1},
186 function test_unlock(data) {
254 function test_unlock(data) {
187 enteredLabel.text = ""
255 enteredLabel.text = ""
188− pinLengthTextField.text = data.pinLength
256+ minPinLengthTextField.text = data.minPinLength
257+ maxPinLengthTextField.text = data.maxPinLength
189 LightDM.Greeter.authenticate(data.username)
258 LightDM.Greeter.authenticate(data.username)
190− waitForRendering(lockscreen)
259+ waitForLockscreenReady();
192 var inputField = findChild(lockscreen, "pinentryField")
261 var inputField = findChild(lockscreen, "pinentryField")
193 if (data.alphanumeric) {
262 if (data.alphanumeric) {
194 mouseClick(inputField, units.gu(1), units.gu(1))
263 mouseClick(inputField, units.gu(1), units.gu(1))
264+ tryCompare(inputField, "focus", true);
195 typeString(data.password)
265 typeString(data.password)
196 keyClick(Qt.Key_Enter)
266 keyClick(Qt.Key_Enter)
@@ -200,7 +270,7 @@ Rectangle {
200 var button = findChild(lockscreen, "pinPadButton" + character)
270 var button = findChild(lockscreen, "pinPadButton" + character)
201 mouseClick(button, units.gu(1), units.gu(1))
271 mouseClick(button, units.gu(1), units.gu(1))
203− if (data.pinLength == -1) {
273+ if (data.minPinLength !== data.maxPinLength || data.minPinLength == -1) {
204 var pinPadButtonErase = findChild(lockscreen, "pinPadButtonErase");
274 var pinPadButtonErase = findChild(lockscreen, "pinPadButtonErase");
205 mouseClick(pinPadButtonErase, units.gu(1), units.gu(1));
275 mouseClick(pinPadButtonErase, units.gu(1), units.gu(1));
@@ -219,11 +289,12 @@ Rectangle {
220 function test_clear(data) {
290 function test_clear(data) {
221 pinPadCheckBox.checked = data.alphanumeric
291 pinPadCheckBox.checked = data.alphanumeric
222− waitForRendering(lockscreen)
292+ waitForLockscreenReady();
224 var inputField = findChild(lockscreen, "pinentryField")
294 var inputField = findChild(lockscreen, "pinentryField")
225 if (data.alphanumeric) {
295 if (data.alphanumeric) {
226 mouseClick(inputField, units.gu(1), units.gu(1))
296 mouseClick(inputField, units.gu(1), units.gu(1))
297+ tryCompare(inputField, "activeFocus", true);
227 typeString("1")
298 typeString("1")
229 var button = findChild(lockscreen, "pinPadButton1")
300 var button = findChild(lockscreen, "pinPadButton1")
@@ -239,6 +310,16 @@ Rectangle {
240 wait(0) // Trigger event loop to make sure the animation would start running
311 wait(0) // Trigger event loop to make sure the animation would start running
241 compare(animation.running, data.animation)
312 compare(animation.running, data.animation)
313+ if (data.animation) {
314+ if (data.alphanumeric) {
315+ tryCompare(inputField, "placeholderText", lockscreen.wrongPlaceholderText)
316+ tryCompare(inputField, "placeholderText", lockscreen.placeholderText)
318+ var label = findChild(lockscreen, "pinentryFieldPlaceHolder");
319+ tryCompare(label, "text", lockscreen.wrongPlaceholderText)
320+ tryCompare(label, "text", lockscreen.placeholderText)
243 // wait for animation to finish to not disturb other tests
324 // wait for animation to finish to not disturb other tests
244 tryCompare(animation, "running", false)
325 tryCompare(animation, "running", false)
@@ -246,33 +327,130 @@ Rectangle {
247 function test_backspace_data() {
328 function test_backspace_data() {
249− {tag: "fixed length", pinLength: 4},
330+ {tag: "fixed length", minPinLength: 4, maxPinLength: 4},
250− {tag: "variable length", pinLength: -1}
331+ {tag: "variable undefined length", minPinLength: -1, maxPinLength: -1},
332+ {tag: "variable restricted length", minPinLength: 4, maxPinLength: 8}
254 function test_backspace(data) {
336 function test_backspace(data) {
255 pinPadCheckBox.checked = false
337 pinPadCheckBox.checked = false
256− pinLengthTextField.text = data.pinLength
338+ minPinLengthTextField.text = data.minPinLength
257− waitForRendering(lockscreen);
339+ maxPinLengthTextField.text = data.maxPinLength
340+ waitForLockscreenReady();
259 var pinPadButtonErase = findChild(lockscreen, "pinPadButtonErase");
342 var pinPadButtonErase = findChild(lockscreen, "pinPadButtonErase");
260 var backspaceIcon = findChild(lockscreen, "backspaceIcon");
343 var backspaceIcon = findChild(lockscreen, "backspaceIcon");
261 var pinEntryField = findChild(lockscreen, "pinentryField");
344 var pinEntryField = findChild(lockscreen, "pinentryField");
346+ var autoConfirmEnabled = data.minPinLength === data.maxPinLength && data.minPinLength !== -1;
263− compare(pinPadButtonErase.iconName, data.pinLength == -1 ? "" : "erase");
347+ compare(pinPadButtonErase.iconName, autoConfirmEnabled ? "erase" : "");
264− compare(backspaceIcon.visible, data.pinLength == -1);
348+ compare(backspaceIcon.visible, !autoConfirmEnabled);
266 var pinPadButton5 = findChild(lockscreen, "pinPadButton5");
350 var pinPadButton5 = findChild(lockscreen, "pinPadButton5");
267 mouseClick(pinPadButton5, units.gu(1), units.gu(1));
351 mouseClick(pinPadButton5, units.gu(1), units.gu(1));
268 compare(pinEntryField.text, "5");
352 compare(pinEntryField.text, "5");
270− if (data.pinLength == -1) {
354+ if (data.minPinLength !== data.maxPinLength) {
271 mouseClick(backspaceIcon, units.gu(1), units.gu(1));
355 mouseClick(backspaceIcon, units.gu(1), units.gu(1));
273 mouseClick(pinPadButtonErase, units.gu(1), units.gu(1));
357 mouseClick(pinPadButtonErase, units.gu(1), units.gu(1));
275 compare(pinEntryField.text, "");
359 compare(pinEntryField.text, "");
362+ function test_minMaxLength_data() {
364+ {tag: "undefined", minPinLength: -1, maxPinLength: -1},
365+ {tag: "fixed", minPinLength: 4, maxPinLength: 4},
366+ {tag: "variable, limited", minPinLength: 4, maxPinLength: 8},
370+ function test_minMaxLength(data) {
371+ pinPadCheckBox.checked = false
372+ minPinLengthTextField.text = data.minPinLength
373+ maxPinLengthTextField.text = data.maxPinLength
374+ waitForLockscreenReady();
376+ var pinPadButton5 = findChild(lockscreen, "pinPadButton5");
377+ var pinPadButtonErase = findChild(lockscreen, "pinPadButtonErase");
378+ var inputField = findChild(lockscreen, "pinentryField")
380+ for (var i = 0; i < 10; i++) {
381+ mouseClick(pinPadButton5, units.gu(1), units.gu(1));
383+ if (data.minPinLength == data.maxPinLength && data.minPinLength != -1) {
384+ // auto confirm mode...
385+ compare(inputField.text.length, (i+1) % data.minPinLength);
387+ // manual confirm mode
388+ tryCompare(pinPadButtonErase, "enabled", (i+1) >= data.minPinLength)
389+ if (data.maxPinLength == -1) {
390+ compare(inputField.text.length, i+1);
392+ compare(inputField.text.length, Math.min(data.maxPinLength, i+1));
399+ function test_retryDisplay_data() {
401+ {tag: "empty", retryText: "", shown: false},
402+ {tag: "3 retries left", retryText: "3 retries left", shown: true},
406+ function test_retryDisplay(data) {
407+ pinPadCheckBox.checked = false
408+ waitForLockscreenReady();
410+ retryCountTextField.text = data.retryText;
411+ var label = findChild(lockscreen, "retryCountLabel")
412+ compare(label.visible, data.shown);
415+ function test_infoPopup() {
416+ verify(findChild(root, "infoPopup") === null);
417+ lockscreen.showInfoPopup("foo", "bar");
418+ tryCompareFunction(function() { return findChild(root, "infoPopup") !== null}, true);
420+ var infoPopup = findChild(root, "infoPopup");
421+ compare(infoPopup.title, "foo");
422+ compare(infoPopup.text, "bar");
424+ signalSpy.signalName = "infoPopupConfirmed"
427+ var okButton = findChild(root, "infoPopupOkButton");
428+ mouseClick(okButton, okButton.width / 2, okButton.height / 2);
430+ tryCompareFunction(function() { return findChild(root, "infoPopup") === null}, true);
432+ tryCompare(signalSpy, "count", 1);
435+ function test_infoTextDisplay_data() {
437+ {tag: "empty string", text: "", shown: false},
438+ {tag: "hello world", text: "hello world", shown: true},
442+ function test_infoTextDisplay(data) {
443+ pinPadCheckBox.checked = false
444+ waitForLockscreenReady();
446+ infoTextTextField.text = data.text;
447+ var label = findChild(lockscreen, "infoTextLabel")
448+ compare(label.visible, data.shown);