@@ -39,6 +39,8 @@ Rectangle {
3939 width: units.gu(160) + controls.width
4040 height: units.gu(100)
4141
42+ property var tryShell: null
43+
4244 Binding {
4345 target: LightDMController
4446 property: "userMode"
@@ -93,7 +95,7 @@ Rectangle {
9395 State {
9496 name: "mako"
9597 PropertyChanges {
96− target: orientedShellLoader
98+ target: shellRect
9799 width: units.gu(40)
98100 height: units.gu(71)
99101 }
@@ -109,7 +111,7 @@ Rectangle {
109111 State {
110112 name: "manta"
111113 PropertyChanges {
112− target: orientedShellLoader
114+ target: shellRect
113115 width: units.gu(160)
114116 height: units.gu(60)
115117 }
@@ -125,7 +127,7 @@ Rectangle {
125127 State {
126128 name: "flo"
127129 PropertyChanges {
128− target: orientedShellLoader
130+ target: shellRect
129131 width: units.gu(60)
130132 height: units.gu(100)
131133 }
@@ -141,7 +143,7 @@ Rectangle {
141143 State {
142144 name: "desktop"
143145 PropertyChanges {
144− target: orientedShellLoader
146+ target: shellRect
145147 width: units.gu(100)
146148 height: units.gu(65)
147149 }
@@ -156,26 +158,21 @@ Rectangle {
156158 }
157159 ]
158160
159− Loader {
160− id: orientedShellLoader
161+ Component {
162+ id: shellComponent
163+ OrientedShell {
164+ anchors.fill: parent
165+ physicalOrientation: root.physicalOrientation0
166+ orientationLocked: orientationLockedCheckBox.checked
167+ orientationLock: mockOrientationLock
168+ }
169+ }
161170
171+ Rectangle {
172+ id: shellRect
173+ color: "black"
162174 x: ((root.width - controls.width) - width) / 2
163175 y: (root.height - height) / 2
164−
165− focus: true
166−
167− property bool itemDestroyed: false
168− sourceComponent: Component {
169− OrientedShell {
170− anchors.fill: parent
171− physicalOrientation: root.physicalOrientation0
172− orientationLocked: orientationLockedCheckBox.checked
173− orientationLock: mockOrientationLock
174− Component.onDestruction: {
175− orientedShellLoader.itemDestroyed = true;
176− }
177− }
178− }
179176 }
180177
181178 function orientationsToStr(orientations) {
@@ -224,11 +221,19 @@ Rectangle {
224221 id: controlsColumn
225222 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
226223 spacing: units.gu(1)
224+
225+ Button {
226+ text: "Load shell"
227+ onClicked: {
228+ createTryShell();
229+ }
230+ }
231+
227232 Button {
228233 text: "Show Greeter"
229234 activeFocusOnPress: false
230235 onClicked: {
231− if (orientedShellLoader.status !== Loader.Ready)
236+ if (tryShell === null)
232237 return;
233238
234239 LightDM.Greeter.showGreeter();
@@ -241,10 +246,8 @@ Rectangle {
241246 id: rotate0Button
242247 text: root.orientationsToStr(root.physicalOrientation0) + " (0)"
243248 activeFocusOnPress: false
244− onClicked: {
245− orientedShellLoader.item.physicalOrientation = root.physicalOrientation0;
246− }
247− color: orientedShellLoader.item && orientedShellLoader.item.physicalOrientation === root.physicalOrientation0 ?
249+ onClicked: rotate0(tryShell)
250+ color: tryShell && tryShell.physicalOrientation === root.physicalOrientation0 ?
248251 UbuntuColors.green :
249252 __styleInstance.defaultColor
250253 }
@@ -252,10 +255,8 @@ Rectangle {
252255 id: rotate90Button
253256 text: root.orientationsToStr(root.physicalOrientation90) + " (90)"
254257 activeFocusOnPress: false
255− onClicked: {
256− orientedShellLoader.item.physicalOrientation = root.physicalOrientation90;
257− }
258− color: orientedShellLoader.item && orientedShellLoader.item.physicalOrientation === root.physicalOrientation90 ?
258+ onClicked: rotate90(tryShell)
259+ color: tryShell && tryShell.physicalOrientation === root.physicalOrientation90 ?
259260 UbuntuColors.green :
260261 __styleInstance.defaultColor
261262 }
@@ -263,10 +264,8 @@ Rectangle {
263264 id: rotate180Button
264265 text: root.orientationsToStr(root.physicalOrientation180) + " (180)"
265266 activeFocusOnPress: false
266− onClicked: {
267− orientedShellLoader.item.physicalOrientation = root.physicalOrientation180;
268− }
269− color: orientedShellLoader.item && orientedShellLoader.item.physicalOrientation === root.physicalOrientation180 ?
267+ onClicked: rotate180(tryShell)
268+ color: tryShell && tryShell.physicalOrientation === root.physicalOrientation180 ?
270269 UbuntuColors.green :
271270 __styleInstance.defaultColor
272271 }
@@ -274,10 +273,8 @@ Rectangle {
274273 id: rotate270Button
275274 text: root.orientationsToStr(root.physicalOrientation270) + " (270)"
276275 activeFocusOnPress: false
277− onClicked: {
278− orientedShellLoader.item.physicalOrientation = root.physicalOrientation270;
279− }
280− color: orientedShellLoader.item && orientedShellLoader.item.physicalOrientation === root.physicalOrientation270 ?
276+ onClicked: rotate270(tryShell)
277+ color: tryShell && tryShell.physicalOrientation === root.physicalOrientation270 ?
281278 UbuntuColors.green :
282279 __styleInstance.defaultColor
283280 }
@@ -289,14 +286,15 @@ Rectangle {
289286 activeFocusOnPress: false
290287 }
291288 Label {
289+ Layout.fillWidth: true
290+ Layout.fillHeight: true
292291 text: "Orientation Locked"
293− anchors.verticalCenter: parent.verticalCenter
294292 }
295293 }
296294 Button {
297295 text: "Power dialog"
298296 activeFocusOnPress: false
299− onClicked: { testCase.showPowerDialog(); }
297+ onClicked: { testCase.showPowerDialog(tryShell); }
300298 }
301299 ListItem.ItemSelector {
302300 id: deviceNameSelector
@@ -305,9 +303,9 @@ Rectangle {
305303 text: "Device Name"
306304 model: ["mako", "manta", "flo", "desktop"]
307305 onSelectedIndexChanged: {
308− testCase.tearDown();
306+ destroyShell();
309307 applicationArguments.deviceName = model[selectedIndex];
310− orientedShellLoader.active = true;
308+ createTryShell();
311309 }
312310 }
313311 ListItem.ItemSelector {
@@ -350,10 +348,12 @@ Rectangle {
350348 }
351349 }
352350 Label {
351+ Layout.fillWidth: true
352+ Layout.fillHeight: true
353353 text: "Input Method"
354− anchors.verticalCenter: parent.verticalCenter
355354 }
356355 }
356+
357357 Button {
358358 text: Powerd.status === Powerd.On ? "Display ON" : "Display OFF"
359359 activeFocusOnPress: false
@@ -438,15 +438,43 @@ Rectangle {
438438 }
439439 }
440440
441+ function createTryShell() {
442+ if (root.tryShell === null) {
443+ root.tryShell = shellComponent.createObject(shellRect);
444+ }
445+ }
446+
447+ function destroyShell() {
448+ if (root.tryShell === null) {
449+ return;
450+ }
451+ tryShell.destroy();
452+ testCase.wait(100); // Need to wait for things like the SurfaceManager to be destroyed
453+
454+ testCase.tearDown();
455+ }
456+
457+ function rotate0(orientedShell) {
458+ orientedShell.physicalOrientation = root.physicalOrientation0;
459+ }
460+
461+ function rotate90(orientedShell) {
462+ orientedShell.physicalOrientation = root.physicalOrientation90;
463+ }
464+
465+ function rotate180(orientedShell) {
466+ orientedShell.physicalOrientation = root.physicalOrientation180;
467+ }
468+
469+ function rotate270(orientedShell) {
470+ orientedShell.physicalOrientation = root.physicalOrientation270;
471+ }
472+
441473 UnityTestCase {
442474 id: testCase
443475 name: "OrientedShell"
444476 when: windowShown
445477
446− property Item orientedShell: orientedShellLoader.status === Loader.Ready ? orientedShellLoader.item : null
447− property Item shell
448− property QtObject topLevelSurfaceList
449−
450478 SignalSpy { id: signalSpy }
451479 SignalSpy { id: signalSpy2 }
452480
@@ -462,62 +490,41 @@ Rectangle {
462490 }
463491
464492 function init() {
465− if (orientedShellLoader.active) {
466− // happens for the very first test function as shell
467− // is loaded by default
468− tearDown();
469− }
470− }
471−
472− function tearDown() {
473− orientedShellLoader.itemDestroyed = false;
474− orientedShellLoader.active = false;
475−
476− tryCompare(orientedShellLoader, "status", Loader.Null);
477− tryCompare(orientedShellLoader, "item", null);
478− // Loader.status might be Loader.Null and Loader.item might be null but the Loader
479− // actually took place. Likely because Loader waits until the next event loop
480− // iteration to do its work. So to ensure the reload, we will wait until the
481− // Shell instance gets destroyed.
482− tryCompare(orientedShellLoader, "itemDestroyed", true);
483−
484− // kill all (fake) running apps
485− killApps();
486−
487493 while (miceModel.count > 0)
488494 MockInputDeviceBackend.removeDevice("/mouse" + (miceModel.count - 1));
489495 while (touchpadModel.count > 0)
490496 MockInputDeviceBackend.removeDevice("/touchpad" + (touchpadModel.count - 1));
491497 while (keyboardsModel.count > 0)
492498 MockInputDeviceBackend.removeDevice("/kbd" + (keyboardsModel.count - 1))
499+ usageModeSelector.selectStaged();
500+ }
493501
494− appRepeaterConnections.target = null;
495− appRepeaterConnections.itemAddedCallback = null;
496− signalSpy.target = null;
497− signalSpy.signalName = "";
498−
502+ function tearDown() {
503+ // kill all (fake) running apps
504+ testCase.killApps();
499505 LightDM.Greeter.authenticate(""); // reset greeter
500−
501− usageModeSelector.selectStaged();
502506 }
503507
504508 function cleanup() {
505− tryCompare(shell, "waitingOnGreeter", false, 10000); // make sure greeter didn't leave us in disabled state
506− shell = null;
507− topLevelSurfaceList = null;
509+ appRepeaterConnections.target = null;
510+ appRepeaterConnections.itemAddedCallback = null;
511+ signalSpy.target = null;
512+ signalSpy.signalName = "";
508513
509514 tearDown();
510515 }
511516
512517 function test_appSupportingOnlyPrimaryOrientationMakesPhoneShellStayPut() {
513− loadShell("mako");
518+ var orientedShell = loadShell("mako");
519+ var topLevelSurfaceList = findInvisibleChild(orientedShell, "topLevelSurfaceList");
520+ var shell = findChild(orientedShell, "shell");
514521
515522 var primarySurfaceId = topLevelSurfaceList.nextId;
516523 var primaryApp = ApplicationManager.startApplication("primary-oriented-app");
517524 verify(primaryApp);
518− waitUntilAppWindowIsFullyLoaded(primarySurfaceId);
525+ waitUntilAppWindowIsFullyLoaded(primarySurfaceId, orientedShell);
519526
520− var primaryAppWindow = findAppWindowForSurfaceId(primarySurfaceId);
527+ var primaryAppWindow = findAppWindowForSurfaceId(primarySurfaceId, orientedShell);
521528 verify(primaryAppWindow)
522529 var primaryDelegate = findChild(shell, "appDelegate_" + primarySurfaceId);
523530
@@ -526,22 +533,22 @@ Rectangle {
526533 compare(primaryApp.supportedOrientations, Qt.PrimaryOrientation);
527534
528535 tryVerify(function(){return primaryDelegate.surface});
529− verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle));
536+ verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle, orientedShell));
530537
531538 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
532− rotateTo(90);
539+ rotateTo(90, orientedShell);
533540
534− verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle));
541+ verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle, orientedShell));
535542 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
536543
537− rotateTo(180);
544+ rotateTo(180, orientedShell);
538545
539− verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle));
546+ verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle, orientedShell));
540547 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
541548
542− rotateTo(270);
549+ rotateTo(270, orientedShell);
543550
544− verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle));
551+ verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle, orientedShell));
545552 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
546553 }
547554
@@ -552,14 +559,16 @@ Rectangle {
552559 ];
553560 }
554561 function test_appSupportingOnlyPrimaryOrientationWillOnlyRotateInLandscape(data) {
555− loadShell(data.deviceName);
562+ var orientedShell = loadShell(data.deviceName);
563+ var shell = findChild(orientedShell, "shell");
564+ var topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
556565
557566 var primarySurfaceId = topLevelSurfaceList.nextId;
558567 var primaryApp = ApplicationManager.startApplication("primary-oriented-app");
559568 verify(primaryApp);
560− waitUntilAppWindowIsFullyLoaded(primarySurfaceId);
569+ waitUntilAppWindowIsFullyLoaded(primarySurfaceId, orientedShell);
561570
562− var primaryAppWindow = findAppWindowForSurfaceId(primarySurfaceId);
571+ var primaryAppWindow = findAppWindowForSurfaceId(primarySurfaceId, orientedShell);
563572 verify(primaryAppWindow)
564573
565574 // primary-oriented-app supports only primary orientation
@@ -572,22 +581,22 @@ Rectangle {
572581
573582 tryCompareFunction(function(){return primaryApp.surfaceList.count > 0;}, true);
574583
575− tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle)}, true);
584+ tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle, orientedShell)}, true);
576585 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
577586
578− rotateTo(90);
587+ rotateTo(90, orientedShell);
579588
580− tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle)}, true);
589+ tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle, orientedShell)}, true);
581590 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
582591
583− rotateTo(180);
592+ rotateTo(180, orientedShell);
584593
585− tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle + 180)}, true);
594+ tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle + 180, orientedShell)}, true);
586595 compare(shell.transformRotationAngle, root.primaryOrientationAngle + 180);
587596
588− rotateTo(270);
597+ rotateTo(270, orientedShell);
589598
590− tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle + 180)}, true);
599+ tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle + 180, orientedShell)}, true);
591600 compare(shell.transformRotationAngle, root.primaryOrientationAngle + 180);
592601 }
593602
@@ -599,7 +608,8 @@ Rectangle {
599608 ];
600609 }
601610 function test_greeterRemainsInPrimaryOrientation(data) {
602− loadShell(data.deviceName);
611+ var orientedShell = loadShell(data.deviceName);
612+ var shell = findChild(orientedShell, "shell");
603613
604614 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
605615 verify(gmailApp);
@@ -613,17 +623,17 @@ Rectangle {
613623 tryCompare(shell, "orientationChangesEnabled", true);
614624
615625 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
616− rotateTo(90);
626+ rotateTo(90, orientedShell);
617627 tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle + 90);
618628
619− showGreeter();
629+ showGreeter(orientedShell);
620630
621631 tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle);
622− rotateTo(180);
632+ rotateTo(180, orientedShell);
623633 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
624− rotateTo(270);
634+ rotateTo(270, orientedShell);
625635 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
626− rotateTo(0);
636+ rotateTo(0, orientedShell);
627637 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
628638 }
629639
@@ -638,7 +648,9 @@ Rectangle {
638648 ];
639649 }
640650 function test_appRotatesWindowContents(data) {
641− loadShell(data.deviceName);
651+ var orientedShell = loadShell(data.deviceName);
652+ var shell = findChild(orientedShell, "shell");
653+ var topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
642654
643655 if (data.windowed) {
644656 usageModeSelector.selectWindowed();
@@ -658,7 +670,7 @@ Rectangle {
658670 compare(cameraApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
659671 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
660672
661− waitUntilAppWindowIsFullyLoaded(cameraSurfaceId);
673+ waitUntilAppWindowIsFullyLoaded(cameraSurfaceId, orientedShell);
662674
663675 var focusChangedSpy = signalSpy;
664676 focusChangedSpy.clear();
@@ -686,7 +698,7 @@ Rectangle {
686698 transitionSpy.signalName = "runningChanged";
687699 verify(transitionSpy.valid);
688700
689− rotateTo(90);
701+ rotateTo(90, orientedShell);
690702
691703 tryCompare(cameraSurface, "orientationAngle", data.orientationAngleAfterRotation);
692704
@@ -724,7 +736,9 @@ Rectangle {
724736 ];
725737 }
726738 function test_switchingToAppWithDifferentRotation(data) {
727− loadShell(data.deviceName);
739+ var orientedShell = loadShell(data.deviceName);
740+ var shell = findChild(orientedShell, "shell");
741+ var topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
728742 var gmailSurfaceId = topLevelSurfaceList.nextId;
729743 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
730744 verify(gmailApp);
@@ -734,7 +748,7 @@ Rectangle {
734748 compare(gmailApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
735749 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
736750
737− waitUntilAppWindowIsFullyLoaded(gmailSurfaceId);
751+ waitUntilAppWindowIsFullyLoaded(gmailSurfaceId, orientedShell);
738752
739753 var musicSurfaceId = topLevelSurfaceList.nextId;
740754 var musicApp = ApplicationManager.startApplication("music-app");
@@ -749,13 +763,13 @@ Rectangle {
749763 compare(musicDelegate.stage, ApplicationInfoInterface.MainStage);
750764 }
751765
752− waitUntilAppWindowIsFullyLoaded(musicSurfaceId);
766+ waitUntilAppWindowIsFullyLoaded(musicSurfaceId, orientedShell);
753767 tryCompare(shell, "orientationChangesEnabled", true);
754768
755− rotateTo(90);
769+ rotateTo(90, orientedShell);
756770 tryCompare(shell, "transformRotationAngle", data.shellAngleAfterRotation);
757771
758− performEdgeSwipeToSwitchToPreviousApp();
772+ performEdgeSwipeToSwitchToPreviousApp(orientedShell);
759773
760774 tryCompare(shell, "mainAppWindowOrientationAngle", data.shellAngleAfterRotation);
761775 compare(shell.transformRotationAngle, data.shellAngleAfterRotation);
@@ -783,7 +797,9 @@ Rectangle {
783797 orientation (Screen.orientation), so they are both equally good alternatives
784798 */
785799 function test_rotateToUnsupportedDeviceOrientation(data) {
786− loadShell("mako");
800+ var orientedShell = loadShell("mako");
801+ var shell = findChild(orientedShell, "shell");
802+ var topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
787803 var twitterSurfaceId = topLevelSurfaceList.nextId;
788804 var twitterApp = ApplicationManager.startApplication("twitter-webapp");
789805 verify(twitterApp);
@@ -793,12 +809,12 @@ Rectangle {
793809 compare(twitterApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
794810 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
795811
796− waitUntilAppWindowIsFullyLoaded(twitterSurfaceId);
812+ waitUntilAppWindowIsFullyLoaded(twitterSurfaceId, orientedShell);
797813
798− rotateTo(data.rotationAngle);
814+ rotateTo(data.rotationAngle, orientedShell);
799815 tryCompare(shell, "transformRotationAngle", data.rotationAngle);
800816
801− rotateTo(180);
817+ rotateTo(180, orientedShell);
802818 tryCompare(shell, "transformRotationAngle", data.rotationAngle);
803819 }
804820 function test_rotateToUnsupportedDeviceOrientation_data() {
@@ -809,7 +825,9 @@ Rectangle {
809825 }
810826
811827 function test_launchLandscapeOnlyAppFromPortrait() {
812− loadShell("mako");
828+ var orientedShell = loadShell("mako");
829+ var shell = findChild(orientedShell, "shell");
830+ var topLevelSurfaceList = findInvisibleChild(orientedShell, "topLevelSurfaceList");
813831 var weatherSurfaceId = topLevelSurfaceList.nextId;
814832 var weatherApp = ApplicationManager.startApplication("ubuntu-weather-app");
815833 verify(weatherApp);
@@ -817,7 +835,7 @@ Rectangle {
817835 // ensure the mock app is as we expect
818836 compare(weatherApp.supportedOrientations, Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation);
819837
820− waitUntilAppWindowIsFullyLoaded(weatherSurfaceId);
838+ waitUntilAppWindowIsFullyLoaded(weatherSurfaceId, orientedShell);
821839
822840 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
823841 waitUntilTransitionsEnd(rotationStates);
@@ -849,13 +867,15 @@ Rectangle {
849867 have an opacity > 0.
850868 */
851869 function test_greeterStaysAwayAfterRotation() {
852− loadShell("mako");
870+ var orientedShell = loadShell("mako");
871+ var shell = findChild(orientedShell, "shell");
872+ var topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
853873
854874 // Load an app which only supports primary
855875 var primarySurfaceId = topLevelSurfaceList.nextId;
856876 var primaryApp = ApplicationManager.startApplication("primary-oriented-app");
857877 verify(primaryApp);
858− waitUntilAppWindowIsFullyLoaded(primarySurfaceId);
878+ waitUntilAppWindowIsFullyLoaded(primarySurfaceId, orientedShell);
859879
860880 var twitterSurfaceId = topLevelSurfaceList.nextId;
861881 var twitterApp = ApplicationManager.startApplication("twitter-webapp");
@@ -866,17 +886,17 @@ Rectangle {
866886 compare(twitterApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
867887 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
868888
869− waitUntilAppWindowIsFullyLoaded(twitterSurfaceId);
870− waitUntilAppWindowCanRotate(twitterSurfaceId);
889+ waitUntilAppWindowIsFullyLoaded(twitterSurfaceId, orientedShell);
890+ waitUntilAppWindowCanRotate(twitterSurfaceId, orientedShell);
871891
872892 // go back to primary-oriented-app
873− performEdgeSwipeToSwitchToPreviousApp();
893+ performEdgeSwipeToSwitchToPreviousApp(orientedShell);
874894
875− rotateTo(90);
895+ rotateTo(90, orientedShell);
876896 wait(1); // spin the event loop to let all bindings do their thing
877897 tryCompare(shell, "transformRotationAngle", 0);
878898
879− performEdgeSwipeToShowAppSpread();
899+ performEdgeSwipeToShowAppSpread(shell);
880900
881901 // wait until things have settled
882902 var greeter = findChild(shell, "greeter");
@@ -901,7 +921,9 @@ Rectangle {
901921 }
902922 function test_appInSideStageDoesntRotateOnStartUp(data) {
903923 WindowStateStorage.saveStage("twitter-webapp", ApplicationInfoInterface.SideStage)
904− loadShell(data.deviceName);
924+ var orientedShell = loadShell(data.deviceName);
925+ var shell = findChild(orientedShell, "shell");
926+ var topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
905927
906928 var twitterSurfaceId = topLevelSurfaceList.nextId;
907929 var twitterApp = ApplicationManager.startApplication("twitter-webapp");
@@ -931,7 +953,8 @@ Rectangle {
931953 ];
932954 }
933955 function test_portraitOnlyAppInSideStage(data) {
934− loadShell(data.deviceName);
956+ var orientedShell = loadShell(data.deviceName);
957+ var shell = findChild(orientedShell, "shell");
935958
936959 var dialerDelegate = null;
937960 verify(appRepeaterConnections.target);
@@ -972,12 +995,13 @@ Rectangle {
972995 ];
973996 }
974997 function test_launchedAppHasActiveFocus(data) {
975− loadShell(data.deviceName);
998+ var orientedShell = loadShell(data.deviceName);
999+ var topLevelSurfaceList = findInvisibleChild(orientedShell, "topLevelSurfaceList");
9761000
9771001 var gmailSurfaceId = topLevelSurfaceList.nextId;
9781002 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
9791003 verify(gmailApp);
980− waitUntilAppWindowIsFullyLoaded(gmailSurfaceId);
1004+ waitUntilAppWindowIsFullyLoaded(gmailSurfaceId, orientedShell);
9811005
9821006 var gmailSurface = gmailApp.surfaceList.get(0);
9831007 verify(gmailSurface);
@@ -986,12 +1010,14 @@ Rectangle {
9861010 }
9871011
9881012 function test_launchLandscapeOnlyAppOverPortraitOnlyDashThenSwitchToDash() {
989− loadShell("mako");
1013+ var orientedShell = loadShell("mako");
1014+ var shell = findChild(orientedShell, "shell");
1015+ var topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
9901016
9911017 var dashSurfaceId = topLevelSurfaceList.nextId;
9921018 var dashApp = ApplicationManager.startApplication("unity8-dash");
9931019 verify(dashApp);
994− waitUntilAppWindowIsFullyLoaded(dashSurfaceId);
1020+ waitUntilAppWindowIsFullyLoaded(dashSurfaceId, orientedShell);
9951021
9961022 // starts as portrait, as unity8-dash is portrait only
9971023 tryCompare(shell, "transformRotationAngle", 0);
@@ -1003,7 +1029,7 @@ Rectangle {
10031029 // ensure the mock app is as we expect
10041030 compare(weatherApp.supportedOrientations, Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation);
10051031
1006− waitUntilAppWindowIsFullyLoaded(weatherSurfaceId);
1032+ waitUntilAppWindowIsFullyLoaded(weatherSurfaceId, orientedShell);
10071033
10081034 // should have rotated to landscape
10091035 tryCompareFunction(function () { return shell.transformRotationAngle == 270
@@ -1036,13 +1062,13 @@ Rectangle {
10361062 }
10371063
10381064 function test_attachRemoveInputDevices(data) {
1039− loadShell("mako")
1040− MockInputDeviceBackend.removeDevice("/indicator_kbd0");
1065+ var orientedShell = loadShell("mako");
10411066 var shell = findChild(orientedShell, "shell");
1067+ MockInputDeviceBackend.removeDevice("/indicator_kbd0");
10421068 var inputMethod = findChild(shell, "inputMethod");
10431069
1044− var oldWidth = orientedShellLoader.width;
1045− orientedShellLoader.width = data.screenWidth;
1070+ var oldWidth = shellRect.width;
1071+ shellRect.width = data.screenWidth;
10461072
10471073 tryCompare(shell, "usageScenario", "phone");
10481074 tryCompare(inputMethod, "enabled", true);
@@ -1060,17 +1086,17 @@ Rectangle {
10601086 tryCompare(oskSettings, "disableHeight", data.expectedMode == "desktop" || data.kbd);
10611087
10621088 // Restore width
1063− orientedShellLoader.width = oldWidth;
1089+ shellRect.width = oldWidth;
10641090 }
10651091
10661092 function test_screenSizeChanges() {
1067− loadShell("mako")
1093+ var orientedShell = loadShell("mako");
10681094 var shell = findChild(orientedShell, "shell");
10691095
10701096 tryCompare(shell, "usageScenario", "phone");
10711097
10721098 // make screen larger
1073− orientedShellLoader.width = units.gu(90);
1099+ shellRect.width = units.gu(90);
10741100 tryCompare(shell, "usageScenario", "phone");
10751101
10761102 // plug a mouse
@@ -1078,17 +1104,18 @@ Rectangle {
10781104 tryCompare(shell, "usageScenario", "desktop");
10791105
10801106 // make the screen smaller again, it should go back to staged even though there's still a mouse around
1081− orientedShellLoader.width = units.gu(40);
1107+ shellRect.width = units.gu(40);
10821108
10831109 tryCompare(shell, "usageScenario", "phone");
10841110 }
10851111
10861112 function test_overrideStaged() {
1087− loadShell("mako")
1113+ var orientedShell = loadShell("mako");
1114+ var shell = findChild(orientedShell, "shell");
10881115
10891116 // make sure we're big enough so that the automatism starts working
1090− var oldWidth = orientedShellLoader.width;
1091− orientedShellLoader.width = units.gu(100);
1117+ var oldWidth = shellRect.width;
1118+ shellRect.width = units.gu(100);
10921119
10931120 // start off by plugging a mouse, we should switch to windowed
10941121 MockInputDeviceBackend.addMockDevice("/mouse0", InputInfo.Mouse);
@@ -1115,7 +1142,7 @@ Rectangle {
11151142 tryCompare(shell, "usageScenario", "phone");
11161143
11171144 // Restore width
1118− orientedShellLoader.width = oldWidth;
1145+ shellRect.width = oldWidth;
11191146 }
11201147
11211148 function test_setsUsageModeOnStartup() {
@@ -1125,17 +1152,19 @@ Rectangle {
11251152 compare(unity8Settings.usageMode, "Staged");
11261153
11271154 // Load shell, and have it pick desktop
1128− loadShell("desktop");
1155+ var orientedShell = loadShell("desktop");
1156+ var shell = findChild(orientedShell, "shell");
11291157 compare(shell.usageScenario, "desktop");
11301158 compare(unity8Settings.usageMode, "Windowed");
11311159 }
11321160
11331161 function test_overrideWindowed() {
1134− loadShell("mako")
1162+ var orientedShell = loadShell("mako")
1163+ var shell = findChild(orientedShell, "shell");
11351164
11361165 // make sure we're big enough so that the automatism starts working
1137− var oldWidth = orientedShellLoader.width;
1138− orientedShellLoader.width = units.gu(100);
1166+ var oldWidth = shellRect.width;
1167+ shellRect.width = units.gu(100);
11391168
11401169 // No mouse attached... we should be in staged
11411170 tryCompare(shell, "usageScenario", "phone");
@@ -1153,7 +1182,7 @@ Rectangle {
11531182 tryCompare(shell, "usageScenario", "phone");
11541183
11551184 // Restore width
1156− orientedShellLoader.width = oldWidth;
1185+ shellRect.width = oldWidth;
11571186 }
11581187
11591188 /*
@@ -1178,7 +1207,8 @@ Rectangle {
11781207 hence the bug.
11791208 */
11801209 function test_phoneWithSpreadInLandscapeWhenGreeterShowsUp() {
1181− loadShell("mako");
1210+ var orientedShell = loadShell("mako");
1211+ var shell = findChild(orientedShell, "shell");
11821212
11831213 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
11841214 verify(gmailApp);
@@ -1191,12 +1221,12 @@ Rectangle {
11911221 // wait until it's able to rotate
11921222 tryCompare(shell, "orientationChangesEnabled", true);
11931223
1194− rotateTo(90);
1224+ rotateTo(90, orientedShell);
11951225 tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle + 90);
11961226
1197− performEdgeSwipeToShowAppSpread();
1227+ performEdgeSwipeToShowAppSpread(shell);
11981228
1199− showGreeter();
1229+ showGreeter(orientedShell);
12001230
12011231 tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle);
12021232 }
@@ -1221,22 +1251,24 @@ Rectangle {
12211251 - The portrait-only application rotates freely
12221252 */
12231253 function test_lockPhoneAfterClosingAppInSpreadThenUnlockAndRotate() {
1224− loadShell("mako");
1254+ var orientedShell = loadShell("mako");
1255+ var topLevelSurfaceList = findInvisibleChild(orientedShell, "topLevelSurfaceList");
1256+ var shell = findChild(orientedShell, "shell");
12251257
12261258 var primarySurfaceId = topLevelSurfaceList.nextId;
12271259 var primaryApp = ApplicationManager.startApplication("primary-oriented-app");
12281260 verify(primaryApp);
1229− waitUntilAppWindowIsFullyLoaded(primarySurfaceId);
1261+ waitUntilAppWindowIsFullyLoaded(primarySurfaceId, orientedShell);
12301262
12311263 var gmailSurfaceId = topLevelSurfaceList.nextId;
12321264 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
12331265 verify(gmailApp);
12341266
1235− waitUntilAppWindowIsFullyLoaded(gmailSurfaceId);
1267+ waitUntilAppWindowIsFullyLoaded(gmailSurfaceId, orientedShell);
12361268
1237− performEdgeSwipeToShowAppSpread();
1269+ performEdgeSwipeToShowAppSpread(shell);
12381270
1239− swipeToCloseCurrentAppInSpread();
1271+ swipeToCloseCurrentAppInSpread(orientedShell);
12401272
12411273 // press the power key once
12421274 Powerd.setStatus(Powerd.Off, Powerd.Unknown);
@@ -1246,23 +1278,24 @@ Rectangle {
12461278 // and a second time to turn the display back on
12471279 Powerd.setStatus(Powerd.On, Powerd.Unknown);
12481280
1249− swipeAwayGreeter();
1281+ swipeAwayGreeter(orientedShell);
12501282
1251− tryCompareFunction(function() { return isAppSurfaceFocused(primarySurfaceId)}, true, 10000)
1283+ tryCompareFunction(function() { return isAppSurfaceFocused(topLevelSurfaceList, primarySurfaceId)}, true, 10000)
12521284
12531285 signalSpy.clear();
12541286 signalSpy.target = shell;
12551287 signalSpy.signalName = "widthChanged";
12561288 verify(signalSpy.valid);
12571289
1258− rotateTo(90);
1290+ rotateTo(90, orientedShell);
12591291
12601292 // shell shouldn't have change its orientation at any moment
12611293 compare(signalSpy.count, 0);
12621294 }
12631295
12641296 function test_moveToExternalMonitor() {
1265− loadShell("flo");
1297+ var orientedShell = loadShell("flo");
1298+ var shell = findChild(orientedShell, "shell");
12661299
12671300 compare(orientedShell.orientation, Qt.InvertedLandscapeOrientation);
12681301 compare(shell.transformRotationAngle, 90);
@@ -1296,7 +1329,9 @@ Rectangle {
12961329 ];
12971330 }
12981331 function test_portraitOnlyAppInLandscapeDesktop(data) {
1299− loadShell(data.deviceName);
1332+ var orientedShell = loadShell(data.deviceName);
1333+ var topLevelSurfaceList = findInvisibleChild(orientedShell, "topLevelSurfaceList");
1334+ var shell = findChild(orientedShell, "shell");
13001335
13011336 ////
13021337 // setup preconditions (put shell in Desktop mode and landscape)
@@ -1304,8 +1339,8 @@ Rectangle {
13041339 usageModeSelector.selectWindowed();
13051340
13061341 orientedShell.physicalOrientation = orientedShell.orientations.landscape;
1307− waitUntilShellIsInOrientation(orientedShell.orientations.landscape);
1308− waitForRotationAnimationsToFinish();
1342+ waitUntilShellIsInOrientation(orientedShell.orientations.landscape, orientedShell);
1343+ waitForRotationAnimationsToFinish(orientedShell);
13091344
13101345 ////
13111346 // Launch a portrait-only application
@@ -1318,39 +1353,39 @@ Rectangle {
13181353 compare(dialerApp.rotatesWindowContents, false);
13191354 compare(dialerApp.supportedOrientations, Qt.PortraitOrientation | Qt.InvertedPortraitOrientation);
13201355
1321− waitUntilAppWindowIsFullyLoaded(dialerSurfaceId);
1322− waitUntilAppWindowCanRotate(dialerSurfaceId);
1323− verify(isAppSurfaceFocused(dialerSurfaceId));
1356+ waitUntilAppWindowIsFullyLoaded(dialerSurfaceId, orientedShell);
1357+ waitUntilAppWindowCanRotate(dialerSurfaceId, orientedShell);
1358+ verify(isAppSurfaceFocused(topLevelSurfaceList, dialerSurfaceId));
13241359
13251360 ////
13261361 // check outcome (shell should stay in landscape)
13271362
1328− waitForRotationAnimationsToFinish();
1363+ waitForRotationAnimationsToFinish(orientedShell);
13291364 compare(shell.orientation, orientedShell.orientations.landscape);
13301365 }
13311366
13321367 // angle - rotation angle in degrees clockwise, relative to the primary orientation.
1333− function rotateTo(angle) {
1368+ function rotateTo(angle, orientedShell) {
13341369 switch (angle) {
13351370 case 0:
1336− rotate0Button.clicked();
1371+ root.rotate0(orientedShell);
13371372 break;
13381373 case 90:
1339− rotate90Button.clicked();
1374+ root.rotate90(orientedShell);
13401375 break;
13411376 case 180:
1342− rotate180Button.clicked();
1377+ root.rotate180(orientedShell);
13431378 break;
13441379 case 270:
1345− rotate270Button.clicked();
1380+ root.rotate270(orientedShell);
13461381 break;
13471382 default:
13481383 verify(false);
13491384 }
1350− waitForRotationAnimationsToFinish();
1385+ waitForRotationAnimationsToFinish(orientedShell);
13511386 }
13521387
1353− function waitForRotationAnimationsToFinish() {
1388+ function waitForRotationAnimationsToFinish(orientedShell) {
13541389 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
13551390 verify(rotationStates.d);
13561391 verify(rotationStates.d.stateUpdateTimer);
@@ -1372,8 +1407,8 @@ Rectangle {
13721407 tryCompare(appWindowStates, "state", "surface");
13731408 }
13741409
1375− function findAppWindowForSurfaceId(surfaceId) {
1376− var delegate = findChild(shell, "appDelegate_" + surfaceId);
1410+ function findAppWindowForSurfaceId(surfaceId, orientedShell) {
1411+ var delegate = findChild(orientedShell, "appDelegate_" + surfaceId);
13771412 verify(delegate);
13781413 var appWindow = findChild(delegate, "appWindow");
13791414 return appWindow;
@@ -1381,25 +1416,28 @@ Rectangle {
13811416
13821417 // Wait until the ApplicationWindow for the given Application object is fully loaded
13831418 // (ie, the real surface has replaced the splash screen)
1384− function waitUntilAppWindowIsFullyLoaded(surfaceId) {
1385− var appWindow = findAppWindowForSurfaceId(surfaceId);
1419+ function waitUntilAppWindowIsFullyLoaded(surfaceId, orientedShell) {
1420+ var appWindow = findAppWindowForSurfaceId(surfaceId, orientedShell);
13861421 var appWindowStateGroup = findInvisibleChild(appWindow, "applicationWindowStateGroup");
13871422 tryCompareFunction(function() { return appWindowStateGroup.state === "surface" }, true);
13881423 waitUntilTransitionsEnd(appWindowStateGroup);
13891424 }
13901425
1391− function waitUntilAppWindowCanRotate(surfaceId) {
1392− var appWindow = findAppWindowForSurfaceId(surfaceId);
1426+ function waitUntilAppWindowCanRotate(surfaceId, orientedShell) {
1427+ var appWindow = findAppWindowForSurfaceId(surfaceId, orientedShell);
13931428 tryCompare(appWindow, "orientationChangesEnabled", true);
13941429 }
13951430
1396− function waitUntilShellIsInOrientation(orientation) {
1431+ function waitUntilShellIsInOrientation(orientation, orientedShell) {
1432+ var shell = findInvisibleChild(orientedShell, "shell");
13971433 tryCompare(shell, "orientation", orientation);
13981434 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
13991435 waitUntilTransitionsEnd(rotationStates);
14001436 }
14011437
1402− function performEdgeSwipeToSwitchToPreviousApp() {
1438+ function performEdgeSwipeToSwitchToPreviousApp(orientedShell) {
1439+ var topLevelSurfaceList = findInvisibleChild(orientedShell, "topLevelSurfaceList");
1440+ var shell = findChild(orientedShell, "shell");
14031441 // swipe just enough to ensure an app switch action.
14041442 // If we swipe too much we will trigger the spread mode
14051443 // and we don't want that.
@@ -1414,41 +1452,43 @@ Rectangle {
14141452 tryCompareFunction(function(){ return topLevelSurfaceList.idAt(0); }, previousSurfaceId);
14151453 }
14161454
1417− function performEdgeSwipeToShowAppSpread() {
1418− var touchStartY = shell.height / 2;
1419− touchFlick(shell,
1420− shell.width - 1, touchStartY,
1455+ function performEdgeSwipeToShowAppSpread(orientedShell) {
1456+ var touchStartY = orientedShell.height / 2;
1457+ touchFlick(orientedShell,
1458+ orientedShell.width - 1, touchStartY,
14211459 0, touchStartY);
14221460
1423− var stage = findChild(shell, "stage");
1461+ var stage = findChild(orientedShell, "stage");
14241462 tryCompare(stage, "state", "spread");
14251463 waitForRendering(stage);
14261464 }
14271465
1428− function showPowerDialog() {
1466+ function showPowerDialog(orientedShell) {
14291467 var dialogs = findChild(orientedShell, "dialogs");
14301468 var dialogsPrivate = findInvisibleChild(dialogs, "dialogsPrivate");
14311469 dialogsPrivate.showPowerDialog();
14321470 }
14331471
1434− function swipeAwayGreeter() {
1472+ function swipeAwayGreeter(orientedShell) {
1473+ var shell = findChild(orientedShell, "shell");
14351474 var greeter = findChild(shell, "greeter");
1475+ verify(greeter);
14361476 tryCompare(greeter, "fullyShown", true);
14371477 waitForRendering(greeter)
14381478
14391479 var touchX = shell.width * .75;
14401480 var touchY = shell.height / 2;
1441− touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY);
1481+ touchFlick(shell, touchX, touchY, orientedShell.width * 0.1, touchY);
14421482
14431483 // wait until the animation has finished
14441484 tryCompare(greeter, "shown", false);
14451485 waitForRendering(greeter);
14461486 }
14471487
1448− function showGreeter() {
1488+ function showGreeter(orientedShell) {
14491489 LightDM.Greeter.showGreeter();
14501490 // wait until the animation has finished
1451− var greeter = findChild(shell, "greeter");
1491+ var greeter = findChild(orientedShell, "greeter");
14521492 tryCompare(greeter, "fullyShown", true);
14531493 }
14541494
@@ -1456,32 +1496,29 @@ Rectangle {
14561496 applicationArguments.deviceName = deviceName;
14571497
14581498 // reload our test subject to get it in a fresh state once again
1459− orientedShellLoader.active = true;
1460−
1461− tryCompare(orientedShellLoader, "status", Loader.Ready);
1462− removeTimeConstraintsFromSwipeAreas(orientedShellLoader.item);
1499+ var orientedShell = createTemporaryObject(shellComponent, shellRect);
14631500
1464− shell = findChild(orientedShell, "shell");
1501+ removeTimeConstraintsFromSwipeAreas(orientedShell);
14651502
1466− topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
1467− verify(topLevelSurfaceList);
1503+ var shell = findChild(orientedShell, "shell");
14681504
14691505 tryCompare(shell, "waitingOnGreeter", false); // reset by greeter when ready
14701506
1471− waitUntilShellIsInOrientation(root.physicalOrientation0);
1507+ waitUntilShellIsInOrientation(root.physicalOrientation0, orientedShell);
14721508
1473− waitForGreeterToStabilize();
1509+ waitForGreeterToStabilize(orientedShell);
14741510
1475− swipeAwayGreeter();
1511+ swipeAwayGreeter(orientedShell);
14761512
14771513 var appRepeater = findChild(shell, "appRepeater");
14781514 if (appRepeater) {
14791515 appRepeaterConnections.target = appRepeater;
14801516 }
1517+ return orientedShell;
14811518 }
14821519
1483− function waitForGreeterToStabilize() {
1484− var greeter = findChild(shell, "greeter");
1520+ function waitForGreeterToStabilize(orientedShell) {
1521+ var greeter = findChild(orientedShell, "greeter");
14851522 verify(greeter);
14861523
14871524 var loginList = findChild(greeter, "loginList");
@@ -1494,7 +1531,7 @@ Rectangle {
14941531 }
14951532
14961533 // expectedAngle is in orientedShell's coordinate system
1497− function checkAppSurfaceOrientation(item, app, expectedAngle) {
1534+ function checkAppSurfaceOrientation(item, app, expectedAngle, orientedShell) {
14981535 var surface = app.surfaceList.get(0);
14991536 if (!surface) {
15001537 console.warn("no surface");
@@ -1537,8 +1574,9 @@ Rectangle {
15371574 return null;
15381575 }
15391576
1540− function swipeToCloseCurrentAppInSpread() {
1541− var delegateToClose = findChild(shell, "appDelegate_" + topLevelSurfaceList.idAt(0));
1577+ function swipeToCloseCurrentAppInSpread(orientedShell) {
1578+ var topLevelSurfaceList = findInvisibleChild(orientedShell, "topLevelSurfaceList");
1579+ var delegateToClose = findChild(orientedShell, "appDelegate_" + topLevelSurfaceList.idAt(0));
15421580 verify(delegateToClose);
15431581
15441582 var appIdToClose = ApplicationManager.get(0).appId;
@@ -1555,7 +1593,7 @@ Rectangle {
15551593 compare(ApplicationManager.findApplication(appIdToClose), null);
15561594 }
15571595
1558− function isAppSurfaceFocused(surfaceId) {
1596+ function isAppSurfaceFocused(topLevelSurfaceList, surfaceId) {
15591597 var index = topLevelSurfaceList.indexForId(surfaceId);
15601598 var surface = topLevelSurfaceList.surfaceAt(index);
15611599 verify(surface);
@@ -1570,9 +1608,9 @@ Rectangle {
15701608 }
15711609
15721610 function test_tabCyclyingInShutdownDialog(data) {
1573− loadShell("mako");
1611+ var orientedShell = loadShell("mako");
15741612
1575− testCase.showPowerDialog();
1613+ testCase.showPowerDialog(orientedShell);
15761614
15771615 var dialogs = findChild(orientedShell, "dialogs");
15781616 var buttons = findChildsByType(dialogs, "Button");
@@ -1598,9 +1636,9 @@ Rectangle {
15981636 }
15991637
16001638 function test_escClosesShutdownDialog() {
1601− loadShell("mako");
1639+ var orientedShell = loadShell("mako");
16021640
1603− testCase.showPowerDialog();
1641+ testCase.showPowerDialog(orientedShell);
16041642
16051643 var dialogLoader = findChild(orientedShell, "dialogLoader");
16061644 tryCompareFunction(function() { return dialogLoader.item !== null }, true);
@@ -1611,20 +1649,21 @@ Rectangle {
16111649 }
16121650
16131651 function test_focusOnShutdownDialogClose() {
1614− loadShell("manta");
1652+ var orientedShell = loadShell("manta");
1653+ var topLevelSurfaceList = findInvisibleChild(orientedShell, "topLevelSurfaceList");
16151654 usageModeSelector.selectWindowed();
16161655
16171656 var surfaceId = topLevelSurfaceList.nextId;
16181657 var app = ApplicationManager.startApplication("twitter-webapp");
1619− waitUntilAppWindowIsFullyLoaded(surfaceId);
1658+ waitUntilAppWindowIsFullyLoaded(surfaceId, orientedShell);
16201659
1621− var primaryAppWindow = findAppWindowForSurfaceId(surfaceId);
1660+ var primaryAppWindow = findAppWindowForSurfaceId(surfaceId, orientedShell);
16221661 var surface = app.surfaceList.get(0);
16231662 var surfaceItem = findSurfaceItem(primaryAppWindow, surface);
16241663
16251664 compare(window.activeFocusItem, surfaceItem);
16261665
1627− testCase.showPowerDialog();
1666+ testCase.showPowerDialog(orientedShell);
16281667
16291668 var dialogLoader = findChild(orientedShell, "dialogLoader");
16301669 tryVerify(function() { return dialogLoader.item !== null });
@@ -1635,7 +1674,7 @@ Rectangle {
16351674 compare(window.activeFocusItem, surfaceItem);
16361675
16371676 // Do it twice, our previous solution failed the second time ^_^
1638− testCase.showPowerDialog();
1677+ testCase.showPowerDialog(orientedShell);
16391678
16401679 tryVerify(function() { return dialogLoader.item !== null });
16411680
@@ -1646,7 +1685,8 @@ Rectangle {
16461685 }
16471686
16481687 function test_tutorialDisabledWithNoTouchscreen() {
1649− loadShell("desktop");
1688+ var orientedShell = loadShell("desktop");
1689+ var shell = findChild(orientedShell, "shell");
16501690 usageModeSelector.selectWindowed();
16511691
16521692 MockInputDeviceBackend.addMockDevice("/touchscreen", InputInfo.TouchScreen);