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 . Approved by PS Jenkins bot, Mirco Müller.

commit9802b8195e0fb03c8b378cb5dcbb8eedfcca2cf4 authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 21 Nov 2013, 16:30 (13 years ago) parentc15bc4614c9978
5 files changed+65−36
Greeter/Lockscreen.qml+6−18 Greeter/PassphraseLockscreen.qml+1 Greeter/PinLockscreen.qml+1 Shell.qml+12−1 tests/qmltests/Greeter/tst_Lockscreen.qml+45−17
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 background fails to load or is undefined
5861 id: backgroundBackup
@@ -92,7 +95,7 @@ Showable {
9295 target: pinPadLoader.item
9396
9497 onEntered: {
95− LightDM.Greeter.respond(passphrase);
98+ root.entered(passphrase);
9699 }
97100
98101 onCancel: {
@@ -150,19 +153,4 @@ Showable {
150153 anchors.horizontalCenter: parent.horizontalCenter
151154 }
152155 }
153−
154− Connections {
155− target: LightDM.Greeter
156−
157− onAuthenticationComplete: {
158− if (LightDM.Greeter.promptless) {
159− return;
160− }
161− if (LightDM.Greeter.authenticated) {
162− root.unlocked();
163− } else {
164− pinPadLoader.item.clear(true);
165− }
166− }
167− }
168156}
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
@@ -210,6 +210,7 @@ Column {
210210
211211 WrongPasswordAnimation {
212212 id: wrongPasswordAnimation
213+ objectName: "wrongPasswordAnimation"
213214 target: pinentryField
214215 }
215216}
Shell.qml+12−1
@@ -414,7 +414,7 @@ FocusScope {
414414 height: parent.height - panel.panelHeight
415415 background: shell.background
416416
417− onUnlocked: lockscreen.hide()
417+ onEntered: LightDM.Greeter.respond(passphrase);
418418 onCancel: greeter.show()
419419
420420 Component.onCompleted: {
@@ -440,6 +440,17 @@ FocusScope {
440440 lockscreen.show();
441441 }
442442 }
443+
444+ onAuthenticationComplete: {
445+ if (LightDM.Greeter.promptless) {
446+ return;
447+ }
448+ if (LightDM.Greeter.authenticated) {
449+ lockscreen.hide();
450+ } else {
451+ lockscreen.clear(true);
452+ }
453+ }
443454 }
444455
445456 Greeter {
tests/qmltests/Greeter/tst_Lockscreen.qml+45−17
@@ -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,16 +175,16 @@ Rectangle {
176175
177176 function test_unlock_data() {
178177 return [
179− {tag: "numeric", alphanumeric: false, username: "has-pin", password: "1234", unlockedSignal: true, pinLength: 4},
180− {tag: "alphanumeric", alphanumeric: true, username: "has-password", password: "password", unlockedSignal: true, pinLength: -1},
181− {tag: "numeric (wrong)", alphanumeric: false, username: "has-pin", password: "4321", unlockedSignal: false, pinLength: 4},
182− {tag: "alphanumeric (wrong)", alphanumeric: true, username: "has-password", password: "drowssap", unlockedSignal: false, pinLength: -1},
183− {tag: "flexible length", alphanumeric: false, username: "has-pin", password: "1234", unlockedSignal: true, pinLength: -1},
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},
184183 ]
185184 }
186185
187186 function test_unlock(data) {
188− unlockedCheckBox.checked = false
187+ enteredLabel.text = ""
189188 pinLengthTextField.text = data.pinLength
190189 LightDM.Greeter.authenticate(data.username)
191190 waitForRendering(lockscreen)
@@ -206,14 +205,43 @@ Rectangle {
206205 mouseClick(pinPadButtonErase, units.gu(1), units.gu(1));
207206 }
208207 }
208+ tryCompare(enteredLabel, "text", data.password)
209+ }
210+
211+ function test_clear_data() {
212+ return [
213+ {tag: "animated PIN", animation: true, alphanumeric: false},
214+ {tag: "not animated PIN", animation: false, alphanumeric: false},
215+ {tag: "animated passphrase", animation: true, alphanumeric: true},
216+ {tag: "not animated passphrase", animation: false, alphanumeric: true}
217+ ];
218+ }
219+
220+ function test_clear(data) {
221+ pinPadCheckBox.checked = data.alphanumeric
222+ waitForRendering(lockscreen)
209223
210− tryCompare(unlockedCheckBox, "checked", data.unlockedSignal)
211− if (!data.unlockedSignal) {
212− // make sure the input is cleared on wrong input
213− tryCompareFunction(function() {return inputField.text.length == 0}, true)
224+ var inputField = findChild(lockscreen, "pinentryField")
225+ if (data.alphanumeric) {
226+ mouseClick(inputField, units.gu(1), units.gu(1))
227+ typeString("1")
214228 } else {
215− tryCompareFunction(function() {return inputField.text.length > 0}, true)
229+ var button = findChild(lockscreen, "pinPadButton1")
230+ mouseClick(button, units.gu(1), units.gu(1))
216231 }
232+
233+ var animation = findInvisibleChild(lockscreen, "wrongPasswordAnimation")
234+
235+ tryCompare(inputField, "text", "1")
236+
237+ lockscreen.clear(data.animation)
238+ tryCompare(inputField, "text", "")
239+
240+ wait(0) // Trigger event loop to make sure the animation would start running
241+ compare(animation.running, data.animation)
242+
243+ // wait for animation to finish to not disturb other tests
244+ tryCompare(animation, "running", false)
217245 }
218246
219247 function test_backspace_data() {
@@ -224,7 +252,7 @@ Rectangle {
224252 }
225253
226254 function test_backspace(data) {
227− LightDM.Greeter.authenticate("has-pin");
255+ pinPadCheckBox.checked = false
228256 pinLengthTextField.text = data.pinLength
229257 waitForRendering(lockscreen);
230258