on xenial help sign in
Fix up the TabletStage tests
3c2f020Dalton Durst
tests/qmltests/Stage/tst_TabletStage.qml+107−136
@@ -66,9 +66,6 @@ Rectangle {
66 id: availableDesktopAreaItem
66 id: availableDesktopAreaItem
67 anchors.fill: parent
67 anchors.fill: parent
68 }
68 }
69− Component.onCompleted: {
70− ApplicationManager.startApplication("unity8-dash");
71− }
72 }
69 }
73
70
74 Rectangle {
71 Rectangle {
@@ -108,6 +105,22 @@ Rectangle {
108 }
105 }
109 }
106 }
110
107
108+ Button {
109+ text: "Drag app to side stage"
110+ activeFocusOnPress: false
111+ onClicked: {
112+ testCase.dragToSideStage();
113+ }
114+ }
115+
116+ Button {
117+ text: "Drag app to main stage"
118+ activeFocusOnPress: false
119+ onClicked: {
120+ testCase.dragToMainStage();
121+ }
122+ }
123+
111 ApplicationCheckBox {
124 ApplicationCheckBox {
112 id: webbrowserCheckBox
125 id: webbrowserCheckBox
113 appId: "morph-browser"
126 appId: "morph-browser"
@@ -144,37 +157,17 @@ Rectangle {
144 function init() {
157 function init() {
145 stageSaver.clear();
158 stageSaver.clear();
146
159
147− ApplicationManager.startApplication("unity8-dash");
148− tryCompare(topSurfaceList, "count", 1);
160+ tryCompare(topSurfaceList, "count", 0);
149− compare(topSurfaceList.applicationAt(0).appId, "unity8-dash");
150−
151− // this is very strange, but sometimes the test starts without
152− // Stage components having finished loading themselves
153− var appWindow = null
154− while (!appWindow) {
155− appWindow = findAppWindowForSurfaceId(topSurfaceList.idAt(0));
156− if (!appWindow) {
157− console.log("didn't find unity8-dash appWindow in Stage. Trying again...");
158− wait(50);
159− }
160− }
161
161
162 // wait for Stage to stabilize back into its initial state
162 // wait for Stage to stabilize back into its initial state
163 var appRepeater = findChild(stage, "appRepeater");
163 var appRepeater = findChild(stage, "appRepeater");
164− tryCompare(appRepeater, "count", 1);
164+ tryCompare(appRepeater, "count", 0);
165− tryCompare(appRepeater.itemAt(0), "x", 0);
166
165
167− waitUntilAppSurfaceShowsUp(topSurfaceList.idAt(0));
168 sideStage.hideNow()
166 sideStage.hideNow()
169 tryCompare(sideStage, "x", stage.width)
167 tryCompare(sideStage, "x", stage.width)
170 }
168 }
171
169
172 function cleanup() {
170 function cleanup() {
173− ApplicationManager.requestFocusApplication("unity8-dash");
174− tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
175− tryCompare(stage, "state", "stagedWithSideStage");
176− waitForRendering(stage);
177−
178 killApps();
171 killApps();
179
172
180 sideStage.hideNow();
173 sideStage.hideNow();
@@ -194,6 +187,9 @@ Rectangle {
194 }
187 }
195
188
196 function findAppWindowForSurfaceId(surfaceId) {
189 function findAppWindowForSurfaceId(surfaceId) {
190+ tryVerify(function() {
191+ return findChild(stage, "appDelegate_" + surfaceId);
192+ }, 100, "Found app surface with ID " + surfaceId);
197 var spreadDelegate = findChild(stage, "appDelegate_" + surfaceId);
193 var spreadDelegate = findChild(stage, "appDelegate_" + surfaceId);
198 if (!spreadDelegate) {
194 if (!spreadDelegate) {
199 return null;
195 return null;
@@ -203,12 +199,14 @@ Rectangle {
203 }
199 }
204
200
205 function switchToSurface(targetSurfaceId) {
201 function switchToSurface(targetSurfaceId) {
202+ waitForRendering(stage);
206 performEdgeSwipeToShowAppSpread();
203 performEdgeSwipeToShowAppSpread();
207
204
208 waitUntilAppDelegateStopsMoving(targetSurfaceId);
205 waitUntilAppDelegateStopsMoving(targetSurfaceId);
209 var targetAppWindow = findAppWindowForSurfaceId(targetSurfaceId);
206 var targetAppWindow = findAppWindowForSurfaceId(targetSurfaceId);
210 verify(targetAppWindow);
207 verify(targetAppWindow);
211 tap(targetAppWindow, 10, 10);
208 tap(targetAppWindow, 10, 10);
209+ waitForRendering(stage);
212 }
210 }
213
211
214 function waitUntilAppDelegateStopsMoving(targetSurfaceId)
212 function waitUntilAppDelegateStopsMoving(targetSurfaceId)
@@ -241,7 +239,6 @@ Rectangle {
241
239
242 function dragToSideStage(surfaceId) {
240 function dragToSideStage(surfaceId) {
243 sideStage.showNow();
241 sideStage.showNow();
244− var targetAppDelegate = findChild(stage, "appDelegate_" + surfaceId);
245
242
246 var pos = stage.width - sideStage.width - (stage.width - sideStage.width) / 2;
243 var pos = stage.width - sideStage.width - (stage.width - sideStage.width) / 2;
247 var end_pos = stage.width - sideStage.width / 2;
244 var end_pos = stage.width - sideStage.width / 2;
@@ -252,13 +249,15 @@ Rectangle {
252 return sideStage.shown && !sideStage.showAnimation.running &&
249 return sideStage.shown && !sideStage.showAnimation.running &&
253 pos >= end_pos;
250 pos >= end_pos;
254 });
251 });
252+ if (surfaceId != null) {
253+ var targetAppDelegate = findChild(stage, "appDelegate_" + surfaceId);
254+ verify(targetAppDelegate);
255− tryCompare(targetAppDelegate, "stage", ApplicationInfoInterface.SideStage);
255+ tryCompare(targetAppDelegate, "stage", ApplicationInfoInterface.SideStage);
256+ }
256 }
257 }
257
258
258 function dragToMainStage(surfaceId) {
259 function dragToMainStage(surfaceId) {
259 sideStage.showNow();
260 sideStage.showNow();
260− var targetAppDelegate = findChild(stage, "appDelegate_" + surfaceId);
261− verify(targetAppDelegate);
262
261
263 var pos = stage.width - sideStage.width / 2;
262 var pos = stage.width - sideStage.width / 2;
264 var end_pos = stage.width - sideStage.width - (stage.width - sideStage.width) / 2;
263 var end_pos = stage.width - sideStage.width - (stage.width - sideStage.width) / 2;
@@ -273,15 +272,42 @@ Rectangle {
273 pos -= units.gu(3);
272 pos -= units.gu(3);
274 return pos <= end_pos;
273 return pos <= end_pos;
275 });
274 });
275+ if (surfaceId != null) {
276+ var targetAppDelegate = findChild(stage, "appDelegate_" + surfaceId);
277+ verify(targetAppDelegate);
276− tryCompare(targetAppDelegate, "stage", ApplicationInfoInterface.MainStage);
278+ tryCompare(targetAppDelegate, "stage", ApplicationInfoInterface.MainStage);
279+ }
280+ }
281+
282+ // Launch one of the available apps in this test case
283+ // Return the topSurfaceList's ID for the launched app
284+ // Valid values are: "morph", "gallery", "dialer", and "facebook"
285+ // "facebook" will be launched if no name is given
286+ function launchApp(appName) {
287+ var nextAppId = topSurfaceList.nextId;
288+ switch (appName) {
289+ case "morph":
290+ webbrowserCheckBox.checked = true;
291+ break;
292+ case "gallery":
293+ galleryCheckBox.checked = true;
294+ break;
295+ case "dialer":
296+ dialerCheckBox.checked = true;
297+ break;
298+ case "facebook":
299+ default:
300+ facebookCheckBox.checked = true;
301+ break;
302+ }
303+ waitUntilAppSurfaceShowsUp(nextAppId);
304+ return nextAppId;
277 }
305 }
278
306
279 function test_tappingSwitchesFocusBetweenStages() {
307 function test_tappingSwitchesFocusBetweenStages() {
280 WindowStateStorage.saveStage(dialerCheckBox.appId, ApplicationInfoInterface.SideStage)
308 WindowStateStorage.saveStage(dialerCheckBox.appId, ApplicationInfoInterface.SideStage)
281
309
282− var webbrowserSurfaceId = topSurfaceList.nextId;
310+ var webbrowserSurfaceId = launchApp("morph");
283− webbrowserCheckBox.checked = true;
284− waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
285 var webbrowserDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
311 var webbrowserDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
286 verify(webbrowserDelegate);
312 verify(webbrowserDelegate);
287 compare(webbrowserDelegate.stage, ApplicationInfoInterface.MainStage);
313 compare(webbrowserDelegate.stage, ApplicationInfoInterface.MainStage);
@@ -290,9 +316,7 @@ Rectangle {
290
316
291 tryCompare(webbrowserWindow.surface, "activeFocus", true);
317 tryCompare(webbrowserWindow.surface, "activeFocus", true);
292
318
293− var dialerSurfaceId = topSurfaceList.nextId;
319+ var dialerSurfaceId = launchApp("dialer");
294− dialerCheckBox.checked = true;
295− waitUntilAppSurfaceShowsUp(dialerSurfaceId);
296
320
297 var dialerApp = ApplicationManager.findApplication(dialerCheckBox.appId);
321 var dialerApp = ApplicationManager.findApplication(dialerCheckBox.appId);
298 var dialerDelegate = findChild(stage, "appDelegate_" + dialerSurfaceId);
322 var dialerDelegate = findChild(stage, "appDelegate_" + dialerSurfaceId);
@@ -322,9 +346,7 @@ Rectangle {
322 function test_closeAppInSideStage() {
346 function test_closeAppInSideStage() {
323 WindowStateStorage.saveStage(dialerCheckBox.appId, ApplicationInfoInterface.SideStage)
347 WindowStateStorage.saveStage(dialerCheckBox.appId, ApplicationInfoInterface.SideStage)
324
348
325− var dialerSurfaceId = topSurfaceList.nextId;
349+ var dialerSurfaceId = launchApp("dialer");
326− dialerCheckBox.checked = true;
327− waitUntilAppSurfaceShowsUp(dialerSurfaceId);
328
350
329 performEdgeSwipeToShowAppSpread();
351 performEdgeSwipeToShowAppSpread();
330
352
@@ -348,18 +370,14 @@ Rectangle {
348 }
370 }
349
371
350 function test_suspendsAndResumesAppsInMainStage() {
372 function test_suspendsAndResumesAppsInMainStage() {
351− var webbrowserSurfaceId = topSurfaceList.nextId;
373+ var webbrowserSurfaceId = launchApp("morph");
352− webbrowserCheckBox.checked = true;
353− waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
354 var webbrowserApp = ApplicationManager.findApplication(webbrowserCheckBox.appId);
374 var webbrowserApp = ApplicationManager.findApplication(webbrowserCheckBox.appId);
355 var webbrowserDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
375 var webbrowserDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
356 compare(webbrowserDelegate.stage, ApplicationInfoInterface.MainStage);
376 compare(webbrowserDelegate.stage, ApplicationInfoInterface.MainStage);
357
377
358 tryCompare(webbrowserApp, "state", ApplicationInfoInterface.Running);
378 tryCompare(webbrowserApp, "state", ApplicationInfoInterface.Running);
359
379
360− var gallerySurfaceId = topSurfaceList.nextId;
380+ var gallerySurfaceId = launchApp("gallery");
361− galleryCheckBox.checked = true;
362− waitUntilAppSurfaceShowsUp(gallerySurfaceId);
363 var galleryApp = ApplicationManager.findApplication(galleryCheckBox.appId);
381 var galleryApp = ApplicationManager.findApplication(galleryCheckBox.appId);
364 var galleryDelegate = findChild(stage, "appDelegate_" + gallerySurfaceId);
382 var galleryDelegate = findChild(stage, "appDelegate_" + gallerySurfaceId);
365 compare(galleryDelegate.stage, ApplicationInfoInterface.MainStage);
383 compare(galleryDelegate.stage, ApplicationInfoInterface.MainStage);
@@ -388,17 +406,13 @@ Rectangle {
388 // launch two main stage apps
406 // launch two main stage apps
389 // gallery will be on foreground and webbrowser on background
407 // gallery will be on foreground and webbrowser on background
390
408
391− var webbrowserSurfaceId = topSurfaceList.nextId;
409+ var webbrowserSurfaceId = launchApp("morph");
392− webbrowserCheckBox.checked = true;
393− waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
394 var webbrowserDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
410 var webbrowserDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
395 verify(webbrowserDelegate);
411 verify(webbrowserDelegate);
396 compare(webbrowserDelegate.stage, ApplicationInfoInterface.MainStage);
412 compare(webbrowserDelegate.stage, ApplicationInfoInterface.MainStage);
397 var webbrowserApp = ApplicationManager.findApplication(webbrowserCheckBox.appId);
413 var webbrowserApp = ApplicationManager.findApplication(webbrowserCheckBox.appId);
398
414
399− var gallerySurfaceId = topSurfaceList.nextId;
415+ var gallerySurfaceId = launchApp("gallery");
400− galleryCheckBox.checked = true;
401− waitUntilAppSurfaceShowsUp(gallerySurfaceId);
402 var galleryApp = ApplicationManager.findApplication(galleryCheckBox.appId);
416 var galleryApp = ApplicationManager.findApplication(galleryCheckBox.appId);
403 var galleryDelegate = findChild(stage, "appDelegate_" + gallerySurfaceId);
417 var galleryDelegate = findChild(stage, "appDelegate_" + gallerySurfaceId);
404 compare(galleryDelegate.stage, ApplicationInfoInterface.MainStage);
418 compare(galleryDelegate.stage, ApplicationInfoInterface.MainStage);
@@ -408,16 +422,12 @@ Rectangle {
408 // then launch two side stage apps
422 // then launch two side stage apps
409 // facebook will be on foreground and dialer on background
423 // facebook will be on foreground and dialer on background
410
424
411− var dialerSurfaceId = topSurfaceList.nextId;
425+ var dialerSurfaceId = launchApp("dialer");
412− dialerCheckBox.checked = true;
413− waitUntilAppSurfaceShowsUp(dialerSurfaceId);
414 var dialerApp = ApplicationManager.findApplication(dialerCheckBox.appId);
426 var dialerApp = ApplicationManager.findApplication(dialerCheckBox.appId);
415 var dialerDelegate = findChild(stage, "appDelegate_" + dialerSurfaceId);
427 var dialerDelegate = findChild(stage, "appDelegate_" + dialerSurfaceId);
416 compare(dialerDelegate.stage, ApplicationInfoInterface.SideStage);
428 compare(dialerDelegate.stage, ApplicationInfoInterface.SideStage);
417
429
418− var facebookSurfaceId = topSurfaceList.nextId;
430+ var facebookSurfaceId = launchApp("facebook");
419− facebookCheckBox.checked = true;
420− waitUntilAppSurfaceShowsUp(facebookSurfaceId);
421 var facebookApp = ApplicationManager.findApplication(facebookCheckBox.appId);
431 var facebookApp = ApplicationManager.findApplication(facebookCheckBox.appId);
422 var facebookDelegate = findChild(stage, "appDelegate_" + facebookSurfaceId);
432 var facebookDelegate = findChild(stage, "appDelegate_" + facebookSurfaceId);
423 compare(facebookDelegate.stage, ApplicationInfoInterface.SideStage);
433 compare(facebookDelegate.stage, ApplicationInfoInterface.SideStage);
@@ -450,16 +460,12 @@ Rectangle {
450 function test_foregroundAppsAreSuspendedWhenStageIsSuspended() {
460 function test_foregroundAppsAreSuspendedWhenStageIsSuspended() {
451 WindowStateStorage.saveStage(dialerCheckBox.appId, ApplicationInfoInterface.SideStage)
461 WindowStateStorage.saveStage(dialerCheckBox.appId, ApplicationInfoInterface.SideStage)
452
462
453− var webbrowserSurfaceId = topSurfaceList.nextId;
463+ var webbrowserSurfaceId = launchApp("morph");
454− webbrowserCheckBox.checked = true;
455− waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
456 var webbrowserApp = ApplicationManager.findApplication(webbrowserCheckBox.appId);
464 var webbrowserApp = ApplicationManager.findApplication(webbrowserCheckBox.appId);
457 var webbrowserDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
465 var webbrowserDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
458 compare(webbrowserDelegate.stage, ApplicationInfoInterface.MainStage);
466 compare(webbrowserDelegate.stage, ApplicationInfoInterface.MainStage);
459
467
460− var dialerSurfaceId = topSurfaceList.nextId;
468+ var dialerSurfaceId = launchApp("dialer");
461− dialerCheckBox.checked = true;
462− waitUntilAppSurfaceShowsUp(dialerSurfaceId);
463 var dialerApp = ApplicationManager.findApplication(dialerCheckBox.appId);
469 var dialerApp = ApplicationManager.findApplication(dialerCheckBox.appId);
464 var dialerDelegate = findChild(stage, "appDelegate_" + dialerSurfaceId);
470 var dialerDelegate = findChild(stage, "appDelegate_" + dialerSurfaceId);
465 compare(dialerDelegate.stage, ApplicationInfoInterface.SideStage);
471 compare(dialerDelegate.stage, ApplicationInfoInterface.SideStage);
@@ -520,7 +526,7 @@ Rectangle {
520 function test_applicationLoadsInDefaultStage_data() {
526 function test_applicationLoadsInDefaultStage_data() {
521 return [
527 return [
522 { tag: "MainStage", appId: "morph-browser", mainStageAppId: "morph-browser", sideStageAppId: "" },
528 { tag: "MainStage", appId: "morph-browser", mainStageAppId: "morph-browser", sideStageAppId: "" },
523− { tag: "SideStage", appId: "dialer-app", mainStageAppId: "unity8-dash", sideStageAppId: "dialer-app" },
529+ { tag: "SideStage", appId: "dialer-app", mainStageAppId: "facebook-webapp", sideStageAppId: "dialer-app" },
524 ];
530 ];
525 }
531 }
526
532
@@ -528,7 +534,9 @@ Rectangle {
528 var stagesPriv = findInvisibleChild(stage, "DesktopStagePrivate");
534 var stagesPriv = findInvisibleChild(stage, "DesktopStagePrivate");
529 verify(stagesPriv);
535 verify(stagesPriv);
530
536
537+ facebookCheckBox.checked = true;
538+
531− tryCompare(stagesPriv, "mainStageAppId", "unity8-dash");
539+ tryCompare(stagesPriv, "mainStageAppId", "facebook-webapp");
532 tryCompare(stagesPriv, "sideStageAppId", "");
540 tryCompare(stagesPriv, "sideStageAppId", "");
533
541
534 var appSurfaceId = topSurfaceList.nextId;
542 var appSurfaceId = topSurfaceList.nextId;
@@ -542,7 +550,7 @@ Rectangle {
542 function test_applicationLoadsInSavedStage_data() {
550 function test_applicationLoadsInSavedStage_data() {
543 return [
551 return [
544 { tag: "MainStage", stage: ApplicationInfoInterface.MainStage, mainStageAppId: "morph-browser", sideStageAppId: ""},
552 { tag: "MainStage", stage: ApplicationInfoInterface.MainStage, mainStageAppId: "morph-browser", sideStageAppId: ""},
545− { tag: "SideStage", stage: ApplicationInfoInterface.SideStage, mainStageAppId: "unity8-dash", sideStageAppId: "morph-browser" },
553+ { tag: "SideStage", stage: ApplicationInfoInterface.SideStage, mainStageAppId: "facebook-webapp", sideStageAppId: "morph-browser" },
546 ];
554 ];
547 }
555 }
548
556
@@ -552,12 +560,12 @@ Rectangle {
552 var stagesPriv = findInvisibleChild(stage, "DesktopStagePrivate");
560 var stagesPriv = findInvisibleChild(stage, "DesktopStagePrivate");
553 verify(stagesPriv);
561 verify(stagesPriv);
554
562
563+ facebookCheckBox.checked = true;
564+
555− tryCompare(stagesPriv, "mainStageAppId", "unity8-dash");
565+ tryCompare(stagesPriv, "mainStageAppId", "facebook-webapp");
556 tryCompare(stagesPriv, "sideStageAppId", "");
566 tryCompare(stagesPriv, "sideStageAppId", "");
557
567
558− var webbrowserSurfaceId = topSurfaceList.nextId;
568+ var webbrowserSurfaceId = launchApp("morph");
559− webbrowserCheckBox.checked = true;
560− waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
561
569
562 tryCompare(stagesPriv, "mainStageAppId", data.mainStageAppId);
570 tryCompare(stagesPriv, "mainStageAppId", data.mainStageAppId);
563 tryCompare(stagesPriv, "sideStageAppId", data.sideStageAppId);
571 tryCompare(stagesPriv, "sideStageAppId", data.sideStageAppId);
@@ -577,12 +585,12 @@ Rectangle {
577 var stagesPriv = findInvisibleChild(stage, "DesktopStagePrivate");
585 var stagesPriv = findInvisibleChild(stage, "DesktopStagePrivate");
578 verify(stagesPriv);
586 verify(stagesPriv);
579
587
588+ facebookCheckBox.checked = true;
589+
580− tryCompare(stagesPriv, "mainStageAppId", "unity8-dash");
590+ tryCompare(stagesPriv, "mainStageAppId", "facebook-webapp");
581 tryCompare(stagesPriv, "sideStageAppId", "");
591 tryCompare(stagesPriv, "sideStageAppId", "");
582
592
583− var webbrowserSurfaceId = topSurfaceList.nextId;
593+ var webbrowserSurfaceId = launchApp("morph");
584− webbrowserCheckBox.checked = true;
585− waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
586
594
587 if (data.toStage === ApplicationInfoInterface.SideStage) {
595 if (data.toStage === ApplicationInfoInterface.SideStage) {
588 dragToSideStage(webbrowserSurfaceId);
596 dragToSideStage(webbrowserSurfaceId);
@@ -597,10 +605,7 @@ Rectangle {
597
605
598 function test_loadSideStageByDraggingFromMainStage() {
606 function test_loadSideStageByDraggingFromMainStage() {
599 sideStage.showNow();
607 sideStage.showNow();
600− print("sidestage now shown. launching browser")
601− var webbrowserSurfaceId = topSurfaceList.nextId;
608+ var webbrowserSurfaceId = launchApp("morph")
602− webbrowserCheckBox.checked = true;
603− waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
604
609
605 var appDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
610 var appDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
606 verify(appDelegate);
611 verify(appDelegate);
@@ -619,9 +624,7 @@ Rectangle {
619 tryCompareFunction(function() {
624 tryCompareFunction(function() {
620 return WindowStateStorage.getStage(webbrowserCheckBox.appId, ApplicationInfoInterface.MainStage) === ApplicationInfoInterface.SideStage
625 return WindowStateStorage.getStage(webbrowserCheckBox.appId, ApplicationInfoInterface.MainStage) === ApplicationInfoInterface.SideStage
621 }, true);
626 }, true);
622− var webbrowserSurfaceId = topSurfaceList.nextId;
627+ var webbrowserSurfaceId = launchApp("morph");
623− webbrowserCheckBox.checked = true;
624− waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
625
628
626 var appDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
629 var appDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
627 verify(appDelegate);
630 verify(appDelegate);
@@ -643,18 +646,18 @@ Rectangle {
643 Application gets relaunched. Its new surface will seamlessly replace the screenshot.
646 Application gets relaunched. Its new surface will seamlessly replace the screenshot.
644 */
647 */
645 function test_selectSuspendedAppWithoutSurface() {
648 function test_selectSuspendedAppWithoutSurface() {
649+ launchApp("facebook");
646− compare(topSurfaceList.applicationAt(0).appId, "unity8-dash");
650+ compare(topSurfaceList.applicationAt(0).appId, "facebook-webapp");
647− var dashSurfaceId = topSurfaceList.idAt(0);
651+ var facebookSurfaceId = topSurfaceList.idAt(0);
648− var dashWindow = topSurfaceList.windowAt(0);
652+ var facebookWindow = topSurfaceList.windowAt(0);
649
653
650 var webbrowserSurfaceId = topSurfaceList.nextId;
654 var webbrowserSurfaceId = topSurfaceList.nextId;
651− webbrowserCheckBox.checked = true;
655+ launchApp("morph");
652− waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
653 var webbrowserApp = ApplicationManager.findApplication(webbrowserCheckBox.appId);
656 var webbrowserApp = ApplicationManager.findApplication(webbrowserCheckBox.appId);
654
657
655− switchToSurface(dashSurfaceId);
658+ switchToSurface(facebookSurfaceId);
656
659
657− tryCompare(topLevelSurfaceList, "focusedWindow", dashWindow);
660+ tryCompare(topLevelSurfaceList, "focusedWindow", facebookWindow);
658 tryCompare(webbrowserApp, "state", ApplicationInfoInterface.Suspended);
661 tryCompare(webbrowserApp, "state", ApplicationInfoInterface.Suspended);
659
662
660 compare(webbrowserApp.surfaceList.count, 1);
663 compare(webbrowserApp.surfaceList.count, 1);
@@ -679,9 +682,7 @@ Rectangle {
679 }
682 }
680
683
681 function test_draggingSurfaceKeepsSurfaceFocus() {
684 function test_draggingSurfaceKeepsSurfaceFocus() {
682− var webbrowserSurfaceId = topSurfaceList.nextId;
685+ var webbrowserSurfaceId = launchApp("morph");
683− webbrowserCheckBox.checked = true;
684− waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
685
686
686 var appDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
687 var appDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
687 verify(appDelegate);
688 verify(appDelegate);
@@ -695,34 +696,9 @@ Rectangle {
695 tryCompare(appDelegate, "stage", ApplicationInfoInterface.SideStage);
696 tryCompare(appDelegate, "stage", ApplicationInfoInterface.SideStage);
696 }
697 }
697
698
698− function test_dashDoesNotDragToSidestage() {
699− sideStage.showNow();
700− compare(topSurfaceList.applicationAt(0).appId, "unity8-dash");
701− var dashSurfaceId = topSurfaceList.idAt(0);
702−
703− var appDelegate = findChild(stage, "appDelegate_" + dashSurfaceId);
704− verify(appDelegate);
705− compare(appDelegate.stage, ApplicationInfoInterface.MainStage);
706−
707− var pos = stage.width - sideStage.width - (stage.width - sideStage.width) / 2;
708− var end_pos = stage.width - sideStage.width / 2;
709−
710− multiTouchDragUntil([0,1,2], stage, pos, stage.height / 2, units.gu(3), 0,
711− function() {
712− pos += units.gu(3);
713− return sideStage.shown && !sideStage.showAnimation.running &&
714− pos >= end_pos;
715− });
716−
717− waitForRendering(stage);
718− tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
719− }
720−
721 function test_switchRestoreStageOnRotation() {
699 function test_switchRestoreStageOnRotation() {
722 WindowStateStorage.saveStage(webbrowserCheckBox.appId, ApplicationInfoInterface.SideStage)
700 WindowStateStorage.saveStage(webbrowserCheckBox.appId, ApplicationInfoInterface.SideStage)
723− var webbrowserSurfaceId = topSurfaceList.nextId;
701+ var webbrowserSurfaceId = launchApp("morph");
724− webbrowserCheckBox.checked = true;
725− waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
726
702
727 var appDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
703 var appDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
728 verify(appDelegate);
704 verify(appDelegate);
@@ -739,9 +715,7 @@ Rectangle {
739 }
715 }
740
716
741 function test_restoreSavedStageOnCloseReopen() {
717 function test_restoreSavedStageOnCloseReopen() {
742− var webbrowserSurfaceId = topSurfaceList.nextId;
718+ var webbrowserSurfaceId = launchApp("morph");
743− webbrowserCheckBox.checked = true;
744− waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
745
719
746 var appDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
720 var appDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
747 verify(appDelegate);
721 verify(appDelegate);
@@ -752,14 +726,12 @@ Rectangle {
752 tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
726 tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
753
727
754 webbrowserCheckBox.checked = false;
728 webbrowserCheckBox.checked = false;
755− tryCompare(ApplicationManager, "count", 1);
729+ tryCompare(ApplicationManager, "count", 0);
756
730
757 // back to landscape
731 // back to landscape
758 stage.shellOrientation = Qt.LandscapeOrientation;
732 stage.shellOrientation = Qt.LandscapeOrientation;
759
733
760− webbrowserSurfaceId = topSurfaceList.nextId;
734+ webbrowserSurfaceId = launchApp("morph");
761− webbrowserCheckBox.checked = true;
762− waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
763
735
764 appDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
736 appDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
765 verify(appDelegate);
737 verify(appDelegate);
@@ -773,9 +745,8 @@ Rectangle {
773 the window (and not get eaten by some translucent decoration like in that bug).
745 the window (and not get eaten by some translucent decoration like in that bug).
774 */
746 */
775 function test_clickNearTopEdgeGoesToWindow() {
747 function test_clickNearTopEdgeGoesToWindow() {
776− compare(topLevelSurfaceList.count, 1); // assume unity8-dash is already there
748+ var facebookSurfaceId = launchApp("facebook");
777−
778− var appDelegate = findChild(stage, "appDelegate_" + topLevelSurfaceList.idAt(0));
749+ var appDelegate = findChild(stage, "appDelegate_" + facebookSurfaceId);
779 verify(appDelegate);
750 verify(appDelegate);
780
751
781 var surfaceItem = findChild(appDelegate, "surfaceItem");
752 var surfaceItem = findChild(appDelegate, "surfaceItem");
@@ -784,20 +755,20 @@ Rectangle {
784 compare(surfaceItem.mousePressCount, 0);
755 compare(surfaceItem.mousePressCount, 0);
785 compare(surfaceItem.mouseReleaseCount, 0);
756 compare(surfaceItem.mouseReleaseCount, 0);
786
757
787− mouseClick(appDelegate, 1, 1); // near top left
758+ mouseClick(surfaceItem, 1, 1); // near top left
788
759
789− compare(surfaceItem.mousePressCount, 1);
760+ tryCompare(surfaceItem, "mousePressCount", 1);
790− compare(surfaceItem.mouseReleaseCount, 1);
761+ tryCompare(surfaceItem, "mouseReleaseCount", 1);
791
762
792− mouseClick(appDelegate, appDelegate.width / 2, 1); // near top
763+ mouseClick(stage, appDelegate.width / 2, 1); // near top
793
764
794− compare(surfaceItem.mousePressCount, 2);
765+ tryCompare(surfaceItem, "mousePressCount", 2);
795− compare(surfaceItem.mouseReleaseCount, 2);
766+ tryCompare(surfaceItem, "mouseReleaseCount", 2);
796
767
797− mouseClick(appDelegate, appDelegate.width - 1, 1); // near top right
768+ mouseClick(stage, appDelegate.width - 1, 1); // near top right
798
769
799− compare(surfaceItem.mousePressCount, 3);
770+ tryCompare(surfaceItem, "mousePressCount", 3);
800− compare(surfaceItem.mouseReleaseCount, 3);
771+ tryCompare(surfaceItem, "mouseReleaseCount", 3);
801 }
772 }
802 }
773 }
803}
774}