~mzanetti/unity8/spread-blur

« back to all changes in this revision

Viewing changes to tests/qmltests/Stage/tst_PhoneStage.qml

  • Committer: Bileto Bot
  • Author(s): Michael Zanetti
  • Date: 2016-10-24 11:34:08 UTC
  • mfrom: (2400.6.204 unity8-unified-spread)
  • Revision ID: ci-train-bot@canonical.com-20161024113408-7ul8ivww68dqm74v
Merge all Stages into one single codebase. Apply new spread visuals.

This deletes PhoneStage, TabletStage and DesktopStage, and merges all of the functionality into Stage. Also the spread visuals have been updated by design to work with all usage modes. (LP: #1489517, #1603914, #1635800)

Approved by: Lukáš Tinkl

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import Unity.Test 0.1 as UT
20
20
import ".."
21
21
import "../../../qml/Components"
22
 
import "../../../qml/Stages"
 
22
import "../../../qml/Stage"
23
23
import Ubuntu.Components 1.3
24
24
import Unity.Application 0.1
25
25
import WindowManager 0.1
31
31
 
32
32
    property var greeter: { fullyShown: true }
33
33
 
34
 
    PhoneStage {
35
 
        id: phoneStage
 
34
    Stage {
 
35
        id: stage
36
36
        anchors { fill: parent; rightMargin: units.gu(30) }
37
37
        focus: true
38
38
        dragAreaWidth: units.gu(2)
39
 
        maximizedAppTopMargin: units.gu(3)
40
39
        interactive: true
41
40
        shellOrientation: Qt.PortraitOrientation
42
41
        orientations: Orientations {}
43
42
        applicationManager: ApplicationManager
 
43
        mode: "staged"
44
44
        topLevelSurfaceList: TopLevelSurfaceList {
45
45
            id: topLevelSurfaceList
46
46
            applicationsModel: ApplicationManager
66
66
                    id: edgeBarrierControls
67
67
                    text: "Drag here to pull out spread"
68
68
                    backgroundColor: "blue"
69
 
                    onDragged: { phoneStage.pushRightEdge(amount); }
 
69
                    onDragged: { stage.pushRightEdge(amount); }
70
70
                    Component.onCompleted: {
71
 
                        edgeBarrierControls.target = testCase.findChild(phoneStage, "edgeBarrierController");
 
71
                        edgeBarrierControls.target = testCase.findChild(stage, "edgeBarrierController");
72
72
                    }
73
73
                }
74
74
                Repeater {
84
84
        name: "PhoneStage"
85
85
        when: windowShown
86
86
 
 
87
        function init() {
 
88
            // wait until unity8-dash is up and running.
 
89
            // it's started automatically by ApplicationManager mock implementation
 
90
            tryCompare(ApplicationManager, "count", 1);
 
91
            var dashApp = ApplicationManager.findApplication("unity8-dash");
 
92
            verify(dashApp);
 
93
            tryCompare(dashApp, "state", ApplicationInfoInterface.Running);
 
94
        }
 
95
 
 
96
        function cleanup() {
 
97
            ApplicationManager.requestFocusApplication("unity8-dash");
 
98
            tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
 
99
            tryCompare(stage, "state", "staged");
 
100
            waitForRendering(stage);
 
101
 
 
102
            killApps();
 
103
            // wait for Stage to stabilize back into its initial state
 
104
            var appRepeater = findChild(stage, "appRepeater");
 
105
            tryCompare(appRepeater, "count", 1);
 
106
            tryCompare(appRepeater.itemAt(0), "x", 0);
 
107
 
 
108
            stage.shellOrientationAngle = 0;
 
109
 
 
110
            waitForRendering(stage)
 
111
        }
 
112
 
87
113
        function findAppWindowForSurfaceId(surfaceId) {
88
 
            var delegateObjectName = "spreadDelegate_" + surfaceId;
89
 
            var spreadDelegate = findChild(phoneStage, delegateObjectName);
 
114
            var delegateObjectName = "appDelegate_" + surfaceId;
 
115
            var spreadDelegate = findChild(stage, delegateObjectName);
90
116
            if (!spreadDelegate) {
91
 
                console.warn("Failed to find " + delegateObjectName + " in phoneStage ("+phoneStage+")");
 
117
                console.warn("Failed to find " + delegateObjectName + " in stage");
92
118
                return null;
93
119
            }
94
120
            var appWindow = findChild(spreadDelegate, "appWindow");
108
134
        function addApps(count) {
109
135
            if (count == undefined) count = 1;
110
136
            for (var i = 0; i < count; i++) {
 
137
                var startingAppId = ApplicationManager.availableApplications[ApplicationManager.count];
111
138
                var appSurfaceId = topLevelSurfaceList.nextId;
112
 
                var app = ApplicationManager.startApplication(ApplicationManager.availableApplications[ApplicationManager.count])
 
139
                var app = ApplicationManager.startApplication(startingAppId)
113
140
                tryCompare(app, "state", ApplicationInfoInterface.Running)
114
 
                var spreadView = findChild(phoneStage, "spreadView");
115
 
                tryCompare(spreadView, "contentX", -spreadView.shift);
116
141
                waitUntilAppSurfaceShowsUp(appSurfaceId);
117
 
                waitForRendering(phoneStage)
 
142
                waitForRendering(stage)
 
143
                tryCompare(ApplicationManager, "focusedApplicationId", startingAppId)
118
144
            }
119
145
        }
120
146
 
121
147
        function performEdgeSwipeToShowAppSpread() {
122
 
            var spreadView = findChild(phoneStage, "spreadView");
123
 
 
124
 
            // Keep it inside the PhoneStage otherwise the controls on the right side will
 
148
            // Keep it inside the Stage otherwise the controls on the right side will
125
149
            // capture the press thus the "- 2"  on startX.
126
 
            var startX = phoneStage.width - 2;
127
 
            var startY = phoneStage.height / 2;
 
150
            var startX = stage.width - 2;
 
151
            var startY = stage.height / 2;
128
152
            var endY = startY;
129
 
            var endX = phoneStage.width / 2;
 
153
            var endX = stage.width / 2;
130
154
 
131
 
            touchFlick(phoneStage, startX, startY, endX, endY,
 
155
            touchFlick(stage, startX, startY, endX, endY,
132
156
                       true /* beginTouch */, true /* endTouch */, units.gu(10), 50);
133
157
 
134
 
            tryCompare(spreadView, "phase", 2);
135
 
            tryCompare(spreadView, "flicking", false);
136
 
            tryCompare(spreadView, "moving", false);
137
 
            waitForRendering(phoneStage);
 
158
            tryCompare(stage, "state", "spread");
 
159
            // Make sure all the transitions have finished
 
160
            var appRepeater = findChild(stage, "appRepeater");
 
161
            for (var i = 0; i < appRepeater.count; i++) {
 
162
                waitUntilTransitionsEnd(appRepeater.itemAt(i));
 
163
            }
 
164
            waitForRendering(stage);
138
165
        }
139
166
 
140
167
        function swipeSurfaceUpwards(surfaceId) {
163
190
 
164
191
        function waitUntilAppDelegateStopsMoving(targetSurfaceId)
165
192
        {
166
 
            var targetAppDelegate = findChild(phoneStage, "spreadDelegate_" + targetSurfaceId);
 
193
            var targetAppDelegate = findChild(stage, "appDelegate_" + targetSurfaceId);
167
194
            verify(targetAppDelegate);
168
195
            var lastValue = undefined;
169
196
            do {
172
199
            } while (lastValue != targetAppDelegate.animatedProgress);
173
200
        }
174
201
 
175
 
        function test_shortFlick() {
176
 
            addApps(2)
177
 
            var startX = phoneStage.width - units.gu(1);
178
 
            var startY = phoneStage.height / 2;
179
 
            var endX = startX - units.gu(4);
180
 
            var endY = startY;
181
 
 
182
 
            var activeApp = ApplicationManager.get(0);
183
 
            var inactiveApp = ApplicationManager.get(1);
184
 
 
185
 
            touchFlick(phoneStage, startX, startY, endX, endY,
186
 
                       true /* beginTouch */, true /* endTouch */, units.gu(10), 50);
187
 
 
188
 
            tryCompare(ApplicationManager, "focusedApplicationId", inactiveApp.appId)
189
 
 
190
 
            touchFlick(phoneStage, startX, startY, endX, endY,
191
 
                       true /* beginTouch */, true /* endTouch */, units.gu(10), 50);
192
 
 
193
 
            tryCompare(ApplicationManager, "focusedApplicationId", activeApp.appId)
194
 
        }
195
 
 
196
202
        function test_enterSpread_data() {
197
203
            return [
198
 
                {tag: "<position1 (linear movement)", positionMarker: "positionMarker1", linear: true, offset: 0, endPhase: 0, targetPhase: 0, newFocusedIndex: 1 },
199
 
                {tag: "<position1 (non-linear movement)", positionMarker: "positionMarker1", linear: false, offset: 0, endPhase: 0, targetPhase: 0, newFocusedIndex: 0 },
200
 
                {tag: ">position1", positionMarker: "positionMarker1", linear: true, offset: +5, endPhase: 0, targetPhase: 0, newFocusedIndex: 1 },
201
 
                {tag: "<position2 (linear)", positionMarker: "positionMarker2", linear: true, offset: 0, endPhase: 0, targetPhase: 0, newFocusedIndex: 1 },
202
 
                {tag: "<position2 (non-linear)", positionMarker: "positionMarker2", linear: false, offset: 0, endPhase: 0, targetPhase: 0, newFocusedIndex: 1 },
203
 
                {tag: ">position2", positionMarker: "positionMarker2", linear: true, offset: +5, endPhase: 1, targetPhase: 0, newFocusedIndex: 1 },
204
 
                {tag: "<position3", positionMarker: "positionMarker3", linear: true, offset: 0, endPhase: 1, targetPhase: 0, newFocusedIndex: 1 },
205
 
                {tag: ">position3", positionMarker: "positionMarker3", linear: true, offset: +5, endPhase: 1, targetPhase: 2, newFocusedIndex: 2 },
 
204
                {tag: "<breakPoint (trigger)", progress: .2, cancel: false, endState: "staged", newFocusedIndex: 1 },
 
205
                {tag: "<breakPoint (cancel)", progress: .2, cancel: true, endState: "staged", newFocusedIndex: 0 },
 
206
                {tag: ">breakPoint (trigger)", progress: .5, cancel: false, endState: "spread", newFocusedIndex: 0 },
 
207
                {tag: ">breakPoint (cancel)", progress: .8, cancel: true, endState: "staged", newFocusedIndex: 0 },
206
208
            ];
207
209
        }
208
210
 
209
211
        function test_enterSpread(data) {
210
212
            addApps(5)
211
213
 
212
 
            var spreadView = findChild(phoneStage, "spreadView");
213
 
 
214
 
            // Keep it inside the PhoneStage otherwise the controls on the right side will
 
214
            // Keep it inside the Stage otherwise the controls on the right side will
215
215
            // capture the press thus the "- 2"  on startX.
216
 
            var startX = phoneStage.width - 2;
217
 
            var startY = phoneStage.height / 2;
 
216
            var startX = stage.width - 2;
 
217
            var startY = stage.height / 2;
218
218
            var endY = startY;
219
 
            var endX = spreadView.width - (spreadView.width * spreadView[data.positionMarker]) - data.offset
220
 
                - phoneStage.dragAreaWidth;
 
219
            var endX = stage.width - (stage.width * data.progress) - stage.dragAreaWidth;
221
220
 
222
221
            var oldFocusedApp = ApplicationManager.get(0);
223
222
            var newFocusedApp = ApplicationManager.get(data.newFocusedIndex);
224
223
 
225
 
            touchFlick(phoneStage, startX, startY, endX, endY,
 
224
            touchFlick(stage, startX, startY, endX, endY,
226
225
                       true /* beginTouch */, false /* endTouch */, units.gu(10), 50);
227
226
 
228
 
            tryCompare(spreadView, "phase", data.endPhase)
229
 
 
230
 
            if (!data.linear) {
231
 
                touchFlick(phoneStage, endX, endY, endX + units.gu(.5), endY,
232
 
                           false /* beginTouch */, false /* endTouch */, units.gu(10), 50);
233
 
                touchFlick(phoneStage, endY + units.gu(.5), endY, endX, endY,
234
 
                           false /* beginTouch */, false /* endTouch */, units.gu(10), 50);
235
 
            }
236
 
 
237
 
            touchRelease(phoneStage, endX, endY);
238
 
 
239
 
            tryCompare(spreadView, "phase", data.targetPhase)
240
 
 
241
 
            if (data.targetPhase == 2) {
242
 
                var app2 = findChild(spreadView, "spreadDelegate_" + topLevelSurfaceList.idAt(2));
243
 
                tryCompare(app2, "swipeToCloseEnabled", true);
244
 
                mouseClick(app2, units.gu(1), units.gu(1));
245
 
            }
246
 
 
247
 
            tryCompare(ApplicationManager, "focusedApplicationId", newFocusedApp.appId);
 
227
            if (data.cancel) {
 
228
                touchFlick(stage, endX, endY, endX + units.gu(5), endY,
 
229
                           false /* beginTouch */, true /* endTouch */, units.gu(10), 50);
 
230
            } else {
 
231
                touchRelease(stage, endX, endY);            }
 
232
 
 
233
            tryCompare(stage, "state", data.endState);
 
234
            tryCompare(ApplicationManager, "focusedApplicationId", data.endState == "spread" ? oldFocusedApp.appId : newFocusedApp.appId);
248
235
        }
249
236
 
250
237
        function test_selectAppFromSpread_data() {
263
250
        function test_selectAppFromSpread(data) {
264
251
            addApps(data.total)
265
252
 
266
 
            var spreadView = findChild(phoneStage, "spreadView");
267
 
 
268
253
            performEdgeSwipeToShowAppSpread();
269
254
 
270
 
            tryCompare(spreadView, "phase", 2);
271
 
 
272
 
            var tile = findChild(spreadView, "spreadDelegate_" + topLevelSurfaceList.idAt(data.index));
 
255
            var tile = findChild(stage, "appDelegate_" + topLevelSurfaceList.idAt(data.index));
273
256
            var appId = ApplicationManager.get(data.index).appId;
274
257
 
275
 
            if (tile.mapToItem(spreadView, 0, 0).x > spreadView.width) {
 
258
            if (tile.mapToItem(stage, 0, 0).x > stage.width - units.gu(3)) {
276
259
                // Item is not visible... Need to flick the spread
277
 
                var startX = phoneStage.width - units.gu(1);
278
 
                var startY = phoneStage.height / 2;
 
260
                var startX = stage.width - units.gu(1);
 
261
                var startY = stage.height / 2;
279
262
                var endY = startY;
280
263
                var endX = units.gu(2);
281
 
                touchFlick(phoneStage, startX, startY, endX, endY, true, true, units.gu(10), 50)
282
 
                tryCompare(spreadView, "flicking", false);
283
 
                tryCompare(spreadView, "moving", false);
284
 
//                waitForRendering(phoneStage);
 
264
                touchFlick(stage, startX, startY, endX, endY, true, true, units.gu(10), 50)
285
265
            }
286
266
 
287
267
            console.log("clicking app", data.index, "(", appId, ")")
288
 
            tryCompare(tile, "swipeToCloseEnabled", true);
289
 
            mouseClick(spreadView, tile.mapToItem(spreadView, 0, 0).x + units.gu(1), spreadView.height / 2)
 
268
            var dragArea = findChild(tile, "dragArea");
 
269
            tryCompare(dragArea, "closeable", true);
 
270
            mouseClick(stage, tile.mapToItem(stage, 0, 0).x + units.gu(1), stage.height / 2)
290
271
            tryCompare(ApplicationManager, "focusedApplicationId", appId);
291
 
            tryCompare(spreadView, "phase", 0);
 
272
            tryCompare(stage, "state", "staged");
292
273
        }
293
274
 
294
275
        function test_select_data() {
302
283
        function test_select(data) {
303
284
            addApps(5);
304
285
 
305
 
            var spreadView = findChild(phoneStage, "spreadView");
306
286
            var selectedApp = ApplicationManager.get(data.index);
 
287
            var appRepeater = findChild(stage, "appRepeater");
 
288
            var selectedAppDeleage = appRepeater.itemAt(data.index);
307
289
 
308
290
            performEdgeSwipeToShowAppSpread();
309
291
 
310
 
            phoneStage.select(selectedApp.appId);
311
 
 
312
 
            tryCompare(spreadView, "contentX", -spreadView.shift);
313
 
 
314
 
            compare(ApplicationManager.focusedApplicationId, selectedApp.appId);
 
292
            print("tapping", selectedAppDeleage.appId, selectedAppDeleage.visible)
 
293
            if (selectedAppDeleage.x > stage.width - units.gu(5)) {
 
294
                touchFlick(stage, stage.width - units.gu(2), stage.height / 2, units.gu(2), stage.height / 2, true, true, units.gu(2), 10)
 
295
            }
 
296
 
 
297
            tap(selectedAppDeleage, 1, 1);
 
298
 
 
299
            tryCompare(stage, "state", "staged");
 
300
 
 
301
            tryCompare(ApplicationManager, "focusedApplicationId", selectedApp.appId);
315
302
        }
316
303
 
317
304
        function test_backgroundClickCancelsSpread() {
320
307
            var focusedAppId = ApplicationManager.focusedApplicationId;
321
308
 
322
309
            performEdgeSwipeToShowAppSpread();
323
 
 
324
 
            mouseClick(phoneStage, units.gu(1), units.gu(1));
325
 
 
326
 
            // Make sure the spread is in the idle position
327
 
            var spreadView = findChild(phoneStage, "spreadView");
328
 
            tryCompare(spreadView, "contentX", -spreadView.shift);
 
310
            tryCompare(stage, "state", "spread");
 
311
 
 
312
            mouseClick(stage, units.gu(1), units.gu(1));
 
313
 
 
314
            tryCompare(stage, "state", "staged");
329
315
 
330
316
            // Make sure the same app is still focused
331
 
            compare(focusedAppId, ApplicationManager.focusedApplicationId);
332
 
        }
333
 
 
334
 
        function init() {
335
 
            // wait until unity8-dash is up and running.
336
 
            // it's started automatically by ApplicationManager mock implementation
337
 
            tryCompare(ApplicationManager, "count", 1);
338
 
            var dashApp = ApplicationManager.findApplication("unity8-dash");
339
 
            verify(dashApp);
340
 
            tryCompare(dashApp, "state", ApplicationInfoInterface.Running);
341
 
        }
342
 
 
343
 
        function cleanup() {
344
 
            killApps();
345
 
 
346
 
            phoneStage.shellOrientationAngle = 0;
347
 
            phoneStage.select(ApplicationManager.get(0).appId);
348
 
 
349
 
            // wait for PhoneStage to stabilize back into its initial state
350
 
            var spreadView = findChild(phoneStage, "spreadView");
351
 
            while (spreadView.phase !== 0 || spreadView.contentX !== -spreadView.shift || spreadView.selectedIndex != -1) {
352
 
                wait(50);
353
 
            }
 
317
            tryCompare(ApplicationManager, "focusedApplicationId", focusedAppId);
354
318
        }
355
319
 
356
320
        function test_focusNewTopMostAppAfterFocusedOneClosesItself() {
370
334
            tryCompare(firstApp, "focused", true);
371
335
        }
372
336
 
373
 
        function test_cantCloseWhileSnapping() {
374
 
            addApps(2);
375
 
 
376
 
            performEdgeSwipeToShowAppSpread();
377
 
 
378
 
            var spreadView = findChild(phoneStage, "spreadView");
379
 
            var selectedApp = ApplicationManager.get(2);
380
 
 
381
 
            performEdgeSwipeToShowAppSpread();
382
 
 
383
 
            var app0 = findChild(spreadView, "spreadDelegate_" + topLevelSurfaceList.idAt(0));
384
 
            var app1 = findChild(spreadView, "spreadDelegate_" + topLevelSurfaceList.idAt(1));
385
 
            var app2 = findChild(spreadView, "spreadDelegate_" + topLevelSurfaceList.idAt(2));
386
 
 
387
 
            var dragArea0 = findChild(app0, "dragArea");
388
 
            var dragArea1 = findChild(app1, "dragArea");
389
 
            var dragArea2 = findChild(app2, "dragArea");
390
 
 
391
 
            compare(dragArea0.enabled, true);
392
 
            compare(dragArea1.enabled, true);
393
 
            compare(dragArea2.enabled, true);
394
 
 
395
 
            phoneStage.select(selectedApp.appId);
396
 
 
397
 
            // Make sure all drag areas are disabled instantly. Don't use tryCompare here!
398
 
            compare(dragArea0.enabled, false);
399
 
            compare(dragArea1.enabled, false);
400
 
            compare(dragArea2.enabled, false);
401
 
 
402
 
            tryCompare(spreadView, "contentX", -spreadView.shift)
403
 
        }
404
 
 
405
 
        function test_cantAccessPhoneStageWhileRightEdgeGesture() {
406
 
            var spreadView = findChild(phoneStage, "spreadView");
407
 
            var eventEaterArea = findChild(phoneStage, "eventEaterArea")
408
 
 
409
 
            var startX = phoneStage.width - 2;
410
 
            var startY = phoneStage.height / 2;
411
 
            var endY = startY;
412
 
            var endX = phoneStage.width / 2;
413
 
 
414
 
            touchFlick(phoneStage, startX, startY, endX, endY,
415
 
                       true /* beginTouch */, false /* endTouch */, units.gu(10), 50);
416
 
 
417
 
            compare(eventEaterArea.enabled, true);
418
 
 
419
 
            touchRelease(phoneStage, endX, endY);
420
 
 
421
 
            compare(eventEaterArea.enabled, false);
422
 
        }
423
 
 
424
337
        function test_leftEdge_data() {
425
338
            return [
426
 
                { tag: "normal", inSpread: false, leftEdgeDragWidth: units.gu(5), shouldMoveApp: true },
 
339
                { tag: "normal", inSpread: false, leftEdgeDragWidth: units.gu(20), shouldMoveApp: true },
427
340
                { tag: "inSpread", inSpread: true, leftEdgeDragWidth: units.gu(5), shouldMoveApp: false }
428
341
            ]
429
342
        }
435
348
                performEdgeSwipeToShowAppSpread();
436
349
            }
437
350
 
438
 
            var focusedDelegate = findChild(phoneStage, "spreadDelegate_" + topLevelSurfaceList.idAt(0));
439
 
            phoneStage.inverseProgress = data.leftEdgeDragWidth;
440
 
 
441
 
            tryCompare(focusedDelegate, "x", data.shouldMoveApp ? data.leftEdgeDragWidth : 0);
442
 
 
443
 
            phoneStage.inverseProgress = 0;
444
 
 
445
 
            tryCompare(focusedDelegate, "x", 0);
 
351
            var focusedDelegate = findChild(stage, "appDelegate_" + topLevelSurfaceList.idAt(0));
 
352
            var currentX = focusedDelegate.x;
 
353
 
 
354
            stage.leftEdgeDragProgress = data.leftEdgeDragWidth;
 
355
 
 
356
            tryCompare(focusedDelegate, "x", data.shouldMoveApp ? data.leftEdgeDragWidth : currentX);
 
357
 
 
358
            stage.leftEdgeDragProgress = 0;
 
359
 
 
360
            tryCompare(focusedDelegate, "x", currentX);
446
361
        }
447
362
 
448
363
        function test_focusedAppIsTheOnlyRunningApp() {
449
364
            addApps(2);
450
365
 
451
 
            var delegateA = findChild(phoneStage, "spreadDelegate_" + topLevelSurfaceList.idAt(0));
 
366
            var delegateA = findChild(stage, "appDelegate_" + topLevelSurfaceList.idAt(0));
452
367
            verify(delegateA);
453
 
            var delegateB = findChild(phoneStage, "spreadDelegate_" + topLevelSurfaceList.idAt(1));
 
368
            var delegateB = findChild(stage, "appDelegate_" + topLevelSurfaceList.idAt(1));
454
369
            verify(delegateB);
455
370
 
456
371
            // A is focused and running, B is unfocused and suspended
461
376
 
462
377
            // Switch foreground/focused appp from A to B
463
378
            performEdgeSwipeToShowAppSpread();
464
 
            phoneStage.select(delegateB.application.appId);
 
379
            tap(delegateB, 1, 1);
465
380
 
466
381
            // Now it's the other way round
467
382
            // A is unfocused and suspended, B is focused and running
474
389
        function test_dashRemainsRunningIfStageIsToldSo() {
475
390
            addApps(1);
476
391
 
477
 
            var delegateDash = findChild(phoneStage, "spreadDelegate_" + topLevelSurfaceList.idAt(1));
 
392
            var delegateDash = findChild(stage, "appDelegate_" + topLevelSurfaceList.idAt(1));
478
393
            verify(delegateDash);
479
394
            compare(delegateDash.application.appId, "unity8-dash");
480
395
 
481
 
            var delegateOther = findChild(phoneStage, "spreadDelegate_" + topLevelSurfaceList.idAt(0));
 
396
            var delegateOther = findChild(stage, "appDelegate_" + topLevelSurfaceList.idAt(0));
482
397
            verify(delegateOther);
483
398
 
484
399
            performEdgeSwipeToShowAppSpread();
485
 
            phoneStage.select("unity8-dash");
 
400
            tap(delegateDash, 1, 1);
486
401
 
487
402
            tryCompare(delegateDash, "focus", true);
488
403
            tryCompare(delegateDash.application, "requestedState", ApplicationInfoInterface.RequestedRunning);
490
405
            compare(delegateOther.application.requestedState, ApplicationInfoInterface.RequestedSuspended);
491
406
 
492
407
            performEdgeSwipeToShowAppSpread();
493
 
            phoneStage.select(delegateOther.application.appId);
494
 
 
 
408
            tap(delegateOther, 1, 1);
495
409
            // The other app gets focused and running but dash is kept running despite being unfocused
 
410
            tryCompare(delegateOther, "focus", true);
 
411
            tryCompare(delegateOther.application, "requestedState", ApplicationInfoInterface.RequestedRunning);
496
412
            tryCompare(delegateDash, "focus", false);
497
413
            tryCompare(delegateDash.application, "requestedState", ApplicationInfoInterface.RequestedRunning);
498
 
            compare(delegateOther.focus, true);
499
 
            compare(delegateOther.application.requestedState, ApplicationInfoInterface.RequestedRunning);
500
414
        }
501
415
 
502
416
        function test_foregroundAppIsSuspendedWhenStageIsSuspended() {
503
417
            addApps(1);
504
418
 
505
 
            var delegate = findChild(phoneStage, "spreadDelegate_" + topLevelSurfaceList.idAt(0));
 
419
            var delegate = findChild(stage, "appDelegate_" + topLevelSurfaceList.idAt(0));
506
420
            verify(delegate);
507
421
 
508
422
            compare(delegate.focus, true);
509
423
            compare(delegate.application.requestedState, ApplicationInfoInterface.RequestedRunning);
510
424
 
511
 
            phoneStage.suspended = true;
 
425
            stage.suspended = true;
512
426
 
513
427
            tryCompare(delegate.application, "requestedState", ApplicationInfoInterface.RequestedSuspended);
514
428
 
515
 
            phoneStage.suspended = false;
 
429
            stage.suspended = false;
516
430
 
517
431
            tryCompare(delegate.application, "requestedState", ApplicationInfoInterface.RequestedRunning);
518
432
        }
519
433
 
520
434
        function test_mouseEdgePush() {
521
 
            var spreadView = findChild(phoneStage, "spreadView")
522
435
            addApps(1);
523
 
            mouseMove(phoneStage, phoneStage.width -  1, units.gu(10));
 
436
            mouseMove(stage, stage.width -  1, units.gu(10));
524
437
            for (var i = 0; i < units.gu(10); i++) {
525
 
                phoneStage.pushRightEdge(1);
 
438
                stage.pushRightEdge(1);
526
439
            }
527
 
            tryCompare(spreadView, "phase", 2);
 
440
            mouseMove(stage, stage.width - units.gu(5), units.gu(10));
 
441
            compare(stage.state, "spread");
528
442
        }
529
443
 
530
444
        function test_closeSurfaceOfMultiSurfaceApp() {
539
453
 
540
454
            performEdgeSwipeToShowAppSpread();
541
455
 
542
 
            var appDelegate = findChild(phoneStage, "spreadDelegate_" + surface1Id);
543
 
            verify(appDelegate);
544
 
            tryCompare(appDelegate, "swipeToCloseEnabled", true);
 
456
            var appDelegate = findChild(stage, "appDelegate_" + surface1Id);
 
457
            var dragArea = findChild(appDelegate, "dragArea")
 
458
            verify(dragArea);
 
459
            tryCompare(dragArea, "closeable", true);
545
460
 
546
461
            compare(webbrowserApp.surfaceList.count, 2);
547
 
            compare(webbrowserApp.state, ApplicationInfoInterface.Running);
548
462
 
549
463
            swipeSurfaceUpwards(surface1Id);
550
464
 
551
465
            // Surface must eventually be gone
552
466
            tryCompareFunction(function() { return topLevelSurfaceList.indexForId(surface1Id); }, -1);
553
467
            tryCompare(webbrowserApp.surfaceList, "count", 1);
554
 
            compare(webbrowserApp.state, ApplicationInfoInterface.Running);
 
468
        }
 
469
 
 
470
        function test_swipeToClose_data() {
 
471
            return [
 
472
                { tag: "closeable", closeable: true },
 
473
                { tag: "not closeable", closeable: false }
 
474
            ]
 
475
        }
 
476
 
 
477
        function test_swipeToClose(data) {
 
478
            var surface1Id = topLevelSurfaceList.nextId;
 
479
            var webbrowserApp  = ApplicationManager.startApplication("webbrowser-app");
 
480
            waitUntilAppSurfaceShowsUp(surface1Id);
 
481
 
 
482
            performEdgeSwipeToShowAppSpread();
 
483
 
 
484
            var appDelegate = findChild(stage, "appDelegate_" + surface1Id);
 
485
            var dragArea = findChild(appDelegate, "dragArea")
 
486
            verify(dragArea);
 
487
            dragArea.closeable = data.closeable;
 
488
 
 
489
            var oldCount = ApplicationManager.count;
 
490
 
 
491
            swipeSurfaceUpwards(surface1Id);
 
492
 
 
493
            tryCompare(ApplicationManager, "count", data.closeable ? oldCount - 1 : oldCount);
555
494
        }
556
495
 
557
496
        /*
632
571
 
633
572
            performEdgeSwipeToShowAppSpread();
634
573
 
635
 
            {
636
 
                var appDelegate = findChild(phoneStage, "spreadDelegate_" + webbrowserSurfaceId);
637
 
                verify(appDelegate);
638
 
                tryCompare(appDelegate, "swipeToCloseEnabled", true);
639
 
            }
 
574
            var appDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
 
575
            var dragArea = findChild(appDelegate, "dragArea");
 
576
            verify(dragArea);
 
577
            tryCompare(dragArea, "closeable", true);
640
578
 
641
579
            swipeSurfaceUpwards(webbrowserSurfaceId);
642
580