~josharenson/unity8/slim_greeter_real_lightdm

« back to all changes in this revision

Viewing changes to tests/qmltests/Stages/tst_TabletStage.qml

  • Committer: Josh Arenson
  • Date: 2016-06-29 14:44:41 UTC
  • mfrom: (1789.412.85 unity8)
  • Revision ID: joshua.arenson@canonical.com-20160629144441-du2vd7vu97b2n8pc
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
242
242
                    appWindow.width * 0.1, -appWindow.height / 2);
243
243
        }
244
244
 
 
245
        function dragToSideStage(surfaceId) {
 
246
            sideStage.showNow();
 
247
            var targetAppDelegate = findChild(tabletStage, "spreadDelegate_" + surfaceId);
 
248
 
 
249
            var pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
 
250
            var end_pos = tabletStage.width - sideStage.width / 2;
 
251
 
 
252
            multiTouchDragUntil([0,1,2],
 
253
                                tabletStage,
 
254
                                pos,
 
255
                                tabletStage.height / 2,
 
256
                                units.gu(3),
 
257
                                0,
 
258
                                function() {
 
259
                                    pos += units.gu(3);
 
260
                                    return sideStage.shown && !sideStage.showAnimation.running &&
 
261
                                           pos >= end_pos;
 
262
                                });
 
263
            tryCompare(targetAppDelegate, "stage", ApplicationInfoInterface.SideStage);
 
264
        }
 
265
 
 
266
        function dragToMainStage(surfaceId) {
 
267
            sideStage.showNow();
 
268
            var targetAppDelegate = findChild(tabletStage, "spreadDelegate_" + surfaceId);
 
269
            verify(targetAppDelegate);
 
270
 
 
271
            var pos = tabletStage.width - sideStage.width / 2;
 
272
            var end_pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
 
273
 
 
274
            multiTouchDragUntil([0,1,2],
 
275
                                tabletStage,
 
276
                                pos,
 
277
                                tabletStage.height / 2,
 
278
                                -units.gu(3),
 
279
                                0,
 
280
                                function() {
 
281
                                    pos -= units.gu(3);
 
282
                                    return pos <= end_pos;
 
283
                                });
 
284
            tryCompare(targetAppDelegate, "stage", ApplicationInfoInterface.MainStage);
 
285
        }
 
286
 
245
287
        function test_tappingSwitchesFocusBetweenStages() {
246
288
            WindowStateStorage.saveStage(dialerCheckBox.appId, ApplicationInfoInterface.SideStage)
247
289
 
493
535
                                function() { return sideStage.shown; });
494
536
        }
495
537
 
496
 
        function test_applicationLoadsInCorrectStage_data() {
 
538
        function test_applicationLoadsInDefaultStage_data() {
 
539
            return [
 
540
                { tag: "MainStage", appId: "webbrowser-app", mainStageAppId: "webbrowser-app", sideStageAppId: "" },
 
541
                { tag: "SideStage", appId: "dialer-app", mainStageAppId: "unity8-dash", sideStageAppId: "dialer-app" },
 
542
            ];
 
543
        }
 
544
 
 
545
        function test_applicationLoadsInDefaultStage(data) {
 
546
            var stagesPriv = findInvisibleChild(tabletStage, "stagesPriv");
 
547
            verify(stagesPriv);
 
548
 
 
549
            tryCompare(stagesPriv, "mainStageAppId", "unity8-dash");
 
550
            tryCompare(stagesPriv, "sideStageAppId", "");
 
551
 
 
552
            var appSurfaceId = topSurfaceList.nextId;
 
553
            var app = ApplicationManager.startApplication(data.appId);
 
554
            waitUntilAppSurfaceShowsUp(appSurfaceId);
 
555
 
 
556
            tryCompare(stagesPriv, "mainStageAppId", data.mainStageAppId);
 
557
            tryCompare(stagesPriv, "sideStageAppId", data.sideStageAppId);
 
558
        }
 
559
 
 
560
        function test_applicationLoadsInSavedStage_data() {
497
561
            return [
498
562
                { tag: "MainStage", stage: ApplicationInfoInterface.MainStage, mainStageAppId: "webbrowser-app", sideStageAppId: ""},
499
563
                { tag: "SideStage", stage: ApplicationInfoInterface.SideStage, mainStageAppId: "unity8-dash", sideStageAppId: "webbrowser-app" },
500
564
            ];
501
565
        }
502
566
 
503
 
        function test_applicationLoadsInCorrectStage(data) {
 
567
        function test_applicationLoadsInSavedStage(data) {
504
568
            WindowStateStorage.saveStage(webbrowserCheckBox.appId, data.stage)
505
569
 
506
570
            var stagesPriv = findInvisibleChild(tabletStage, "stagesPriv");
519
583
 
520
584
        function test_applicationSavesLastStage_data() {
521
585
            return [
522
 
                { tag: "MainStage", stage: ApplicationInfoInterface.MainStage},
523
 
                { tag: "SideStage", stage: ApplicationInfoInterface.SideStage},
 
586
                { tag: "MainStage", fromStage: ApplicationInfoInterface.MainStage, toStage: ApplicationInfoInterface.SideStage },
 
587
                { tag: "SideStage", fromStage: ApplicationInfoInterface.SideStage, toStage: ApplicationInfoInterface.MainStage },
524
588
            ];
525
589
        }
526
590
 
527
591
        function test_applicationSavesLastStage(data) {
528
 
            WindowStateStorage.saveStage(webbrowserCheckBox.appId, data.stage);
 
592
            WindowStateStorage.saveStage(webbrowserCheckBox.appId, data.fromStage);
529
593
            stageSaver.clear();
530
594
 
531
595
            var stagesPriv = findInvisibleChild(tabletStage, "stagesPriv");
538
602
            webbrowserCheckBox.checked = true;
539
603
            waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
540
604
 
541
 
            webbrowserCheckBox.checked = false;
 
605
            if (data.toStage === ApplicationInfoInterface.SideStage) {
 
606
                dragToSideStage(webbrowserSurfaceId);
 
607
            } else {
 
608
                dragToMainStage(webbrowserSurfaceId);
 
609
            }
542
610
 
543
611
            tryCompare(stageSaver, "count", 1);
544
612
            compare(stageSaver.signalArguments[0][0], "webbrowser-app")
545
 
            compare(stageSaver.signalArguments[0][1], data.stage)
 
613
            compare(stageSaver.signalArguments[0][1], data.toStage)
546
614
        }
547
615
 
548
616
        function test_loadSideStageByDraggingFromMainStage() {
555
623
            verify(appDelegate);
556
624
            compare(appDelegate.stage, ApplicationInfoInterface.MainStage);
557
625
 
558
 
            var pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
559
 
            var end_pos = tabletStage.width - sideStage.width / 2;
560
 
 
561
 
            multiTouchDragUntil([0,1,2],
562
 
                                tabletStage,
563
 
                                pos,
564
 
                                tabletStage.height / 2,
565
 
                                units.gu(3),
566
 
                                0,
567
 
                                function() {
568
 
                                    pos += units.gu(3);
569
 
                                    return sideStage.shown && !sideStage.showAnimation.running &&
570
 
                                           pos >= end_pos;
571
 
                                });
572
 
 
 
626
            dragToSideStage(webbrowserSurfaceId);
 
627
 
 
628
            var spreadView = findChild(tabletStageLoader, "spreadView")
 
629
            tryCompare(spreadView, "surfaceDragging", false);
573
630
            tryCompare(appDelegate, "stage", ApplicationInfoInterface.SideStage);
574
631
        }
575
632
 
584
641
            verify(appDelegate);
585
642
            compare(appDelegate.stage, ApplicationInfoInterface.SideStage);
586
643
 
587
 
            var pos = tabletStage.width - sideStage.width / 2;
588
 
            var end_pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
589
 
 
590
 
            multiTouchDragUntil([0,1,2],
591
 
                                tabletStage,
592
 
                                pos,
593
 
                                tabletStage.height / 2,
594
 
                                -units.gu(3),
595
 
                                0,
596
 
                                function() {
597
 
                                    pos -= units.gu(3);
598
 
                                    return pos <= end_pos;
599
 
                                });
600
 
 
 
644
            dragToMainStage(webbrowserSurfaceId);
 
645
 
 
646
            var spreadView = findChild(tabletStageLoader, "spreadView")
 
647
            tryCompare(spreadView, "surfaceDragging", false);
601
648
            tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
602
649
        }
603
650
 
737
784
 
738
785
            tryCompare(appDelegate.surface, "activeFocus", true);
739
786
 
 
787
            dragToSideStage(webbrowserSurfaceId);
 
788
 
 
789
            var spreadView = findChild(tabletStageLoader, "spreadView")
 
790
            tryCompare(spreadView, "surfaceDragging", false);
 
791
            tryCompare(appDelegate.surface, "activeFocus", true);
 
792
        }
 
793
 
 
794
        function test_dashDoesNotDragToSidestage() {
 
795
            sideStage.showNow();
 
796
            compare(topSurfaceList.applicationAt(0).appId, "unity8-dash");
 
797
            var dashSurfaceId = topSurfaceList.idAt(0);
 
798
 
 
799
            var appDelegate = findChild(tabletStage, "spreadDelegate_" + dashSurfaceId);
 
800
            verify(appDelegate);
 
801
            compare(appDelegate.stage, ApplicationInfoInterface.MainStage);
 
802
 
740
803
            var pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
741
804
            var end_pos = tabletStage.width - sideStage.width / 2;
742
805
 
752
815
                                           pos >= end_pos;
753
816
                                });
754
817
 
755
 
            tryCompare(appDelegate.surface, "activeFocus", true);
756
 
        }
 
818
            var spreadView = findChild(tabletStageLoader, "spreadView")
 
819
            tryCompare(spreadView, "surfaceDragging", false);
 
820
            tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
 
821
        }
 
822
 
 
823
        function test_switchStageOnRotation() {
 
824
            WindowStateStorage.saveStage(webbrowserCheckBox.appId, ApplicationInfoInterface.SideStage)
 
825
            var webbrowserSurfaceId = topSurfaceList.nextId;
 
826
            webbrowserCheckBox.checked = true;
 
827
            waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
 
828
 
 
829
            var appDelegate = findChild(tabletStage, "spreadDelegate_" + webbrowserSurfaceId);
 
830
            verify(appDelegate);
 
831
            compare(appDelegate.stage, ApplicationInfoInterface.SideStage);
 
832
 
 
833
            tabletStage.shellOrientation = Qt.PortraitOrientation;
 
834
            tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
 
835
        }
 
836
 
 
837
        function test_restoreOriginalStageOnRotation() {
 
838
            var webbrowserSurfaceId = topSurfaceList.nextId;
 
839
            webbrowserCheckBox.checked = true;
 
840
            waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
 
841
 
 
842
            var appDelegate = findChild(tabletStage, "spreadDelegate_" + webbrowserSurfaceId);
 
843
            verify(appDelegate);
 
844
 
 
845
            dragToSideStage(webbrowserSurfaceId);
 
846
 
 
847
            // will be in sidestage now
 
848
            tabletStage.shellOrientation = Qt.PortraitOrientation;
 
849
            tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
 
850
 
 
851
            tabletStage.shellOrientation = Qt.LandscapeOrientation;
 
852
            tryCompare(appDelegate, "stage", ApplicationInfoInterface.SideStage);
 
853
        }
 
854
 
 
855
        function test_restoreSavedStageOnCloseReopen() {
 
856
            var webbrowserSurfaceId = topSurfaceList.nextId;
 
857
            webbrowserCheckBox.checked = true;
 
858
            waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
 
859
 
 
860
            var appDelegate = findChild(tabletStage, "spreadDelegate_" + webbrowserSurfaceId);
 
861
            verify(appDelegate);
 
862
 
 
863
            dragToSideStage(webbrowserSurfaceId);
 
864
            // will be in sidestage now
 
865
            tabletStage.shellOrientation = Qt.PortraitOrientation;
 
866
            tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
 
867
 
 
868
            webbrowserCheckBox.checked = false;
 
869
            tryCompare(ApplicationManager, "count", 1);
 
870
 
 
871
            // back to landscape
 
872
            tabletStage.shellOrientation = Qt.LandscapeOrientation;
 
873
 
 
874
            webbrowserSurfaceId = topSurfaceList.nextId;
 
875
            webbrowserCheckBox.checked = true;
 
876
            waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
 
877
 
 
878
            appDelegate = findChild(tabletStage, "spreadDelegate_" + webbrowserSurfaceId);
 
879
            verify(appDelegate);
 
880
            tryCompare(appDelegate, "stage", ApplicationInfoInterface.SideStage);
 
881
        }
 
882
 
 
883
 
757
884
    }
758
885
}