on xenial help sign in
And add a tst_NarrowView.qml too
commit4d73fd997708fbc0ed83f982ac92765c205d754c authorMichael Terry <michael.terry@canonical.com> dateFri 16 Jan 2015, 16:12 (12 years ago) parente806e8c
8 files changed+391−21
qml/Components/DelayedLockscreen.qml+3 qml/Greeter/CoverPage.qml+18−16 qml/Greeter/Greeter.qml+8−3 qml/Greeter/NarrowView.qml+10−1 qml/Greeter/WideView.qml+1 tests/qmltests/CMakeLists.txt+1 tests/qmltests/Greeter/tst_NarrowView.qml+332 tests/qmltests/Greeter/tst_WideView.qml+18−1
qml/Components/DelayedLockscreen.qml+3
@@ -25,6 +25,9 @@ Item {
2525 property int delayMinutes
2626 property bool alphaNumeric
2727
28+ signal entered(string passphrase) // unused
29+ signal cancel() // unused
30+
2831 function clear(playAnimation) {}
2932
3033 Column {
qml/Greeter/CoverPage.qml+18−16
@@ -53,22 +53,7 @@ Showable {
5353
5454 // We don't directly bind "x" because that's owned by the DragHandle. So
5555 // instead, we can get a little extra horizontal push by using transforms.
56− transform: Translate { x: draggable ? launcherOffset : 0 }
57−
58− DragHandle {
59− id: dragHandle
60− anchors.fill: parent
61− anchors.leftMargin: root.dragHandleLeftMargin
62− enabled: root.draggable
63− direction: Direction.Horizontal
64−
65− onDraggingChanged: {
66− if (dragging) {
67− root.tease();
68− showLabelAnimation.start();
69− }
70− }
71− }
56+ transform: Translate { x: root.draggable ? launcherOffset : 0 }
7257
7358 Rectangle {
7459 // In case background fails to load
@@ -139,6 +124,21 @@ Showable {
139124 }
140125 }
141126
127+ DragHandle {
128+ id: dragHandle
129+ anchors.fill: parent
130+ anchors.leftMargin: root.dragHandleLeftMargin
131+ enabled: root.draggable
132+ direction: Direction.Horizontal
133+
134+ onDraggingChanged: {
135+ if (dragging) {
136+ root.tease();
137+ showLabelAnimation.start();
138+ }
139+ }
140+ }
141+
142142 // right side shadow
143143 Image {
144144 anchors.left: parent.right
@@ -187,6 +187,7 @@ Showable {
187187 hideAnimation: SequentialAnimation {
188188 id: hideAnimation
189189 objectName: "hideAnimation"
190+ property var target // unused, here to silence Showable warning
190191 StandardAnimation {
191192 id: hideTranslation
192193 property: "x"
@@ -199,6 +200,7 @@ Showable {
199200 showAnimation: SequentialAnimation {
200201 id: showAnimation
201202 objectName: "showAnimation"
203+ property var target // unused, here to silence Showable warning
202204 PropertyAction { target: root; property: "visible"; value: true }
203205 PropertyAction { target: positionLock; property: "enabled"; value: false }
204206 StandardAnimation {
qml/Greeter/Greeter.qml+8−3
@@ -182,9 +182,8 @@ Showable {
182182
183183 anchors.fill: parent
184184
185− source: root.required ? ((!d.multiUser && !tabletMode) ? "NarrowView.qml"
186− : "WideView.qml")
187− : ""
185+ active: root.required
186+ source: (d.multiUser || tabletMode) ? "WideView.qml" : "NarrowView.qml"
188187
189188 onLoaded: {
190189 loader.item.reset();
@@ -251,6 +250,12 @@ Showable {
251250 value: root.locked
252251 }
253252
253+ Binding {
254+ target: loader.item
255+ property: "alphanumeric"
256+ value: AccountsService.passwordDisplayHint === AccountsService.Keyboard
257+ }
258+
254259 Binding {
255260 target: loader.item
256261 property: "currentIndex"
qml/Greeter/NarrowView.qml+10−1
@@ -29,6 +29,7 @@ Item {
2929 property alias backgroundTopMargin: coverPage.backgroundTopMargin
3030 property url background
3131 property bool locked
32+ property bool alphanumeric
3233 property var userModel // unused
3334 property alias infographicModel: coverPage.infographicModel
3435 readonly property bool fullyShown: coverPage.showProgress === 1 || lockscreen.shown
@@ -89,6 +90,14 @@ Item {
8990 id: d
9091 }
9192
93+ onLockedChanged: {
94+ if (locked) {
95+ lockscreen.maybeShow();
96+ } else {
97+ lockscreen.hide();
98+ }
99+ }
100+
92101 Lockscreen {
93102 id: lockscreen
94103 objectName: "lockscreen"
@@ -100,7 +109,7 @@ Item {
100109 visible: required
101110 background: root.background
102111 darkenBackground: 0.4
103− alphaNumeric: AccountsService.passwordDisplayHint === AccountsService.Keyboard
112+ alphaNumeric: root.alphanumeric
104113 minPinLength: 4
105114 maxPinLength: 4
106115
qml/Greeter/WideView.qml+1
@@ -27,6 +27,7 @@ Item {
2727 property alias backgroundTopMargin: coverPage.backgroundTopMargin
2828 property alias background: coverPage.background
2929 property bool locked
30+ property bool alphanumeric // unused
3031 property alias userModel: loginList.model
3132 property alias infographicModel: coverPage.infographicModel
3233 readonly property bool fullyShown: coverPage.showProgress === 1
tests/qmltests/CMakeLists.txt+1
@@ -65,6 +65,7 @@ add_qml_test(Greeter MultiGreeter ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DI
6565add_qml_test(Greeter SingleGreeter ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
6666add_qml_test(Greeter Infographics ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full")
6767add_qml_test(Greeter Clock ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
68+add_qml_test(Greeter NarrowView ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
6869add_qml_test(Greeter WideView ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full")
6970add_qml_test(Launcher Launcher)
7071add_qml_test(Notifications Notifications)
tests/qmltests/Greeter/tst_NarrowView.qmlnew file+332
@@ -0,0 +1,332 @@
1+/*
2+ * Copyright 2014 Canonical Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.0
18+import QtTest 1.0
19+import ".."
20+import "../../../qml/Greeter"
21+import LightDM 0.1 as LightDM
22+import Ubuntu.Components 0.1
23+import Unity.Test 0.1 as UT
24+
25+Item {
26+ id: root
27+ width: units.gu(90)
28+ height: units.gu(80)
29+
30+ Row {
31+ anchors.fill: parent
32+ Loader {
33+ id: loader
34+ width: root.width - controls.width
35+ height: parent.height
36+
37+ property bool itemDestroyed: false
38+ sourceComponent: Component {
39+ NarrowView {
40+ background: Qt.resolvedUrl("../../../qml/graphics/phone_background.jpg")
41+ userModel: LightDM.Users
42+ infographicModel: LightDM.Infographic
43+
44+ launcherOffset: parseFloat(launcherOffsetField.text)
45+ currentIndex: parseInt(currentIndexField.text, 10)
46+ delayMinutes: parseInt(delayMinutesField.text, 10)
47+ backgroundTopMargin: parseFloat(backgroundTopMarginField.text)
48+ locked: lockedCheckBox.checked
49+ alphanumeric: alphanumericCheckBox.checked
50+
51+ Component.onDestruction: {
52+ loader.itemDestroyed = true
53+ }
54+
55+ onSelected: {
56+ currentIndexField.text = index;
57+ }
58+ }
59+ }
60+ }
61+
62+ Rectangle {
63+ id: controls
64+ color: "white"
65+ width: units.gu(40)
66+ height: parent.height
67+
68+ Column {
69+ anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
70+ spacing: units.gu(1)
71+
72+ Row {
73+ Button {
74+ text: "Show Last Chance"
75+ onClicked: loader.item.showLastChance()
76+ }
77+ }
78+ Row {
79+ Button {
80+ text: "Hide"
81+ onClicked: loader.item.hide()
82+ }
83+ }
84+ Row {
85+ Button {
86+ text: "Reset"
87+ onClicked: loader.item.reset()
88+ }
89+ }
90+ Row {
91+ Button {
92+ text: "Show Message"
93+ onClicked: loader.item.showMessage(messageField.text)
94+ }
95+ TextField {
96+ id: messageField
97+ width: units.gu(10)
98+ text: ""
99+ }
100+ }
101+ Row {
102+ Button {
103+ text: "Show Prompt"
104+ onClicked: loader.item.showPrompt(promptField.text, isSecretCheckBox.checked, isDefaultPromptCheckBox.checked)
105+ }
106+ TextField {
107+ id: promptField
108+ width: units.gu(10)
109+ text: ""
110+ }
111+ CheckBox {
112+ id: isSecretCheckBox
113+ }
114+ Label {
115+ text: "secret"
116+ }
117+ CheckBox {
118+ id: isDefaultPromptCheckBox
119+ }
120+ Label {
121+ text: "default"
122+ }
123+ }
124+ Row {
125+ Button {
126+ text: "Authenticated"
127+ onClicked: loader.item.authenticated(successCheckBox.checked)
128+ }
129+ CheckBox {
130+ id: successCheckBox
131+ }
132+ Label {
133+ text: "success"
134+ }
135+ }
136+ Row {
137+ Button {
138+ text: "Try To Unlock"
139+ onClicked: loader.item.tryToUnlock(toTheRightCheckBox.checked)
140+ }
141+ CheckBox {
142+ id: toTheRightCheckBox
143+ }
144+ Label {
145+ text: "toTheRight"
146+ }
147+ }
148+ Row {
149+ TextField {
150+ id: launcherOffsetField
151+ width: units.gu(10)
152+ text: "0"
153+ }
154+ Label {
155+ text: "launcherOffset"
156+ }
157+ }
158+ Row {
159+ TextField {
160+ id: currentIndexField
161+ width: units.gu(10)
162+ text: "0"
163+ }
164+ Label {
165+ text: "currentIndex"
166+ }
167+ }
168+ Row {
169+ TextField {
170+ id: delayMinutesField
171+ width: units.gu(10)
172+ text: "0"
173+ }
174+ Label {
175+ text: "delayMinutes"
176+ }
177+ }
178+ Row {
179+ TextField {
180+ id: backgroundTopMarginField
181+ width: units.gu(10)
182+ text: "0"
183+ }
184+ Label {
185+ text: "backgroundTopMargin"
186+ }
187+ }
188+ Row {
189+ CheckBox {
190+ id: lockedCheckBox
191+ }
192+ Label {
193+ text: "locked"
194+ }
195+ }
196+ Row {
197+ CheckBox {
198+ id: alphanumericCheckBox
199+ }
200+ Label {
201+ text: "alphanumeric"
202+ }
203+ }
204+ Row {
205+ Label {
206+ text: "selected: " + selectedSpy.count
207+ }
208+ }
209+ Row {
210+ Label {
211+ text: "responded: " + respondedSpy.count
212+ }
213+ }
214+ Row {
215+ Label {
216+ text: "teased: " + teaseSpy.count
217+ }
218+ }
219+ Row {
220+ Label {
221+ text: "emergency: " + emergencySpy.count
222+ }
223+ }
224+ Row {
225+ Button {
226+ text: "Reload View"
227+ onClicked: {
228+ loader.active = false;
229+ loader.active = true;
230+ }
231+ }
232+ }
233+ }
234+ }
235+ }
236+
237+ SignalSpy {
238+ id: selectedSpy
239+ target: loader.item
240+ signalName: "selected"
241+ }
242+
243+ SignalSpy {
244+ id: respondedSpy
245+ target: loader.item
246+ signalName: "responded"
247+ }
248+
249+ SignalSpy {
250+ id: teaseSpy
251+ target: loader.item
252+ signalName: "tease"
253+ }
254+
255+ SignalSpy {
256+ id: emergencySpy
257+ target: loader.item
258+ signalName: "emergencyCall"
259+ }
260+
261+ UT.UnityTestCase {
262+ name: "WideView"
263+ when: windowShown
264+
265+ property Item view: loader.status === Loader.Ready ? loader.item : null
266+
267+ function init() {
268+ view.currentIndex = 0; // break binding with text field
269+ selectedSpy.clear();
270+ respondedSpy.clear();
271+ teaseSpy.clear();
272+ emergencySpy.clear();
273+ }
274+
275+ function cleanup() {
276+ loader.itemDestroyed = false;
277+ loader.active = false;
278+ tryCompare(loader, "status", Loader.Null);
279+ tryCompare(loader, "item", null);
280+ tryCompare(loader, "itemDestroyed", true);
281+ loader.active = true;
282+ tryCompare(loader, "status", Loader.Ready);
283+ removeTimeConstraintsFromDirectionalDragAreas(loader.item);
284+ }
285+
286+ function swipeAwayCover() {
287+ tryCompare(view, "fullyShown", true);
288+ var touchY = view.height / 2;
289+ touchFlick(view, view.width, touchY, 0, touchY);
290+ var coverPage = findChild(view, "coverPage");
291+ tryCompare(coverPage, "showProgress", 0);
292+ waitForRendering(view);
293+ }
294+
295+ function enterPin(pin) {
296+ for (var i = 0; i < pin.length; ++i) {
297+ var character = pin.charAt(i);
298+ var button = findChild(view, "pinPadButton" + character);
299+ tap(button);
300+ }
301+ }
302+
303+ function test_tease() {
304+ tap(view, 1, 1);
305+ compare(teaseSpy.count, 1);
306+ }
307+
308+ function test_respondedWithPin() {
309+ view.locked = true;
310+ swipeAwayCover();
311+ enterPin("1234");
312+ compare(respondedSpy.count, 1);
313+ compare(respondedSpy.signalArguments[0][0], "1234");
314+ }
315+
316+ function test_respondedWithPassphrase() {
317+ view.locked = true;
318+ view.alphanumeric = true;
319+ swipeAwayCover();
320+ typeString("test");
321+ keyClick(Qt.Key_Enter);
322+ compare(respondedSpy.count, 1);
323+ compare(respondedSpy.signalArguments[0][0], "test");
324+ }
325+
326+ function test_respondedWithSwipe() {
327+ swipeAwayCover();
328+ compare(respondedSpy.count, 1);
329+ compare(respondedSpy.signalArguments[0][0], "");
330+ }
331+ }
332+}
tests/qmltests/Greeter/tst_WideView.qml+18−1
@@ -271,6 +271,16 @@ Item {
271271 tryCompare(loader, "itemDestroyed", true);
272272 loader.active = true;
273273 tryCompare(loader, "status", Loader.Ready);
274+ removeTimeConstraintsFromDirectionalDragAreas(loader.item);
275+ }
276+
277+ function swipeAwayCover() {
278+ tryCompare(view, "fullyShown", true);
279+ var touchY = view.height / 2;
280+ touchFlick(view, view.width, touchY, 0, touchY);
281+ var coverPage = findChild(view, "coverPage");
282+ tryCompare(coverPage, "showProgress", 0);
283+ waitForRendering(view);
274284 }
275285
276286 function test_tease() {
@@ -286,7 +296,8 @@ Item {
286296 compare(view.currentIndex, 0); // confirm we didn't change
287297 }
288298
289− function test_responded() {
299+ function test_respondedWithPassword() {
300+ view.locked = true;
290301 view.showPrompt("Prompt", true, true);
291302 var passwordInput = findChild(view, "passwordInput");
292303 tap(passwordInput);
@@ -295,5 +306,11 @@ Item {
295306 compare(respondedSpy.count, 1);
296307 compare(respondedSpy.signalArguments[0][0], "password");
297308 }
309+
310+ function test_respondedWithSwipe() {
311+ swipeAwayCover();
312+ compare(respondedSpy.count, 1);
313+ compare(respondedSpy.signalArguments[0][0], "");
314+ }
298315 }
299316}