~josharenson/unity8/fix-greeter-password-focus

« back to all changes in this revision

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

  • Committer: Josh Arenson
  • Date: 2016-03-25 19:54:02 UTC
  • mfrom: (1979.1.9 session-chooser-gui)
  • Revision ID: joshua.arenson@canonical.com-20160325195402-867v3w2zvmjj0kq3
merge prereq

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import Ubuntu.Components.ListItems 1.3 as ListItem
21
21
import Unity.Application 0.1
22
22
import Unity.Test 0.1
 
23
import Utils 0.1
23
24
 
24
25
import ".."
25
26
import "../../../qml/Stages"
78
79
        Column {
79
80
            anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
80
81
            spacing: units.gu(1)
 
82
 
81
83
            EdgeBarrierControls {
82
84
                id: edgeBarrierControls
83
85
                text: "Drag here to pull out spread"
87
89
                    edgeBarrierControls.target = testCase.findChild(tabletStageLoader, "edgeBarrierController");
88
90
                }
89
91
            }
 
92
 
 
93
            Button {
 
94
                text: testCase.sideStage ? testCase.sideStage.shown ? "Hide Side-stage" : "Show Side-stage" : ""
 
95
                enabled: testCase.sideStage
 
96
                onClicked: {
 
97
                    if (testCase.sideStage.shown) testCase.sideStage.hide();
 
98
                    else testCase.sideStage.show();
 
99
                }
 
100
            }
 
101
 
90
102
            ApplicationCheckBox {
91
103
                id: webbrowserCheckBox
92
104
                appId: "webbrowser-app"
112
124
        when: windowShown
113
125
 
114
126
        property Item tabletStage: tabletStageLoader.status === Loader.Ready ? tabletStageLoader.item : null
 
127
        property Item sideStage: tabletStage ? findChild(tabletStage, "sideStage") : null
115
128
 
116
129
        function init() {
117
130
            tabletStageLoader.active = true;
129
142
            }
130
143
 
131
144
            waitUntilAppSurfaceShowsUp("unity8-dash");
 
145
            sideStage.hideNow()
132
146
        }
133
147
 
134
148
        function cleanup() {
148
162
            galleryCheckBox.checked = false;
149
163
            dialerCheckBox.checked = false;
150
164
            facebookCheckBox.checked = false;
 
165
            WindowStateStorage.clear();
151
166
        }
152
167
 
153
168
        function waitUntilAppSurfaceShowsUp(appId) {
187
202
        }
188
203
 
189
204
        function test_tappingSwitchesFocusBetweenStages() {
 
205
            WindowStateStorage.saveStage(dialerCheckBox.appId, ApplicationInfoInterface.SideStage)
 
206
 
190
207
            webbrowserCheckBox.checked = true;
191
208
            waitUntilAppSurfaceShowsUp(webbrowserCheckBox.appId);
192
209
            var webbrowserApp = ApplicationManager.findApplication(webbrowserCheckBox.appId);
222
239
        }
223
240
 
224
241
        function test_closeAppInSideStage() {
 
242
            WindowStateStorage.saveStage(dialerCheckBox.appId, ApplicationInfoInterface.SideStage)
 
243
 
225
244
            dialerCheckBox.checked = true;
226
245
            waitUntilAppSurfaceShowsUp(dialerCheckBox.appId);
227
246
 
293
312
 
294
313
 
295
314
        function test_foregroundMainAndSideStageAppsAreKeptRunning() {
 
315
            WindowStateStorage.saveStage(facebookCheckBox.appId, ApplicationInfoInterface.SideStage)
 
316
            WindowStateStorage.saveStage(dialerCheckBox.appId, ApplicationInfoInterface.SideStage)
296
317
 
297
318
            var stagesPriv = findInvisibleChild(tabletStage, "stagesPriv");
298
319
            verify(stagesPriv);
351
372
        }
352
373
 
353
374
        function test_foregroundAppsAreSuspendedWhenStageIsSuspended() {
 
375
            WindowStateStorage.saveStage(dialerCheckBox.appId, ApplicationInfoInterface.SideStage)
 
376
 
354
377
            webbrowserCheckBox.checked = true;
355
378
            waitUntilAppSurfaceShowsUp(webbrowserCheckBox.appId)
356
379
            var webbrowserApp = ApplicationManager.findApplication(webbrowserCheckBox.appId);
384
407
            }
385
408
            tryCompare(spreadView, "phase", 2);
386
409
        }
 
410
 
 
411
        function test_threeFingerTapOpensSideStage_data() {
 
412
            return [
 
413
                { tag: "1 finger", touchIds: [0], result: false },
 
414
                { tag: "2 finger", touchIds: [0, 1], result: false },
 
415
                { tag: "3 finger", touchIds: [0, 1, 2], result: true },
 
416
                { tag: "4 finger", touchIds: [0, 1, 2, 3], result: false },
 
417
            ];
 
418
        }
 
419
 
 
420
        function test_threeFingerTapOpensSideStage(data) {
 
421
            multiTouchTap(data.touchIds, tabletStage, tabletStage.width / 2, tabletStage.height / 2);
 
422
            wait(200);
 
423
            tryCompare(sideStage, "shown", data.result);
 
424
        }
 
425
 
 
426
 
 
427
        function test_threeFingerTapClosesSideStage_data() {
 
428
            return [
 
429
                { tag: "1 finger", touchIds: [0], result: true },
 
430
                { tag: "2 finger", touchIds: [0, 1], result: true },
 
431
                { tag: "3 finger", touchIds: [0, 1, 2], result: false },
 
432
                { tag: "4 finger", touchIds: [0, 1, 2, 3], result: true },
 
433
            ];
 
434
        }
 
435
 
 
436
        function test_threeFingerTapClosesSideStage(data) {
 
437
            sideStage.showNow();
 
438
 
 
439
            multiTouchTap(data.touchIds, tabletStage, tabletStage.width / 2, tabletStage.height / 2);
 
440
            wait(200);
 
441
            tryCompare(sideStage, "shown", data.result);
 
442
        }
 
443
 
 
444
        function test_threeFingerDragOpensSidestage() {
 
445
            multiTouchDragUntil([0,1,2],
 
446
                                tabletStage,
 
447
                                tabletStage.width / 4,
 
448
                                tabletStage.height / 4,
 
449
                                units.gu(1),
 
450
                                0,
 
451
                                function() { return sideStage.shown; });
 
452
        }
 
453
 
 
454
        function test_applicationLoadsInCorrectStage_data() {
 
455
            return [
 
456
                { tag: "MainStage", stage: ApplicationInfoInterface.MainStage, mainStageAppId: "webbrowser-app", sideStageAppId: ""},
 
457
                { tag: "SideStage", stage: ApplicationInfoInterface.SideStage, mainStageAppId: "unity8-dash", sideStageAppId: "webbrowser-app" },
 
458
            ];
 
459
        }
 
460
 
 
461
        function test_applicationLoadsInCorrectStage(data) {
 
462
            WindowStateStorage.saveStage(webbrowserCheckBox.appId, data.stage)
 
463
 
 
464
            var stagesPriv = findInvisibleChild(tabletStage, "stagesPriv");
 
465
            verify(stagesPriv);
 
466
 
 
467
            tryCompare(stagesPriv, "mainStageAppId", "unity8-dash");
 
468
            tryCompare(stagesPriv, "sideStageAppId", "");
 
469
 
 
470
            webbrowserCheckBox.checked = true;
 
471
            waitUntilAppSurfaceShowsUp(webbrowserCheckBox.appId)
 
472
 
 
473
            tryCompare(stagesPriv, "mainStageAppId", data.mainStageAppId);
 
474
            tryCompare(stagesPriv, "sideStageAppId", data.sideStageAppId);
 
475
        }
 
476
 
 
477
        function test_loadSideStageByDragginFromMainStage() {
 
478
            sideStage.showNow();
 
479
            webbrowserCheckBox.checked = true;
 
480
            waitUntilAppSurfaceShowsUp(webbrowserCheckBox.appId);
 
481
 
 
482
            var appDelegate = findChild(tabletStage, "tabletSpreadDelegate_" + webbrowserCheckBox.appId);
 
483
            verify(appDelegate);
 
484
            compare(appDelegate.stage, ApplicationInfoInterface.MainStage);
 
485
 
 
486
            var pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
 
487
            var end_pos = tabletStage.width - sideStage.width / 2;
 
488
 
 
489
            multiTouchDragUntil([0,1,2],
 
490
                                tabletStage,
 
491
                                pos,
 
492
                                tabletStage.height / 2,
 
493
                                units.gu(3),
 
494
                                0,
 
495
                                function() {
 
496
                                    pos += units.gu(3);
 
497
                                    return sideStage.shown && !sideStage.showAnimation.running &&
 
498
                                           pos >= end_pos;
 
499
                                });
 
500
 
 
501
            tryCompare(appDelegate, "stage", ApplicationInfoInterface.SideStage);
 
502
        }
 
503
 
 
504
        function test_unloadSideStageByDragginFromStageStage() {
 
505
            sideStage.showNow();
 
506
            WindowStateStorage.saveStage(webbrowserCheckBox.appId, ApplicationInfoInterface.SideStage)
 
507
            webbrowserCheckBox.checked = true;
 
508
            waitUntilAppSurfaceShowsUp(webbrowserCheckBox.appId);
 
509
 
 
510
            var appDelegate = findChild(tabletStage, "tabletSpreadDelegate_" + webbrowserCheckBox.appId);
 
511
            verify(appDelegate);
 
512
            compare(appDelegate.stage, ApplicationInfoInterface.SideStage);
 
513
 
 
514
            var pos = tabletStage.width - sideStage.width / 2;
 
515
            var end_pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
 
516
 
 
517
            multiTouchDragUntil([0,1,2],
 
518
                                tabletStage,
 
519
                                pos,
 
520
                                tabletStage.height / 2,
 
521
                                -units.gu(3),
 
522
                                0,
 
523
                                function() {
 
524
                                    pos -= units.gu(3);
 
525
                                    return pos <= end_pos;
 
526
                                });
 
527
 
 
528
            tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
 
529
        }
387
530
    }
388
531
}