~mterry/+junk/u8

« back to all changes in this revision

Viewing changes to tests/qmltests/Tutorial/tst_Tutorial.qml

Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2013,2014,2015 Canonical, Ltd.
 
2
 * Copyright (C) 2013-2016 Canonical, Ltd.
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
5
5
 * it under the terms of the GNU General Public License as published by
17
17
import QtQuick 2.4
18
18
import QtTest 1.0
19
19
import AccountsService 0.1
20
 
import IntegratedLightDM 0.1 as LightDM
 
20
import LightDM.IntegratedLightDM 0.1 as LightDM
21
21
import Ubuntu.Components 1.3
22
22
import Ubuntu.Components.ListItems 1.3
23
23
import Ubuntu.Telephony 0.1 as Telephony
24
24
import Unity.Application 0.1
 
25
import Unity.Notifications 1.0
25
26
import Unity.Test 0.1 as UT
26
27
import Utils 0.1
27
28
 
55
56
        phoneNumber: "+447812221111"
56
57
    }
57
58
 
 
59
    Component {
 
60
        id: mockNotification
 
61
        QtObject {}
 
62
    }
 
63
 
 
64
    ListModel {
 
65
        id: mockNotificationsModel
 
66
 
 
67
        function getRaw(id) {
 
68
            return mockNotification.createObject(mockNotificationsModel)
 
69
        }
 
70
    }
 
71
 
 
72
    function addNotification() {
 
73
        var n = {
 
74
            type: Notification.Confirmation,
 
75
            hints: {},
 
76
            summary: "",
 
77
            body: "",
 
78
            icon: "",
 
79
            secondaryIcon: "",
 
80
            actions: []
 
81
        };
 
82
 
 
83
        mockNotificationsModel.append(n);
 
84
    }
 
85
 
58
86
    Component.onCompleted: {
59
87
        // must set the mock mode before loading the Shell
60
88
        LightDM.Greeter.mockMode = "single-pin";
231
259
            prepareShell();
232
260
 
233
261
            var tutorialLeft = findChild(shell, "tutorialLeft");
 
262
            var tutorialLeftTimer = findInvisibleChild(tutorialLeft, "tutorialLeftTimer");
 
263
            tutorialLeftTimer.interval = 0;
234
264
            tryCompare(tutorialLeft, "opacity", 1);
235
265
        }
236
266
 
260
290
            // reload our test subject to get it in a fresh state once again
261
291
            shellLoader.active = true;
262
292
 
 
293
            mockNotificationsModel.clear();
263
294
            tryCompare(shellLoader, "status", Loader.Ready);
264
295
            removeTimeConstraintsFromSwipeAreas(shellLoader.item);
265
296
        }
266
297
 
267
298
        function prepareShell() {
268
 
            tryCompare(shell, "enabled", true); // enabled by greeter when ready
 
299
            tryCompare(shell, "waitingOnGreeter", false); // reset by greeter when ready
269
300
 
270
301
            WindowStateStorage.clear();
271
302
            SurfaceManager.inputMethodSurface.setState(Mir.MinimizedState);
300
331
            var tutorialTopTimer = findInvisibleChild(tutorialTop, "tutorialTopTimer");
301
332
 
302
333
            tutorialTopTimer.interval = 1;
303
 
            AccountsService.demoEdgesCompleted = ["left", "left-long"];
 
334
            AccountsService.demoEdgesCompleted = ["left"];
304
335
 
305
336
            tryCompare(tutorialLeftLoader, "active", false);
306
337
            tryCompare(tutorialTop, "shown", true);
307
338
            tryCompare(tutorialTop, "opacity", 1);
308
339
        }
309
340
 
 
341
        function openTutorialLeftLong() {
 
342
            var tutorialLeftLong = findChild(shell, "tutorialLeftLong");
 
343
            var tutorialLeftLongTimer = findChild(tutorialLeftLong, "tutorialLeftLongTimer");
 
344
 
 
345
            AccountsService.demoEdgesCompleted = ["left", "top"];
 
346
            ApplicationManager.startApplication("gallery-app");
 
347
 
 
348
            tutorialLeftLongTimer.interval = 1;
 
349
            tryCompare(tutorialLeftLong, "shown", true);
 
350
            tryCompare(tutorialLeftLong, "opacity", 1);
 
351
        }
 
352
 
310
353
        function openTutorialRight() {
311
354
            var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
312
355
            var tutorialRight = findChild(shell, "tutorialRight");
 
356
            var tutorialRightTimer = findChild(tutorialRight, "tutorialRightTimer");
313
357
 
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");
317
362
 
318
363
            tryCompare(tutorialLeftLoader, "active", false);
 
364
            tutorialRightTimer.interval = 1;
319
365
            tryCompare(tutorialRight, "shown", true);
320
366
            tryCompare(tutorialRight, "opacity", 1);
321
367
        }
322
368
 
323
 
        function openTutorialBottom() {
324
 
            var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
325
 
            var tutorialBottom = findChild(shell, "tutorialBottom");
326
 
 
327
 
            AccountsService.demoEdgesCompleted = ["left", "left-long", "top", "right"];
328
 
            tryCompare(tutorialLeftLoader, "active", false);
329
 
 
330
 
            ApplicationManager.startApplication("dialer-app");
331
 
            ApplicationManager.requestFocusApplication("dialer-app");
332
 
 
333
 
            tryCompare(tutorialBottom, "shown", true);
334
 
            tryCompare(tutorialBottom, "opacity", 1);
335
 
        }
336
 
 
337
369
        function test_tutorialLeftEdges() {
338
370
            var tutorial = findChild(shell, "tutorial");
339
371
            var tutorialLeft = findChild(tutorial, "tutorialLeft");
353
385
 
354
386
        function test_tutorialLeftFinish() {
355
387
            var tutorial = findChild(shell, "tutorial");
356
 
            var tutorialLeft = findChild(tutorial, "tutorialLeft");
 
388
            var tutorialLeftLoader = findChild(tutorial, "tutorialLeftLoader");
357
389
            var launcher = findChild(shell, "launcher");
358
390
 
359
391
            touchFlick(shell, 0, halfHeight, halfWidth, halfHeight);
360
392
 
361
 
            tryCompare(tutorialLeft, "shown", false);
 
393
            tryCompare(tutorialLeftLoader, "shown", false);
362
394
            tryCompare(AccountsService, "demoEdgesCompleted", ["left"]);
363
395
            tryCompare(launcher, "state", "visible");
364
396
        }
368
400
            // letting go (i.e. not triggering the "progress" property of
369
401
            // Launcher).
370
402
            var tutorialLeft = findChild(shell, "tutorialLeft");
 
403
            var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
371
404
            var launcher = findChild(shell, "launcher");
372
405
 
373
406
            // Confirm fade during drag
384
417
            // out much.
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
388
421
 
389
422
 
390
423
            // Now drag out but not past launcher itself
391
424
            touchFlick(shell, 0, halfHeight, launcher.panelWidth * 0.9, halfHeight);
392
425
 
393
 
            tryCompare(tutorialLeft, "shown", false);
 
426
            tryCompare(tutorialLeftLoader, "shown", false);
394
427
            tryCompare(AccountsService, "demoEdgesCompleted", ["left"]);
395
428
            tryCompare(launcher, "state", "visible");
396
429
        }
397
430
 
398
 
        function test_tutorialLeftLongDrag() {
399
 
            // Just confirm that a long drag ("dash" drag) doesn't confuse us
400
 
 
401
 
            // So that we actually switch to dash and launcher hides
 
431
        function test_tutorialLeftLongFinish() {
 
432
            AccountsService.demoEdgesCompleted = ["left", "top"];
 
433
 
 
434
            var tutorialLeftLongTimer = findInvisibleChild(shell, "tutorialLeftLongTimer");
 
435
            tutorialLeftLongTimer.interval = 1;
 
436
 
402
437
            ApplicationManager.startApplication("gallery-app");
403
438
 
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);
407
441
 
408
442
            touchFlick(shell, 0, halfHeight, shell.width, halfHeight);
409
443
 
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"]);
412
446
        }
413
447
 
414
448
        function test_tutorialLeftAutoSkipped() {
423
457
            tryCompare(AccountsService, "demoEdgesCompleted", ["left"]);
424
458
        }
425
459
 
 
460
        function test_tutorialLongLeftSwipeDisabled() {
 
461
            // Test that a long left swipe is disabled until we get to or pass
 
462
            // the long left tutorial.
 
463
            var tutorial = findChild(shell, "tutorial");
 
464
 
 
465
            verify(!tutorial.launcherLongSwipeEnabled);
 
466
 
 
467
            openTutorialLeftLong();
 
468
            verify(tutorial.launcherLongSwipeEnabled);
 
469
 
 
470
            openTutorialRight();
 
471
            verify(tutorial.launcherLongSwipeEnabled);
 
472
 
 
473
            AccountsService.demoEdges = false;
 
474
            tryCompare(tutorial, "running", false);
 
475
            verify(tutorial.launcherLongSwipeEnabled);
 
476
        }
 
477
 
426
478
        function test_tutorialTopEdges() {
427
479
            var tutorial = findChild(shell, "tutorial");
428
480
            var tutorialTop = findChild(tutorial, "tutorialTop");
444
496
 
445
497
        function test_tutorialTopFinish() {
446
498
            var tutorial = findChild(shell, "tutorial");
447
 
            var tutorialTop = findChild(tutorial, "tutorialTop");
 
499
            var tutorialTopLoader = findChild(tutorial, "tutorialTopLoader");
448
500
            var panel = findChild(shell, "panel");
449
501
 
450
502
            openTutorialTop();
451
503
            touchFlick(shell, halfWidth, 0, halfWidth, shell.height);
452
504
 
453
 
            tryCompare(tutorialTop, "shown", false);
454
 
            tryCompare(AccountsService, "demoEdgesCompleted", ["left", "left-long", "top"]);
 
505
            tryCompare(tutorialTopLoader, "shown", false);
 
506
            tryCompare(AccountsService, "demoEdgesCompleted", ["left", "top"]);
455
507
            tryCompare(panel.indicators, "fullyOpened", true);
456
508
        }
457
509
 
476
528
            // Test that we skip the tutorial if user uses top edge themselves
477
529
 
478
530
            var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
479
 
            var tutorialTop = findChild(shell, "tutorialTop");
480
 
            AccountsService.demoEdgesCompleted = ["left", "left-long"];
 
531
            var tutorialTopLoader = findChild(shell, "tutorialTopLoader");
 
532
            AccountsService.demoEdgesCompleted = ["left"];
481
533
            tryCompare(tutorialLeftLoader, "active", false);
482
 
            verify(!tutorialTop.shown);
 
534
            verify(!tutorialTopLoader.shown);
483
535
 
484
536
            touchFlick(shell, halfWidth, 0, halfWidth, shell.height);
485
 
            tryCompare(AccountsService, "demoEdgesCompleted", ["left", "left-long", "top"]);
 
537
            tryCompare(AccountsService, "demoEdgesCompleted", ["left", "top"]);
486
538
        }
487
539
 
488
540
        function test_tutorialRightEdges() {
505
557
        }
506
558
 
507
559
        function test_tutorialRightFinish() {
508
 
            var tutorial = findChild(shell, "tutorial");
509
 
            var tutorialRight = findChild(tutorial, "tutorialRight");
510
 
            var stage = findChild(shell, "stage");
511
 
 
512
560
            openTutorialRight();
513
561
            touchFlick(shell, shell.width, halfHeight, 0, halfHeight);
514
562
 
515
 
            tryCompare(tutorialRight, "shown", false);
516
 
            tryCompare(AccountsService, "demoEdgesCompleted", ["left", "left-long", "top", "right"]);
 
563
            tryCompare(AccountsService, "demoEdgesCompleted", ["left", "top", "left-long", "right"]);
 
564
            tryCompare(AccountsService, "demoEdges", false);
517
565
        }
518
566
 
519
567
        function test_tutorialRightShortDrag() {
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");
541
589
 
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);
547
595
 
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);
552
601
        }
553
602
 
554
603
        function test_tutorialRightAutoSkipped() {
555
604
            // Test that we skip the tutorial if user uses right edge themselves
556
605
 
557
606
            var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
558
 
            AccountsService.demoEdgesCompleted = ["left", "left-long"];
 
607
            AccountsService.demoEdgesCompleted = ["left"];
559
608
            tryCompare(tutorialLeftLoader, "active", false);
560
609
 
561
610
            touchFlick(shell, shell.width, halfHeight, 0, halfHeight);
562
 
            tryCompare(AccountsService, "demoEdgesCompleted", ["left", "left-long", "right"]);
563
 
        }
564
 
 
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");
572
 
 
573
 
            openTutorialBottom();
574
 
 
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");
584
 
        }
585
 
 
586
 
        function test_tutorialBottomFinish() {
587
 
            var tutorial = findChild(shell, "tutorial");
588
 
            var tutorialBottom = findChild(tutorial, "tutorialBottom");
589
 
 
590
 
            openTutorialBottom();
591
 
            touchFlick(shell, halfWidth, shell.height, halfWidth, halfHeight);
592
 
 
593
 
            tryCompare(tutorialBottom, "shown", false);
594
 
            tryCompare(AccountsService, "demoEdgesCompleted", ["left", "left-long", "top", "right", "bottom-dialer-app"]);
595
 
 
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",
601
 
                                                  "bottom-dialer-app",
602
 
                                                  "bottom-messaging-app"];
603
 
            verify(!AccountsService.demoEdges);
604
 
        }
605
 
 
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");
613
 
 
614
 
            AccountsService.demoEdgesCompleted = ["left", "left-long", "top"];
615
 
            ApplicationManager.startApplication("gallery-app");
616
 
            ApplicationManager.startApplication("dialer-app");
617
 
 
618
 
            tryCompare(tutorialLeftLoader, "active", false);
619
 
            tryCompare(tutorialBottom, "shown", true);
620
 
            tryCompare(tutorialBottom, "opacity", 1);
621
 
            tryCompare(tutorialRight, "visible", false);
622
 
        }
623
 
 
624
 
        function test_tutorialBottomOnlyCoversSideStageOnTablet() {
625
 
            loadShell("tablet");
626
 
 
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);
631
 
 
632
 
            WindowStateStorage.saveStage("dialer-app", ApplicationInfoInterface.SideStage);
633
 
            openTutorialBottom();
634
 
 
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);
638
 
 
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);
642
 
        }
643
 
 
644
 
        function test_tutorialBottomOnlyCoversMainStageOnTablet() {
645
 
            loadShell("tablet");
646
 
 
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);
651
 
 
652
 
            WindowStateStorage.saveStage("notes-app", ApplicationInfoInterface.SideStage);
653
 
            ApplicationManager.startApplication("notes-app");
654
 
 
655
 
            openTutorialBottom();
656
 
 
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);
660
 
 
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"]);
664
612
        }
665
613
 
666
614
        function test_activeCallInterruptsTutorial() {
678
626
            verify(!tutorialLeft.paused);
679
627
        }
680
628
 
681
 
        function test_dialerInterruptionWithNoOverlappingTutorials() {
682
 
            var tutorialLeft = findChild(shell, "tutorialLeft");
683
 
            var tutorialBottom = findChild(shell, "tutorialBottom");
684
 
            verify(tutorialLeft.shown);
685
 
 
686
 
            // Start call, hiding left tutorial
687
 
            callManager.foregroundCall = phoneCall;
688
 
            tryCompare(tutorialLeft, "shown", false);
689
 
 
690
 
            // Start dialer app
691
 
            ApplicationManager.startApplication("dialer-app");
692
 
            tryCompare(ApplicationManager, "focusedApplicationId", "dialer-app");
693
 
            verify(!tutorialBottom.shown);
694
 
 
695
 
            // Dismiss call, bottom tutorial should appear
696
 
            callManager.foregroundCall = null;
697
 
            tryCompare(tutorialBottom, "shown", true);
698
 
            verify(!tutorialLeft.shown);
699
 
 
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);
704
 
        }
705
 
 
706
629
        function test_greeterInterruptsTutorial() {
707
630
            var tutorialLeft = findChild(shell, "tutorialLeft");
708
631
            verify(tutorialLeft.shown);
738
661
            verify(!tutorialRight.isReady);
739
662
            verify(!tutorialRight.shown);
740
663
            verify(!tutorialRight.paused);
741
 
            compare(AccountsService.demoEdgesCompleted, ["left", "left-long", "top"]);
 
664
            compare(AccountsService.demoEdgesCompleted, ["left", "top", "left-long"]);
742
665
        }
743
666
 
744
667
        function test_desktopOnlyShowsTutorialRight() {
746
669
 
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, []);
756
679
 
 
680
            var tutorialRightTimer = findInvisibleChild(tutorialRightLoader, "tutorialRightTimer");
 
681
            tutorialRightTimer.interval = 1;
 
682
 
757
683
            ApplicationManager.startApplication("dialer-app");
758
684
            ApplicationManager.startApplication("camera-app");
 
685
            ApplicationManager.startApplication("facebook-webapp");
759
686
            tryCompare(tutorialRightLoader.item, "isReady", true);
 
687
 
760
688
            tryCompare(tutorialRightLoader, "shown", true);
761
689
        }
762
690
 
763
691
        function test_desktopTutorialRightFinish() {
764
692
            loadShell("desktop");
765
693
 
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);
770
701
 
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);
775
706
 
776
707
            tryCompare(AccountsService, "demoEdges", false);
777
708
        }
778
709
 
779
710
        function test_oskDoesNotHideTutorial() {
780
 
            var tutorialLeft = findChild(shell, "tutorialLeft");
781
 
            verify(tutorialLeft.shown);
782
 
 
783
 
            var surface = SurfaceManager.inputMethodSurface;
784
 
            surface.setState(Mir.RestoredState);
785
 
 
786
 
            var inputMethod = findInvisibleChild(shell, "inputMethod");
787
 
            tryCompare(inputMethod, "state", "shown");
788
 
 
789
 
            verify(tutorialLeft.shown);
790
 
        }
791
 
 
792
 
        function test_oskPreventsTutorial() {
793
 
            var surface = SurfaceManager.inputMethodSurface;
794
 
            var inputMethod = findInvisibleChild(shell, "inputMethod");
795
 
 
796
 
            AccountsService.demoEdges = false;
797
 
            surface.setState(Mir.RestoredState);
798
 
            tryCompare(inputMethod, "state", "shown");
799
 
 
800
 
            var tutorial = findChild(shell, "tutorial");
801
 
            tryCompare(tutorial, "keyboardVisible", true);
802
 
 
803
 
            AccountsService.demoEdges = true;
804
 
            var tutorialLeft = findChild(shell, "tutorialLeft");
805
 
            verify(!tutorialLeft.shown);
806
 
 
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);
 
713
 
 
714
            var surface = SurfaceManager.inputMethodSurface;
 
715
            surface.setState(Mir.RestoredState);
 
716
 
 
717
            var inputMethod = findInvisibleChild(shell, "inputMethod");
 
718
            tryCompare(inputMethod, "visible", true);
 
719
 
 
720
            verify(tutorialLeftLoader.shown);
 
721
        }
 
722
 
 
723
        function test_oskDelaysTutorial() {
 
724
            var tutorial = findChild(shell, "tutorial");
 
725
            verify(!tutorial.delayed);
 
726
 
 
727
            SurfaceManager.inputMethodSurface.setState(Mir.RestoredState);
 
728
 
 
729
            tryCompare(tutorial, "delayed", true);
 
730
        }
 
731
 
 
732
        function test_notificationDelaysTutorial() {
 
733
            var tutorial = findChild(shell, "tutorial");
 
734
            verify(!tutorial.delayed);
 
735
 
 
736
            var notifications = findChild(shell, "notificationList");
 
737
            notifications.model = mockNotificationsModel;
 
738
            addNotification(); // placeholder
 
739
            addNotification();
 
740
 
 
741
            tryCompare(tutorial, "delayed", true);
 
742
        }
 
743
 
 
744
        function test_dialogDelaysTutorial() {
 
745
            var tutorial = findChild(shell, "tutorial");
 
746
            verify(!tutorial.delayed);
 
747
 
 
748
            var dialogs = findChild(shell, "dialogs");
 
749
            dialogs.showPowerDialog();
 
750
 
 
751
            verify(tutorial.delayed);
 
752
        }
 
753
 
 
754
        function test_delayedTutorial() {
 
755
            var tutorial = findChild(shell, "tutorial");
 
756
            var tutorialTop = findChild(tutorial, "tutorialTop");
 
757
            var tutorialTopTimer = findChild(tutorialTop, "tutorialTopTimer");
 
758
 
 
759
            // Get top tutorial ready
 
760
            AccountsService.demoEdgesCompleted = ["left"];
 
761
            verify(tutorialTop.isReady);
 
762
            verify(tutorialTopTimer.running);
 
763
 
 
764
            // Confirm that we become unready when delayed, but timer still goes
 
765
            tutorial.delayed = true;
 
766
            verify(!tutorialTop.isReady);
 
767
            verify(tutorialTopTimer.running);
 
768
 
 
769
            // Confirm that we don't open the tutorial when delayed
 
770
            tutorialTopTimer.interval = 1;
 
771
            wait(5);
 
772
            verify(!tutorialTop.shown);
 
773
 
 
774
            // Confirm we go back to normal when undelayed
 
775
            tutorial.delayed = false;
 
776
            tryCompare(tutorialTop, "shown", true);
810
777
        }
811
778
 
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);
816
782
 
817
783
            AccountsService.demoEdges = false;
818
 
            verify(findChild(shell, "tutorialLeft") == null);
 
784
            verify(findChild(shell, "tutorialLeftLoader") == null);
819
785
 
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);
824
790
        }
825
791
    }
826
792
}