@@ -36,7 +36,7 @@ Rectangle {
3636 property var greeter: { fullyShown: true }
3737
3838 Stage {
39− id: tabletStage
39+ id: stage
4040 anchors { fill: parent; rightMargin: units.gu(30) }
4141 dragAreaWidth: units.gu(2)
4242 maximizedAppTopMargin: units.gu(3)
@@ -67,7 +67,7 @@ Rectangle {
6767 right: parent.right
6868 }
6969
70− // don't let mouse clicks in the controls area disturb the TabletStage behind it
70+ // don't let mouse clicks in the controls area disturb the Stage behind it
7171 MouseArea { anchors.fill: parent }
7272
7373 Column {
@@ -78,9 +78,9 @@ Rectangle {
7878 id: edgeBarrierControls
7979 text: "Drag here to pull out spread"
8080 backgroundColor: "blue"
81− onDragged: { tabletStage.pushRightEdge(amount); }
81+ onDragged: { stage.pushRightEdge(amount); }
8282 Component.onCompleted: {
83− edgeBarrierControls.target = testCase.findChild(tabletStage, "edgeBarrierController");
83+ edgeBarrierControls.target = testCase.findChild(stage, "edgeBarrierController");
8484 }
8585 }
8686
@@ -123,8 +123,8 @@ Rectangle {
123123 name: "TabletStage"
124124 when: windowShown
125125
126− readonly property alias topSurfaceList: tabletStage.topLevelSurfaceList
127− property Item sideStage: tabletStage ? findChild(tabletStage, "sideStage") : null
126+ readonly property alias topSurfaceList: stage.topLevelSurfaceList
127+ property Item sideStage: stage ? findChild(stage, "sideStage") : null
128128
129129 function init() {
130130 stageSaver.clear();
@@ -133,23 +133,40 @@ Rectangle {
133133 compare(topSurfaceList.applicationAt(0).appId, "unity8-dash");
134134
135135 // this is very strange, but sometimes the test starts without
136− // TabletStage components having finished loading themselves
136+ // Stage components having finished loading themselves
137137 var appWindow = null
138138 while (!appWindow) {
139139 appWindow = findAppWindowForSurfaceId(topSurfaceList.idAt(0));
140140 if (!appWindow) {
141− console.log("didn't find unity8-dash appWindow in " + tabletStage + ". Trying again...");
141+ console.log("didn't find unity8-dash appWindow in Stage. Trying again...");
142142 wait(50);
143143 }
144144 }
145145
146146 waitUntilAppSurfaceShowsUp(topSurfaceList.idAt(0));
147147 sideStage.hideNow()
148+ tryCompare(sideStage, "x", stage.width)
148149 }
149150
150151 function cleanup() {
152+ ApplicationManager.requestFocusApplication("unity8-dash");
153+ tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
154+ tryCompare(stage, "state", "stagedWithSideStage");
155+ waitForRendering(stage);
156+
151157 killApps();
158+
159+ // wait for Stage to stabilize back into its initial state
160+ var appRepeater = findChild(stage, "appRepeater");
161+ tryCompare(appRepeater, "count", 1);
162+ tryCompare(appRepeater.itemAt(0), "x", 0);
163+
164+ sideStage.hideNow();
165+ tryCompare(sideStage, "x", stage.width)
166+ waitForRendering(stage)
167+
152168 WindowStateStorage.clear();
169+ wait(100)
153170 }
154171
155172 function waitUntilAppSurfaceShowsUp(surfaceId) {
@@ -161,7 +178,7 @@ Rectangle {
161178 }
162179
163180 function findAppWindowForSurfaceId(surfaceId) {
164− var spreadDelegate = findChild(tabletStage, "appDelegate_" + surfaceId);
181+ var spreadDelegate = findChild(stage, "appDelegate_" + surfaceId);
165182 if (!spreadDelegate) {
166183 return null;
167184 }
@@ -180,7 +197,7 @@ Rectangle {
180197
181198 function waitUntilAppDelegateStopsMoving(targetSurfaceId)
182199 {
183− var targetAppDelegate = findChild(tabletStage, "appDelegate_" + targetSurfaceId);
200+ var targetAppDelegate = findChild(stage, "appDelegate_" + targetSurfaceId);
184201 verify(targetAppDelegate);
185202 var lastValue = undefined;
186203 do {
@@ -190,15 +207,9 @@ Rectangle {
190207 }
191208
192209 function performEdgeSwipeToShowAppSpread() {
193− touchFlick(tabletStage,
194− tabletStage.width - (tabletStage.dragAreaWidth / 2), tabletStage.height / 2,
195− tabletStage.x + 1, tabletStage.height / 2);
210+ touchFlick(stage, stage.width - (stage.dragAreaWidth / 2), stage.height / 2, stage.x + 1, stage.height / 2);
196211
197− var spreadView = findChild(tabletStage, "spreadView");
198− verify(spreadView);
199− tryCompare(spreadView, "phase", 2);
200− tryCompare(spreadView, "flicking", false);
201− tryCompare(spreadView, "moving", false);
212+ tryCompare(stage, "state", "spread");
202213 }
203214
204215 function swipeSurfaceUpwards(surfaceId) {
@@ -214,17 +225,12 @@ Rectangle {
214225
215226 function dragToSideStage(surfaceId) {
216227 sideStage.showNow();
217− var targetAppDelegate = findChild(tabletStage, "appDelegate_" + surfaceId);
228+ var targetAppDelegate = findChild(stage, "appDelegate_" + surfaceId);
218229
219− var pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
220− var end_pos = tabletStage.width - sideStage.width / 2;
230+ var pos = stage.width - sideStage.width - (stage.width - sideStage.width) / 2;
231+ var end_pos = stage.width - sideStage.width / 2;
221232
222− multiTouchDragUntil([0,1,2],
223− tabletStage,
224− pos,
225− tabletStage.height / 2,
226− units.gu(3),
227− 0,
233+ multiTouchDragUntil([0,1,2], stage, pos, stage.height / 2, units.gu(3), 0,
228234 function() {
229235 pos += units.gu(3);
230236 return sideStage.shown && !sideStage.showAnimation.running &&
@@ -235,16 +241,16 @@ Rectangle {
235241
236242 function dragToMainStage(surfaceId) {
237243 sideStage.showNow();
238− var targetAppDelegate = findChild(tabletStage, "appDelegate_" + surfaceId);
244+ var targetAppDelegate = findChild(stage, "appDelegate_" + surfaceId);
239245 verify(targetAppDelegate);
240246
241− var pos = tabletStage.width - sideStage.width / 2;
242− var end_pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
247+ var pos = stage.width - sideStage.width / 2;
248+ var end_pos = stage.width - sideStage.width - (stage.width - sideStage.width) / 2;
243249
244250 multiTouchDragUntil([0,1,2],
245− tabletStage,
251+ stage,
246252 pos,
247− tabletStage.height / 2,
253+ stage.height / 2,
248254 -units.gu(3),
249255 0,
250256 function() {
@@ -260,7 +266,7 @@ Rectangle {
260266 var webbrowserSurfaceId = topSurfaceList.nextId;
261267 webbrowserCheckBox.checked = true;
262268 waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
263− var webbrowserDelegate = findChild(tabletStage, "appDelegate_" + webbrowserSurfaceId);
269+ var webbrowserDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
264270 verify(webbrowserDelegate);
265271 compare(webbrowserDelegate.stage, ApplicationInfoInterface.MainStage);
266272 var webbrowserWindow = findAppWindowForSurfaceId(webbrowserSurfaceId);
@@ -273,7 +279,7 @@ Rectangle {
273279 waitUntilAppSurfaceShowsUp(dialerSurfaceId);
274280
275281 var dialerApp = ApplicationManager.findApplication(dialerCheckBox.appId);
276− var dialerDelegate = findChild(tabletStage, "appDelegate_" + dialerSurfaceId);
282+ var dialerDelegate = findChild(stage, "appDelegate_" + dialerSurfaceId);
277283 verify(dialerDelegate);
278284 compare(dialerDelegate.stage, ApplicationInfoInterface.SideStage);
279285
@@ -306,17 +312,18 @@ Rectangle {
306312
307313 performEdgeSwipeToShowAppSpread();
308314
309− var appDelegate = findChild(tabletStage, "appDelegate_" + dialerSurfaceId);
310− verify(appDelegate);
315+ var appDelegate = findChild(stage, "appDelegate_" + dialerSurfaceId);
316+ var dragArea = findChild(appDelegate, "dragArea");
317+ verify(dragArea);
311318 compare(appDelegate.stage, ApplicationInfoInterface.SideStage);
312− tryCompare(appDelegate, "swipeToCloseEnabled", true);
319+ tryCompare(dragArea, "closeable", true);
313320
314321 swipeSurfaceUpwards(dialerSurfaceId);
315322
316323 // Check that dialer-app has been closed
317324
318325 tryCompareFunction(function() {
319− return findChild(tabletStage, "appWindow_" + dialerCheckBox.appId);
326+ return findChild(stage, "appWindow_" + dialerCheckBox.appId);
320327 }, null);
321328
322329 tryCompareFunction(function() {
@@ -329,7 +336,7 @@ Rectangle {
329336 webbrowserCheckBox.checked = true;
330337 waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
331338 var webbrowserApp = ApplicationManager.findApplication(webbrowserCheckBox.appId);
332− var webbrowserDelegate = findChild(tabletStage, "appDelegate_" + webbrowserSurfaceId);
339+ var webbrowserDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
333340 compare(webbrowserDelegate.stage, ApplicationInfoInterface.MainStage);
334341
335342 tryCompare(webbrowserApp, "state", ApplicationInfoInterface.Running);
@@ -338,7 +345,7 @@ Rectangle {
338345 galleryCheckBox.checked = true;
339346 waitUntilAppSurfaceShowsUp(gallerySurfaceId);
340347 var galleryApp = ApplicationManager.findApplication(galleryCheckBox.appId);
341− var galleryDelegate = findChild(tabletStage, "appDelegate_" + gallerySurfaceId);
348+ var galleryDelegate = findChild(stage, "appDelegate_" + gallerySurfaceId);
342349 compare(galleryDelegate.stage, ApplicationInfoInterface.MainStage);
343350
344351 tryCompare(galleryApp, "state", ApplicationInfoInterface.Running);
@@ -359,7 +366,7 @@ Rectangle {
359366 WindowStateStorage.saveStage(facebookCheckBox.appId, ApplicationInfoInterface.SideStage)
360367 WindowStateStorage.saveStage(dialerCheckBox.appId, ApplicationInfoInterface.SideStage)
361368
362− var stagesPriv = findInvisibleChild(tabletStage, "DesktopStagePrivate");
369+ var stagesPriv = findInvisibleChild(stage, "DesktopStagePrivate");
363370 verify(stagesPriv);
364371
365372 // launch two main stage apps
@@ -368,7 +375,7 @@ Rectangle {
368375 var webbrowserSurfaceId = topSurfaceList.nextId;
369376 webbrowserCheckBox.checked = true;
370377 waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
371− var webbrowserDelegate = findChild(tabletStage, "appDelegate_" + webbrowserSurfaceId);
378+ var webbrowserDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
372379 verify(webbrowserDelegate);
373380 compare(webbrowserDelegate.stage, ApplicationInfoInterface.MainStage);
374381 var webbrowserApp = ApplicationManager.findApplication(webbrowserCheckBox.appId);
@@ -377,7 +384,7 @@ Rectangle {
377384 galleryCheckBox.checked = true;
378385 waitUntilAppSurfaceShowsUp(gallerySurfaceId);
379386 var galleryApp = ApplicationManager.findApplication(galleryCheckBox.appId);
380− var galleryDelegate = findChild(tabletStage, "appDelegate_" + gallerySurfaceId);
387+ var galleryDelegate = findChild(stage, "appDelegate_" + gallerySurfaceId);
381388 compare(galleryDelegate.stage, ApplicationInfoInterface.MainStage);
382389
383390 compare(stagesPriv.mainStageAppId, galleryCheckBox.appId);
@@ -389,14 +396,14 @@ Rectangle {
389396 dialerCheckBox.checked = true;
390397 waitUntilAppSurfaceShowsUp(dialerSurfaceId);
391398 var dialerApp = ApplicationManager.findApplication(dialerCheckBox.appId);
392− var dialerDelegate = findChild(tabletStage, "appDelegate_" + dialerSurfaceId);
399+ var dialerDelegate = findChild(stage, "appDelegate_" + dialerSurfaceId);
393400 compare(dialerDelegate.stage, ApplicationInfoInterface.SideStage);
394401
395402 var facebookSurfaceId = topSurfaceList.nextId;
396403 facebookCheckBox.checked = true;
397404 waitUntilAppSurfaceShowsUp(facebookSurfaceId);
398405 var facebookApp = ApplicationManager.findApplication(facebookCheckBox.appId);
399− var facebookDelegate = findChild(tabletStage, "appDelegate_" + facebookSurfaceId);
406+ var facebookDelegate = findChild(stage, "appDelegate_" + facebookSurfaceId);
400407 compare(facebookDelegate.stage, ApplicationInfoInterface.SideStage);
401408
402409 compare(stagesPriv.sideStageAppId, facebookCheckBox.appId);
@@ -431,40 +438,31 @@ Rectangle {
431438 webbrowserCheckBox.checked = true;
432439 waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
433440 var webbrowserApp = ApplicationManager.findApplication(webbrowserCheckBox.appId);
434− var webbrowserDelegate = findChild(tabletStage, "appDelegate_" + webbrowserSurfaceId);
441+ var webbrowserDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
435442 compare(webbrowserDelegate.stage, ApplicationInfoInterface.MainStage);
436443
437444 var dialerSurfaceId = topSurfaceList.nextId;
438445 dialerCheckBox.checked = true;
439446 waitUntilAppSurfaceShowsUp(dialerSurfaceId);
440447 var dialerApp = ApplicationManager.findApplication(dialerCheckBox.appId);
441− var dialerDelegate = findChild(tabletStage, "appDelegate_" + dialerSurfaceId);
448+ var dialerDelegate = findChild(stage, "appDelegate_" + dialerSurfaceId);
442449 compare(dialerDelegate.stage, ApplicationInfoInterface.SideStage);
443450
444451
445452 compare(webbrowserApp.requestedState, ApplicationInfoInterface.RequestedRunning);
446453 compare(dialerApp.requestedState, ApplicationInfoInterface.RequestedRunning);
447454
448− tabletStage.suspended = true;
455+ stage.suspended = true;
449456
450457 tryCompare(webbrowserApp, "requestedState", ApplicationInfoInterface.RequestedSuspended);
451458 tryCompare(dialerApp, "requestedState", ApplicationInfoInterface.RequestedSuspended);
452459
453− tabletStage.suspended = false;
460+ stage.suspended = false;
454461
455462 tryCompare(webbrowserApp, "requestedState", ApplicationInfoInterface.RequestedRunning);
456463 tryCompare(dialerApp, "requestedState", ApplicationInfoInterface.RequestedRunning);
457464 }
458465
459− function test_mouseEdgePush() {
460− var spreadView = findChild(tabletStageLoader, "spreadView")
461− mouseMove(tabletStageLoader, tabletStageLoader.width - 1, units.gu(10));
462− for (var i = 0; i < units.gu(10); i++) {
463− tabletStageLoader.item.pushRightEdge(1);
464− }
465− tryCompare(spreadView, "phase", 2);
466− }
467−
468466 function test_threeFingerTapOpensSideStage_data() {
469467 return [
470468 { tag: "1 finger", touchIds: [0], result: false },
@@ -475,7 +473,7 @@ Rectangle {
475473 }
476474
477475 function test_threeFingerTapOpensSideStage(data) {
478− multiTouchTap(data.touchIds, tabletStage, tabletStage.width / 2, tabletStage.height / 2);
476+ multiTouchTap(data.touchIds, stage, stage.width / 2, stage.height / 2);
479477 wait(200);
480478 tryCompare(sideStage, "shown", data.result);
481479 }
@@ -493,18 +491,13 @@ Rectangle {
493491 function test_threeFingerTapClosesSideStage(data) {
494492 sideStage.showNow();
495493
496− multiTouchTap(data.touchIds, tabletStage, tabletStage.width / 2, tabletStage.height / 2);
494+ multiTouchTap(data.touchIds, stage, stage.width / 2, stage.height / 2);
497495 wait(200);
498496 tryCompare(sideStage, "shown", data.result);
499497 }
500498
501499 function test_threeFingerDragOpensSidestage() {
502− multiTouchDragUntil([0,1,2],
503− tabletStage,
504− tabletStage.width / 4,
505− tabletStage.height / 4,
506− units.gu(1),
507− 0,
500+ multiTouchDragUntil([0,1,2], stage, stage.width / 4, stage.height / 4, units.gu(1), 0,
508501 function() { return sideStage.shown; });
509502 }
510503
@@ -516,7 +509,7 @@ Rectangle {
516509 }
517510
518511 function test_applicationLoadsInDefaultStage(data) {
519− var stagesPriv = findInvisibleChild(tabletStage, "DesktopStagePrivate");
512+ var stagesPriv = findInvisibleChild(stage, "DesktopStagePrivate");
520513 verify(stagesPriv);
521514
522515 tryCompare(stagesPriv, "mainStageAppId", "unity8-dash");
@@ -540,7 +533,7 @@ Rectangle {
540533 function test_applicationLoadsInSavedStage(data) {
541534 WindowStateStorage.saveStage(webbrowserCheckBox.appId, data.stage)
542535
543− var stagesPriv = findInvisibleChild(tabletStage, "DesktopStagePrivate");
536+ var stagesPriv = findInvisibleChild(stage, "DesktopStagePrivate");
544537 verify(stagesPriv);
545538
546539 tryCompare(stagesPriv, "mainStageAppId", "unity8-dash");
@@ -565,7 +558,7 @@ Rectangle {
565558 WindowStateStorage.saveStage(webbrowserCheckBox.appId, data.fromStage);
566559 stageSaver.clear();
567560
568− var stagesPriv = findInvisibleChild(tabletStage, "DesktopStagePrivate");
561+ var stagesPriv = findInvisibleChild(stage, "DesktopStagePrivate");
569562 verify(stagesPriv);
570563
571564 tryCompare(stagesPriv, "mainStageAppId", "unity8-dash");
@@ -588,17 +581,21 @@ Rectangle {
588581
589582 function test_loadSideStageByDraggingFromMainStage() {
590583 sideStage.showNow();
584+ print("sidestage now shown. launching browser")
591585 var webbrowserSurfaceId = topSurfaceList.nextId;
592586 webbrowserCheckBox.checked = true;
593587 waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
594588
595− var appDelegate = findChild(tabletStage, "appDelegate_" + webbrowserSurfaceId);
589+ print("browser should be focused now")
590+ return;
591+ wait(10000)
592+ var appDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
596593 verify(appDelegate);
597594 compare(appDelegate.stage, ApplicationInfoInterface.MainStage);
598595
599596 dragToSideStage(webbrowserSurfaceId);
600597
601− var spreadView = findChild(tabletStageLoader, "spreadView")
598+ var spreadView = findChild(stageLoader, "spreadView")
602599 tryCompare(spreadView, "surfaceDragging", false);
603600 tryCompare(appDelegate, "stage", ApplicationInfoInterface.SideStage);
604601 }
@@ -610,45 +607,15 @@ Rectangle {
610607 webbrowserCheckBox.checked = true;
611608 waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
612609
613− var appDelegate = findChild(tabletStage, "appDelegate_" + webbrowserSurfaceId);
610+ var appDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
614611 verify(appDelegate);
615612 compare(appDelegate.stage, ApplicationInfoInterface.SideStage);
616613
617614 dragToMainStage(webbrowserSurfaceId);
618615
619− var spreadView = findChild(tabletStageLoader, "spreadView")
620− tryCompare(spreadView, "surfaceDragging", false);
621616 tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
622617 }
623618
624− function test_closeSurfaceOfMultiSurfaceApp() {
625− var surface1Id = topSurfaceList.nextId;
626− webbrowserCheckBox.checked = true;
627− waitUntilAppSurfaceShowsUp(surface1Id);
628− var webbrowserApp = ApplicationManager.findApplication(webbrowserCheckBox.appId);
629−
630− var surface2Id = topSurfaceList.nextId;
631− verify(surface1Id !== surface2Id); // sanity checking
632− webbrowserCheckBox.createSurface();
633− waitUntilAppSurfaceShowsUp(surface2Id);
634−
635− performEdgeSwipeToShowAppSpread();
636−
637− var appDelegate = findChild(tabletStage, "appDelegate_" + surface1Id);
638− verify(appDelegate);
639− tryCompare(appDelegate, "swipeToCloseEnabled", true);
640−
641− compare(webbrowserApp.surfaceList.count, 2);
642− compare(webbrowserApp.state, ApplicationInfoInterface.Running);
643−
644− swipeSurfaceUpwards(surface1Id);
645−
646− // Surface must eventually be gone
647− tryCompareFunction(function() { return topSurfaceList.indexForId(surface1Id); }, -1);
648− tryCompare(webbrowserApp.surfaceList, "count", 1);
649− compare(webbrowserApp.state, ApplicationInfoInterface.Running);
650− }
651−
652619 /*
653620 1- Suspended app gets killed behind the scenes, causing its surface to go zombie.
654621 2- Surface gets screenshotted and removed. Its slot in the topSurfaceList remains,
@@ -694,64 +661,12 @@ Rectangle {
694661 compare(webbrowserApp.surfaceList.count, 1);
695662 }
696663
697− /*
698− 1 - user suspends an application (ie, focus a surface from a different application)
699− 2 - That suspended application gets killed, causing its surface to go zombie
700− 3 - user goes to spread and closes that zombie surface. Actually, by that time
701− Tablet shell will be displaying a screenshot of it instead, so there's no
702− MirSurface whatsoever backing it up.
703− */
704− function test_closeZombieSurface()
705− {
706− compare(topSurfaceList.applicationAt(0).appId, "unity8-dash");
707− var dashSurfaceId = topSurfaceList.idAt(0);
708− var dashSurface = topSurfaceList.surfaceAt(0);
709−
710− var webbrowserSurfaceId = topSurfaceList.nextId;
711− webbrowserCheckBox.checked = true;
712− waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
713− var webbrowserApp = ApplicationManager.findApplication(webbrowserCheckBox.appId);
714−
715− switchToSurface(dashSurfaceId);
716−
717− tryCompare(MirFocusController, "focusedSurface", dashSurface);
718− tryCompare(webbrowserApp, "state", ApplicationInfoInterface.Suspended);
719−
720− compare(webbrowserApp.surfaceList.count, 1);
721−
722− // simulate the suspended app being killed by the out-of-memory daemon
723− webbrowserApp.surfaceList.get(0).setLive(false);
724−
725− // wait until the surface is gone
726− tryCompare(webbrowserApp.surfaceList, "count", 0);
727− compare(topSurfaceList.surfaceAt(topSurfaceList.indexForId(webbrowserSurfaceId)), null);
728−
729− performEdgeSwipeToShowAppSpread();
730−
731− {
732− var appDelegate = findChild(tabletStage, "appDelegate_" + webbrowserSurfaceId);
733− verify(appDelegate);
734− tryCompare(appDelegate, "swipeToCloseEnabled", true);
735− }
736−
737− swipeSurfaceUpwards(webbrowserSurfaceId);
738−
739− // webbrowser entry is nowhere to be seen
740− tryCompareFunction(function(){return topSurfaceList.indexForId(webbrowserSurfaceId);}, -1);
741−
742− // nor is its app
743− compare(ApplicationManager.findApplication(webbrowserCheckBox.appId), null);
744−
745− // only unity8-dash surface is left
746− compare(topSurfaceList.count, 1);
747− }
748−
749664 function test_draggingSurfaceKeepsSurfaceFocus() {
750665 var webbrowserSurfaceId = topSurfaceList.nextId;
751666 webbrowserCheckBox.checked = true;
752667 waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
753668
754− var appDelegate = findChild(tabletStage, "appDelegate_" + webbrowserSurfaceId);
669+ var appDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
755670 verify(appDelegate);
756671 compare(appDelegate.stage, ApplicationInfoInterface.MainStage);
757672
@@ -759,9 +674,8 @@ Rectangle {
759674
760675 dragToSideStage(webbrowserSurfaceId);
761676
762− var spreadView = findChild(tabletStageLoader, "spreadView")
763− tryCompare(spreadView, "surfaceDragging", false);
764677 tryCompare(appDelegate.surface, "activeFocus", true);
678+ tryCompare(appDelegate, "stage", ApplicationInfoInterface.SideStage);
765679 }
766680
767681 function test_dashDoesNotDragToSidestage() {
@@ -769,59 +683,41 @@ Rectangle {
769683 compare(topSurfaceList.applicationAt(0).appId, "unity8-dash");
770684 var dashSurfaceId = topSurfaceList.idAt(0);
771685
772− var appDelegate = findChild(tabletStage, "appDelegate_" + dashSurfaceId);
686+ var appDelegate = findChild(stage, "appDelegate_" + dashSurfaceId);
773687 verify(appDelegate);
774688 compare(appDelegate.stage, ApplicationInfoInterface.MainStage);
775689
776− var pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
777− var end_pos = tabletStage.width - sideStage.width / 2;
690+ var pos = stage.width - sideStage.width - (stage.width - sideStage.width) / 2;
691+ var end_pos = stage.width - sideStage.width / 2;
778692
779− multiTouchDragUntil([0,1,2],
780− tabletStage,
781− pos,
782− tabletStage.height / 2,
783− units.gu(3),
784− 0,
693+ multiTouchDragUntil([0,1,2], stage, pos, stage.height / 2, units.gu(3), 0,
785694 function() {
786695 pos += units.gu(3);
787696 return sideStage.shown && !sideStage.showAnimation.running &&
788697 pos >= end_pos;
789698 });
790699
791− var spreadView = findChild(tabletStageLoader, "spreadView")
792− tryCompare(spreadView, "surfaceDragging", false);
700+ waitForRendering(stage);
793701 tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
794702 }
795703
796− function test_switchStageOnRotation() {
704+ function test_switchRestoreStageOnRotation() {
797705 WindowStateStorage.saveStage(webbrowserCheckBox.appId, ApplicationInfoInterface.SideStage)
798706 var webbrowserSurfaceId = topSurfaceList.nextId;
799707 webbrowserCheckBox.checked = true;
800708 waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
801709
802− var appDelegate = findChild(tabletStage, "appDelegate_" + webbrowserSurfaceId);
710+ var appDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
803711 verify(appDelegate);
804712 compare(appDelegate.stage, ApplicationInfoInterface.SideStage);
805713
806− tabletStage.shellOrientation = Qt.PortraitOrientation;
807− tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
808− }
809−
810− function test_restoreOriginalStageOnRotation() {
811− var webbrowserSurfaceId = topSurfaceList.nextId;
812− webbrowserCheckBox.checked = true;
813− waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
814−
815− var appDelegate = findChild(tabletStage, "appDelegate_" + webbrowserSurfaceId);
816− verify(appDelegate);
817−
818714 dragToSideStage(webbrowserSurfaceId);
819715
820716 // will be in sidestage now
821− tabletStage.shellOrientation = Qt.PortraitOrientation;
717+ stage.shellOrientation = Qt.PortraitOrientation;
822718 tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
823719
824− tabletStage.shellOrientation = Qt.LandscapeOrientation;
720+ stage.shellOrientation = Qt.LandscapeOrientation;
825721 tryCompare(appDelegate, "stage", ApplicationInfoInterface.SideStage);
826722 }
827723
@@ -830,25 +726,25 @@ Rectangle {
830726 webbrowserCheckBox.checked = true;
831727 waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
832728
833− var appDelegate = findChild(tabletStage, "appDelegate_" + webbrowserSurfaceId);
729+ var appDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
834730 verify(appDelegate);
835731
836732 dragToSideStage(webbrowserSurfaceId);
837733 // will be in sidestage now
838− tabletStage.shellOrientation = Qt.PortraitOrientation;
734+ stage.shellOrientation = Qt.PortraitOrientation;
839735 tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
840736
841737 webbrowserCheckBox.checked = false;
842738 tryCompare(ApplicationManager, "count", 1);
843739
844740 // back to landscape
845− tabletStage.shellOrientation = Qt.LandscapeOrientation;
741+ stage.shellOrientation = Qt.LandscapeOrientation;
846742
847743 webbrowserSurfaceId = topSurfaceList.nextId;
848744 webbrowserCheckBox.checked = true;
849745 waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
850746
851− appDelegate = findChild(tabletStage, "appDelegate_" + webbrowserSurfaceId);
747+ appDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
852748 verify(appDelegate);
853749 tryCompare(appDelegate, "stage", ApplicationInfoInterface.SideStage);
854750 }