on xenial help sign in
enhance lockscreen

* add a retry indication label (e.g. 3 attempts left) * add an additional label (e.g. phone number for multi sim) * add a infoPopup (e.g. to display a warning for last retry) * add min and max limit values * add tests for the above Fixes: 1302050, 1303633, 1303635, 1303680, 1315451, 1323302

commitae0e951817a8bc4a2a47f6a725b6936552b41fa2 authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 27 May 2014, 07:46 (12 years ago) parentf60499187fe2ae
6 files changed+338−52
qml/Components/PinPadButton.qml+2−1 qml/Greeter/Lockscreen.qml+91−7 qml/Greeter/PassphraseLockscreen.qml+6−2 qml/Greeter/PinLockscreen.qml+29−11 qml/Shell.qml+2−1 tests/qmltests/Greeter/tst_Lockscreen.qml+208−30
qml/Components/PinPadButton.qml+2−1
@@ -19,6 +19,7 @@ import Ubuntu.Components 0.1
1919
2020Item {
2121 id: root
22+ opacity: enabled ? 1 : 0.6
2223
2324 property alias text: label.text
2425 property alias subText: subTextLabel.text
@@ -62,7 +63,7 @@ Item {
6263 Label {
6364 id: subTextLabel
6465 fontSize: "small"
65− color: "grey"
66+ color: "#f3f3e7"
6667 anchors.horizontalCenter: parent.horizontalCenter
6768 visible: text.length > 0
6869 }
qml/Greeter/Lockscreen.qml+91−7
@@ -15,7 +15,8 @@
1515 */
1616
1717import QtQuick 2.0
18−import Ubuntu.Components 0.1
18+import Ubuntu.Components 1.0
19+import Ubuntu.Components.Popups 1.0
1920import "../Components"
2021
2122Showable {
@@ -26,19 +27,34 @@ Showable {
2627
2728 // Placeholder text
2829 property string placeholderText: ""
30+ // Placeholder text while shaking (e.g. Incorrect passprase)
31+ property string wrongPlaceholderText: ""
32+ // Retries text (e.g. 3 retries left)
33+ property string retryText: ""
34+
35+ // Informational text. (e.g. some text to tell which domain this is pin is entered for.
36+ property string infoText: ""
2937
3038 // In case the Lockscreen can show a greeter message, this is the username
3139 property string username: ""
3240
33− // Set this to a value greater 0 to enable auto-confirm behavior for the lockscreen.
34− // This is ignored by the alphaNumeric lockscreen as that one is confirmed with pressing enter on the OSK.
35− property int pinLength: -1
41+ // Set those to a value greater 0 to restrict the pin length.
42+ // If both are unset, the Lockscreen will show a confirm button and allow typing any length of pin before
43+ // confirming. If minPinLength is set to a value > 0, the confirm button will only become active when the
44+ // entered pin is at least that long. If maxPinLength is set, the lockscreen won't allow entering any
45+ // more numbers than that. If both are set to the same value, the lockscreen will enter auto confirming
46+ // behavior, hiding the confirmation button and triggering that automatically when the entered pin reached
47+ // that length. This is ignored by the alphaNumeric lockscreen as that one is always confirmed by pressing
48+ // enter on the OSK.
49+ property int minPinLength: -1
50+ property int maxPinLength: -1
3651
3752 property url background: ""
3853
3954 signal entered(string passphrase)
4055 signal cancel()
4156 signal emergencyCall()
57+ signal infoPopupConfirmed()
4258
4359 onRequiredChanged: {
4460 if (required && pinPadLoader.item) {
@@ -56,6 +72,10 @@ Showable {
5672 pinPadLoader.item.clear(showAnimation);
5773 }
5874
75+ function showInfoPopup(title, text) {
76+ PopupUtils.open(infoPopupComponent, root, {title: title, text: text})
77+ }
78+
5979 Rectangle {
6080 // In case background fails to load or is undefined
6181 id: backgroundBackup
@@ -68,7 +88,6 @@ Showable {
6888 objectName: "lockscreenBackground"
6989 anchors {
7090 fill: parent
71− topMargin: backgroundTopMargin
7291 }
7392 source: root.required ? root.background : ""
7493 fillMode: Image.PreserveAspectCrop
@@ -78,6 +97,43 @@ Showable {
7897 anchors.fill: root
7998 }
8099
100+ Column {
101+ spacing: units.gu(2)
102+ anchors {
103+ left: parent.left
104+ right: parent.right
105+ bottom: pinPadLoader.top
106+ bottomMargin: units.gu(2)
107+ }
108+ Label {
109+ objectName: "retryCountLabel"
110+ anchors {
111+ left: parent.left
112+ right: parent.right
113+ }
114+ text: root.retryText
115+ horizontalAlignment: Text.AlignHCenter
116+ color: "#f3f3e7"
117+ opacity: 0.6
118+ visible: root.retryText.length > 0
119+ }
120+ Label {
121+ id: infoTextLabel
122+ objectName: "infoTextLabel"
123+ anchors {
124+ left: parent.left
125+ right: parent.right
126+ }
127+ text: root.infoText
128+ horizontalAlignment: Text.AlignHCenter
129+ color: "#f3f3e7"
130+ opacity: 0.6
131+ visible: root.infoText.length > 0
132+ }
133+ }
134+
135+
136+
81137 Loader {
82138 id: pinPadLoader
83139 objectName: "pinPadLoader"
@@ -105,14 +161,24 @@ Showable {
105161
106162 Binding {
107163 target: pinPadLoader.item
108− property: "pinLength"
109− value: root.pinLength
164+ property: "minPinLength"
165+ value: root.minPinLength
166+ }
167+ Binding {
168+ target: pinPadLoader.item
169+ property: "maxPinLength"
170+ value: root.maxPinLength
110171 }
111172 Binding {
112173 target: pinPadLoader.item
113174 property: "placeholderText"
114175 value: root.placeholderText
115176 }
177+ Binding {
178+ target: pinPadLoader.item
179+ property: "wrongPlaceholderText"
180+ value: root.wrongPlaceholderText
181+ }
116182 Binding {
117183 target: pinPadLoader.item
118184 property: "username"
@@ -153,4 +219,22 @@ Showable {
153219 anchors.horizontalCenter: parent.horizontalCenter
154220 }
155221 }
222+
223+ Component {
224+ id: infoPopupComponent
225+ Dialog {
226+ id: dialog
227+ objectName: "infoPopup"
228+ modal: true
229+
230+ Button {
231+ objectName: "infoPopupOkButton"
232+ text: i18n.tr("OK")
233+ onClicked: {
234+ PopupUtils.close(dialog)
235+ root.infoPopupConfirmed();
236+ }
237+ }
238+ }
239+ }
156240}
qml/Greeter/PassphraseLockscreen.qml+6−2
@@ -22,7 +22,8 @@ Item {
2222 id: root
2323 height: highlightItem.height
2424
25− property alias placeholderText: pinentryField.placeholderText
25+ property string placeholderText
26+ property string wrongPlaceholderText
2627 property string username: ""
2728
2829 signal entered(string passphrase)
@@ -73,9 +74,12 @@ Item {
7374 echoMode: TextInput.Password
7475 opacity: 0.9
7576 hasClearButton: false
77+ placeholderText: wrongPasswordAnimation.running ? root.wrongPlaceholderText : root.placeholderText
7678
7779 onAccepted: {
78− root.entered(pinentryField.text);
80+ if (pinentryField.text) {
81+ root.entered(pinentryField.text);
82+ }
7983 }
8084 }
8185 }
qml/Greeter/PinLockscreen.qml+29−11
@@ -25,9 +25,11 @@ Column {
2525 spacing: units.gu(3.5)
2626
2727 property alias placeholderText: pinentryField.placeholderText
28+ property alias wrongPlaceholderText: pinentryField.wrongPlaceholderText
2829 property int padWidth: units.gu(34)
2930 property int padHeight: units.gu(28)
30− property int pinLength: -1
31+ property int minPinLength: -1
32+ property int maxPinLength: -1
3133
3234 signal entered(string passphrase)
3335 signal cancel()
@@ -41,6 +43,10 @@ Column {
4143 }
4244 }
4345
46+ QtObject {
47+ id: priv
48+ property bool autoConfirm: root.minPinLength == root.maxPinLength && root.minPinLength != -1
49+ }
4450
4551 UbuntuShape {
4652 id: pinentryField
@@ -52,12 +58,20 @@ Column {
5258 radius: "medium"
5359 property string text: ""
5460 property string placeholderText: ""
61+ property string wrongPlaceholderText: ""
62+
63+ function appendChar(character) {
64+ if (root.maxPinLength == -1 || pinentryField.text.length < root.maxPinLength) {
65+ pinentryField.text = pinentryField.text + character;
66+ }
67+ }
68+
5569 onTextChanged: {
5670 pinentryFieldLabel.text = "";
5771 for (var i = 0; i < text.length; ++i) {
5872 pinentryFieldLabel.text += "•";
5973 }
60− if (text.length === root.pinLength) {
74+ if (priv.autoConfirm && text.length === root.maxPinLength) {
6175 root.entered(text);
6276 }
6377 }
@@ -74,9 +88,11 @@ Column {
7488 }
7589 Label {
7690 id: pinentryFieldPlaceHolder
91+ objectName: "pinentryFieldPlaceHolder"
7792 anchors.centerIn: parent
78− color: "grey"
79− text: parent.placeholderText
93+ color: "#f3f3e7"
94+ opacity: 0.6
95+ text: wrongPasswordAnimation.running ? parent.wrongPlaceholderText : parent.placeholderText
8096 visible: pinentryFieldLabel.text.length == 0
8197 }
8298
@@ -91,9 +107,11 @@ Column {
91107 bottom: parent.bottom
92108 bottomMargin: units.gu(1)
93109 }
94− visible: root.pinLength == -1
110+ visible: !priv.autoConfirm
95111 width: height
96112 name: "erase"
113+ color: "#f3f3e7"
114+ opacity: 0.6
97115 MouseArea {
98116 anchors.fill: parent
99117 onClicked: pinentryField.text = pinentryField.text.substring(0, pinentryField.text.length-1);
@@ -168,7 +186,7 @@ Column {
168186 enabled: entryEnabled
169187
170188 onClicked: {
171− pinentryField.text = pinentryField.text + text;
189+ pinentryField.appendChar(text);
172190 }
173191 }
174192 }
@@ -186,7 +204,7 @@ Column {
186204 width: root.padWidth / 3
187205 height: root.padHeight / 4
188206 text: "0"
189− onClicked: pinentryField.text = pinentryField.text + text
207+ onClicked: pinentryField.appendChar(text);
190208 enabled: entryEnabled
191209 }
192210
@@ -194,16 +212,16 @@ Column {
194212 objectName: "pinPadButtonErase"
195213 width: root.padWidth / 3
196214 height: root.padHeight / 4
197− iconName: root.pinLength == -1 ? "" : "erase"
198− subText: root.pinLength == -1 ? "DONE" : ""
215+ iconName: priv.autoConfirm ? "erase" : ""
216+ subText: priv.autoConfirm ? "" : "DONE"
199217 onClicked: {
200− if (root.pinLength !== -1) {
218+ if (priv.autoConfirm) {
201219 pinentryField.text = pinentryField.text.substring(0, pinentryField.text.length-1);
202220 } else {
203221 root.entered(pinentryField.text);
204222 }
205223 }
206− enabled: entryEnabled
224+ enabled: priv.autoConfirm ? entryEnabled : pinentryField.text.length >= root.minPinLength
207225 }
208226 }
209227 }
qml/Shell.qml+2−1
@@ -316,7 +316,8 @@ FocusScope {
316316 width: parent.width
317317 height: parent.height - panel.panelHeight
318318 background: shell.background
319− pinLength: 4
319+ minPinLength: 4
320+ maxPinLength: 4
320321
321322 onEntered: LightDM.Greeter.respond(passphrase);
322323 onCancel: greeter.show()
tests/qmltests/Greeter/tst_Lockscreen.qml+208−30
@@ -23,25 +23,34 @@ import LightDM 0.1 as LightDM
2323import Unity.Test 0.1 as UT
2424
2525Rectangle {
26− width: units.gu(60)
26+ id: root
27+ width: units.gu(80)
2728 height: units.gu(80)
2829 color: "orange"
2930
3031 Lockscreen {
3132 id: lockscreen
3233 anchors.fill: parent
33− anchors.rightMargin: units.gu(18)
34+ anchors.rightMargin: units.gu(30)
3435 placeholderText: "Please enter your PIN"
36+ wrongPlaceholderText: "Incorrect PIN"
37+ retryText: retryCountTextField.text
3538 alphaNumeric: pinPadCheckBox.checked
36− pinLength: pinLengthTextField.text
39+ minPinLength: minPinLengthTextField.text
40+ maxPinLength: maxPinLengthTextField.text
3741 username: "Lola"
42+ background: "../../../qml/graphics/phone_background.jpg"
43+ infoText: infoTextTextField.text
3844 }
3945
4046 Connections {
4147 target: lockscreen
4248
4349 onEmergencyCall: emergencyCheckBox.checked = true
44− onEntered: enteredLabel.text = passphrase
50+ onEntered: {
51+ enteredLabel.text = passphrase
52+ lockscreen.clear(true)
53+ }
4554 }
4655
4756 Connections {
@@ -49,9 +58,9 @@ Rectangle {
4958
5059 onShowPrompt: {
5160 if (text.indexOf("PIN") >= 0) {
52− lockscreen.alphaNumeric = false
61+ pinPadCheckBox.checked = false
5362 } else {
54− lockscreen.alphaNumeric = true
63+ pinPadCheckBox.checked = true
5564 }
5665 lockscreen.placeholderText = text;
5766 }
@@ -65,6 +74,7 @@ Rectangle {
6574 Column {
6675 anchors.fill: parent
6776 anchors.margins: units.gu(1)
77+ spacing: units.gu(1)
6878
6979 Row {
7080 CheckBox {
@@ -86,12 +96,32 @@ Rectangle {
8696 }
8797 Row {
8898 TextField {
89− id: pinLengthTextField
99+ id: minPinLengthTextField
90100 width: units.gu(7)
91101 text: "4"
92102 }
93103 Label {
94− text: "PIN length"
104+ text: "Min PIN length"
105+ }
106+ }
107+ Row {
108+ TextField {
109+ id: maxPinLengthTextField
110+ width: units.gu(7)
111+ text: "4"
112+ }
113+ Label {
114+ text: "Max PIN length"
115+ }
116+ }
117+ Row {
118+ TextField {
119+ id: retryCountTextField
120+ width: units.gu(7)
121+ text: "3 retries left"
122+ }
123+ Label {
124+ text: "Retries left"
95125 }
96126 }
97127 Label {
@@ -108,12 +138,40 @@ Rectangle {
108138 }
109139 Button {
110140 text: "start auth (1234)"
141+ width: parent.width
111142 onClicked: LightDM.Greeter.authenticate("has-pin")
112143 }
113144 Button {
114145 text: "start auth (password)"
146+ width: parent.width
115147 onClicked: LightDM.Greeter.authenticate("has-password")
116148 }
149+
150+ TextField {
151+ id: infoTextTextField
152+ width: parent.width
153+ placeholderText: "Infotext"
154+ text: "+49 179 3253553"
155+ }
156+
157+ TextField {
158+ id: infoPopupTitleTextField
159+ width: parent.width
160+ placeholderText: "Popup title"
161+ text: "This will be the last attempt"
162+ }
163+
164+ TextArea {
165+ id: infoPopupTextArea
166+ width: parent.width
167+ text: "If the SIM PIN is entered incorrectly, your SIM will be blocked and would require the PUK code to unlock."
168+ }
169+
170+ Button {
171+ text: "open info popup"
172+ width: parent.width
173+ onClicked: lockscreen.showInfoPopup(infoPopupTitleTextField.text, infoPopupTextArea.text)
174+ }
117175 }
118176 }
119177
@@ -121,6 +179,16 @@ Rectangle {
121179 name: "Lockscreen"
122180 when: windowShown
123181
182+ function cleanup() {
183+ lockscreen.clear(false);
184+ }
185+
186+ function waitForLockscreenReady() {
187+ var pinPadLoader = findChild(lockscreen, "pinPadLoader");
188+ tryCompare(pinPadLoader, "status", Loader.Ready)
189+ waitForRendering(lockscreen)
190+ }
191+
124192 function test_loading_data() {
125193 return [
126194 {tag: "numeric", alphanumeric: false, pinPadAvailable: true },
@@ -129,8 +197,8 @@ Rectangle {
129197 }
130198
131199 function test_loading(data) {
132− lockscreen.alphaNumeric = data.alphanumeric
133− waitForRendering(lockscreen)
200+ pinPadCheckBox.checked = data.alphanumeric
201+ waitForLockscreenReady();
134202 if (data.pinPadAvailable) {
135203 compare(findChild(lockscreen, "pinPadButton8").text, "8", "Could not find number 8 on PinPad")
136204 } else {
@@ -147,8 +215,8 @@ Rectangle {
147215
148216 function test_emergency_call(data) {
149217 emergencyCheckBox.checked = false
150− lockscreen.alphaNumeric = data.alphanumeric
151− waitForRendering(lockscreen)
218+ pinPadCheckBox.checked = data.alphanumeric
219+ waitForLockscreenReady();
152220 var emergencyButton = findChild(lockscreen, "emergencyCallIcon")
153221 mouseClick(emergencyButton, units.gu(1), units.gu(1))
154222 tryCompare(emergencyCheckBox, "checked", true)
@@ -163,9 +231,9 @@ Rectangle {
163231 }
164232
165233 function test_labels(data) {
166− lockscreen.alphaNumeric = data.alphanumeric
234+ pinPadCheckBox.checked = data.alphanumeric
167235 lockscreen.placeholderText = data.placeholderText
168− waitForRendering(lockscreen)
236+ waitForLockscreenReady();
169237 compare(findChild(lockscreen, "pinentryField").placeholderText, data.placeholderText, "Placeholdertext is not what it should be")
170238 if (data.alphanumeric) {
171239 compare(findChild(lockscreen, "greeterLabel").text, "Hello " + data.username, "Greeter is not set correctly")
@@ -175,23 +243,25 @@ Rectangle {
175243
176244 function test_unlock_data() {
177245 return [
178− {tag: "numeric", alphanumeric: false, username: "has-pin", password: "1234", pinLength: 4},
179− {tag: "alphanumeric", alphanumeric: true, username: "has-password", password: "password", pinLength: -1},
180− {tag: "numeric (wrong)", alphanumeric: false, username: "has-pin", password: "4321", pinLength: 4},
181− {tag: "alphanumeric (wrong)", alphanumeric: true, username: "has-password", password: "drowssap", pinLength: -1},
182− {tag: "flexible length", alphanumeric: false, username: "has-pin", password: "1234", pinLength: -1},
246+ {tag: "numeric", alphanumeric: false, username: "has-pin", password: "1234", minPinLength: 4, maxPinLength: 4},
247+ {tag: "alphanumeric", alphanumeric: true, username: "has-password", password: "password", minPinLength: -1, maxPinLength: -1},
248+ {tag: "numeric (wrong)", alphanumeric: false, username: "has-pin", password: "4321", minPinLength: 4, maxPinLength: 4},
249+ {tag: "alphanumeric (wrong)", alphanumeric: true, username: "has-password", password: "drowssap", minPinLength: -1, maxPinLength: -1},
250+ {tag: "flexible length", alphanumeric: false, username: "has-pin", password: "1234", minPinLength: -1, maxPinLength: -1},
183251 ]
184252 }
185253
186254 function test_unlock(data) {
187255 enteredLabel.text = ""
188− pinLengthTextField.text = data.pinLength
256+ minPinLengthTextField.text = data.minPinLength
257+ maxPinLengthTextField.text = data.maxPinLength
189258 LightDM.Greeter.authenticate(data.username)
190− waitForRendering(lockscreen)
259+ waitForLockscreenReady();
191260
192261 var inputField = findChild(lockscreen, "pinentryField")
193262 if (data.alphanumeric) {
194263 mouseClick(inputField, units.gu(1), units.gu(1))
264+ tryCompare(inputField, "focus", true);
195265 typeString(data.password)
196266 keyClick(Qt.Key_Enter)
197267 } else {
@@ -200,7 +270,7 @@ Rectangle {
200270 var button = findChild(lockscreen, "pinPadButton" + character)
201271 mouseClick(button, units.gu(1), units.gu(1))
202272 }
203− if (data.pinLength == -1) {
273+ if (data.minPinLength !== data.maxPinLength || data.minPinLength == -1) {
204274 var pinPadButtonErase = findChild(lockscreen, "pinPadButtonErase");
205275 mouseClick(pinPadButtonErase, units.gu(1), units.gu(1));
206276 }
@@ -219,11 +289,12 @@ Rectangle {
219289
220290 function test_clear(data) {
221291 pinPadCheckBox.checked = data.alphanumeric
222− waitForRendering(lockscreen)
292+ waitForLockscreenReady();
223293
224294 var inputField = findChild(lockscreen, "pinentryField")
225295 if (data.alphanumeric) {
226296 mouseClick(inputField, units.gu(1), units.gu(1))
297+ tryCompare(inputField, "activeFocus", true);
227298 typeString("1")
228299 } else {
229300 var button = findChild(lockscreen, "pinPadButton1")
@@ -239,6 +310,16 @@ Rectangle {
239310
240311 wait(0) // Trigger event loop to make sure the animation would start running
241312 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)
317+ } else {
318+ var label = findChild(lockscreen, "pinentryFieldPlaceHolder");
319+ tryCompare(label, "text", lockscreen.wrongPlaceholderText)
320+ tryCompare(label, "text", lockscreen.placeholderText)
321+ }
322+ }
242323
243324 // wait for animation to finish to not disturb other tests
244325 tryCompare(animation, "running", false)
@@ -246,33 +327,130 @@ Rectangle {
246327
247328 function test_backspace_data() {
248329 return [
249− {tag: "fixed length", pinLength: 4},
250− {tag: "variable length", pinLength: -1}
330+ {tag: "fixed length", minPinLength: 4, maxPinLength: 4},
331+ {tag: "variable undefined length", minPinLength: -1, maxPinLength: -1},
332+ {tag: "variable restricted length", minPinLength: 4, maxPinLength: 8}
251333 ];
252334 }
253335
254336 function test_backspace(data) {
255337 pinPadCheckBox.checked = false
256− pinLengthTextField.text = data.pinLength
257− waitForRendering(lockscreen);
338+ minPinLengthTextField.text = data.minPinLength
339+ maxPinLengthTextField.text = data.maxPinLength
340+ waitForLockscreenReady();
258341
259342 var pinPadButtonErase = findChild(lockscreen, "pinPadButtonErase");
260343 var backspaceIcon = findChild(lockscreen, "backspaceIcon");
261344 var pinEntryField = findChild(lockscreen, "pinentryField");
262345
263− compare(pinPadButtonErase.iconName, data.pinLength == -1 ? "" : "erase");
264− compare(backspaceIcon.visible, data.pinLength == -1);
346+ var autoConfirmEnabled = data.minPinLength === data.maxPinLength && data.minPinLength !== -1;
347+ compare(pinPadButtonErase.iconName, autoConfirmEnabled ? "erase" : "");
348+ compare(backspaceIcon.visible, !autoConfirmEnabled);
265349
266350 var pinPadButton5 = findChild(lockscreen, "pinPadButton5");
267351 mouseClick(pinPadButton5, units.gu(1), units.gu(1));
268352 compare(pinEntryField.text, "5");
269353
270− if (data.pinLength == -1) {
354+ if (data.minPinLength !== data.maxPinLength) {
271355 mouseClick(backspaceIcon, units.gu(1), units.gu(1));
272356 } else {
273357 mouseClick(pinPadButtonErase, units.gu(1), units.gu(1));
274358 }
275359 compare(pinEntryField.text, "");
276360 }
361+
362+ function test_minMaxLength_data() {
363+ return [
364+ {tag: "undefined", minPinLength: -1, maxPinLength: -1},
365+ {tag: "fixed", minPinLength: 4, maxPinLength: 4},
366+ {tag: "variable, limited", minPinLength: 4, maxPinLength: 8},
367+ ];
368+ }
369+
370+ function test_minMaxLength(data) {
371+ pinPadCheckBox.checked = false
372+ minPinLengthTextField.text = data.minPinLength
373+ maxPinLengthTextField.text = data.maxPinLength
374+ waitForLockscreenReady();
375+
376+ var pinPadButton5 = findChild(lockscreen, "pinPadButton5");
377+ var pinPadButtonErase = findChild(lockscreen, "pinPadButtonErase");
378+ var inputField = findChild(lockscreen, "pinentryField")
379+
380+ for (var i = 0; i < 10; i++) {
381+ mouseClick(pinPadButton5, units.gu(1), units.gu(1));
382+
383+ if (data.minPinLength == data.maxPinLength && data.minPinLength != -1) {
384+ // auto confirm mode...
385+ compare(inputField.text.length, (i+1) % data.minPinLength);
386+ } else {
387+ // manual confirm mode
388+ tryCompare(pinPadButtonErase, "enabled", (i+1) >= data.minPinLength)
389+ if (data.maxPinLength == -1) {
390+ compare(inputField.text.length, i+1);
391+ } else {
392+ compare(inputField.text.length, Math.min(data.maxPinLength, i+1));
393+ }
394+
395+ }
396+ }
397+ }
398+
399+ function test_retryDisplay_data() {
400+ return [
401+ {tag: "empty", retryText: "", shown: false},
402+ {tag: "3 retries left", retryText: "3 retries left", shown: true},
403+ ]
404+ }
405+
406+ function test_retryDisplay(data) {
407+ pinPadCheckBox.checked = false
408+ waitForLockscreenReady();
409+
410+ retryCountTextField.text = data.retryText;
411+ var label = findChild(lockscreen, "retryCountLabel")
412+ compare(label.visible, data.shown);
413+ }
414+
415+ function test_infoPopup() {
416+ verify(findChild(root, "infoPopup") === null);
417+ lockscreen.showInfoPopup("foo", "bar");
418+ tryCompareFunction(function() { return findChild(root, "infoPopup") !== null}, true);
419+
420+ var infoPopup = findChild(root, "infoPopup");
421+ compare(infoPopup.title, "foo");
422+ compare(infoPopup.text, "bar");
423+
424+ signalSpy.signalName = "infoPopupConfirmed"
425+ signalSpy.clear();
426+
427+ var okButton = findChild(root, "infoPopupOkButton");
428+ mouseClick(okButton, okButton.width / 2, okButton.height / 2);
429+
430+ tryCompareFunction(function() { return findChild(root, "infoPopup") === null}, true);
431+
432+ tryCompare(signalSpy, "count", 1);
433+ }
434+
435+ function test_infoTextDisplay_data() {
436+ return [
437+ {tag: "empty string", text: "", shown: false},
438+ {tag: "hello world", text: "hello world", shown: true},
439+ ]
440+ }
441+
442+ function test_infoTextDisplay(data) {
443+ pinPadCheckBox.checked = false
444+ waitForLockscreenReady();
445+
446+ infoTextTextField.text = data.text;
447+ var label = findChild(lockscreen, "infoTextLabel")
448+ compare(label.visible, data.shown);
449+ }
450+ }
451+
452+ SignalSpy {
453+ id: signalSpy
454+ target: lockscreen
277455 }
278456}