on xenial help sign in
drop all references to LighDM from the Lockscreen

This should make it generic enough to allow reusing it for SIM PIN entry

commitbdb07c63aa0af6e6723a7be98afc6a69a43c9d99 authorMichael Zanetti <michael.zanetti@canonical.com> dateMon 21 Oct 2013, 11:08 (13 years ago) parentf2920dd
5 files changed+64−34
Greeter/Lockscreen.qml+6−18 Greeter/PassphraseLockscreen.qml+1 Greeter/PinLockscreen.qml+1 Shell.qml+12−1 tests/qmltests/Greeter/tst_Lockscreen.qml+44−15
Greeter/Lockscreen.qml+6−18
@@ -17,7 +17,6 @@
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
1919import "../Components"
20−import LightDM 0.1 as LightDM
2120
2221Showable {
2322 id: root
@@ -37,7 +36,7 @@ Showable {
3736
3837 property url background: ""
3938
40− signal unlocked()
39+ signal entered(string passphrase)
4140 signal cancel()
4241 signal emergencyCall()
4342
@@ -53,6 +52,10 @@ Showable {
5352 pinPadLoader.resetting = false;
5453 }
5554
55+ function clear(showAnimation) {
56+ pinPadLoader.item.clear(showAnimation);
57+ }
58+
5659 Rectangle {
5760 // In case wallpaper fails to load or is undefined
5861 id: wallpaperBackup
@@ -88,7 +91,7 @@ Showable {
8891 target: pinPadLoader.item
8992
9093 onEntered: {
91− LightDM.Greeter.respond(passphrase);
94+ root.entered(passphrase);
9295 }
9396
9497 onCancel: {
@@ -146,19 +149,4 @@ Showable {
146149 anchors.horizontalCenter: parent.horizontalCenter
147150 }
148151 }
149−
150− Connections {
151− target: LightDM.Greeter
152−
153− onAuthenticationComplete: {
154− if (LightDM.Greeter.promptless) {
155− return;
156− }
157− if (LightDM.Greeter.authenticated) {
158− root.unlocked();
159− } else {
160− pinPadLoader.item.clear(true);
161− }
162− }
163− }
164152}
Greeter/PassphraseLockscreen.qml+1
@@ -82,6 +82,7 @@ Item {
8282
8383 WrongPasswordAnimation {
8484 id: wrongPasswordAnimation
85+ objectName: "wrongPasswordAnimation"
8586 target: pinentryField
8687 }
8788}
Greeter/PinLockscreen.qml+1
@@ -180,6 +180,7 @@ Column {
180180
181181 WrongPasswordAnimation {
182182 id: wrongPasswordAnimation
183+ objectName: "wrongPasswordAnimation"
183184 target: pinentryField
184185 }
185186}
Shell.qml+12−1
@@ -413,7 +413,7 @@ FocusScope {
413413 height: parent.height - panel.panelHeight
414414 background: shell.background
415415
416− onUnlocked: lockscreen.hide()
416+ onEntered: LightDM.Greeter.respond(passphrase);
417417 onCancel: greeter.show()
418418
419419 Component.onCompleted: {
@@ -439,6 +439,17 @@ FocusScope {
439439 lockscreen.show();
440440 }
441441 }
442+
443+ onAuthenticationComplete: {
444+ if (LightDM.Greeter.promptless) {
445+ return;
446+ }
447+ if (LightDM.Greeter.authenticated) {
448+ lockscreen.hide();
449+ } else {
450+ lockscreen.clear(true);
451+ }
452+ }
442453 }
443454
444455 Greeter {
tests/qmltests/Greeter/tst_Lockscreen.qml+44−15
@@ -41,7 +41,7 @@ Rectangle {
4141 target: lockscreen
4242
4343 onEmergencyCall: emergencyCheckBox.checked = true
44− onUnlocked: unlockedCheckBox.checked = true
44+ onEntered: enteredLabel.text = passphrase
4545 }
4646
4747 Connections {
@@ -99,12 +99,11 @@ Rectangle {
9999 anchors.verticalCenter: parent.verticalCenter
100100 }
101101 Row {
102− CheckBox {
103− id: unlockedCheckBox
102+ Label {
103+ text: "Entered:"
104104 }
105105 Label {
106− text: "Unlocked signal"
107− anchors.verticalCenter: parent.verticalCenter
106+ id: enteredLabel
108107 }
109108 }
110109 Button {
@@ -176,15 +175,15 @@ Rectangle {
176175
177176 function test_unlock_data() {
178177 return [
179− {tag: "numeric", alphanumeric: false, username: "has-pin", password: "1234", unlockedSignal: true},
180− {tag: "alphanumeric", alphanumeric: true, username: "has-password", password: "password", unlockedSignal: true},
181− {tag: "numeric (wrong)", alphanumeric: false, username: "has-pin", password: "4321", unlockedSignal: false},
182− {tag: "alphanumeric (wrong)", alphanumeric: true, username: "has-password", password: "drowssap", unlockedSignal: false},
178+ {tag: "numeric", alphanumeric: false, username: "has-pin", password: "1234"},
179+ {tag: "alphanumeric", alphanumeric: true, username: "has-password", password: "password"},
180+ {tag: "numeric (wrong)", alphanumeric: false, username: "has-pin", password: "4321"},
181+ {tag: "alphanumeric (wrong)", alphanumeric: true, username: "has-password", password: "drowssap"},
183182 ]
184183 }
185184
186185 function test_unlock(data) {
187− unlockedCheckBox.checked = false
186+ enteredLabel.text = ""
188187 LightDM.Greeter.authenticate(data.username)
189188 waitForRendering(lockscreen)
190189
@@ -200,13 +199,43 @@ Rectangle {
200199 mouseClick(button, units.gu(1), units.gu(1))
201200 }
202201 }
203− tryCompare(unlockedCheckBox, "checked", data.unlockedSignal)
204− if (!data.unlockedSignal) {
205− // make sure the input is cleared on wrong input
206− tryCompareFunction(function() {return inputField.text.length == 0}, true)
202+ tryCompare(enteredLabel, "text", data.password)
203+ }
204+
205+ function test_clear_data() {
206+ return [
207+ {tag: "animated PIN", animation: true, alphanumeric: false},
208+ {tag: "not animated PIN", animation: false, alphanumeric: false},
209+ {tag: "animated passphrase", animation: true, alphanumeric: true},
210+ {tag: "not animated passphrase", animation: false, alphanumeric: true}
211+ ];
212+ }
213+
214+ function test_clear(data) {
215+ pinPadCheckBox.checked = data.alphanumeric
216+ waitForRendering(lockscreen)
217+
218+ var inputField = findChild(lockscreen, "pinentryField")
219+ if (data.alphanumeric) {
220+ mouseClick(inputField, units.gu(1), units.gu(1))
221+ typeString("1")
207222 } else {
208− tryCompareFunction(function() {return inputField.text.length > 0}, true)
223+ var button = findChild(lockscreen, "pinPadButton1")
224+ mouseClick(button, units.gu(1), units.gu(1))
209225 }
226+
227+ var animation = findInvisibleChild(lockscreen, "wrongPasswordAnimation")
228+
229+ tryCompare(inputField, "text", "1")
230+
231+ lockscreen.clear(data.animation)
232+ tryCompare(inputField, "text", "")
233+
234+ wait(0) // Trigger event loop to make sure the animation would start running
235+ compare(animation.running, data.animation)
236+
237+ // wait for animation to finish to not disturb other tests
238+ tryCompare(animation, "running", false)
210239 }
211240 }
212241}