on xenial help sign in
More work, add new WideView test
commite806e8c4edc3838f667852eb771cad1d1da8f272 authorMichael Terry <michael.terry@canonical.com> dateFri 16 Jan 2015, 09:41 (12 years ago) parent4224813
7 files changed+459−142
qml/Greeter/CoverPage.qml+23−39 qml/Greeter/Greeter.qml+67−20 qml/Greeter/LoginList.qml+24−34 qml/Greeter/NarrowGreeter.qml → qml/Greeter/NarrowView.qml+16−23 qml/Greeter/WideGreeter.qml → qml/Greeter/WideView.qml+29−26 tests/qmltests/CMakeLists.txt+1 tests/qmltests/Greeter/tst_WideView.qml+299
qml/Greeter/CoverPage.qml+23−39
@@ -15,8 +15,6 @@
1515 */
1616
1717import QtQuick 2.3
18−import AccountsService 0.1
19−import LightDM 0.1 as LightDM
2018import Ubuntu.Components 1.1
2119import Ubuntu.Gestures 0.1
2220import "../Components"
@@ -29,7 +27,7 @@ Showable {
2927 property alias background: greeterBackground.source
3028 property real backgroundTopMargin
3129 property bool ready: greeterBackground.source == "" || greeterBackground.status == Image.Ready || greeterBackground.status == Image.Error
32− property int currentIndex
30+ property var infographicModel
3331 property bool draggable: true
3432
3533 property alias infographics: infographics
@@ -39,20 +37,24 @@ Showable {
3937 signal tease()
4038
4139 function hideRight() {
42− if (shown) {
43− hideAnimation = d.rightHideAnimation;
44− hide();
45− }
40+ d.forceRightOnNextHideAnimation = true;
41+ hide();
4642 }
4743
48− property real dragOffset
49− x: launcherOffset + dragOffset
44+ QtObject {
45+ id: d
46+ property bool forceRightOnNextHideAnimation: false
47+ }
5048
51− function startTease() {
52− tease();
53− showLabelAnimation.start();
49+ prepareToHide: function () {
50+ hideTranslation.to = root.x > 0 || d.forceRightOnNextHideAnimation ? root.width : -root.width;
51+ d.forceRightOnNextHideAnimation = false;
5452 }
5553
54+ // We don't directly bind "x" because that's owned by the DragHandle. So
55+ // instead, we can get a little extra horizontal push by using transforms.
56+ transform: Translate { x: draggable ? launcherOffset : 0 }
57+
5658 DragHandle {
5759 id: dragHandle
5860 anchors.fill: parent
@@ -60,11 +62,10 @@ Showable {
6062 enabled: root.draggable
6163 direction: Direction.Horizontal
6264
63− onTapped: root.startTease()
64−
6565 onDraggingChanged: {
6666 if (dragging) {
67− root.startTease();
67+ root.tease();
68+ showLabelAnimation.start();
6869 }
6970 }
7071 }
@@ -99,24 +100,7 @@ Showable {
99100 id: infographics
100101 objectName: "infographics"
101102 height: parent.height
102− model: LightDM.Infographic
103−
104− property string selectedUser: LightDM.Users.data(root.currentIndex, LightDM.UserRoles.NameRole)
105−
106− Component.onCompleted: {
107− LightDM.Infographic.readyForDataChange();
108− }
109−
110− Binding {
111− target: LightDM.Infographic
112− property: "username"
113− value: AccountsService.statsWelcomeScreen ? infographics.selectedUser : ""
114− }
115−
116− Connections {
117− target: i18n
118− onLanguageChanged: LightDM.Infographic.readyForDataChange()
119− }
103+ model: root.infographicModel
120104
121105 anchors {
122106 verticalCenter: parent.verticalCenter
@@ -183,10 +167,10 @@ Showable {
183167 }
184168
185169 if (enabled) {
186− if (root.dragOffset > 0) {
187− value = Qt.binding(function() { return greeter.width; })
170+ if (root.x > 0) {
171+ value = Qt.binding(function() { return root.width; })
188172 } else {
189− value = Qt.binding(function() { return -greeter.width; })
173+ value = Qt.binding(function() { return -root.width; })
190174 }
191175 }
192176
@@ -197,7 +181,7 @@ Showable {
197181
198182 target: root
199183 when: __enabled
200− property: "dragOffset"
184+ property: "x"
201185 }
202186
203187 hideAnimation: SequentialAnimation {
@@ -205,7 +189,7 @@ Showable {
205189 objectName: "hideAnimation"
206190 StandardAnimation {
207191 id: hideTranslation
208− property: "dragOffset"
192+ property: "x"
209193 target: root
210194 }
211195 PropertyAction { target: root; property: "visible"; value: false }
@@ -218,7 +202,7 @@ Showable {
218202 PropertyAction { target: root; property: "visible"; value: true }
219203 PropertyAction { target: positionLock; property: "enabled"; value: false }
220204 StandardAnimation {
221− property: "dragOffset"
205+ property: "x"
222206 target: root
223207 to: 0
224208 duration: UbuntuAnimation.FastDuration
qml/Greeter/Greeter.qml+67−20
@@ -23,7 +23,7 @@ import Unity.Launcher 0.1
2323import "../Components"
2424
2525Showable {
26− id: greeter
26+ id: root
2727 created: loader.status == Loader.Ready
2828
2929 property real dragHandleLeftMargin: 0
@@ -95,15 +95,9 @@ Showable {
9595 d.startUnlock(true);
9696 }
9797
98− prepareToHide: function () {
99− hideTranslation.to = greeter.x > 0 || d.forceRightOnNextHideAnimation ? greeter.width : -greeter.width;
100− d.forceRightOnNextHideAnimation = false;
101− }
102−
10398 QtObject {
10499 id: d
105100
106− property bool forceRightOnNextHideAnimation: false
107101 readonly property bool multiUser: LightDM.Users.count > 1
108102 property int currentIndex
109103 property int delayMinutes
@@ -188,15 +182,16 @@ Showable {
188182
189183 anchors.fill: parent
190184
191− source: greeter.required ? ((!d.multiUser && !tabletMode) ? "NarrowGreeter.qml"
192− : "WideGreeter.qml")
193− : ""
185+ source: root.required ? ((!d.multiUser && !tabletMode) ? "NarrowView.qml"
186+ : "WideView.qml")
187+ : ""
194188
195189 onLoaded: {
196190 loader.item.reset();
197− greeter.lockedApp = "";
198− greeter.forceActiveFocus();
191+ root.lockedApp = "";
192+ root.forceActiveFocus();
199193 d.selectUser(d.currentIndex);
194+ LightDM.InfoGraphic.readyForDataChange();
200195 }
201196
202197 Connections {
@@ -204,13 +199,18 @@ Showable {
204199 onSelected: {
205200 d.selectUser(index);
206201 }
207− onUnlocked: {
208− d.login()
202+ onResponded: {
203+ if (root.locked) {
204+ LightDM.Greeter.respond(response);
205+ } else {
206+ d.login();
207+ }
209208 }
210− onTease: greeter.tease()
209+ onTease: root.tease()
210+ onEmergencyCall: root.emergencyCall()
211211 onRequiredChanged: {
212212 if (!loader.item.required) {
213− greeter.hide();
213+ root.hide();
214214 }
215215 }
216216 }
@@ -218,7 +218,7 @@ Showable {
218218 Binding {
219219 target: loader.item
220220 property: "backgroundTopMargin"
221− value: -greeter.y
221+ value: -root.y
222222 }
223223
224224 Binding {
@@ -230,7 +230,7 @@ Showable {
230230 Binding {
231231 target: loader.item
232232 property: "dragHandleLeftMargin"
233− value: greeter.dragHandleLeftMargin
233+ value: root.dragHandleLeftMargin
234234 }
235235
236236 Binding {
@@ -238,13 +238,49 @@ Showable {
238238 property: "delayMinutes"
239239 value: d.delayMinutes
240240 }
241+
242+ Binding {
243+ target: loader.item
244+ property: "background"
245+ value: root.background
246+ }
247+
248+ Binding {
249+ target: loader.item
250+ property: "locked"
251+ value: root.locked
252+ }
253+
254+ Binding {
255+ target: loader.item
256+ property: "currentIndex"
257+ value: d.currentIndex
258+ }
259+
260+ Binding {
261+ target: loader.item
262+ property: "currentUser"
263+ value: LightDM.Users.data(d.currentIndex, LightDM.UserRoles.NameRole)
264+ }
265+
266+ Binding {
267+ target: loader.item
268+ property: "userModel"
269+ value: LightDM.Users
270+ }
271+
272+ Binding {
273+ target: loader.item
274+ property: "infographicModel"
275+ value: LightDM.Infographic
276+ }
241277 }
242278
243279 Connections {
244280 target: LightDM.Greeter
245281
246282 onShowGreeter: {
247− greeter.show();
283+ root.show();
248284 loader.item.reset();
249285 d.selectUser(d.currentIndex);
250286 }
@@ -331,6 +367,17 @@ Showable {
331367 Binding {
332368 target: LightDM.Greeter
333369 property: "active"
334− value: greeter.active
370+ value: root.active
371+ }
372+
373+ Binding {
374+ target: LightDM.Infographic
375+ property: "username"
376+ value: AccountsService.statsWelcomeScreen ? LightDM.Users.data(d.currentIndex, LightDM.UserRoles.NameRole) : ""
377+ }
378+
379+ Connections {
380+ target: i18n
381+ onLanguageChanged: LightDM.Infographic.readyForDataChange()
335382 }
336383}
qml/Greeter/LoginList.qml+24−34
@@ -16,35 +16,35 @@
1616
1717import QtQuick 2.3
1818import Ubuntu.Components 1.1
19−import LightDM 0.1 as LightDM
2019import "../Components"
2120
2221Item {
2322 id: root
2423
25− property alias userList: userList
2624 property alias model: userList.model
27− property alias currentIndex: userList.currentIndex
25+ property int currentIndex
26+ property bool locked
2827
2928 readonly property int numAboveBelow: 4
3029 readonly property int cellHeight: units.gu(5)
3130 readonly property int highlightedHeight: units.gu(10)
3231 readonly property int moveDuration: 200
32+ readonly property string currentUser: userList.currentItem.username
3333 property bool wasPrompted: false
3434
35− signal selected(int uid)
36− signal unlocked()
35+ signal selected(int index)
36+ signal responded(string response)
3737
3838 function tryToUnlock() {
39− if (LightDM.Greeter.promptless) {
40− if (LightDM.Greeter.authenticated) {
41− root.unlocked()
42− } else {
43− root.resetAuthentication()
39+ if (wasPrompted) {
40+ passwordInput.forceActiveFocus();
41+ } else {
42+ if (root.locked) {
43+ root.resetAuthentication();
4444 root.selected(currentIndex);
45+ } else {
46+ root.responded("");
4547 }
46− } else {
47− passwordInput.forceActiveFocus()
4848 }
4949 }
5050
@@ -106,18 +106,10 @@ Item {
106106
107107 readonly property bool movingInternally: moveTimer.running || userList.moving
108108
109+ currentIndex: root.currentIndex
109110 onCurrentIndexChanged: {
110− if (LightDM.Greeter.authenticationUser != userList.model.data(currentIndex, LightDM.UserRoles.NameRole)) {
111− root.resetAuthentication();
112− root.selected(currentIndex);
113− }
114− }
115−
116− onMovingInternallyChanged: {
117− // Only emit the selected signal once we stop moving to avoid frequent background changes
118− if (!movingInternally) {
119− root.selected(userList.currentIndex);
120− }
111+ root.resetAuthentication();
112+ moveTimer.start();
121113 }
122114
123115 delegate: Item {
@@ -126,6 +118,7 @@ Item {
126118
127119 readonly property bool belowHighlight: (userList.currentIndex < 0 && index > 0) || (userList.currentIndex >= 0 && index > userList.currentIndex)
128120 readonly property int belowOffset: root.highlightedHeight - root.cellHeight
121+ readonly property string username: name
129122
130123 opacity: {
131124 // The goal here is to make names less and less opaque as they
@@ -173,11 +166,8 @@ Item {
173166 topMargin: parent.belowHighlight ? parent.belowOffset : 0
174167 }
175168 height: parent.height
176− enabled: userList.currentIndex !== index
177− onClicked: {
178− moveTimer.start();
179− userList.currentIndex = index;
180− }
169+ enabled: userList.currentIndex !== index && parent.opacity > 0
170+ onClicked: root.selected(index)
181171
182172 Behavior on anchors.topMargin { NumberAnimation { duration: root.moveDuration; easing.type: Easing.InOutQuad; } }
183173 }
@@ -230,9 +220,9 @@ Item {
230220 opacity: userList.movingInternally ? 0 : 1
231221
232222 property string promptText
233− placeholderText: LightDM.Greeter.promptless ? (LightDM.Greeter.authenticated ? i18n.tr("Tap to unlock")
234− : i18n.tr("Retry"))
235− : promptText
223+ placeholderText: root.wasPrompted ? promptText
224+ : (root.locked ? i18n.tr("Retry")
225+ : i18n.tr("Tap to unlock"))
236226
237227 Behavior on opacity {
238228 NumberAnimation { duration: 100 }
@@ -243,7 +233,7 @@ Item {
243233 return;
244234 root.focus = true; // so that it can handle Escape presses for us
245235 enabled = false;
246− LightDM.Greeter.respond(text);
236+ root.responded(text);
247237 }
248238 Keys.onEscapePressed: {
249239 root.resetAuthentication();
@@ -256,7 +246,7 @@ Item {
256246 rightMargin: units.gu(2)
257247 verticalCenter: parent.verticalCenter
258248 }
259− visible: LightDM.Greeter.promptless
249+ visible: !root.wasPrompted
260250 source: "graphics/icon_arrow.png"
261251 }
262252
@@ -280,7 +270,7 @@ Item {
280270 id: passwordMouseArea
281271 objectName: "passwordMouseArea"
282272 anchors.fill: passwordInput
283− enabled: LightDM.Greeter.promptless
273+ enabled: !root.wasPrompted
284274 onClicked: root.tryToUnlock()
285275 }
286276
qml/Greeter/NarrowGreeter.qml → qml/Greeter/NarrowView.qmlrenamed+16−23
@@ -16,7 +16,6 @@
1616
1717import QtQuick 2.3
1818import AccountsService 0.1
19−import LightDM 0.1 as LightDM
2019import Ubuntu.Components 1.1
2120import "../Components"
2221
@@ -28,12 +27,17 @@ Item {
2827 property int currentIndex // unused
2928 property alias delayMinutes: lockscreen.delayMinutes
3029 property alias backgroundTopMargin: coverPage.backgroundTopMargin
31− property bool fullyShown: coverPage.showProgress === 1 || lockscreen.shown
32− property bool required: coverPage.required || lockscreen.required
30+ property url background
31+ property bool locked
32+ property var userModel // unused
33+ property alias infographicModel: coverPage.infographicModel
34+ readonly property bool fullyShown: coverPage.showProgress === 1 || lockscreen.shown
35+ readonly property bool required: coverPage.required || lockscreen.required
3336
3437 signal selected(int index)
35− signal unlocked()
38+ signal responded(string response)
3639 signal tease()
40+ signal emergencyCall()
3741
3842 function showMessage(html) {
3943 // TODO
@@ -73,9 +77,7 @@ Item {
7377 }
7478
7579 function tryToUnlock(toTheRight) {
76− if (!LightDM.Greeter.authenticated) {
77− lockscreen.maybeShow();
78− }
80+ lockscreen.maybeShow();
7981 if (toTheRight) {
8082 coverPage.hideRight();
8183 } else {
@@ -96,7 +98,7 @@ Item {
9698 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
9799 anchors.fill: parent
98100 visible: required
99− background: greeter.background
101+ background: root.background
100102 darkenBackground: 0.4
101103 alphaNumeric: AccountsService.passwordDisplayHint === AccountsService.Keyboard
102104 minPinLength: 4
@@ -111,21 +113,12 @@ Item {
111113 i18n.tr("Please re-enter") :
112114 i18n.tr("Sorry, incorrect passcode")
113115
114− // FIXME: We *should* show emergency dialer if there is a SIM present,
115− // regardless of whether the side stage is enabled. But right now,
116− // the assumption is that narrow screens are phones which have SIMs
117− // and wider screens are tablets which don't. When we do allow this
118− // on devices with a side stage and a SIM, work should be done to
119− // ensure that the main stage is disabled while the dialer is present
120− // in the side stage. See the FIXME in the stage loader in Shell.qml.
121− showEmergencyCallButton: !greeter.tabletMode
122−
123− onEntered: LightDM.Greeter.respond(passphrase)
116+ onEntered: root.responded(passphrase)
124117 onCancel: coverPage.show()
125− onEmergencyCall: greeter.emergencyCall()
118+ onEmergencyCall: root.emergencyCall()
126119
127120 function maybeShow() {
128− if (!greeter.forcedUnlock) {
121+ if (root.locked) {
129122 showNow();
130123 }
131124 }
@@ -142,7 +135,7 @@ Item {
142135 objectName: "coverPage"
143136 height: parent.height
144137 width: parent.width
145− background: greeter.background
138+ background: root.background
146139 onTease: root.tease()
147140
148141 onShowProgressChanged: {
@@ -151,10 +144,10 @@ Item {
151144 }
152145
153146 if (showProgress === 0) {
154− if (greeter.locked) {
147+ if (root.locked) {
155148 lockscreen.clear(false); // to reset focus if necessary
156149 } else {
157− root.unlocked();
150+ root.responded("");
158151 }
159152 }
160153 }
qml/Greeter/WideGreeter.qml → qml/Greeter/WideView.qmlrenamed+29−26
@@ -15,7 +15,6 @@
1515 */
1616
1717import QtQuick 2.3
18−import LightDM 0.1 as LightDM
1918import Ubuntu.Components 1.1
2019
2120Item {
@@ -26,12 +25,17 @@ Item {
2625 property alias currentIndex: loginList.currentIndex
2726 property int delayMinutes // TODO
2827 property alias backgroundTopMargin: coverPage.backgroundTopMargin
29− property bool fullyShown: coverPage.showProgress === 1
30− property bool required: coverPage.required
28+ property alias background: coverPage.background
29+ property bool locked
30+ property alias userModel: loginList.model
31+ property alias infographicModel: coverPage.infographicModel
32+ readonly property bool fullyShown: coverPage.showProgress === 1
33+ readonly property bool required: coverPage.required
3134
3235 signal selected(int index)
33− signal unlocked()
36+ signal responded(string response)
3437 signal tease()
38+ signal emergencyCall() // UNUSED
3539
3640 function showMessage(html) {
3741 loginList.showMessage(html);
@@ -60,15 +64,15 @@ Item {
6064 }
6165
6266 function tryToUnlock(toTheRight) {
63− if (LightDM.Greeter.authenticated) {
67+ if (root.locked) {
68+ coverPage.show();
69+ loginList.tryToUnlock();
70+ } else {
6471 if (toTheRight) {
6572 coverPage.hideRight();
6673 } else {
6774 coverPage.hide();
6875 }
69− } else {
70− coverPage.show();
71− loginList.tryToUnlock();
7276 }
7377 }
7478
@@ -87,8 +91,7 @@ Item {
8791 objectName: "coverPage"
8892 height: parent.height
8993 width: parent.width
90− background: greeter.background
91− draggable: !greeter.locked
94+ draggable: !root.locked
9295
9396 infographics {
9497 height: 0.75 * parent.height
@@ -98,27 +101,27 @@ Item {
98101 onTease: root.tease()
99102
100103 onShowProgressChanged: {
101− if (showProgress === 0 && !greeter.locked) {
102− root.unlocked();
104+ if (showProgress === 0 && !root.locked) {
105+ root.responded("");
103106 }
104107 }
105− }
106108
107− LoginList {
108− id: loginList
109− objectName: "loginList"
109+ LoginList {
110+ id: loginList
111+ objectName: "loginList"
110112
111− anchors {
112− left: parent.left
113− leftMargin: Math.min(parent.width * 0.16, units.gu(20))
114− verticalCenter: parent.verticalCenter
115− }
116− width: units.gu(29)
117− height: parent.height
113+ anchors {
114+ left: parent.left
115+ leftMargin: Math.min(parent.width * 0.16, units.gu(20))
116+ verticalCenter: parent.verticalCenter
117+ }
118+ width: units.gu(29)
119+ height: parent.height
118120
119− model: LightDM.Users
121+ locked: root.locked
120122
121− onSelected: root.selected(uid)
122− onUnlocked: coverPage.hide()
123+ onSelected: root.selected(index)
124+ onResponded: root.responded(response)
125+ }
123126 }
124127}
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 WideView ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full")
6869add_qml_test(Launcher Launcher)
6970add_qml_test(Notifications Notifications)
7071add_qml_test(Notifications VisualSnapDecisionsQueue)
tests/qmltests/Greeter/tst_WideView.qmlnew file+299
@@ -0,0 +1,299 @@
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(120)
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+ WideView {
40+ background: Qt.resolvedUrl("../../../qml/graphics/tablet_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+
50+ Component.onDestruction: {
51+ loader.itemDestroyed = true
52+ }
53+
54+ onSelected: {
55+ currentIndexField.text = index;
56+ }
57+ }
58+ }
59+ }
60+
61+ Rectangle {
62+ id: controls
63+ color: "white"
64+ width: units.gu(40)
65+ height: parent.height
66+
67+ Column {
68+ anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
69+ spacing: units.gu(1)
70+
71+ Row {
72+ Button {
73+ text: "Show Last Chance"
74+ onClicked: loader.item.showLastChance()
75+ }
76+ }
77+ Row {
78+ Button {
79+ text: "Hide"
80+ onClicked: loader.item.hide()
81+ }
82+ }
83+ Row {
84+ Button {
85+ text: "Reset"
86+ onClicked: loader.item.reset()
87+ }
88+ }
89+ Row {
90+ Button {
91+ text: "Show Message"
92+ onClicked: loader.item.showMessage(messageField.text)
93+ }
94+ TextField {
95+ id: messageField
96+ width: units.gu(10)
97+ text: ""
98+ }
99+ }
100+ Row {
101+ Button {
102+ text: "Show Prompt"
103+ onClicked: loader.item.showPrompt(promptField.text, isSecretCheckBox.checked, isDefaultPromptCheckBox.checked)
104+ }
105+ TextField {
106+ id: promptField
107+ width: units.gu(10)
108+ text: ""
109+ }
110+ CheckBox {
111+ id: isSecretCheckBox
112+ }
113+ Label {
114+ text: "secret"
115+ }
116+ CheckBox {
117+ id: isDefaultPromptCheckBox
118+ }
119+ Label {
120+ text: "default"
121+ }
122+ }
123+ Row {
124+ Button {
125+ text: "Authenticated"
126+ onClicked: loader.item.authenticated(successCheckBox.checked)
127+ }
128+ CheckBox {
129+ id: successCheckBox
130+ }
131+ Label {
132+ text: "success"
133+ }
134+ }
135+ Row {
136+ Button {
137+ text: "Try To Unlock"
138+ onClicked: loader.item.tryToUnlock(toTheRightCheckBox.checked)
139+ }
140+ CheckBox {
141+ id: toTheRightCheckBox
142+ }
143+ Label {
144+ text: "toTheRight"
145+ }
146+ }
147+ Row {
148+ TextField {
149+ id: launcherOffsetField
150+ width: units.gu(10)
151+ text: "0"
152+ }
153+ Label {
154+ text: "launcherOffset"
155+ }
156+ }
157+ Row {
158+ TextField {
159+ id: currentIndexField
160+ width: units.gu(10)
161+ text: "0"
162+ }
163+ Label {
164+ text: "currentIndex"
165+ }
166+ }
167+ Row {
168+ TextField {
169+ id: delayMinutesField
170+ width: units.gu(10)
171+ text: "0"
172+ }
173+ Label {
174+ text: "delayMinutes"
175+ }
176+ }
177+ Row {
178+ TextField {
179+ id: backgroundTopMarginField
180+ width: units.gu(10)
181+ text: "0"
182+ }
183+ Label {
184+ text: "backgroundTopMargin"
185+ }
186+ }
187+ Row {
188+ CheckBox {
189+ id: lockedCheckBox
190+ }
191+ Label {
192+ text: "locked"
193+ }
194+ }
195+ Row {
196+ Label {
197+ text: "selected: " + selectedSpy.count
198+ }
199+ }
200+ Row {
201+ Label {
202+ text: "responded: " + respondedSpy.count
203+ }
204+ }
205+ Row {
206+ Label {
207+ text: "teased: " + teaseSpy.count
208+ }
209+ }
210+ Row {
211+ Label {
212+ text: "emergency: " + emergencySpy.count
213+ }
214+ }
215+ Row {
216+ Button {
217+ text: "Reload View"
218+ onClicked: {
219+ loader.active = false;
220+ loader.active = true;
221+ }
222+ }
223+ }
224+ }
225+ }
226+ }
227+
228+ SignalSpy {
229+ id: selectedSpy
230+ target: loader.item
231+ signalName: "selected"
232+ }
233+
234+ SignalSpy {
235+ id: respondedSpy
236+ target: loader.item
237+ signalName: "responded"
238+ }
239+
240+ SignalSpy {
241+ id: teaseSpy
242+ target: loader.item
243+ signalName: "tease"
244+ }
245+
246+ SignalSpy {
247+ id: emergencySpy
248+ target: loader.item
249+ signalName: "emergencyCall"
250+ }
251+
252+ UT.UnityTestCase {
253+ name: "WideView"
254+ when: windowShown
255+
256+ property Item view: loader.status === Loader.Ready ? loader.item : null
257+
258+ function init() {
259+ view.currentIndex = 0; // break binding with text field
260+ selectedSpy.clear();
261+ respondedSpy.clear();
262+ teaseSpy.clear();
263+ emergencySpy.clear();
264+ }
265+
266+ function cleanup() {
267+ loader.itemDestroyed = false;
268+ loader.active = false;
269+ tryCompare(loader, "status", Loader.Null);
270+ tryCompare(loader, "item", null);
271+ tryCompare(loader, "itemDestroyed", true);
272+ loader.active = true;
273+ tryCompare(loader, "status", Loader.Ready);
274+ }
275+
276+ function test_tease() {
277+ tap(view, 1, 1);
278+ compare(teaseSpy.count, 1);
279+ }
280+
281+ function test_selected() {
282+ var delegate = findChild(view, "username2");
283+ tap(delegate);
284+ compare(selectedSpy.count, 1);
285+ compare(selectedSpy.signalArguments[0][0], 2);
286+ compare(view.currentIndex, 0); // confirm we didn't change
287+ }
288+
289+ function test_responded() {
290+ view.showPrompt("Prompt", true, true);
291+ var passwordInput = findChild(view, "passwordInput");
292+ tap(passwordInput);
293+ typeString("password");
294+ keyClick(Qt.Key_Enter);
295+ compare(respondedSpy.count, 1);
296+ compare(respondedSpy.signalArguments[0][0], "password");
297+ }
298+ }
299+}