on xenial help sign in
enhance lockscreen
ba4f0beMichael Zanetti
qml/Greeter/Lockscreen.qml+79−7
@@ -15,7 +15,8 @@
15 */
15 */
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18−import Ubuntu.Components 0.1
18+import Ubuntu.Components 1.0
19+import Ubuntu.Components.Popups 1.0
19import "../Components"
20import "../Components"
20
21
21Showable {
22Showable {
@@ -27,12 +28,24 @@ Showable {
27 // Placeholder text
28 // Placeholder text
28 property string placeholderText: ""
29 property string placeholderText: ""
29
30
31+ // Informational text. (e.g. some text to tell which domain this is pin is entered for.
32+ property string infoText: ""
33+
30 // In case the Lockscreen can show a greeter message, this is the username
34 // In case the Lockscreen can show a greeter message, this is the username
31 property string username: ""
35 property string username: ""
32
36
33− // Set this to a value greater 0 to enable auto-confirm behavior for the lockscreen.
37+ // Set those to a value greater 0 to restrict the pin length.
38+ // If both are unset, the Lockscreen will show a confirm button and allow typing any length of pin before
39+ // confirming. If minPinLength is set to a value > 0, the confirm button will only become active when the
40+ // entered pin is at least that long. If maxPinLength is set, the lockscreen won't allow entering any
41+ // more numbers than that. If both are set, the lockscreen will enter auto confirming behavior, hiding the
42+ // confirmation button and triggering that automatically when the entered pin reached that length.
34− // This is ignored by the alphaNumeric lockscreen as that one is confirmed with pressing enter on the OSK.
43+ // This is ignored by the alphaNumeric lockscreen as that one is always confirmed by pressing enter on the OSK.
35− property int pinLength: -1
44+ property int minPinLength: -1
45+ property int maxPinLength: -1
46+
47+ // Set this to a value greater 0 to show a label telling the user how many retries are left
48+ property int retryCount: -1
36
49
37 property url background: ""
50 property url background: ""
38
51
@@ -56,6 +69,10 @@ Showable {
56 pinPadLoader.item.clear(showAnimation);
69 pinPadLoader.item.clear(showAnimation);
57 }
70 }
58
71
72+ function showInfoPopup(title, text) {
73+ PopupUtils.open(infoPopupComponent, root, {title: title, text: text})
74+ }
75+
59 Rectangle {
76 Rectangle {
60 // In case background fails to load or is undefined
77 // In case background fails to load or is undefined
61 id: backgroundBackup
78 id: backgroundBackup
@@ -68,7 +85,6 @@ Showable {
68 objectName: "lockscreenBackground"
85 objectName: "lockscreenBackground"
69 anchors {
86 anchors {
70 fill: parent
87 fill: parent
71− topMargin: backgroundTopMargin
72 }
88 }
73 source: root.required ? root.background : ""
89 source: root.required ? root.background : ""
74 fillMode: Image.PreserveAspectCrop
90 fillMode: Image.PreserveAspectCrop
@@ -78,6 +94,43 @@ Showable {
78 anchors.fill: root
94 anchors.fill: root
79 }
95 }
80
96
97+ Column {
98+ spacing: units.gu(2)
99+ anchors {
100+ left: parent.left
101+ right: parent.right
102+ bottom: pinPadLoader.top
103+ bottomMargin: units.gu(2)
104+ }
105+ Label {
106+ objectName: "retryCountLabel"
107+ anchors {
108+ left: parent.left
109+ right: parent.right
110+ }
111+ text: i18n.tr("%1 retries remaining").arg(root.retryCount)
112+ horizontalAlignment: Text.AlignHCenter
113+ color: "#f3f3e7"
114+ opacity: 0.6
115+ visible: root.retryCount >= 0
116+ }
117+ Label {
118+ id: infoTextLabel
119+ objectName: "infoTextLabel"
120+ anchors {
121+ left: parent.left
122+ right: parent.right
123+ }
124+ text: root.infoText
125+ horizontalAlignment: Text.AlignHCenter
126+ color: "#f3f3e7"
127+ opacity: 0.6
128+ visible: root.infoText.length > 0
129+ }
130+ }
131+
132+
133+
81 Loader {
134 Loader {
82 id: pinPadLoader
135 id: pinPadLoader
83 objectName: "pinPadLoader"
136 objectName: "pinPadLoader"
@@ -105,8 +158,13 @@ Showable {
105
158
106 Binding {
159 Binding {
107 target: pinPadLoader.item
160 target: pinPadLoader.item
108− property: "pinLength"
161+ property: "minPinLength"
162+ value: root.minPinLength
163+ }
164+ Binding {
165+ target: pinPadLoader.item
166+ property: "maxPinLength"
109− value: root.pinLength
167+ value: root.maxPinLength
110 }
168 }
111 Binding {
169 Binding {
112 target: pinPadLoader.item
170 target: pinPadLoader.item
@@ -153,4 +211,18 @@ Showable {
153 anchors.horizontalCenter: parent.horizontalCenter
211 anchors.horizontalCenter: parent.horizontalCenter
154 }
212 }
155 }
213 }
214+
215+ Component {
216+ id: infoPopupComponent
217+ Dialog {
218+ id: dialog
219+ objectName: "infoPopup"
220+
221+ Button {
222+ objectName: "infoPopupOkButton"
223+ text: i18n.tr("OK")
224+ onClicked: PopupUtils.close(dialog)
225+ }
226+ }
227+ }
156}
228}
qml/Greeter/PassphraseLockscreen.qml+3−1
@@ -75,7 +75,9 @@ Item {
75 hasClearButton: false
75 hasClearButton: false
76
76
77 onAccepted: {
77 onAccepted: {
78+ if (pinentryField.text) {
78− root.entered(pinentryField.text);
79+ root.entered(pinentryField.text);
80+ }
79 }
81 }
80 }
82 }
81 }
83 }
qml/Greeter/PinLockscreen.qml+21−9
@@ -27,7 +27,8 @@ Column {
27 property alias placeholderText: pinentryField.placeholderText
27 property alias placeholderText: pinentryField.placeholderText
28 property int padWidth: units.gu(34)
28 property int padWidth: units.gu(34)
29 property int padHeight: units.gu(28)
29 property int padHeight: units.gu(28)
30− property int pinLength: -1
30+ property int minPinLength: -1
31+ property int maxPinLength: -1
31
32
32 signal entered(string passphrase)
33 signal entered(string passphrase)
33 signal cancel()
34 signal cancel()
@@ -41,6 +42,10 @@ Column {
41 }
42 }
42 }
43 }
43
44
45+ QtObject {
46+ id: priv
47+ property bool autoConfirm: root.minPinLength == root.maxPinLength && root.minPinLength != -1
48+ }
44
49
45 UbuntuShape {
50 UbuntuShape {
46 id: pinentryField
51 id: pinentryField
@@ -52,12 +57,19 @@ Column {
52 radius: "medium"
57 radius: "medium"
53 property string text: ""
58 property string text: ""
54 property string placeholderText: ""
59 property string placeholderText: ""
60+
61+ function appendChar(character) {
62+ if (root.maxPinLength == -1 || pinentryField.text.length < root.maxPinLength) {
63+ pinentryField.text = pinentryField.text + character;
64+ }
65+ }
66+
55 onTextChanged: {
67 onTextChanged: {
56 pinentryFieldLabel.text = "";
68 pinentryFieldLabel.text = "";
57 for (var i = 0; i < text.length; ++i) {
69 for (var i = 0; i < text.length; ++i) {
58 pinentryFieldLabel.text += "•";
70 pinentryFieldLabel.text += "•";
59 }
71 }
60− if (text.length === root.pinLength) {
72+ if (priv.autoConfirm && text.length === root.maxPinLength) {
61 root.entered(text);
73 root.entered(text);
62 }
74 }
63 }
75 }
@@ -91,7 +103,7 @@ Column {
91 bottom: parent.bottom
103 bottom: parent.bottom
92 bottomMargin: units.gu(1)
104 bottomMargin: units.gu(1)
93 }
105 }
94− visible: root.pinLength == -1
106+ visible: !priv.autoConfirm
95 width: height
107 width: height
96 name: "erase"
108 name: "erase"
97 MouseArea {
109 MouseArea {
@@ -168,7 +180,7 @@ Column {
168 enabled: entryEnabled
180 enabled: entryEnabled
169
181
170 onClicked: {
182 onClicked: {
171− pinentryField.text = pinentryField.text + text;
183+ pinentryField.appendChar(text);
172 }
184 }
173 }
185 }
174 }
186 }
@@ -186,7 +198,7 @@ Column {
186 width: root.padWidth / 3
198 width: root.padWidth / 3
187 height: root.padHeight / 4
199 height: root.padHeight / 4
188 text: "0"
200 text: "0"
189− onClicked: pinentryField.text = pinentryField.text + text
201+ onClicked: pinentryField.appendChar(text);
190 enabled: entryEnabled
202 enabled: entryEnabled
191 }
203 }
192
204
@@ -194,16 +206,16 @@ Column {
194 objectName: "pinPadButtonErase"
206 objectName: "pinPadButtonErase"
195 width: root.padWidth / 3
207 width: root.padWidth / 3
196 height: root.padHeight / 4
208 height: root.padHeight / 4
197− iconName: root.pinLength == -1 ? "" : "erase"
209+ iconName: priv.autoConfirm ? "erase" : ""
198− subText: root.pinLength == -1 ? "DONE" : ""
210+ subText: priv.autoConfirm ? "" : "DONE"
199 onClicked: {
211 onClicked: {
200− if (root.pinLength !== -1) {
212+ if (priv.autoConfirm) {
201 pinentryField.text = pinentryField.text.substring(0, pinentryField.text.length-1);
213 pinentryField.text = pinentryField.text.substring(0, pinentryField.text.length-1);
202 } else {
214 } else {
203 root.entered(pinentryField.text);
215 root.entered(pinentryField.text);
204 }
216 }
205 }
217 }
206− enabled: entryEnabled
218+ enabled: priv.autoConfirm ? entryEnabled : pinentryField.text.length >= root.minPinLength
207 }
219 }
208 }
220 }
209 }
221 }
qml/Shell.qml+2−1
@@ -318,7 +318,8 @@ FocusScope {
318 width: parent.width
318 width: parent.width
319 height: parent.height - panel.panelHeight
319 height: parent.height - panel.panelHeight
320 background: shell.background
320 background: shell.background
321− pinLength: 4
321+ minPinLength: 4
322+ maxPinLength: 4
322
323
323 onEntered: LightDM.Greeter.respond(passphrase);
324 onEntered: LightDM.Greeter.respond(passphrase);
324 onCancel: greeter.show()
325 onCancel: greeter.show()
tests/qmltests/Greeter/tst_Lockscreen.qml+188−30
@@ -23,25 +23,33 @@ import LightDM 0.1 as LightDM
23import Unity.Test 0.1 as UT
23import Unity.Test 0.1 as UT
24
24
25Rectangle {
25Rectangle {
26+ id: root
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"
29
30
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"
35 alphaNumeric: pinPadCheckBox.checked
36 alphaNumeric: pinPadCheckBox.checked
36− pinLength: pinLengthTextField.text
37+ minPinLength: minPinLengthTextField.text
38+ maxPinLength: maxPinLengthTextField.text
39+ retryCount: retryCountTextField.text
37 username: "Lola"
40 username: "Lola"
41+ background: "../../../qml/graphics/phone_background.jpg"
42+ infoText: infoTextTextField.text
38 }
43 }
39
44
40 Connections {
45 Connections {
41 target: lockscreen
46 target: lockscreen
42
47
43 onEmergencyCall: emergencyCheckBox.checked = true
48 onEmergencyCall: emergencyCheckBox.checked = true
49+ onEntered: {
44− onEntered: enteredLabel.text = passphrase
50+ enteredLabel.text = passphrase
51+ lockscreen.clear(true)
52+ }
45 }
53 }
46
54
47 Connections {
55 Connections {
@@ -49,9 +57,9 @@ Rectangle {
49
57
50 onShowPrompt: {
58 onShowPrompt: {
51 if (text.indexOf("PIN") >= 0) {
59 if (text.indexOf("PIN") >= 0) {
52− lockscreen.alphaNumeric = false
60+ pinPadCheckBox.checked = false
53 } else {
61 } else {
54− lockscreen.alphaNumeric = true
62+ pinPadCheckBox.checked = true
55 }
63 }
56 lockscreen.placeholderText = text;
64 lockscreen.placeholderText = text;
57 }
65 }
@@ -65,6 +73,7 @@ Rectangle {
65 Column {
73 Column {
66 anchors.fill: parent
74 anchors.fill: parent
67 anchors.margins: units.gu(1)
75 anchors.margins: units.gu(1)
76+ spacing: units.gu(1)
68
77
69 Row {
78 Row {
70 CheckBox {
79 CheckBox {
@@ -86,12 +95,32 @@ Rectangle {
86 }
95 }
87 Row {
96 Row {
88 TextField {
97 TextField {
89− id: pinLengthTextField
98+ id: minPinLengthTextField
99+ width: units.gu(7)
100+ text: "4"
101+ }
102+ Label {
103+ text: "Min PIN length"
104+ }
105+ }
106+ Row {
107+ TextField {
108+ id: maxPinLengthTextField
90 width: units.gu(7)
109 width: units.gu(7)
91 text: "4"
110 text: "4"
92 }
111 }
93 Label {
112 Label {
94− text: "PIN length"
113+ text: "Max PIN length"
114+ }
115+ }
116+ Row {
117+ TextField {
118+ id: retryCountTextField
119+ width: units.gu(7)
120+ text: "3"
121+ }
122+ Label {
123+ text: "Retries left"
95 }
124 }
96 }
125 }
97 Label {
126 Label {
@@ -108,12 +137,40 @@ Rectangle {
108 }
137 }
109 Button {
138 Button {
110 text: "start auth (1234)"
139 text: "start auth (1234)"
140+ width: parent.width
111 onClicked: LightDM.Greeter.authenticate("has-pin")
141 onClicked: LightDM.Greeter.authenticate("has-pin")
112 }
142 }
113 Button {
143 Button {
114 text: "start auth (password)"
144 text: "start auth (password)"
145+ width: parent.width
115 onClicked: LightDM.Greeter.authenticate("has-password")
146 onClicked: LightDM.Greeter.authenticate("has-password")
116 }
147 }
148+
149+ TextField {
150+ id: infoTextTextField
151+ width: parent.width
152+ placeholderText: "Infotext"
153+ text: "+49 179 3253553"
154+ }
155+
156+ TextField {
157+ id: infoPopupTitleTextField
158+ width: parent.width
159+ placeholderText: "Popup title"
160+ text: "This will be the last attempt"
161+ }
162+
163+ TextArea {
164+ id: infoPopupTextArea
165+ width: parent.width
166+ text: "If the SIM PIN is entered incorrectly, your SIM will be blocked and would require the PUK code to unlock."
167+ }
168+
169+ Button {
170+ text: "open info popup"
171+ width: parent.width
172+ onClicked: lockscreen.showInfoPopup(infoPopupTitleTextField.text, infoPopupTextArea.text)
173+ }
117 }
174 }
118 }
175 }
119
176
@@ -121,6 +178,16 @@ Rectangle {
121 name: "Lockscreen"
178 name: "Lockscreen"
122 when: windowShown
179 when: windowShown
123
180
181+ function cleanup() {
182+ lockscreen.clear(false);
183+ }
184+
185+ function waitForLockscreenReady() {
186+ var pinPadLoader = findChild(lockscreen, "pinPadLoader");
187+ tryCompare(pinPadLoader, "status", Loader.Ready)
188+ waitForRendering(lockscreen)
189+ }
190+
124 function test_loading_data() {
191 function test_loading_data() {
125 return [
192 return [
126 {tag: "numeric", alphanumeric: false, pinPadAvailable: true },
193 {tag: "numeric", alphanumeric: false, pinPadAvailable: true },
@@ -129,8 +196,8 @@ Rectangle {
129 }
196 }
130
197
131 function test_loading(data) {
198 function test_loading(data) {
132− lockscreen.alphaNumeric = data.alphanumeric
199+ pinPadCheckBox.checked = data.alphanumeric
133− waitForRendering(lockscreen)
200+ waitForLockscreenReady();
134 if (data.pinPadAvailable) {
201 if (data.pinPadAvailable) {
135 compare(findChild(lockscreen, "pinPadButton8").text, "8", "Could not find number 8 on PinPad")
202 compare(findChild(lockscreen, "pinPadButton8").text, "8", "Could not find number 8 on PinPad")
136 } else {
203 } else {
@@ -147,8 +214,8 @@ Rectangle {
147
214
148 function test_emergency_call(data) {
215 function test_emergency_call(data) {
149 emergencyCheckBox.checked = false
216 emergencyCheckBox.checked = false
150− lockscreen.alphaNumeric = data.alphanumeric
217+ pinPadCheckBox.checked = data.alphanumeric
151− waitForRendering(lockscreen)
218+ waitForLockscreenReady();
152 var emergencyButton = findChild(lockscreen, "emergencyCallIcon")
219 var emergencyButton = findChild(lockscreen, "emergencyCallIcon")
153 mouseClick(emergencyButton, units.gu(1), units.gu(1))
220 mouseClick(emergencyButton, units.gu(1), units.gu(1))
154 tryCompare(emergencyCheckBox, "checked", true)
221 tryCompare(emergencyCheckBox, "checked", true)
@@ -163,9 +230,9 @@ Rectangle {
163 }
230 }
164
231
165 function test_labels(data) {
232 function test_labels(data) {
166− lockscreen.alphaNumeric = data.alphanumeric
233+ pinPadCheckBox.checked = data.alphanumeric
167 lockscreen.placeholderText = data.placeholderText
234 lockscreen.placeholderText = data.placeholderText
168− waitForRendering(lockscreen)
235+ waitForLockscreenReady();
169 compare(findChild(lockscreen, "pinentryField").placeholderText, data.placeholderText, "Placeholdertext is not what it should be")
236 compare(findChild(lockscreen, "pinentryField").placeholderText, data.placeholderText, "Placeholdertext is not what it should be")
170 if (data.alphanumeric) {
237 if (data.alphanumeric) {
171 compare(findChild(lockscreen, "greeterLabel").text, "Hello " + data.username, "Greeter is not set correctly")
238 compare(findChild(lockscreen, "greeterLabel").text, "Hello " + data.username, "Greeter is not set correctly")
@@ -175,23 +242,25 @@ Rectangle {
175
242
176 function test_unlock_data() {
243 function test_unlock_data() {
177 return [
244 return [
178− {tag: "numeric", alphanumeric: false, username: "has-pin", password: "1234", pinLength: 4},
245+ {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},
246+ {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},
247+ {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},
248+ {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},
249+ {tag: "flexible length", alphanumeric: false, username: "has-pin", password: "1234", minPinLength: -1, maxPinLength: -1},
183 ]
250 ]
184 }
251 }
185
252
186 function test_unlock(data) {
253 function test_unlock(data) {
187 enteredLabel.text = ""
254 enteredLabel.text = ""
188− pinLengthTextField.text = data.pinLength
255+ minPinLengthTextField.text = data.minPinLength
256+ maxPinLengthTextField.text = data.maxPinLength
189 LightDM.Greeter.authenticate(data.username)
257 LightDM.Greeter.authenticate(data.username)
190− waitForRendering(lockscreen)
258+ waitForLockscreenReady();
191
259
192 var inputField = findChild(lockscreen, "pinentryField")
260 var inputField = findChild(lockscreen, "pinentryField")
193 if (data.alphanumeric) {
261 if (data.alphanumeric) {
194 mouseClick(inputField, units.gu(1), units.gu(1))
262 mouseClick(inputField, units.gu(1), units.gu(1))
263+ tryCompare(inputField, "focus", true);
195 typeString(data.password)
264 typeString(data.password)
196 keyClick(Qt.Key_Enter)
265 keyClick(Qt.Key_Enter)
197 } else {
266 } else {
@@ -200,7 +269,7 @@ Rectangle {
200 var button = findChild(lockscreen, "pinPadButton" + character)
269 var button = findChild(lockscreen, "pinPadButton" + character)
201 mouseClick(button, units.gu(1), units.gu(1))
270 mouseClick(button, units.gu(1), units.gu(1))
202 }
271 }
203− if (data.pinLength == -1) {
272+ if (data.minPinLength !== data.maxPinLength || data.minPinLength == -1) {
204 var pinPadButtonErase = findChild(lockscreen, "pinPadButtonErase");
273 var pinPadButtonErase = findChild(lockscreen, "pinPadButtonErase");
205 mouseClick(pinPadButtonErase, units.gu(1), units.gu(1));
274 mouseClick(pinPadButtonErase, units.gu(1), units.gu(1));
206 }
275 }
@@ -219,11 +288,12 @@ Rectangle {
219
288
220 function test_clear(data) {
289 function test_clear(data) {
221 pinPadCheckBox.checked = data.alphanumeric
290 pinPadCheckBox.checked = data.alphanumeric
222− waitForRendering(lockscreen)
291+ waitForLockscreenReady();
223
292
224 var inputField = findChild(lockscreen, "pinentryField")
293 var inputField = findChild(lockscreen, "pinentryField")
225 if (data.alphanumeric) {
294 if (data.alphanumeric) {
226 mouseClick(inputField, units.gu(1), units.gu(1))
295 mouseClick(inputField, units.gu(1), units.gu(1))
296+ tryCompare(inputField, "activeFocus", true);
227 typeString("1")
297 typeString("1")
228 } else {
298 } else {
229 var button = findChild(lockscreen, "pinPadButton1")
299 var button = findChild(lockscreen, "pinPadButton1")
@@ -246,33 +316,121 @@ Rectangle {
246
316
247 function test_backspace_data() {
317 function test_backspace_data() {
248 return [
318 return [
249− {tag: "fixed length", pinLength: 4},
319+ {tag: "fixed length", minPinLength: 4, maxPinLength: 4},
250− {tag: "variable length", pinLength: -1}
320+ {tag: "variable undefined length", minPinLength: -1, maxPinLength: -1},
321+ {tag: "variable restricted length", minPinLength: 4, maxPinLength: 8}
251 ];
322 ];
252 }
323 }
253
324
254 function test_backspace(data) {
325 function test_backspace(data) {
255 pinPadCheckBox.checked = false
326 pinPadCheckBox.checked = false
256− pinLengthTextField.text = data.pinLength
327+ minPinLengthTextField.text = data.minPinLength
257− waitForRendering(lockscreen);
328+ maxPinLengthTextField.text = data.maxPinLength
329+ waitForLockscreenReady();
258
330
259 var pinPadButtonErase = findChild(lockscreen, "pinPadButtonErase");
331 var pinPadButtonErase = findChild(lockscreen, "pinPadButtonErase");
260 var backspaceIcon = findChild(lockscreen, "backspaceIcon");
332 var backspaceIcon = findChild(lockscreen, "backspaceIcon");
261 var pinEntryField = findChild(lockscreen, "pinentryField");
333 var pinEntryField = findChild(lockscreen, "pinentryField");
262
334
335+ var autoConfirmEnabled = data.minPinLength === data.maxPinLength && data.minPinLength !== -1;
263− compare(pinPadButtonErase.iconName, data.pinLength == -1 ? "" : "erase");
336+ compare(pinPadButtonErase.iconName, autoConfirmEnabled ? "erase" : "");
264− compare(backspaceIcon.visible, data.pinLength == -1);
337+ compare(backspaceIcon.visible, !autoConfirmEnabled);
265
338
266 var pinPadButton5 = findChild(lockscreen, "pinPadButton5");
339 var pinPadButton5 = findChild(lockscreen, "pinPadButton5");
267 mouseClick(pinPadButton5, units.gu(1), units.gu(1));
340 mouseClick(pinPadButton5, units.gu(1), units.gu(1));
268 compare(pinEntryField.text, "5");
341 compare(pinEntryField.text, "5");
269
342
270− if (data.pinLength == -1) {
343+ if (data.minPinLength !== data.maxPinLength) {
271 mouseClick(backspaceIcon, units.gu(1), units.gu(1));
344 mouseClick(backspaceIcon, units.gu(1), units.gu(1));
272 } else {
345 } else {
273 mouseClick(pinPadButtonErase, units.gu(1), units.gu(1));
346 mouseClick(pinPadButtonErase, units.gu(1), units.gu(1));
274 }
347 }
275 compare(pinEntryField.text, "");
348 compare(pinEntryField.text, "");
276 }
349 }
350+
351+ function test_minMaxLength_data() {
352+ return [
353+ {tag: "undefined", minPinLength: -1, maxPinLength: -1},
354+ {tag: "fixed", minPinLength: 4, maxPinLength: 4},
355+ {tag: "variable, limited", minPinLength: 4, maxPinLength: 8},
356+ ];
357+ }
358+
359+ function test_minMaxLength(data) {
360+ pinPadCheckBox.checked = false
361+ minPinLengthTextField.text = data.minPinLength
362+ maxPinLengthTextField.text = data.maxPinLength
363+ waitForLockscreenReady();
364+
365+ var pinPadButton5 = findChild(lockscreen, "pinPadButton5");
366+ var pinPadButtonErase = findChild(lockscreen, "pinPadButtonErase");
367+ var inputField = findChild(lockscreen, "pinentryField")
368+
369+ for (var i = 0; i < 10; i++) {
370+ mouseClick(pinPadButton5, units.gu(1), units.gu(1));
371+
372+ if (data.minPinLength == data.maxPinLength && data.minPinLength != -1) {
373+ // auto confirm mode...
374+ compare(inputField.text.length, (i+1) % data.minPinLength);
375+ } else {
376+ // manual confirm mode
377+ tryCompare(pinPadButtonErase, "enabled", (i+1) >= data.minPinLength)
378+ if (data.maxPinLength == -1) {
379+ compare(inputField.text.length, i+1);
380+ } else {
381+ compare(inputField.text.length, Math.min(data.maxPinLength, i+1));
382+ }
383+
384+ }
385+ }
386+ }
387+
388+ function test_retryDisplay_data() {
389+ return [
390+ {tag: "0", retryCount: 0, shown: true},
391+ {tag: "1", retryCount: 1, shown: true},
392+ {tag: "3", retryCount: 3, shown: true},
393+ {tag: "-1", retryCount: -1, shown: false},
394+ ]
395+ }
396+
397+ function test_retryDisplay(data) {
398+ pinPadCheckBox.checked = false
399+ waitForLockscreenReady();
400+
401+ retryCountTextField.text = data.retryCount;
402+ var label = findChild(lockscreen, "retryCountLabel")
403+ compare(label.visible, data.shown);
404+ }
405+
406+ function test_infoPopup() {
407+ verify(findChild(root, "infoPopup") === null);
408+ lockscreen.showInfoPopup("foo", "bar");
409+ tryCompareFunction(function() { return findChild(root, "infoPopup") !== null}, true);
410+
411+ var infoPopup = findChild(root, "infoPopup");
412+ compare(infoPopup.title, "foo");
413+ compare(infoPopup.text, "bar");
414+ var okButton = findChild(root, "infoPopupOkButton");
415+ mouseClick(okButton, okButton.width / 2, okButton.height / 2);
416+
417+ tryCompareFunction(function() { return findChild(root, "infoPopup") === null}, true);
418+ }
419+
420+ function test_infoTextDisplay_data() {
421+ return [
422+ {tag: "empty string", text: "", shown: false},
423+ {tag: "hello world", text: "hello world", shown: true},
424+ ]
425+ }
426+
427+ function test_infoTextDisplay(data) {
428+ pinPadCheckBox.checked = false
429+ waitForLockscreenReady();
430+
431+ infoTextTextField.text = data.text;
432+ var label = findChild(lockscreen, "infoTextLabel")
433+ compare(label.visible, data.shown);
434+ }
277 }
435 }
278}
436}