300
331
var tutorialTopTimer = findInvisibleChild(tutorialTop, "tutorialTopTimer");
302
333
tutorialTopTimer.interval = 1;
303
AccountsService.demoEdgesCompleted = ["left", "left-long"];
334
AccountsService.demoEdgesCompleted = ["left"];
305
336
tryCompare(tutorialLeftLoader, "active", false);
306
337
tryCompare(tutorialTop, "shown", true);
307
338
tryCompare(tutorialTop, "opacity", 1);
341
function openTutorialLeftLong() {
342
var tutorialLeftLong = findChild(shell, "tutorialLeftLong");
343
var tutorialLeftLongTimer = findChild(tutorialLeftLong, "tutorialLeftLongTimer");
345
AccountsService.demoEdgesCompleted = ["left", "top"];
346
ApplicationManager.startApplication("gallery-app");
348
tutorialLeftLongTimer.interval = 1;
349
tryCompare(tutorialLeftLong, "shown", true);
350
tryCompare(tutorialLeftLong, "opacity", 1);
310
353
function openTutorialRight() {
311
354
var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
312
355
var tutorialRight = findChild(shell, "tutorialRight");
356
var tutorialRightTimer = findChild(tutorialRight, "tutorialRightTimer");
314
AccountsService.demoEdgesCompleted = ["left", "left-long", "top"];
358
AccountsService.demoEdgesCompleted = ["left", "top", "left-long"];
315
359
ApplicationManager.startApplication("gallery-app");
316
360
ApplicationManager.startApplication("facebook-webapp");
361
ApplicationManager.startApplication("camera-app");
318
363
tryCompare(tutorialLeftLoader, "active", false);
364
tutorialRightTimer.interval = 1;
319
365
tryCompare(tutorialRight, "shown", true);
320
366
tryCompare(tutorialRight, "opacity", 1);
323
function openTutorialBottom() {
324
var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
325
var tutorialBottom = findChild(shell, "tutorialBottom");
327
AccountsService.demoEdgesCompleted = ["left", "left-long", "top", "right"];
328
tryCompare(tutorialLeftLoader, "active", false);
330
ApplicationManager.startApplication("dialer-app");
331
ApplicationManager.requestFocusApplication("dialer-app");
333
tryCompare(tutorialBottom, "shown", true);
334
tryCompare(tutorialBottom, "opacity", 1);
337
369
function test_tutorialLeftEdges() {
338
370
var tutorial = findChild(shell, "tutorial");
339
371
var tutorialLeft = findChild(tutorial, "tutorialLeft");
385
418
touchFlick(shell, 0, halfHeight, launcher.panelWidth * 0.4, halfHeight);
386
419
tryCompare(launcher, "state", ""); // should remain hidden
387
tryCompare(tutorialLeft, "shown", true); // and we should still be on left
420
tryCompare(tutorialLeftLoader, "shown", true); // and we should still be on left
390
423
// Now drag out but not past launcher itself
391
424
touchFlick(shell, 0, halfHeight, launcher.panelWidth * 0.9, halfHeight);
393
tryCompare(tutorialLeft, "shown", false);
426
tryCompare(tutorialLeftLoader, "shown", false);
394
427
tryCompare(AccountsService, "demoEdgesCompleted", ["left"]);
395
428
tryCompare(launcher, "state", "visible");
398
function test_tutorialLeftLongDrag() {
399
// Just confirm that a long drag ("dash" drag) doesn't confuse us
401
// So that we actually switch to dash and launcher hides
431
function test_tutorialLeftLongFinish() {
432
AccountsService.demoEdgesCompleted = ["left", "top"];
434
var tutorialLeftLongTimer = findInvisibleChild(shell, "tutorialLeftLongTimer");
435
tutorialLeftLongTimer.interval = 1;
402
437
ApplicationManager.startApplication("gallery-app");
404
var launcher = findChild(shell, "launcher");
405
var tutorialLeft = findChild(shell, "tutorialLeftLoader");
406
verify(tutorialLeft);
439
var tutorialLeftLongLoader = findChild(shell, "tutorialLeftLongLoader");
440
tryCompare(tutorialLeftLongLoader, "shown", true);
408
442
touchFlick(shell, 0, halfHeight, shell.width, halfHeight);
410
tryCompare(tutorialLeft, "shown", false);
411
tryCompare(AccountsService, "demoEdgesCompleted", ["left", "left-long"]);
444
tryCompare(tutorialLeftLongLoader, "shown", false);
445
tryCompare(AccountsService, "demoEdgesCompleted", ["left", "top", "left-long"]);
414
448
function test_tutorialLeftAutoSkipped() {
536
584
function test_tutorialRightDelay() {
537
585
// Test that if we exit the top tutorial, we don't immediately
538
586
// jump into right tutorial.
539
var tutorialRight = findChild(shell, "tutorialRight");
540
var tutorialRightTimer = findInvisibleChild(tutorialRight, "tutorialRightInactivityTimer");
587
var tutorialRightLoader = findChild(shell, "tutorialRightLoader");
588
var tutorialRightTimer = findInvisibleChild(tutorialRightLoader, "tutorialRightTimer");
542
tutorialRightTimer.interval = 1;
543
590
openTutorialTop();
544
591
ApplicationManager.startApplication("gallery-app");
545
592
ApplicationManager.startApplication("facebook-webapp");
546
tryCompare(ApplicationManager, "count", 3);
593
ApplicationManager.startApplication("camera-app");
594
tryCompare(ApplicationManager, "count", 4);
548
AccountsService.demoEdgesCompleted = ["left", "left-long", "top"];
549
verify(tutorialRightTimer.running, true);
550
verify(!tutorialRight.shown);
551
tryCompare(tutorialRight, "shown", true);
596
AccountsService.demoEdgesCompleted = ["left", "top", "left-long"];
597
verify(tutorialRightTimer.running);
598
verify(!tutorialRightLoader.shown);
599
tutorialRightTimer.interval = 1;
600
tryCompare(tutorialRightLoader, "shown", true);
554
603
function test_tutorialRightAutoSkipped() {
555
604
// Test that we skip the tutorial if user uses right edge themselves
557
606
var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
558
AccountsService.demoEdgesCompleted = ["left", "left-long"];
607
AccountsService.demoEdgesCompleted = ["left"];
559
608
tryCompare(tutorialLeftLoader, "active", false);
561
610
touchFlick(shell, shell.width, halfHeight, 0, halfHeight);
562
tryCompare(AccountsService, "demoEdgesCompleted", ["left", "left-long", "right"]);
565
function test_tutorialBottomEdges() {
566
var tutorial = findChild(shell, "tutorial");
567
var tutorialBottom = findChild(tutorial, "tutorialBottom");
568
var tutorialLabel = findChild(tutorialBottom, "tutorialLabel");
569
var launcher = findChild(shell, "launcher");
570
var stage = findChild(shell, "stage");
571
var panel = findChild(shell, "panel");
573
openTutorialBottom();
575
tryCompare(tutorial, "running", true);
576
verify(!tutorial.launcherEnabled);
577
verify(!tutorial.spreadEnabled);
578
verify(!tutorial.panelEnabled);
579
verify(tutorialBottom.shown);
580
verify(!launcher.available);
581
verify(!stage.spreadEnabled);
582
verify(!panel.indicators.available);
583
compare(tutorialLabel.text, "Swipe up for recent calls");
586
function test_tutorialBottomFinish() {
587
var tutorial = findChild(shell, "tutorial");
588
var tutorialBottom = findChild(tutorial, "tutorialBottom");
590
openTutorialBottom();
591
touchFlick(shell, halfWidth, shell.height, halfWidth, halfHeight);
593
tryCompare(tutorialBottom, "shown", false);
594
tryCompare(AccountsService, "demoEdgesCompleted", ["left", "left-long", "top", "right", "bottom-dialer-app"]);
596
// OK, we did one, just confirm that when all are done, we mark whole tutorial as done.
597
verify(AccountsService.demoEdges);
598
AccountsService.demoEdgesCompleted = ["left", "left-long", "top", "right",
599
"bottom-address-book-app",
600
"bottom-com.ubuntu.calculator_calculator",
602
"bottom-messaging-app"];
603
verify(!AccountsService.demoEdges);
606
function test_tutorialBottomAppearsBeforeRight() {
607
// Confirm that if bottom edge and right edge would appear on the
608
// the same app open, bottom edge appears first. (this is a lightly
609
// edited version of openTutorialRight)
610
var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
611
var tutorialRight = findChild(shell, "tutorialRight");
612
var tutorialBottom = findChild(shell, "tutorialBottom");
614
AccountsService.demoEdgesCompleted = ["left", "left-long", "top"];
615
ApplicationManager.startApplication("gallery-app");
616
ApplicationManager.startApplication("dialer-app");
618
tryCompare(tutorialLeftLoader, "active", false);
619
tryCompare(tutorialBottom, "shown", true);
620
tryCompare(tutorialBottom, "opacity", 1);
621
tryCompare(tutorialRight, "visible", false);
624
function test_tutorialBottomOnlyCoversSideStageOnTablet() {
627
var tutorialBottom = findChild(shell, "tutorialBottom");
628
var targetHeight = shell.height - units.gu(4);
629
var mainStageX = units.gu(20);
630
var sideStageX = shell.width - units.gu(20);
632
WindowStateStorage.saveStage("dialer-app", ApplicationInfoInterface.SideStage);
633
openTutorialBottom();
635
touchFlick(shell, mainStageX, shell.height, mainStageX, targetHeight, true, false);
636
compare(tutorialBottom.opacity, 1);
637
touchFlick(shell, mainStageX, shell.height, mainStageX, targetHeight, false, true);
639
touchFlick(shell, sideStageX, shell.height, sideStageX, targetHeight, true, false);
640
verify(tutorialBottom.opacity < 1);
641
touchFlick(shell, sideStageX, shell.height, sideStageX, targetHeight, false, true);
644
function test_tutorialBottomOnlyCoversMainStageOnTablet() {
647
var tutorialBottom = findChild(shell, "tutorialBottom");
648
var targetHeight = shell.height - units.gu(4);
649
var mainStageX = units.gu(20);
650
var sideStageX = shell.width - units.gu(20);
652
WindowStateStorage.saveStage("notes-app", ApplicationInfoInterface.SideStage);
653
ApplicationManager.startApplication("notes-app");
655
openTutorialBottom();
657
touchFlick(shell, sideStageX, shell.height, sideStageX, targetHeight, true, false);
658
compare(tutorialBottom.opacity, 1);
659
touchFlick(shell, sideStageX, shell.height, sideStageX, targetHeight, false, true);
661
touchFlick(shell, mainStageX, shell.height, mainStageX, targetHeight, true, false);
662
verify(tutorialBottom.opacity < 1);
663
touchFlick(shell, mainStageX, shell.height, mainStageX, targetHeight, false, true);
611
tryCompare(AccountsService, "demoEdgesCompleted", ["left", "right"]);
666
614
function test_activeCallInterruptsTutorial() {
678
626
verify(!tutorialLeft.paused);
681
function test_dialerInterruptionWithNoOverlappingTutorials() {
682
var tutorialLeft = findChild(shell, "tutorialLeft");
683
var tutorialBottom = findChild(shell, "tutorialBottom");
684
verify(tutorialLeft.shown);
686
// Start call, hiding left tutorial
687
callManager.foregroundCall = phoneCall;
688
tryCompare(tutorialLeft, "shown", false);
691
ApplicationManager.startApplication("dialer-app");
692
tryCompare(ApplicationManager, "focusedApplicationId", "dialer-app");
693
verify(!tutorialBottom.shown);
695
// Dismiss call, bottom tutorial should appear
696
callManager.foregroundCall = null;
697
tryCompare(tutorialBottom, "shown", true);
698
verify(!tutorialLeft.shown);
700
// Get rid of bottom tutorial, left should now be shown
701
touchFlick(shell, halfWidth, shell.height, halfWidth, halfHeight);
702
tryCompare(tutorialBottom, "shown", false);
703
tryCompare(tutorialLeft, "shown", true);
706
629
function test_greeterInterruptsTutorial() {
707
630
var tutorialLeft = findChild(shell, "tutorialLeft");
708
631
verify(tutorialLeft.shown);
747
670
var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
748
671
var tutorialTopLoader = findChild(shell, "tutorialTopLoader");
672
var tutorialLeftLongLoader = findChild(shell, "tutorialLeftLongLoader");
749
673
var tutorialRightLoader = findChild(shell, "tutorialRightLoader");
750
var tutorialBottomLoader = findChild(shell, "tutorialBottomLoader");
751
674
verify(!tutorialLeftLoader.active);
752
675
verify(!tutorialTopLoader.active);
676
verify(!tutorialLeftLongLoader.active);
753
677
verify(tutorialRightLoader.active);
754
verify(!tutorialBottomLoader.active);
755
678
compare(AccountsService.demoEdgesCompleted, []);
680
var tutorialRightTimer = findInvisibleChild(tutorialRightLoader, "tutorialRightTimer");
681
tutorialRightTimer.interval = 1;
757
683
ApplicationManager.startApplication("dialer-app");
758
684
ApplicationManager.startApplication("camera-app");
685
ApplicationManager.startApplication("facebook-webapp");
759
686
tryCompare(tutorialRightLoader.item, "isReady", true);
760
688
tryCompare(tutorialRightLoader, "shown", true);
763
691
function test_desktopTutorialRightFinish() {
764
692
loadShell("desktop");
766
var tutorialRight = findChild(shell, "tutorialRight");
694
var tutorialRightLoader = findChild(shell, "tutorialRightLoader");
695
var tutorialRightTimer = findInvisibleChild(tutorialRightLoader, "tutorialRightTimer");
696
tutorialRightTimer.interval = 1;
767
697
ApplicationManager.startApplication("dialer-app");
768
698
ApplicationManager.startApplication("camera-app");
769
tryCompare(tutorialRight, "shown", true);
699
ApplicationManager.startApplication("facebook-webapp");
700
tryCompare(tutorialRightLoader, "shown", true);
771
702
var stage = findChild(shell, "stage");
772
703
mouseMove(shell, shell.width, shell.height / 2);
773
704
stage.pushRightEdge(units.gu(8));
774
tryCompare(tutorialRight, "shown", false);
705
tryCompare(tutorialRightLoader, "shown", false);
776
707
tryCompare(AccountsService, "demoEdges", false);
779
710
function test_oskDoesNotHideTutorial() {
780
var tutorialLeft = findChild(shell, "tutorialLeft");
781
verify(tutorialLeft.shown);
783
var surface = SurfaceManager.inputMethodSurface;
784
surface.setState(Mir.RestoredState);
786
var inputMethod = findInvisibleChild(shell, "inputMethod");
787
tryCompare(inputMethod, "state", "shown");
789
verify(tutorialLeft.shown);
792
function test_oskPreventsTutorial() {
793
var surface = SurfaceManager.inputMethodSurface;
794
var inputMethod = findInvisibleChild(shell, "inputMethod");
796
AccountsService.demoEdges = false;
797
surface.setState(Mir.RestoredState);
798
tryCompare(inputMethod, "state", "shown");
800
var tutorial = findChild(shell, "tutorial");
801
tryCompare(tutorial, "keyboardVisible", true);
803
AccountsService.demoEdges = true;
804
var tutorialLeft = findChild(shell, "tutorialLeft");
805
verify(!tutorialLeft.shown);
807
surface.setState(Mir.MinimizedState);
808
tryCompare(inputMethod, "state", "hidden");
809
tryCompare(tutorialLeft, "shown", false);
711
var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
712
verify(tutorialLeftLoader.shown);
714
var surface = SurfaceManager.inputMethodSurface;
715
surface.setState(Mir.RestoredState);
717
var inputMethod = findInvisibleChild(shell, "inputMethod");
718
tryCompare(inputMethod, "visible", true);
720
verify(tutorialLeftLoader.shown);
723
function test_oskDelaysTutorial() {
724
var tutorial = findChild(shell, "tutorial");
725
verify(!tutorial.delayed);
727
SurfaceManager.inputMethodSurface.setState(Mir.RestoredState);
729
tryCompare(tutorial, "delayed", true);
732
function test_notificationDelaysTutorial() {
733
var tutorial = findChild(shell, "tutorial");
734
verify(!tutorial.delayed);
736
var notifications = findChild(shell, "notificationList");
737
notifications.model = mockNotificationsModel;
738
addNotification(); // placeholder
741
tryCompare(tutorial, "delayed", true);
744
function test_dialogDelaysTutorial() {
745
var tutorial = findChild(shell, "tutorial");
746
verify(!tutorial.delayed);
748
var dialogs = findChild(shell, "dialogs");
749
dialogs.showPowerDialog();
751
verify(tutorial.delayed);
754
function test_delayedTutorial() {
755
var tutorial = findChild(shell, "tutorial");
756
var tutorialTop = findChild(tutorial, "tutorialTop");
757
var tutorialTopTimer = findChild(tutorialTop, "tutorialTopTimer");
759
// Get top tutorial ready
760
AccountsService.demoEdgesCompleted = ["left"];
761
verify(tutorialTop.isReady);
762
verify(tutorialTopTimer.running);
764
// Confirm that we become unready when delayed, but timer still goes
765
tutorial.delayed = true;
766
verify(!tutorialTop.isReady);
767
verify(tutorialTopTimer.running);
769
// Confirm that we don't open the tutorial when delayed
770
tutorialTopTimer.interval = 1;
772
verify(!tutorialTop.shown);
774
// Confirm we go back to normal when undelayed
775
tutorial.delayed = false;
776
tryCompare(tutorialTop, "shown", true);
812
779
function test_accountsServiceSettings() {
813
var tutorialLeft = findChild(shell, "tutorialLeft");
814
verify(tutorialLeft != null);
815
verify(tutorialLeft.shown);
780
var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
781
verify(tutorialLeftLoader.shown);
817
783
AccountsService.demoEdges = false;
818
verify(findChild(shell, "tutorialLeft") == null);
784
verify(findChild(shell, "tutorialLeftLoader") == null);
820
786
AccountsService.demoEdges = true;
821
tutorialLeft = findChild(shell, "tutorialLeft");
822
verify(tutorialLeft != null);
823
tryCompare(tutorialLeft, "shown", true);
787
tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
788
var tutorialLeftTimer = findChild(tutorialLeftLoader, "tutorialLeftTimer");
789
verify(tutorialLeftTimer.running);