on 3d22307 help sign in
unity8/tests/qmltests/Tutorial/tst_Tutorial.qml
830 lines 33 kB history raw
1/*
2 * Copyright (C) 2013,2014,2015 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 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.Test 0.1 as UT
26import Utils 0.1
28import "../../../qml"
29import "../../../qml/Components"
31Rectangle {
32 id: root
33 color: UbuntuColors.lightGrey
34 width: units.gu(100) + buttons.width
35 height: units.gu(71)
37 QtObject {
38 id: applicationArguments
40 function hasGeometry() {
41 return false;
42 }
44 function width() {
45 return 0;
46 }
48 function height() {
49 return 0;
50 }
51 }
53 Telephony.CallEntry {
54 id: phoneCall
55 phoneNumber: "+447812221111"
56 }
58 Component.onCompleted: {
59 // must set the mock mode before loading the Shell
60 LightDM.Greeter.mockMode = "single-pin";
61 LightDM.Users.mockMode = "single-pin";
62 shellLoader.active = true;
63 }
65 Item {
66 id: shellContainer
67 anchors.left: root.left
68 anchors.right: buttons.left
69 anchors.top: root.top
70 anchors.bottom: root.bottom
72 Loader {
73 id: shellLoader
75 active: false
76 anchors.horizontalCenter: parent.horizontalCenter
77 anchors.top: parent.top
78 anchors.bottom: parent.bottom
80 property int shellOrientation: Qt.PortraitOrientation
81 property int nativeOrientation: Qt.PortraitOrientation
82 property int primaryOrientation: Qt.PortraitOrientation
84 state: modeSelector.model[modeSelector.selectedIndex]
85 states: [
86 State {
87 name: "phone"
88 PropertyChanges {
89 target: shellLoader
90 width: units.gu(40)
91 }
92 },
93 State {
94 name: "tablet"
95 PropertyChanges {
96 target: shellLoader
97 width: units.gu(100)
98 shellOrientation: Qt.LandscapeOrientation
99 nativeOrientation: Qt.LandscapeOrientation
100 primaryOrientation: Qt.LandscapeOrientation
101 }
102 },
103 State {
104 name: "desktop"
105 PropertyChanges {
106 target: shellLoader
107 width: units.gu(100)
108 }
109 }
110 ]
112 property bool itemDestroyed: false
113 sourceComponent: Component {
114 Shell {
115 usageScenario: shellLoader.state
116 property string indicatorProfile: "phone"
117 orientation: shellLoader.shellOrientation
118 orientations: Orientations {
119 native_: shellLoader.nativeOrientation
120 primary: shellLoader.primaryOrientation
121 }
123 Component.onDestruction: {
124 shellLoader.itemDestroyed = true;
125 }
126 }
127 }
128 }
129 }
131 Rectangle {
132 id: buttons
133 color: UbuntuColors.darkGrey
134 width: units.gu(30)
135 anchors.top: root.top
136 anchors.bottom: root.bottom
137 anchors.right: root.right
139 Column {
140 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
141 spacing: units.gu(1)
142 Row {
143 anchors { left: parent.left; right: parent.right }
144 Button {
145 text: "Hide Greeter"
146 onClicked: {
147 if (shellLoader.status !== Loader.Ready)
148 return;
150 var greeter = testCase.findChild(shellLoader.item, "greeter");
151 if (greeter.shown) {
152 greeter.hide();
153 }
154 }
155 }
156 }
158 Row {
159 anchors { left: parent.left; right: parent.right }
160 Button {
161 text: "Restart Tutorial"
162 onClicked: {
163 if (shellLoader.status !== Loader.Ready)
164 return;
166 AccountsService.demoEdges = false;
167 AccountsService.demoEdgesCompleted = [];
168 AccountsService.demoEdges = true;
169 }
170 }
171 }
173 Row {
174 anchors { left: parent.left; right: parent.right }
175 CheckBox {
176 onCheckedChanged: {
177 if (checked) {
178 callManager.foregroundCall = phoneCall;
179 } else {
180 callManager.foregroundCall = null;
181 }
182 }
183 }
184 Label {
185 text: "Active Call"
186 anchors.verticalCenter: parent.verticalCenter
187 }
188 }
190 Row {
191 anchors { left: parent.left; right: parent.right }
192 CheckBox {
193 activeFocusOnPress: false
194 onCheckedChanged: {
195 var surface = SurfaceManager.inputMethodSurface;
196 if (checked) {
197 surface.setState(Mir.RestoredState);
198 } else {
199 surface.setState(Mir.MinimizedState);
200 }
201 }
202 }
203 Label {
204 text: "Input Method"
205 anchors.verticalCenter: parent.verticalCenter
206 }
207 }
209 ItemSelector {
210 id: modeSelector
211 anchors { left: parent.left; right: parent.right }
212 activeFocusOnPress: false
213 text: "Mode"
214 model: ["phone", "tablet", "desktop"]
215 }
216 }
217 }
219 UT.UnityTestCase {
220 id: testCase
221 name: "Tutorial"
222 when: windowShown
224 property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null
225 property real halfWidth: shell ? shell.width / 2 : 0
226 property real halfHeight: shell ? shell.height / 2 : 0
228 function init() {
229 prepareShell();
231 var tutorialLeft = findChild(shell, "tutorialLeft");
232 tryCompare(tutorialLeft, "opacity", 1);
233 }
235 function cleanup() {
236 resetLoader("phone");
237 }
239 function resetLoader(state) {
240 shellLoader.itemDestroyed = false;
242 shellLoader.active = false;
243 shellLoader.state = state;
245 tryCompare(shellLoader, "status", Loader.Null);
246 tryCompare(shellLoader, "item", null);
247 // Loader.status might be Loader.Null and Loader.item might be null but the Loader
248 // item might still be alive. So if we set Loader.active back to true
249 // again right now we will get the very same Shell instance back. So no reload
250 // actually took place. Likely because Loader waits until the next event loop
251 // iteration to do its work. So to ensure the reload, we will wait until the
252 // Shell instance gets destroyed.
253 tryCompare(shellLoader, "itemDestroyed", true);
255 // kill all (fake) running apps
256 killApps();
258 // reload our test subject to get it in a fresh state once again
259 shellLoader.active = true;
261 tryCompare(shellLoader, "status", Loader.Ready);
262 removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item);
263 }
265 function prepareShell() {
266 tryCompare(shell, "enabled", true); // enabled by greeter when ready
268 WindowStateStorage.clear();
269 SurfaceManager.inputMethodSurface.setState(Mir.MinimizedState);
270 callManager.foregroundCall = null;
271 AccountsService.demoEdges = false;
272 AccountsService.demoEdgesCompleted = [];
273 AccountsService.demoEdges = true;
275 LightDM.Greeter.hideGreeter();
276 }
278 function loadShell(state) {
279 resetLoader(state);
280 prepareShell();
281 }
283 function killApps() {
284 while (ApplicationManager.count > 1) {
285 var appIndex = ApplicationManager.get(0).appId == "unity8-dash" ? 1 : 0
286 ApplicationManager.stopApplication(ApplicationManager.get(appIndex).appId);
287 }
288 compare(ApplicationManager.count, 1)
289 }
291 function swipeAwayGreeter() {
292 var coverPage = findChild(shell, "coverPage");
293 tryCompare(coverPage, "showProgress", 1);
295 touchFlick(shell, halfWidth, halfHeight, shell.width, halfHeight);
297 // wait until the animation has finished
298 var greeter = findChild(shell, "greeter");
299 tryCompare(greeter, "required", false);
300 waitForRendering(greeter);
301 }
303 function openTutorialTop() {
304 var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
305 var tutorialTop = findChild(shell, "tutorialTop");
306 var tutorialTopTimer = findInvisibleChild(tutorialTop, "tutorialTopTimer");
308 tutorialTopTimer.interval = 1;
309 AccountsService.demoEdgesCompleted = ["left", "left-long"];
311 tryCompare(tutorialLeftLoader, "active", false);
312 tryCompare(tutorialTop, "shown", true);
313 tryCompare(tutorialTop, "opacity", 1);
314 }
316 function openTutorialRight() {
317 var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
318 var tutorialRight = findChild(shell, "tutorialRight");
320 AccountsService.demoEdgesCompleted = ["left", "left-long", "top"];
321 ApplicationManager.startApplication("gallery-app");
322 ApplicationManager.startApplication("facebook-webapp");
324 tryCompare(tutorialLeftLoader, "active", false);
325 tryCompare(tutorialRight, "shown", true);
326 tryCompare(tutorialRight, "opacity", 1);
327 }
329 function openTutorialBottom() {
330 var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
331 var tutorialBottom = findChild(shell, "tutorialBottom");
333 AccountsService.demoEdgesCompleted = ["left", "left-long", "top", "right"];
334 tryCompare(tutorialLeftLoader, "active", false);
336 ApplicationManager.startApplication("dialer-app");
337 ApplicationManager.requestFocusApplication("dialer-app");
339 tryCompare(tutorialBottom, "shown", true);
340 tryCompare(tutorialBottom, "opacity", 1);
341 }
343 function test_tutorialLeftEdges() {
344 var tutorial = findChild(shell, "tutorial");
345 var tutorialLeft = findChild(tutorial, "tutorialLeft");
346 var launcher = findChild(shell, "launcher");
347 var stage = findChild(shell, "stage");
348 var panel = findChild(shell, "panel");
350 verify(tutorial.running);
351 verify(tutorial.launcherEnabled);
352 verify(!tutorial.spreadEnabled);
353 verify(!tutorial.panelEnabled);
354 verify(tutorialLeft.shown);
355 verify(launcher.available);
356 verify(!stage.spreadEnabled);
357 verify(!panel.indicators.available);
358 }
360 function test_tutorialLeftFinish() {
361 var tutorial = findChild(shell, "tutorial");
362 var tutorialLeft = findChild(tutorial, "tutorialLeft");
363 var launcher = findChild(shell, "launcher");
365 touchFlick(shell, 0, halfHeight, halfWidth, halfHeight);
367 tryCompare(tutorialLeft, "shown", false);
368 tryCompare(AccountsService, "demoEdgesCompleted", ["left"]);
369 tryCompare(launcher, "state", "visible");
370 }
372 function test_tutorialLeftShortDrag() {
373 // Here we want to test just barely pulling the launcher out and
374 // letting go (i.e. not triggering the "progress" property of
375 // Launcher).
376 var tutorialLeft = findChild(shell, "tutorialLeft");
377 var launcher = findChild(shell, "launcher");
379 // Confirm fade during drag
380 touchFlick(shell, 0, halfHeight, launcher.panelWidth * 0.4, halfHeight, true, false);
381 // compare opacity with a bound rather than hard 0.6 because progress doesn't
382 // always match the drag perfectly (takes a moment for drag to kick in)
383 tryCompareFunction(function() {
384 return tutorialLeft.opacity >= 0.6 && tutorialLeft.opacity < 0.8;
385 }, true);
386 touchFlick(shell, 0, halfHeight, launcher.panelWidth * 0.4, halfHeight, false, true);
389 // Make sure we don't do anything if we don't pull the launcher
390 // out much.
391 touchFlick(shell, 0, halfHeight, launcher.panelWidth * 0.4, halfHeight);
392 tryCompare(launcher, "state", ""); // should remain hidden
393 tryCompare(tutorialLeft, "shown", true); // and we should still be on left
396 // Now drag out but not past launcher itself
397 touchFlick(shell, 0, halfHeight, launcher.panelWidth * 0.9, halfHeight);
399 tryCompare(tutorialLeft, "shown", false);
400 tryCompare(AccountsService, "demoEdgesCompleted", ["left"]);
401 tryCompare(launcher, "state", "visible");
402 }
404 function test_tutorialLeftLongDrag() {
405 // Just confirm that a long drag ("dash" drag) doesn't confuse us
407 // So that we actually switch to dash and launcher hides
408 ApplicationManager.startApplication("gallery-app");
410 var launcher = findChild(shell, "launcher");
411 var tutorialLeft = findChild(shell, "tutorialLeftLoader");
412 touchFlick(shell, 0, halfHeight, shell.width, halfHeight);
414 tryCompare(tutorialLeft, "shown", false);
415 tryCompare(AccountsService, "demoEdgesCompleted", ["left", "left-long"]);
416 }
418 function test_tutorialLeftAutoSkipped() {
419 // Test that we skip the tutorial if user uses left edge themselves
421 var tutorialLeft = findChild(shell, "tutorialLeft");
422 LightDM.Greeter.showGreeter();
423 tryCompare(tutorialLeft, "visible", false);
424 compare(AccountsService.demoEdgesCompleted, []);
426 touchFlick(shell, 0, halfHeight, halfWidth, halfHeight);
427 tryCompare(AccountsService, "demoEdgesCompleted", ["left"]);
428 }
430 function test_tutorialTopEdges() {
431 var tutorial = findChild(shell, "tutorial");
432 var tutorialTop = findChild(tutorial, "tutorialTop");
433 var launcher = findChild(shell, "launcher");
434 var stage = findChild(shell, "stage");
435 var panel = findChild(shell, "panel");
437 openTutorialTop();
439 tryCompare(tutorial, "running", true);
440 verify(!tutorial.launcherEnabled);
441 verify(!tutorial.spreadEnabled);
442 verify(tutorial.panelEnabled);
443 verify(tutorialTop.shown);
444 verify(!launcher.available);
445 verify(!stage.spreadEnabled);
446 verify(panel.indicators.available);
447 }
449 function test_tutorialTopFinish() {
450 var tutorial = findChild(shell, "tutorial");
451 var tutorialTop = findChild(tutorial, "tutorialTop");
452 var panel = findChild(shell, "panel");
454 openTutorialTop();
455 touchFlick(shell, halfWidth, 0, halfWidth, shell.height);
457 tryCompare(tutorialTop, "shown", false);
458 tryCompare(AccountsService, "demoEdgesCompleted", ["left", "left-long", "top"]);
459 tryCompare(panel.indicators, "fullyOpened", true);
460 }
462 function test_tutorialTopShortDrag() {
463 var tutorial = findChild(shell, "tutorial");
464 var tutorialTop = findChild(tutorial, "tutorialTop");
465 var panel = findChild(shell, "panel");
467 openTutorialTop();
468 touchFlick(shell, halfWidth, 0, halfWidth, shell.height * 0.4, true, false);
469 // compare opacity with a bound rather than hard 0.6 because progress doesn't
470 // always match the drag perfectly (takes a moment for drag to kick in)
471 tryCompareFunction(function() {
472 return tutorialTop.opacity >= 0.6 && tutorialTop.opacity < 0.7;
473 }, true);
474 touchFlick(shell, halfWidth, 0, halfWidth, shell.height * 0.4, false, true);
476 compare(tutorialTop.shown, true);
477 }
479 function test_tutorialTopAutoSkipped() {
480 // Test that we skip the tutorial if user uses top edge themselves
482 var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
483 var tutorialTop = findChild(shell, "tutorialTop");
484 AccountsService.demoEdgesCompleted = ["left", "left-long"];
485 tryCompare(tutorialLeftLoader, "active", false);
486 verify(!tutorialTop.shown);
488 touchFlick(shell, halfWidth, 0, halfWidth, shell.height);
489 tryCompare(AccountsService, "demoEdgesCompleted", ["left", "left-long", "top"]);
490 }
492 function test_tutorialRightEdges() {
493 var tutorial = findChild(shell, "tutorial");
494 var tutorialRight = findChild(tutorial, "tutorialRight");
495 var launcher = findChild(shell, "launcher");
496 var stage = findChild(shell, "stage");
497 var panel = findChild(shell, "panel");
499 openTutorialRight();
501 tryCompare(tutorial, "running", true);
502 verify(!tutorial.launcherEnabled);
503 verify(tutorial.spreadEnabled);
504 verify(!tutorial.panelEnabled);
505 verify(tutorialRight.shown);
506 verify(!launcher.available);
507 verify(stage.spreadEnabled);
508 verify(!panel.indicators.available);
509 }
511 function test_tutorialRightFinish() {
512 var tutorial = findChild(shell, "tutorial");
513 var tutorialRight = findChild(tutorial, "tutorialRight");
514 var stage = findChild(shell, "stage");
516 openTutorialRight();
517 touchFlick(shell, shell.width, halfHeight, 0, halfHeight);
519 tryCompare(tutorialRight, "shown", false);
520 tryCompare(AccountsService, "demoEdgesCompleted", ["left", "left-long", "top", "right"]);
521 }
523 function test_tutorialRightShortDrag() {
524 var tutorial = findChild(shell, "tutorial");
525 var tutorialRight = findChild(tutorial, "tutorialRight");
526 var stage = findChild(shell, "stage");
528 openTutorialRight();
529 touchFlick(shell, shell.width, halfHeight, shell.width * 0.8, halfHeight, true, false);
530 // compare opacity with a bound rather than hard 0.6 because progress doesn't
531 // always match the drag perfectly (takes a moment for drag to kick in)
532 tryCompareFunction(function() {
533 return tutorialRight.opacity >= 0.6 && tutorialRight.opacity < 0.8;
534 }, true);
535 touchFlick(shell, shell.width, halfHeight, shell.width * 0.8, halfHeight, false, true);
537 compare(tutorialRight.shown, true);
538 }
540 function test_tutorialRightDelay() {
541 // Test that if we exit the top tutorial, we don't immediately
542 // jump into right tutorial.
543 var tutorialRight = findChild(shell, "tutorialRight");
544 var tutorialRightTimer = findInvisibleChild(tutorialRight, "tutorialRightInactivityTimer");
546 tutorialRightTimer.interval = 1;
547 openTutorialTop();
548 ApplicationManager.startApplication("gallery-app");
549 ApplicationManager.startApplication("facebook-webapp");
550 tryCompare(ApplicationManager, "count", 3);
552 AccountsService.demoEdgesCompleted = ["left", "left-long", "top"];
553 verify(tutorialRightTimer.running, true);
554 verify(!tutorialRight.shown);
555 tryCompare(tutorialRight, "shown", true);
556 }
558 function test_tutorialRightAutoSkipped() {
559 // Test that we skip the tutorial if user uses right edge themselves
561 var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
562 AccountsService.demoEdgesCompleted = ["left", "left-long"];
563 tryCompare(tutorialLeftLoader, "active", false);
565 touchFlick(shell, shell.width, halfHeight, 0, halfHeight);
566 tryCompare(AccountsService, "demoEdgesCompleted", ["left", "left-long", "right"]);
567 }
569 function test_tutorialBottomEdges() {
570 var tutorial = findChild(shell, "tutorial");
571 var tutorialBottom = findChild(tutorial, "tutorialBottom");
572 var tutorialLabel = findChild(tutorialBottom, "tutorialLabel");
573 var launcher = findChild(shell, "launcher");
574 var stage = findChild(shell, "stage");
575 var panel = findChild(shell, "panel");
577 openTutorialBottom();
579 tryCompare(tutorial, "running", true);
580 verify(!tutorial.launcherEnabled);
581 verify(!tutorial.spreadEnabled);
582 verify(!tutorial.panelEnabled);
583 verify(tutorialBottom.shown);
584 verify(!launcher.available);
585 verify(!stage.spreadEnabled);
586 verify(!panel.indicators.available);
587 compare(tutorialLabel.text, "Swipe up for recent calls");
588 }
590 function test_tutorialBottomFinish() {
591 var tutorial = findChild(shell, "tutorial");
592 var tutorialBottom = findChild(tutorial, "tutorialBottom");
594 openTutorialBottom();
595 touchFlick(shell, halfWidth, shell.height, halfWidth, halfHeight);
597 tryCompare(tutorialBottom, "shown", false);
598 tryCompare(AccountsService, "demoEdgesCompleted", ["left", "left-long", "top", "right", "bottom-dialer-app"]);
600 // OK, we did one, just confirm that when all are done, we mark whole tutorial as done.
601 verify(AccountsService.demoEdges);
602 AccountsService.demoEdgesCompleted = ["left", "left-long", "top", "right",
603 "bottom-address-book-app",
604 "bottom-com.ubuntu.calculator_calculator",
605 "bottom-dialer-app",
606 "bottom-messaging-app"];
607 verify(!AccountsService.demoEdges);
608 }
610 function test_tutorialBottomAppearsBeforeRight() {
611 // Confirm that if bottom edge and right edge would appear on the
612 // the same app open, bottom edge appears first. (this is a lightly
613 // edited version of openTutorialRight)
614 var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
615 var tutorialRight = findChild(shell, "tutorialRight");
616 var tutorialBottom = findChild(shell, "tutorialBottom");
618 AccountsService.demoEdgesCompleted = ["left", "left-long", "top"];
619 ApplicationManager.startApplication("gallery-app");
620 ApplicationManager.startApplication("dialer-app");
622 tryCompare(tutorialLeftLoader, "active", false);
623 tryCompare(tutorialBottom, "shown", true);
624 tryCompare(tutorialBottom, "opacity", 1);
625 tryCompare(tutorialRight, "visible", false);
626 }
628 function test_tutorialBottomOnlyCoversSideStageOnTablet() {
629 loadShell("tablet");
631 var tutorialBottom = findChild(shell, "tutorialBottom");
632 var targetHeight = shell.height - units.gu(4);
633 var mainStageX = units.gu(20);
634 var sideStageX = shell.width - units.gu(20);
636 WindowStateStorage.saveStage("dialer-app", ApplicationInfoInterface.SideStage);
637 openTutorialBottom();
639 touchFlick(shell, mainStageX, shell.height, mainStageX, targetHeight, true, false);
640 compare(tutorialBottom.opacity, 1);
641 touchFlick(shell, mainStageX, shell.height, mainStageX, targetHeight, false, true);
643 touchFlick(shell, sideStageX, shell.height, sideStageX, targetHeight, true, false);
644 verify(tutorialBottom.opacity < 1);
645 touchFlick(shell, sideStageX, shell.height, sideStageX, targetHeight, false, true);
646 }
648 function test_tutorialBottomOnlyCoversMainStageOnTablet() {
649 loadShell("tablet");
651 var tutorialBottom = findChild(shell, "tutorialBottom");
652 var targetHeight = shell.height - units.gu(4);
653 var mainStageX = units.gu(20);
654 var sideStageX = shell.width - units.gu(20);
656 WindowStateStorage.saveStage("notes-app", ApplicationInfoInterface.SideStage);
657 ApplicationManager.startApplication("notes-app");
659 openTutorialBottom();
661 touchFlick(shell, sideStageX, shell.height, sideStageX, targetHeight, true, false);
662 compare(tutorialBottom.opacity, 1);
663 touchFlick(shell, sideStageX, shell.height, sideStageX, targetHeight, false, true);
665 touchFlick(shell, mainStageX, shell.height, mainStageX, targetHeight, true, false);
666 verify(tutorialBottom.opacity < 1);
667 touchFlick(shell, mainStageX, shell.height, mainStageX, targetHeight, false, true);
668 }
670 function test_activeCallInterruptsTutorial() {
671 var tutorialLeft = findChild(shell, "tutorialLeft");
672 verify(tutorialLeft.shown);
673 verify(!tutorialLeft.paused);
675 callManager.foregroundCall = phoneCall;
676 verify(!tutorialLeft.shown);
677 verify(tutorialLeft.paused);
678 tryCompare(tutorialLeft, "visible", false);
680 callManager.foregroundCall = null;
681 tryCompare(tutorialLeft, "shown", true);
682 verify(!tutorialLeft.paused);
683 }
685 function test_dialerInterruptionWithNoOverlappingTutorials() {
686 var tutorialLeft = findChild(shell, "tutorialLeft");
687 var tutorialBottom = findChild(shell, "tutorialBottom");
688 verify(tutorialLeft.shown);
690 // Start call, hiding left tutorial
691 callManager.foregroundCall = phoneCall;
692 tryCompare(tutorialLeft, "shown", false);
694 // Start dialer app
695 ApplicationManager.startApplication("dialer-app");
696 tryCompare(ApplicationManager, "focusedApplicationId", "dialer-app");
697 verify(!tutorialBottom.shown);
699 // Dismiss call, bottom tutorial should appear
700 callManager.foregroundCall = null;
701 tryCompare(tutorialBottom, "shown", true);
702 verify(!tutorialLeft.shown);
704 // Get rid of bottom tutorial, left should now be shown
705 touchFlick(shell, halfWidth, shell.height, halfWidth, halfHeight);
706 tryCompare(tutorialBottom, "shown", false);
707 tryCompare(tutorialLeft, "shown", true);
708 }
710 function test_greeterInterruptsTutorial() {
711 var tutorialLeft = findChild(shell, "tutorialLeft");
712 verify(tutorialLeft.shown);
713 verify(!tutorialLeft.paused);
715 LightDM.Greeter.showGreeter();
716 verify(!tutorialLeft.shown);
717 verify(tutorialLeft.paused);
718 tryCompare(tutorialLeft, "visible", false);
720 LightDM.Greeter.hideGreeter();
721 tryCompare(tutorialLeft, "shown", true);
722 verify(!tutorialLeft.paused);
723 }
725 function test_interruptionChecksReadyStateWhenDone() {
726 // If we're done with an interruption (like active call), make sure
727 // that we don't blindly resume the tutorial -- our trigger
728 // conditions still need to be met. For example, there need to be
729 // enough apps open for the right edge tutorial.
731 openTutorialRight();
733 var tutorialRight = findChild(shell, "tutorialRight");
734 verify(tutorialRight.isReady);
735 verify(tutorialRight.shown);
736 verify(!tutorialRight.paused);
738 callManager.foregroundCall = phoneCall;
739 killApps();
740 callManager.foregroundCall = null;
742 verify(!tutorialRight.isReady);
743 verify(!tutorialRight.shown);
744 verify(!tutorialRight.paused);
745 compare(AccountsService.demoEdgesCompleted, ["left", "left-long", "top"]);
746 }
748 function test_desktopOnlyShowsTutorialRight() {
749 loadShell("desktop");
751 var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
752 var tutorialTopLoader = findChild(shell, "tutorialTopLoader");
753 var tutorialRightLoader = findChild(shell, "tutorialRightLoader");
754 var tutorialBottomLoader = findChild(shell, "tutorialBottomLoader");
755 verify(!tutorialLeftLoader.active);
756 verify(!tutorialTopLoader.active);
757 verify(tutorialRightLoader.active);
758 verify(!tutorialBottomLoader.active);
759 compare(AccountsService.demoEdgesCompleted, []);
761 ApplicationManager.startApplication("dialer-app");
762 ApplicationManager.startApplication("camera-app");
763 tryCompare(tutorialRightLoader.item, "isReady", true);
764 tryCompare(tutorialRightLoader, "shown", true);
765 }
767 function test_desktopTutorialRightFinish() {
768 loadShell("desktop");
770 var tutorialRight = findChild(shell, "tutorialRight");
771 ApplicationManager.startApplication("dialer-app");
772 ApplicationManager.startApplication("camera-app");
773 tryCompare(tutorialRight, "shown", true);
775 var stage = findChild(shell, "stage");
776 mouseMove(shell, shell.width, shell.height / 2);
777 stage.pushRightEdge(units.gu(8));
778 tryCompare(tutorialRight, "shown", false);
780 tryCompare(AccountsService, "demoEdges", false);
781 }
783 function test_oskDoesNotHideTutorial() {
784 var tutorialLeft = findChild(shell, "tutorialLeft");
785 verify(tutorialLeft.shown);
787 var surface = SurfaceManager.inputMethodSurface;
788 surface.setState(Mir.RestoredState);
790 var inputMethod = findInvisibleChild(shell, "inputMethod");
791 tryCompare(inputMethod, "state", "shown");
793 verify(tutorialLeft.shown);
794 }
796 function test_oskPreventsTutorial() {
797 var surface = SurfaceManager.inputMethodSurface;
798 var inputMethod = findInvisibleChild(shell, "inputMethod");
800 AccountsService.demoEdges = false;
801 surface.setState(Mir.RestoredState);
802 tryCompare(inputMethod, "state", "shown");
804 var tutorial = findChild(shell, "tutorial");
805 tryCompare(tutorial, "keyboardVisible", true);
807 AccountsService.demoEdges = true;
808 var tutorialLeft = findChild(shell, "tutorialLeft");
809 verify(!tutorialLeft.shown);
811 surface.setState(Mir.MinimizedState);
812 tryCompare(inputMethod, "state", "hidden");
813 tryCompare(tutorialLeft, "shown", false);
814 }
816 function test_accountsServiceSettings() {
817 var tutorialLeft = findChild(shell, "tutorialLeft");
818 verify(tutorialLeft != null);
819 verify(tutorialLeft.shown);
821 AccountsService.demoEdges = false;
822 verify(findChild(shell, "tutorialLeft") == null);
824 AccountsService.demoEdges = true;
825 tutorialLeft = findChild(shell, "tutorialLeft");
826 verify(tutorialLeft != null);
827 tryCompare(tutorialLeft, "shown", true);
828 }
829 }