@@ -26,22 +26,21 @@ import Unity.Test 0.1 as UT
2626Rectangle {
2727 id: root
2828 width: units.gu(80)
29− height: units.gu(80)
29+ height: units.gu(70)
3030 color: "orange"
3131
3232 Lockscreen {
3333 id: lockscreen
3434 anchors.fill: parent
35− anchors.rightMargin: units.gu(30)
36− placeholderText: "Please enter your PIN"
37− wrongPlaceholderText: "Incorrect PIN"
35+ anchors.rightMargin: units.gu(40)
36+ infoText: infoTextTextField.text
3837 retryText: retryCountTextField.text
38+ errorText: errorTextTextField.text
3939 alphaNumeric: pinPadCheckBox.checked
4040 minPinLength: minPinLengthTextField.text
4141 maxPinLength: maxPinLengthTextField.text
4242 username: "Lola"
4343 background: "../../../qml/graphics/phone_background.jpg"
44− infoText: infoTextTextField.text
4544 }
4645
4746 Connections {
@@ -68,7 +67,7 @@ Rectangle {
6867 } else {
6968 pinPadCheckBox.checked = true
7069 }
71− lockscreen.placeholderText = text;
70+ lockscreen.infoText = text;
7271 }
7372 }
7473
@@ -157,7 +156,14 @@ Rectangle {
157156 id: infoTextTextField
158157 width: parent.width
159158 placeholderText: "Infotext"
160− text: "+49 179 3253553"
159+ text: "Enter SIM1 PIN"
160+ }
161+
162+ TextField {
163+ id: errorTextTextField
164+ width: parent.width
165+ placeholderText: "Error text"
166+ text: "Sorry, incorrect PIN"
161167 }
162168
163169 TextField {
@@ -223,7 +229,7 @@ Rectangle {
223229 emergencyCheckBox.checked = false
224230 pinPadCheckBox.checked = data.alphanumeric
225231 waitForLockscreenReady();
226− var emergencyButton = findChild(lockscreen, "emergencyCallIcon")
232+ var emergencyButton = findChild(lockscreen, "emergencyCallLabel")
227233 mouseClick(emergencyButton, units.gu(1), units.gu(1))
228234 tryCompare(emergencyCheckBox, "checked", true)
229235
@@ -231,18 +237,20 @@ Rectangle {
231237
232238 function test_labels_data() {
233239 return [
234− {tag: "numeric", alphanumeric: false, placeholderText: "Please enter your PIN", username: "foobar" },
235− {tag: "alphanumeric", alphanumeric: true, placeholderText: "Please enter your password", username: "Lola" }
240+ {tag: "numeric", alphanumeric: false, infoText: "Please enter your PIN", username: "foobar" },
241+ {tag: "alphanumeric", alphanumeric: true, infoText: "Please enter your password", username: "Lola" }
236242 ]
237243 }
238244
239245 function test_labels(data) {
240246 pinPadCheckBox.checked = data.alphanumeric
241− lockscreen.placeholderText = data.placeholderText
247+ lockscreen.infoText = data.infoText
242248 waitForLockscreenReady();
243− compare(findChild(lockscreen, "pinentryField").placeholderText, data.placeholderText, "Placeholdertext is not what it should be")
244249 if (data.alphanumeric) {
250+ compare(findChild(lockscreen, "pinentryField").placeholderText, data.infoText, "Placeholdertext is not what it should be")
245251 compare(findChild(lockscreen, "greeterLabel").text, "Hello " + data.username, "Greeter is not set correctly")
252+ } else {
253+ compare(findChild(lockscreen, "infoTextLabel").text, data.infoText, "Placeholdertext is not what it should be")
246254 }
247255 }
248256
@@ -276,10 +284,8 @@ Rectangle {
276284 var button = findChild(lockscreen, "pinPadButton" + character)
277285 mouseClick(button, units.gu(1), units.gu(1))
278286 }
279− if (data.minPinLength !== data.maxPinLength || data.minPinLength == -1) {
280− var pinPadButtonErase = findChild(lockscreen, "pinPadButtonErase");
281− mouseClick(pinPadButtonErase, units.gu(1), units.gu(1));
282− }
287+ var confirmButton = findChild(lockscreen, "confirmButton");
288+ mouseClick(confirmButton, units.gu(1), units.gu(1));
283289 }
284290 tryCompare(enteredLabel, "text", data.password)
285291 }
@@ -317,11 +323,9 @@ Rectangle {
317323 wait(0) // Trigger event loop to make sure the animation would start running
318324 compare(animation.running, data.animation)
319325 if (data.animation) {
320− if (data.alphanumeric) {
321− tryCompare(inputField, "placeholderText", lockscreen.wrongPlaceholderText)
322− } else {
323− var label = findChild(lockscreen, "pinentryFieldPlaceHolder");
324− tryCompare(label, "text", lockscreen.wrongPlaceholderText)
326+ if (!data.alphanumeric) {
327+ var label = findChild(lockscreen, "wrongNoticeLabel");
328+ tryCompare(label, "visible", true)
325329 }
326330 }
327331
@@ -343,24 +347,21 @@ Rectangle {
343347 maxPinLengthTextField.text = data.maxPinLength
344348 waitForLockscreenReady();
345349
346− var pinPadButtonErase = findChild(lockscreen, "pinPadButtonErase");
347350 var backspaceIcon = findChild(lockscreen, "backspaceIcon");
348351 var pinEntryField = findChild(lockscreen, "pinentryField");
349352
350− var autoConfirmEnabled = data.minPinLength === data.maxPinLength && data.minPinLength !== -1;
351− compare(pinPadButtonErase.iconName, autoConfirmEnabled ? "erase" : "");
352− compare(backspaceIcon.visible, !autoConfirmEnabled);
353+ compare(backspaceIcon.opacity, 0);
353354
354355 var pinPadButton5 = findChild(lockscreen, "pinPadButton5");
355356 mouseClick(pinPadButton5, units.gu(1), units.gu(1));
356357 compare(pinEntryField.text, "5");
357358
358− if (data.minPinLength !== data.maxPinLength) {
359− mouseClick(backspaceIcon, units.gu(1), units.gu(1));
360− } else {
361− mouseClick(pinPadButtonErase, units.gu(1), units.gu(1));
362− }
359+ tryCompare(backspaceIcon, "opacity", 1);
360+
361+ mouseClick(backspaceIcon, units.gu(1), units.gu(1));
363362 compare(pinEntryField.text, "");
363+
364+ tryCompare(backspaceIcon, "opacity", 0);
364365 }
365366
366367 function test_minMaxLength_data() {
@@ -373,37 +374,55 @@ Rectangle {
373374
374375 function test_minMaxLength(data) {
375376 pinPadCheckBox.checked = false
376− minPinLengthTextField.text = data.minPinLength
377− maxPinLengthTextField.text = data.maxPinLength
377+ minPinLengthTextField.text = data.minPinLength;
378+ maxPinLengthTextField.text = data.maxPinLength;
378379 waitForLockscreenReady();
379380
380381 var pinPadButton5 = findChild(lockscreen, "pinPadButton5");
381− var pinPadButtonErase = findChild(lockscreen, "pinPadButtonErase");
382− var inputField = findChild(lockscreen, "pinentryField")
382+ var backspaceButton = findChild(lockscreen, "backspaceIcon");
383+ var confirmButton = findChild(lockscreen, "confirmButton");
384+ var inputField = findChild(lockscreen, "pinentryField");
385+
386+ tryCompare(backspaceButton, "opacity", 0);
387+
388+ tryCompare(confirmButton, "visible", (data.minPinLength != data.maxPinLength) || (data.minPinLength == -1));
383389
384390 for (var i = 0; i < 10; i++) {
385391 mouseClick(pinPadButton5, units.gu(1), units.gu(1));
392+ tryCompare(backspaceButton, "opacity", 1)
386393
387− if (data.minPinLength == data.maxPinLength && data.minPinLength != -1) {
388− // auto confirm mode...
389− compare(inputField.text.length, (i+1) % data.minPinLength);
394+ if (data.maxPinLength == data.minPinLength && data.minPinLength > 0) {
395+ // Autoconfirm mode. This will automatically confirm (and with it reset)
396+ // the textfield every data.minPinLength presses
397+ if (i+1 < data.minPinLength) {
398+ compare(inputField.text.length, i + 1);
399+ } else {
400+ compare(inputField.text.length, (i+1) % data.minPinLength)
401+ }
390402 } else {
391− // manual confirm mode
392− tryCompare(pinPadButtonErase, "enabled", (i+1) >= data.minPinLength)
393403 if (data.maxPinLength == -1) {
404+ // Undefined maxLength... make sure all presses are recorded
394405 compare(inputField.text.length, i+1);
395406 } else {
407+ // We have a max length. Make sure we're only accepting maxLength presses
396408 compare(inputField.text.length, Math.min(data.maxPinLength, i+1));
397409 }
398410
411+ if (data.minPinLength == -1) {
412+ // Undefined minLength. Make sure confirm button is always enabled
413+ compare(confirmButton.enabled, true);
414+ } else {
415+ // We have a min length. Make sure the confirm button is only enabled when met.
416+ compare(confirmButton.enabled, (i+1) >= data.minPinLength);
417+ }
399418 }
400419 }
401420 }
402421
403422 function test_retryDisplay_data() {
404423 return [
405− {tag: "empty", retryText: "", shown: false},
406− {tag: "3 retries left", retryText: "3 retries left", shown: true},
424+ {tag: "empty", retryText: " "},
425+ {tag: "3 retries left", retryText: "3 retries left"},
407426 ]
408427 }
409428
@@ -412,8 +431,8 @@ Rectangle {
412431 waitForLockscreenReady();
413432
414433 retryCountTextField.text = data.retryText;
415− var label = findChild(lockscreen, "retryCountLabel")
416− compare(label.visible, data.shown);
434+ var label = findChild(lockscreen, "retryLabel")
435+ compare(label.text, data.retryText);
417436 }
418437
419438 function test_infoPopup() {
@@ -438,8 +457,8 @@ Rectangle {
438457
439458 function test_infoTextDisplay_data() {
440459 return [
441− {tag: "empty string", text: "", shown: false},
442− {tag: "hello world", text: "hello world", shown: true},
460+ {tag: "empty string", text: ""},
461+ {tag: "hello world", text: "hello world"},
443462 ]
444463 }
445464
@@ -449,7 +468,7 @@ Rectangle {
449468
450469 infoTextTextField.text = data.text;
451470 var label = findChild(lockscreen, "infoTextLabel")
452− compare(label.visible, data.shown);
471+ compare(label.text, data.text);
453472 }
454473 }
455474