on xenial help sign in
Fix up tests
commit40af579467075cfe62c58da8a4a0dc5cfc94da97 authorMichael Terry <michael.terry@canonical.com> dateFri 19 Dec 2014, 14:26 (12 years ago) parent709e634
7 files changed+48−55
qml/Launcher/Launcher.qml+4−1 qml/Shell.qml+4−2 qml/Tutorial/Tutorial.qml+1 qml/Tutorial/TutorialLeft.qml+11−13 qml/Tutorial/TutorialLeftFinish.qml+1 qml/Tutorial/TutorialPage.qml+1 tests/qmltests/Tutorial/tst_Tutorial.qml+26−39
qml/Launcher/Launcher.qml+4−1
@@ -34,6 +34,7 @@ Item {
3434 property real progress: dragArea.dragging && dragArea.touchX > panelWidth ?
3535 (width * (dragArea.touchX-panelWidth) / (width - panelWidth)) : 0
3636
37+ readonly property bool dragging: dragArea.dragging
3738 readonly property real dragDistance: dragArea.dragging ? dragArea.touchX : 0
3839 readonly property real visibleWidth: panel.width + panel.x
3940
@@ -70,7 +71,7 @@ Item {
7071 }
7172
7273 function tease(interval) {
73− if (available && !dragArea.dragging) {
74+ if (available && root.state == "" && !dragArea.dragging) {
7475 if (interval === undefined) {
7576 interval = 200;
7677 }
@@ -284,6 +285,8 @@ Item {
284285 } else {
285286 root.switchToNextState("")
286287 }
288+ } else {
289+ teaseTimer.stop();
287290 }
288291 }
289292 }
qml/Shell.qml+4−2
@@ -241,8 +241,10 @@ Item {
241241 }
242242
243243 onApplicationAdded: {
244− if (greeter.shown && appId != "unity8-dash") {
245− greeter.startUnlock()
244+ if (appId != "unity8-dash") {
245+ if (greeter.shown) {
246+ greeter.startUnlock();
247+ }
246248
247249 // If this happens on first boot, we may be in edge
248250 // tutorial or wizard while receiving a call. But a call
qml/Tutorial/Tutorial.qml+1
@@ -65,6 +65,7 @@ Item {
6565
6666 Loader {
6767 id: loader
68+ objectName: "tutorialLoader"
6869
6970 property Component target: {
7071 if (next) {
qml/Tutorial/TutorialLeft.qml+11−13
@@ -32,35 +32,33 @@ TutorialPage {
3232 Connections {
3333 target: root.launcher
3434
35− property bool maybeDone
36−
3735 onStateChanged: {
38− if (launcher.state === "visible") {
39− maybeDone = true;
36+ if (root.launcher.state === "visible") {
37+ finishTimer.start();
4038 }
4139 }
4240
4341 onDash: {
44− maybeDone = false;
42+ finishTimer.stop();
4543 root.showError();
4644 root.launcher.hide();
4745 }
48−
49− onDragDistanceChanged: {
50− if (root.launcher.dragDistance === 0 && maybeDone) {
51− root.hide();
52− }
53− }
5446 }
5547
5648 Timer {
5749 id: teaseTimer
5850 interval: UbuntuAnimation.SleepyDuration
5951 repeat: true
60− running: !root.paused
52+ running: !root.paused && !root.launcher.dragging
6153 onTriggered: root.launcher.tease(UbuntuAnimation.SleepyDuration)
6254 }
6355
56+ Timer {
57+ id: finishTimer
58+ interval: 1
59+ onTriggered: root.hide()
60+ }
61+
6462 foreground {
6563 children: [
6664 LocalComponents.Slider {
@@ -70,7 +68,7 @@ TutorialPage {
7068 topMargin: root.textBottom + units.gu(3)
7169 }
7270 offset: root.launcher.visibleWidth + root.launcher.progress
73− active: root.launcher.dragDistance > 0
71+ active: root.launcher.dragging
7472 shortSwipe: true
7573 }
7674 ]
qml/Tutorial/TutorialLeftFinish.qml+1
@@ -27,6 +27,7 @@ TutorialPage {
2727 foreground {
2828 children: [
2929 Image {
30+ objectName: "tick"
3031 anchors {
3132 horizontalCenter: parent.horizontalCenter
3233 top: parent.top
qml/Tutorial/TutorialPage.qml+1
@@ -159,6 +159,7 @@ Showable {
159159
160160 Label {
161161 id: errorLabel
162+ objectName: "errorLabel"
162163 anchors {
163164 top: parent.verticalCenter
164165 topMargin: d.verticalOffset + root.textYOffset
tests/qmltests/Tutorial/tst_Tutorial.qml+26−39
@@ -199,54 +199,28 @@ Item {
199199 }
200200
201201 function goToPage(name) {
202− var page = waitForPage("tutorialIntro");
203− if (name === "tutorialIntro") return page;
204− tap(page);
205−
206− page = waitForPage("tutorialTop");
207− checkLeftEdge();
208− checkRightEdge();
209− checkBottomEdge();
210− if (name === "tutorialTop") return page;
211− touchFlick(shell, halfWidth, 0, halfWidth, shell.height);
212−
213− page = waitForPage("tutorialTopFinish");
214− checkLeftEdge();
215− checkRightEdge();
216− checkBottomEdge();
217− if (name === "tutorialTopFinish") return page;
218− touchFlick(shell, halfWidth, shell.height, halfWidth, 0);
219−
220− page = waitForPage("tutorialLeft");
202+ var page = waitForPage("tutorialLeft");
221203 checkTopEdge();
222204 checkRightEdge();
223205 checkBottomEdge();
224206 if (name === "tutorialLeft") return page;
225− touchFlick(shell, 0, halfHeight, halfWidth, halfHeight, true, false);
207+ touchFlick(shell, 0, halfHeight, halfWidth, halfHeight);
226208
227− page = waitForPage("tutorialLeftRelease");
228− if (name === "tutorialLeftRelease") return page;
229− touchFlick(shell, halfWidth, halfHeight, halfWidth, halfHeight, false, true);
209+ page = waitForPage("tutorialLeftFinish");
210+ if (name === "tutorialLeftFinish") return page;
211+ var tick = findChild(page, "tick");
212+ tap(tick);
230213
231214 checkFinished();
232215 return null;
233216 }
234217
235− function test_skippable() {
236− var top = goToPage("tutorialTop");
237−
238− var skipLabel = findChild(top, "skipLabel");
239− tap(skipLabel);
240−
241− checkFinished();
242− }
243−
244218 function test_walkthrough() {
245219 goToPage(null);
246220 }
247221
248− function test_launcherShortDrags() {
249− // goToPage does a full launcher pull. But here we want to test
222+ function test_launcherShortDrag() {
223+ // goToPage does a normal launcher pull. But here we want to test
250224 // just barely pulling the launcher out and letting go (i.e. not
251225 // triggering the "progress" property of Launcher).
252226
@@ -263,23 +237,36 @@ Item {
263237 touchFlick(shell, 0, halfHeight, launcher.panelWidth * 0.9, halfHeight);
264238
265239 waitForPage("tutorialLeftFinish");
266− tap(launcher);
240+ }
267241
268− checkFinished();
242+ function test_launcherLongDrag() {
243+ // goToPage does a normal launcher pull. But here we want to test
244+ // a full pull across the page.
245+
246+ var left = goToPage("tutorialLeft");
247+
248+ var launcher = findChild(shell, "launcher");
249+ touchFlick(shell, 0, halfHeight, shell.width, halfHeight);
250+
251+ var errorLabel = findChild(left, "errorLabel");
252+ tryCompare(launcher, "state", ""); // launcher goes away
253+ tryCompare(left, "shown", true); // still on left page
254+ tryCompare(errorLabel, "opacity", 1); // show error
269255 }
270256
271257 function test_launcherDragBack() {
272258 // goToPage does a full launcher pull. But here we test pulling
273259 // all the way out, then dragging back into place.
274260
275− goToPage("tutorialLeftRelease");
261+ var left = goToPage("tutorialLeft");
262+ touchFlick(shell, 0, halfHeight, halfWidth, halfHeight, true, false);
276263 touchFlick(shell, halfWidth, halfHeight, 0, halfHeight, false, true);
277264
278− checkFinished();
265+ tryCompare(left, "shown", true); // and we should still be on left
279266 }
280267
281268 function test_interrupted() {
282− goToPage("tutorialTop");
269+ goToPage("tutorialLeft");
283270 ApplicationManager.startApplication("dialer-app");
284271 checkFinished();
285272 }