on 32d8ead help sign in
unity8/tests/qmltests/Tutorial/tst_Tutorial.qml
814 lines 31 kB history raw
1/*
2 * Copyright (C) 2013-2016 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 */
17import QtQuick 2.4
18import QtTest 1.0
19import AccountsService 0.1
20import LightDM.IntegratedLightDM 0.1 as LightDM
21import Ubuntu.Components 1.3
22import Ubuntu.Components.ListItems 1.3
23import Ubuntu.Telephony 0.1 as Telephony
24import Unity.Application 0.1
25import Unity.Notifications 1.0
26import Unity.Test 0.1 as UT
27import Utils 0.1
29import "../../../qml"
30import "../../../qml/Components"
32Rectangle {
33 id: root
34 color: UbuntuColors.lightGrey
35 width: units.gu(100) + buttons.width
36 height: units.gu(71)
38 QtObject {
39 id: applicationArguments
41 function hasGeometry() {
42 return false;
43 }
45 function width() {
46 return 0;
47 }
49 function height() {
50 return 0;
51 }
52 }
54 Telephony.CallEntry {
55 id: phoneCall
56 phoneNumber: "+447812221111"
57 }
59 Component {
60 id: mockNotification
61 QtObject {}
62 }
64 ListModel {
65 id: mockNotificationsModel
67 function getRaw(id) {
68 return mockNotification.createObject(mockNotificationsModel)
69 }
70 }
72 function addNotification() {
73 var n = {
74 type: Notification.Confirmation,
75 hints: {},
76 summary: "",
77 body: "",
78 icon: "",
79 secondaryIcon: "",
80 actions: []
81 };
83 mockNotificationsModel.append(n);
84 }
86 Component.onCompleted: {
87 // must set the mock mode before loading the Shell
88 LightDM.Greeter.mockMode = "single-pin";
89 LightDM.Users.mockMode = "single-pin";
90 shellLoader.active = true;
91 }
93 Item {
94 id: shellContainer
95 anchors.left: root.left
96 anchors.right: buttons.left
97 anchors.top: root.top
98 anchors.bottom: root.bottom
100 Loader {
101 id: shellLoader
103 active: false
104 anchors.horizontalCenter: parent.horizontalCenter
105 anchors.top: parent.top
106 anchors.bottom: parent.bottom
108 property int shellOrientation: Qt.PortraitOrientation
109 property int nativeOrientation: Qt.PortraitOrientation
110 property int primaryOrientation: Qt.PortraitOrientation
112 state: modeSelector.model[modeSelector.selectedIndex]
113 states: [
114 State {
115 name: "phone"
116 PropertyChanges {
117 target: shellLoader
118 width: units.gu(40)
119 }
120 },
121 State {
122 name: "tablet"
123 PropertyChanges {
124 target: shellLoader
125 width: units.gu(100)
126 shellOrientation: Qt.LandscapeOrientation
127 nativeOrientation: Qt.LandscapeOrientation
128 primaryOrientation: Qt.LandscapeOrientation
129 }
130 },
131 State {
132 name: "desktop"
133 PropertyChanges {
134 target: shellLoader
135 width: units.gu(100)
136 }
137 }
138 ]
140 property bool itemDestroyed: false
141 sourceComponent: Component {
142 Shell {
143 usageScenario: shellLoader.state
144 nativeWidth: width
145 nativeHeight: height
146 property string indicatorProfile: "phone"
147 orientation: shellLoader.shellOrientation
148 orientations: Orientations {
149 native_: shellLoader.nativeOrientation
150 primary: shellLoader.primaryOrientation
151 }
153 Component.onDestruction: {
154 shellLoader.itemDestroyed = true;
155 }
156 }
157 }
158 }
159 }
161 Rectangle {
162 id: buttons
163 color: UbuntuColors.darkGrey
164 width: units.gu(30)
165 anchors.top: root.top
166 anchors.bottom: root.bottom
167 anchors.right: root.right
169 Column {
170 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
171 spacing: units.gu(1)
172 Row {
173 anchors { left: parent.left; right: parent.right }
174 Button {
175 text: "Hide Greeter"
176 onClicked: {
177 if (shellLoader.status !== Loader.Ready)
178 return;
180 var greeter = testCase.findChild(shellLoader.item, "greeter");
181 if (greeter.shown) {
182 greeter.hide();
183 }
184 }
185 }
186 }
188 Row {
189 anchors { left: parent.left; right: parent.right }
190 Button {
191 text: "Restart Tutorial"
192 onClicked: {
193 if (shellLoader.status !== Loader.Ready)
194 return;
196 AccountsService.demoEdges = false;
197 AccountsService.demoEdgesCompleted = [];
198 AccountsService.demoEdges = true;
199 }
200 }
201 }
203 Row {
204 anchors { left: parent.left; right: parent.right }
205 CheckBox {
206 onCheckedChanged: {
207 if (checked) {
208 callManager.foregroundCall = phoneCall;
209 } else {
210 callManager.foregroundCall = null;
211 }
212 }
213 }
214 Label {
215 text: "Active Call"
216 anchors.verticalCenter: parent.verticalCenter
217 }
218 }
220 Row {
221 anchors { left: parent.left; right: parent.right }
222 CheckBox {
223 activeFocusOnPress: false
224 onCheckedChanged: {
225 var surface = topLevelSurfaceList.inputMethodSurface;
226 if (checked) {
227 surface.requestState(Mir.RestoredState);
228 } else {
229 surface.requestState(Mir.MinimizedState);
230 }
231 }
232 }
233 Label {
234 text: "Input Method"
235 anchors.verticalCenter: parent.verticalCenter
236 }
237 }
239 ItemSelector {
240 id: modeSelector
241 anchors { left: parent.left; right: parent.right }
242 activeFocusOnPress: false
243 text: "Mode"
244 model: ["phone", "tablet", "desktop"]
245 }
246 }
247 }
249 UT.StageTestCase {
250 id: testCase
251 name: "Tutorial"
252 when: windowShown
254 property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null
255 property real halfWidth: shell ? shell.width / 2 : 0
256 property real halfHeight: shell ? shell.height / 2 : 0
258 onShellChanged: {
259 if (shell) {
260 topLevelSurfaceList = testCase.findInvisibleChild(shell, "topLevelSurfaceList");
261 } else {
262 topLevelSurfaceList = null;
263 }
264 }
266 function init() {
267 prepareShell();
269 var tutorialLeft = findChild(shell, "tutorialLeft");
270 var tutorialLeftTimer = findInvisibleChild(tutorialLeft, "tutorialLeftTimer");
271 tutorialLeftTimer.interval = 0;
272 tryCompare(tutorialLeft, "opacity", 1);
273 }
275 function cleanup() {
276 resetLoader("phone");
277 }
279 function resetLoader(state) {
280 shellLoader.itemDestroyed = false;
282 shellLoader.active = false;
283 shellLoader.state = state;
285 tryCompare(shellLoader, "status", Loader.Null);
286 tryCompare(shellLoader, "item", null);
287 // Loader.status might be Loader.Null and Loader.item might be null but the Loader
288 // item might still be alive. So if we set Loader.active back to true
289 // again right now we will get the very same Shell instance back. So no reload
290 // actually took place. Likely because Loader waits until the next event loop
291 // iteration to do its work. So to ensure the reload, we will wait until the
292 // Shell instance gets destroyed.
293 tryCompare(shellLoader, "itemDestroyed", true);
295 // kill all (fake) running apps
296 killApps();
298 // reload our test subject to get it in a fresh state once again
299 shellLoader.active = true;
301 mockNotificationsModel.clear();
302 tryCompare(shellLoader, "status", Loader.Ready);
303 removeTimeConstraintsFromSwipeAreas(shellLoader.item);
304 }
306 function prepareShell() {
307 tryCompare(shell, "waitingOnGreeter", false); // reset by greeter when ready
309 WindowStateStorage.clear();
310 //topLevelSurfaceList.inputMethodSurface.setState(Mir.MinimizedState);
311 callManager.foregroundCall = null;
312 AccountsService.demoEdges = false;
313 AccountsService.demoEdgesCompleted = [];
314 AccountsService.demoEdges = true;
316 LightDM.Greeter.hideGreeter();
318 stage = findChild(shell, "stage"); // from StageTestCase
320 startApplication("unity8-dash");
321 }
323 function loadShell(state) {
324 resetLoader(state);
325 prepareShell();
326 }
328 function ensureInputMethodSurface() {
329 var surfaceManager = findInvisibleChild(shell, "surfaceManager");
330 verify(surfaceManager);
331 surfaceManager.createInputMethodSurface();
333 tryCompareFunction(function() { return topLevelSurfaceList.inputMethodSurface !== null }, true);
334 }
336 function swipeAwayGreeter() {
337 var coverPage = findChild(shell, "coverPage");
338 tryCompare(coverPage, "showProgress", 1);
340 touchFlick(shell, halfWidth, halfHeight, shell.width, halfHeight);
342 // wait until the animation has finished
343 var greeter = findChild(shell, "greeter");
344 tryCompare(greeter, "required", false);
345 waitForRendering(greeter);
346 }
348 function openTutorialTop() {
349 var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
350 var tutorialTop = findChild(shell, "tutorialTop");
351 var tutorialTopTimer = findInvisibleChild(tutorialTop, "tutorialTopTimer");
353 tutorialTopTimer.interval = 1;
354 AccountsService.demoEdgesCompleted = ["left"];
356 tryCompare(tutorialLeftLoader, "active", false);
357 tryCompare(tutorialTop, "shown", true);
358 tryCompare(tutorialTop, "opacity", 1);
359 }
361 function openTutorialLeftLong() {
362 var tutorialLeftLong = findChild(shell, "tutorialLeftLong");
363 var tutorialLeftLongTimer = findChild(tutorialLeftLong, "tutorialLeftLongTimer");
365 AccountsService.demoEdgesCompleted = ["left", "top"];
366 ApplicationManager.startApplication("gallery-app");
368 tutorialLeftLongTimer.interval = 1;
369 tryCompare(tutorialLeftLong, "shown", true);
370 tryCompare(tutorialLeftLong, "opacity", 1);
371 }
373 function openTutorialRight() {
374 var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
375 var tutorialRight = findChild(shell, "tutorialRight");
376 var tutorialRightTimer = findChild(tutorialRight, "tutorialRightTimer");
378 AccountsService.demoEdgesCompleted = ["left", "top", "left-long"];
379 ApplicationManager.startApplication("gallery-app");
380 ApplicationManager.startApplication("facebook-webapp");
381 ApplicationManager.startApplication("camera-app");
383 tryCompare(tutorialLeftLoader, "active", false);
384 tutorialRightTimer.interval = 1;
385 tryCompare(tutorialRight, "shown", true);
386 tryCompare(tutorialRight, "opacity", 1);
387 }
389 function test_tutorialLeftEdges() {
390 var tutorial = findChild(shell, "tutorial");
391 var tutorialLeft = findChild(tutorial, "tutorialLeft");
392 var launcher = findChild(shell, "launcher");
393 var stage = findChild(shell, "stage");
394 var panel = findChild(shell, "panel");
396 verify(tutorial.running);
397 verify(tutorial.launcherEnabled);
398 verify(!tutorial.spreadEnabled);
399 verify(!tutorial.panelEnabled);
400 verify(tutorialLeft.shown);
401 verify(launcher.available);
402 verify(!stage.spreadEnabled);
403 verify(!panel.indicators.available);
404 }
406 function test_tutorialLeftFinish() {
407 var tutorial = findChild(shell, "tutorial");
408 var tutorialLeftLoader = findChild(tutorial, "tutorialLeftLoader");
409 var launcher = findChild(shell, "launcher");
411 touchFlick(shell, 0, halfHeight, halfWidth, halfHeight);
413 tryCompare(tutorialLeftLoader, "shown", false);
414 tryCompare(AccountsService, "demoEdgesCompleted", ["left"]);
415 tryCompare(launcher, "state", "visible");
416 }
418 function test_tutorialLeftShortDrag() {
419 // Here we want to test just barely pulling the launcher out and
420 // letting go (i.e. not triggering the "progress" property of
421 // Launcher).
422 var tutorialLeft = findChild(shell, "tutorialLeft");
423 var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
424 var launcher = findChild(shell, "launcher");
426 // Confirm fade during drag
427 touchFlick(shell, 0, halfHeight, launcher.panelWidth * 0.4, halfHeight, true, false);
428 // compare opacity with a bound rather than hard 0.6 because progress doesn't
429 // always match the drag perfectly (takes a moment for drag to kick in)
430 tryCompareFunction(function() {
431 return tutorialLeft.opacity >= 0.6 && tutorialLeft.opacity < 0.8;
432 }, true);
433 touchFlick(shell, 0, halfHeight, launcher.panelWidth * 0.4, halfHeight, false, true);
436 // Make sure we don't do anything if we don't pull the launcher
437 // out much.
438 touchFlick(shell, 0, halfHeight, launcher.panelWidth * 0.4, halfHeight);
439 tryCompare(launcher, "state", ""); // should remain hidden
440 tryCompare(tutorialLeftLoader, "shown", true); // and we should still be on left
443 // Now drag out but not past launcher itself
444 touchFlick(shell, 0, halfHeight, launcher.panelWidth * 0.9, halfHeight);
446 tryCompare(tutorialLeftLoader, "shown", false);
447 tryCompare(AccountsService, "demoEdgesCompleted", ["left"]);
448 tryCompare(launcher, "state", "visible");
449 }
451 function test_tutorialLeftLongFinish() {
452 AccountsService.demoEdgesCompleted = ["left", "top"];
454 var tutorialLeftLongTimer = findInvisibleChild(shell, "tutorialLeftLongTimer");
455 tutorialLeftLongTimer.interval = 1;
457 ApplicationManager.startApplication("gallery-app");
459 var tutorialLeftLongLoader = findChild(shell, "tutorialLeftLongLoader");
460 tryCompare(tutorialLeftLongLoader, "shown", true);
462 touchFlick(shell, 0, halfHeight, shell.width, halfHeight);
464 tryCompare(tutorialLeftLongLoader, "shown", false);
465 tryCompare(AccountsService, "demoEdgesCompleted", ["left", "top", "left-long"]);
466 }
468 function test_tutorialLeftAutoSkipped() {
469 // Test that we skip the tutorial if user uses left edge themselves
471 var tutorialLeft = findChild(shell, "tutorialLeft");
472 LightDM.Greeter.showGreeter();
473 tryCompare(tutorialLeft, "visible", false);
474 compare(AccountsService.demoEdgesCompleted, []);
476 touchFlick(shell, 0, halfHeight, halfWidth, halfHeight);
477 tryCompare(AccountsService, "demoEdgesCompleted", ["left"]);
478 }
480 function test_tutorialLongLeftSwipeDisabled() {
481 // Test that a long left swipe is disabled until we get to or pass
482 // the long left tutorial.
483 var tutorial = findChild(shell, "tutorial");
485 verify(!tutorial.launcherLongSwipeEnabled);
487 openTutorialLeftLong();
488 verify(tutorial.launcherLongSwipeEnabled);
490 openTutorialRight();
491 verify(tutorial.launcherLongSwipeEnabled);
493 AccountsService.demoEdges = false;
494 tryCompare(tutorial, "running", false);
495 verify(tutorial.launcherLongSwipeEnabled);
496 }
498 function test_tutorialTopEdges() {
499 var tutorial = findChild(shell, "tutorial");
500 var tutorialTop = findChild(tutorial, "tutorialTop");
501 var launcher = findChild(shell, "launcher");
502 var stage = findChild(shell, "stage");
503 var panel = findChild(shell, "panel");
505 openTutorialTop();
507 tryCompare(tutorial, "running", true);
508 verify(!tutorial.launcherEnabled);
509 verify(!tutorial.spreadEnabled);
510 verify(tutorial.panelEnabled);
511 verify(tutorialTop.shown);
512 verify(!launcher.available);
513 verify(!stage.spreadEnabled);
514 verify(panel.indicators.available);
515 }
517 function test_tutorialTopFinish() {
518 var tutorial = findChild(shell, "tutorial");
519 var tutorialTopLoader = findChild(tutorial, "tutorialTopLoader");
520 var panel = findChild(shell, "panel");
522 openTutorialTop();
523 touchFlick(shell, halfWidth, 0, halfWidth, shell.height);
525 tryCompare(tutorialTopLoader, "shown", false);
526 tryCompare(AccountsService, "demoEdgesCompleted", ["left", "top"]);
527 tryCompare(panel.indicators, "fullyOpened", true);
528 }
530 function test_tutorialTopShortDrag() {
531 var tutorial = findChild(shell, "tutorial");
532 var tutorialTop = findChild(tutorial, "tutorialTop");
533 var panel = findChild(shell, "panel");
535 openTutorialTop();
536 touchFlick(shell, halfWidth, 0, halfWidth, shell.height * 0.4, true, false);
537 // compare opacity with a bound rather than hard 0.6 because progress doesn't
538 // always match the drag perfectly (takes a moment for drag to kick in)
539 tryCompareFunction(function() {
540 return tutorialTop.opacity >= 0.5 && tutorialTop.opacity < 0.7;
541 }, true);
542 touchFlick(shell, halfWidth, 0, halfWidth, shell.height * 0.4, false, true);
544 compare(tutorialTop.shown, true);
545 }
547 function test_tutorialTopAutoSkipped() {
548 // Test that we skip the tutorial if user uses top edge themselves
550 var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
551 var tutorialTopLoader = findChild(shell, "tutorialTopLoader");
552 AccountsService.demoEdgesCompleted = ["left"];
553 tryCompare(tutorialLeftLoader, "active", false);
554 verify(!tutorialTopLoader.shown);
556 touchFlick(shell, halfWidth, 0, halfWidth, shell.height);
557 tryCompare(AccountsService, "demoEdgesCompleted", ["left", "top"]);
558 }
560 function test_tutorialRightEdges() {
561 var tutorial = findChild(shell, "tutorial");
562 var tutorialRight = findChild(tutorial, "tutorialRight");
563 var launcher = findChild(shell, "launcher");
564 var stage = findChild(shell, "stage");
565 var panel = findChild(shell, "panel");
567 openTutorialRight();
569 tryCompare(tutorial, "running", true);
570 verify(!tutorial.launcherEnabled);
571 verify(tutorial.spreadEnabled);
572 verify(!tutorial.panelEnabled);
573 verify(tutorialRight.shown);
574 verify(!launcher.available);
575 verify(stage.spreadEnabled);
576 verify(!panel.indicators.available);
577 }
579 function test_tutorialRightFinish() {
580 openTutorialRight();
581 touchFlick(shell, shell.width, halfHeight, 0, halfHeight);
583 tryCompare(AccountsService, "demoEdgesCompleted", ["left", "top", "left-long", "right"]);
584 tryCompare(AccountsService, "demoEdges", false);
585 }
587 function test_tutorialRightShortDrag() {
588 var tutorial = findChild(shell, "tutorial");
589 var tutorialRight = findChild(tutorial, "tutorialRight");
590 var stage = findChild(shell, "stage");
592 openTutorialRight();
593 touchFlick(shell, shell.width, halfHeight, shell.width * 0.8, halfHeight, true, false);
594 // compare opacity with a bound rather than hard 0.6 because progress doesn't
595 // always match the drag perfectly (takes a moment for drag to kick in)
596 tryCompareFunction(function() {
597 return tutorialRight.opacity >= 0.6 && tutorialRight.opacity < 0.8;
598 }, true);
599 touchFlick(shell, shell.width, halfHeight, shell.width * 0.8, halfHeight, false, true);
601 compare(tutorialRight.shown, true);
602 }
604 function test_tutorialRightDelay() {
605 // Test that if we exit the top tutorial, we don't immediately
606 // jump into right tutorial.
607 var tutorialRightLoader = findChild(shell, "tutorialRightLoader");
608 var tutorialRightTimer = findInvisibleChild(tutorialRightLoader, "tutorialRightTimer");
610 openTutorialTop();
611 ApplicationManager.startApplication("gallery-app");
612 ApplicationManager.startApplication("facebook-webapp");
613 ApplicationManager.startApplication("camera-app");
614 tryCompare(ApplicationManager, "count", 4);
616 AccountsService.demoEdgesCompleted = ["left", "top", "left-long"];
617 verify(tutorialRightTimer.running);
618 verify(!tutorialRightLoader.shown);
619 tutorialRightTimer.interval = 1;
620 tryCompare(tutorialRightLoader, "shown", true);
621 }
623 function test_tutorialRightAutoSkipped() {
624 // Test that we skip the tutorial if user uses right edge themselves
626 var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
627 AccountsService.demoEdgesCompleted = ["left"];
628 tryCompare(tutorialLeftLoader, "active", false);
630 touchFlick(shell, shell.width, halfHeight, 0, halfHeight);
631 tryCompare(AccountsService, "demoEdgesCompleted", ["left", "right"]);
632 }
634 function test_activeCallInterruptsTutorial() {
635 var tutorialLeft = findChild(shell, "tutorialLeft");
636 verify(tutorialLeft.shown);
637 verify(!tutorialLeft.paused);
639 callManager.foregroundCall = phoneCall;
640 verify(!tutorialLeft.shown);
641 verify(tutorialLeft.paused);
642 tryCompare(tutorialLeft, "visible", false);
644 callManager.foregroundCall = null;
645 tryCompare(tutorialLeft, "shown", true);
646 verify(!tutorialLeft.paused);
647 }
649 function test_greeterInterruptsTutorial() {
650 var tutorialLeft = findChild(shell, "tutorialLeft");
651 verify(tutorialLeft.shown);
652 verify(!tutorialLeft.paused);
654 LightDM.Greeter.showGreeter();
655 verify(!tutorialLeft.shown);
656 verify(tutorialLeft.paused);
657 tryCompare(tutorialLeft, "visible", false);
659 LightDM.Greeter.hideGreeter();
660 tryCompare(tutorialLeft, "shown", true);
661 verify(!tutorialLeft.paused);
662 }
664 function test_interruptionChecksReadyStateWhenDone() {
665 // If we're done with an interruption (like active call), make sure
666 // that we don't blindly resume the tutorial -- our trigger
667 // conditions still need to be met. For example, there need to be
668 // enough apps open for the right edge tutorial.
670 openTutorialRight();
672 var tutorialRight = findChild(shell, "tutorialRight");
673 verify(tutorialRight.isReady);
674 verify(tutorialRight.shown);
675 verify(!tutorialRight.paused);
677 callManager.foregroundCall = phoneCall;
678 killApps();
679 callManager.foregroundCall = null;
681 verify(!tutorialRight.isReady);
682 verify(!tutorialRight.shown);
683 verify(!tutorialRight.paused);
684 compare(AccountsService.demoEdgesCompleted, ["left", "top", "left-long"]);
685 }
687 function test_desktopOnlyShowsTutorialRight() {
688 loadShell("desktop");
690 var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
691 var tutorialTopLoader = findChild(shell, "tutorialTopLoader");
692 var tutorialLeftLongLoader = findChild(shell, "tutorialLeftLongLoader");
693 var tutorialRightLoader = findChild(shell, "tutorialRightLoader");
694 verify(!tutorialLeftLoader.active);
695 verify(!tutorialTopLoader.active);
696 verify(!tutorialLeftLongLoader.active);
697 verify(tutorialRightLoader.active);
698 compare(AccountsService.demoEdgesCompleted, []);
700 var tutorialRightTimer = findInvisibleChild(tutorialRightLoader, "tutorialRightTimer");
701 tutorialRightTimer.interval = 1;
703 ApplicationManager.startApplication("dialer-app");
704 ApplicationManager.startApplication("camera-app");
705 ApplicationManager.startApplication("facebook-webapp");
706 tryCompare(tutorialRightLoader.item, "isReady", true);
708 tryCompare(tutorialRightLoader, "shown", true);
709 }
711 function test_desktopTutorialRightFinish() {
712 loadShell("desktop");
714 var tutorialRightLoader = findChild(shell, "tutorialRightLoader");
715 var tutorialRightTimer = findInvisibleChild(tutorialRightLoader, "tutorialRightTimer");
716 tutorialRightTimer.interval = 1;
717 ApplicationManager.startApplication("dialer-app");
718 ApplicationManager.startApplication("camera-app");
719 ApplicationManager.startApplication("facebook-webapp");
720 tryCompare(tutorialRightLoader, "shown", true);
722 var stage = findChild(shell, "stage");
723 mouseMove(shell, shell.width, shell.height / 2);
724 stage.pushRightEdge(units.gu(8));
725 tryCompare(tutorialRightLoader, "shown", false);
727 tryCompare(AccountsService, "demoEdges", false);
728 }
730 function test_oskDoesNotHideTutorial() {
731 var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
732 verify(tutorialLeftLoader.shown);
734 ensureInputMethodSurface();
735 var surface = topLevelSurfaceList.inputMethodSurface;
736 surface.requestState(Mir.RestoredState);
738 var inputMethod = findInvisibleChild(shell, "inputMethod");
739 tryCompare(inputMethod, "visible", true);
741 verify(tutorialLeftLoader.shown);
742 }
744 function test_oskDelaysTutorial() {
745 var tutorial = findChild(shell, "tutorial");
746 verify(!tutorial.delayed);
748 ensureInputMethodSurface();
749 topLevelSurfaceList.inputMethodSurface.requestState(Mir.RestoredState);
751 tryCompare(tutorial, "delayed", true);
752 }
754 function test_notificationDelaysTutorial() {
755 var tutorial = findChild(shell, "tutorial");
756 verify(!tutorial.delayed);
758 var notifications = findChild(shell, "notificationList");
759 notifications.model = mockNotificationsModel;
760 addNotification(); // placeholder
761 addNotification();
763 tryCompare(tutorial, "delayed", true);
764 }
766 function test_dialogDelaysTutorial() {
767 var tutorial = findChild(shell, "tutorial");
768 verify(!tutorial.delayed);
770 var dialogs = findChild(shell, "dialogs");
771 dialogs.showPowerDialog();
773 verify(tutorial.delayed);
774 }
776 function test_delayedTutorial() {
777 var tutorial = findChild(shell, "tutorial");
778 var tutorialTop = findChild(tutorial, "tutorialTop");
779 var tutorialTopTimer = findChild(tutorialTop, "tutorialTopTimer");
781 // Get top tutorial ready
782 AccountsService.demoEdgesCompleted = ["left"];
783 verify(tutorialTop.isReady);
784 verify(tutorialTopTimer.running);
786 // Confirm that we become unready when delayed, but timer still goes
787 tutorial.delayed = true;
788 verify(!tutorialTop.isReady);
789 verify(tutorialTopTimer.running);
791 // Confirm that we don't open the tutorial when delayed
792 tutorialTopTimer.interval = 1;
793 wait(5);
794 verify(!tutorialTop.shown);
796 // Confirm we go back to normal when undelayed
797 tutorial.delayed = false;
798 tryCompare(tutorialTop, "shown", true);
799 }
801 function test_accountsServiceSettings() {
802 var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
803 verify(tutorialLeftLoader.shown);
805 AccountsService.demoEdges = false;
806 verify(findChild(shell, "tutorialLeftLoader") == null);
808 AccountsService.demoEdges = true;
809 tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
810 var tutorialLeftTimer = findChild(tutorialLeftLoader, "tutorialLeftTimer");
811 verify(tutorialLeftTimer.running);
812 }
813 }