@@ -39,6 +39,8 @@ Rectangle {
39 width: units.gu(160) + controls.width
39 width: units.gu(160) + controls.width
40 height: units.gu(100)
40 height: units.gu(100)
42+ property var tryShell: null
43 target: LightDMController
45 target: LightDMController
44 property: "userMode"
46 property: "userMode"
@@ -93,7 +95,7 @@ Rectangle {
94 name: "mako"
96 name: "mako"
95 PropertyChanges {
97 PropertyChanges {
96− target: orientedShellLoader
98+ target: shellRect
97 width: units.gu(40)
99 width: units.gu(40)
98 height: units.gu(71)
100 height: units.gu(71)
@@ -109,7 +111,7 @@ Rectangle {
110 name: "manta"
112 name: "manta"
111 PropertyChanges {
113 PropertyChanges {
112− target: orientedShellLoader
114+ target: shellRect
113 width: units.gu(160)
115 width: units.gu(160)
114 height: units.gu(60)
116 height: units.gu(60)
@@ -125,7 +127,7 @@ Rectangle {
126 name: "flo"
128 name: "flo"
127 PropertyChanges {
129 PropertyChanges {
128− target: orientedShellLoader
130+ target: shellRect
129 width: units.gu(60)
131 width: units.gu(60)
130 height: units.gu(100)
132 height: units.gu(100)
@@ -141,7 +143,7 @@ Rectangle {
142 name: "desktop"
144 name: "desktop"
143 PropertyChanges {
145 PropertyChanges {
144− target: orientedShellLoader
146+ target: shellRect
145 width: units.gu(100)
147 width: units.gu(100)
146 height: units.gu(65)
148 height: units.gu(65)
@@ -156,26 +158,21 @@ Rectangle {
159− Loader {
161+ Component {
160− id: orientedShellLoader
162+ id: shellComponent
164+ anchors.fill: parent
165+ physicalOrientation: root.physicalOrientation0
166+ orientationLocked: orientationLockedCheckBox.checked
167+ orientationLock: mockOrientationLock
162 x: ((root.width - controls.width) - width) / 2
174 x: ((root.width - controls.width) - width) / 2
163 y: (root.height - height) / 2
175 y: (root.height - height) / 2
167− property bool itemDestroyed: false
168− sourceComponent: Component {
170− anchors.fill: parent
171− physicalOrientation: root.physicalOrientation0
172− orientationLocked: orientationLockedCheckBox.checked
173− orientationLock: mockOrientationLock
174− Component.onDestruction: {
175− orientedShellLoader.itemDestroyed = true;
181 function orientationsToStr(orientations) {
178 function orientationsToStr(orientations) {
@@ -224,11 +221,19 @@ Rectangle {
224 id: controlsColumn
221 id: controlsColumn
225 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
222 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
226 spacing: units.gu(1)
223 spacing: units.gu(1)
228 text: "Show Greeter"
233 text: "Show Greeter"
229 activeFocusOnPress: false
234 activeFocusOnPress: false
230 onClicked: {
235 onClicked: {
231− if (orientedShellLoader.status !== Loader.Ready)
236+ if (tryShell === null)
234 LightDM.Greeter.showGreeter();
239 LightDM.Greeter.showGreeter();
@@ -241,10 +246,8 @@ Rectangle {
241 id: rotate0Button
246 id: rotate0Button
242 text: root.orientationsToStr(root.physicalOrientation0) + " (0)"
247 text: root.orientationsToStr(root.physicalOrientation0) + " (0)"
243 activeFocusOnPress: false
248 activeFocusOnPress: false
244− onClicked: {
249+ onClicked: rotate0(tryShell)
245− orientedShellLoader.item.physicalOrientation = root.physicalOrientation0;
247− color: orientedShellLoader.item && orientedShellLoader.item.physicalOrientation === root.physicalOrientation0 ?
250+ color: tryShell && tryShell.physicalOrientation === root.physicalOrientation0 ?
248 UbuntuColors.green :
251 UbuntuColors.green :
249 __styleInstance.defaultColor
252 __styleInstance.defaultColor
@@ -252,10 +255,8 @@ Rectangle {
252 id: rotate90Button
255 id: rotate90Button
253 text: root.orientationsToStr(root.physicalOrientation90) + " (90)"
256 text: root.orientationsToStr(root.physicalOrientation90) + " (90)"
254 activeFocusOnPress: false
257 activeFocusOnPress: false
255− onClicked: {
258+ onClicked: rotate90(tryShell)
256− orientedShellLoader.item.physicalOrientation = root.physicalOrientation90;
258− color: orientedShellLoader.item && orientedShellLoader.item.physicalOrientation === root.physicalOrientation90 ?
259+ color: tryShell && tryShell.physicalOrientation === root.physicalOrientation90 ?
259 UbuntuColors.green :
260 UbuntuColors.green :
260 __styleInstance.defaultColor
261 __styleInstance.defaultColor
@@ -263,10 +264,8 @@ Rectangle {
263 id: rotate180Button
264 id: rotate180Button
264 text: root.orientationsToStr(root.physicalOrientation180) + " (180)"
265 text: root.orientationsToStr(root.physicalOrientation180) + " (180)"
265 activeFocusOnPress: false
266 activeFocusOnPress: false
266− onClicked: {
267+ onClicked: rotate180(tryShell)
267− orientedShellLoader.item.physicalOrientation = root.physicalOrientation180;
269− color: orientedShellLoader.item && orientedShellLoader.item.physicalOrientation === root.physicalOrientation180 ?
268+ color: tryShell && tryShell.physicalOrientation === root.physicalOrientation180 ?
270 UbuntuColors.green :
269 UbuntuColors.green :
271 __styleInstance.defaultColor
270 __styleInstance.defaultColor
@@ -274,10 +273,8 @@ Rectangle {
274 id: rotate270Button
273 id: rotate270Button
275 text: root.orientationsToStr(root.physicalOrientation270) + " (270)"
274 text: root.orientationsToStr(root.physicalOrientation270) + " (270)"
276 activeFocusOnPress: false
275 activeFocusOnPress: false
277− onClicked: {
276+ onClicked: rotate270(tryShell)
278− orientedShellLoader.item.physicalOrientation = root.physicalOrientation270;
280− color: orientedShellLoader.item && orientedShellLoader.item.physicalOrientation === root.physicalOrientation270 ?
277+ color: tryShell && tryShell.physicalOrientation === root.physicalOrientation270 ?
281 UbuntuColors.green :
278 UbuntuColors.green :
282 __styleInstance.defaultColor
279 __styleInstance.defaultColor
@@ -297,7 +294,7 @@ Rectangle {
298 text: "Power dialog"
295 text: "Power dialog"
299 activeFocusOnPress: false
296 activeFocusOnPress: false
300− onClicked: { testCase.showPowerDialog(); }
297+ onClicked: { testCase.showPowerDialog(tryShell); }
302 ListItem.ItemSelector {
299 ListItem.ItemSelector {
303 id: deviceNameSelector
300 id: deviceNameSelector
@@ -306,9 +303,9 @@ Rectangle {
306 text: "Device Name"
303 text: "Device Name"
307 model: ["mako", "manta", "flo", "desktop"]
304 model: ["mako", "manta", "flo", "desktop"]
308 onSelectedIndexChanged: {
305 onSelectedIndexChanged: {
309− testCase.tearDown();
306+ destroyShell();
310 applicationArguments.deviceName = model[selectedIndex];
307 applicationArguments.deviceName = model[selectedIndex];
311− orientedShellLoader.active = true;
308+ createTryShell();
314 ListItem.ItemSelector {
311 ListItem.ItemSelector {
@@ -356,6 +353,7 @@ Rectangle {
356 text: "Input Method"
353 text: "Input Method"
360 text: Powerd.status === Powerd.On ? "Display ON" : "Display OFF"
358 text: Powerd.status === Powerd.On ? "Display ON" : "Display OFF"
361 activeFocusOnPress: false
359 activeFocusOnPress: false
@@ -440,15 +438,43 @@ Rectangle {
441+ function createTryShell() {
442+ if (root.tryShell === null) {
443+ root.tryShell = shellComponent.createObject(shellRect);
447+ function destroyShell() {
448+ if (root.tryShell === null) {
452+ testCase.wait(100); // Need to wait for things like the SurfaceManager to be destroyed
454+ testCase.tearDown();
457+ function rotate0(orientedShell) {
458+ orientedShell.physicalOrientation = root.physicalOrientation0;
461+ function rotate90(orientedShell) {
462+ orientedShell.physicalOrientation = root.physicalOrientation90;
465+ function rotate180(orientedShell) {
466+ orientedShell.physicalOrientation = root.physicalOrientation180;
469+ function rotate270(orientedShell) {
470+ orientedShell.physicalOrientation = root.physicalOrientation270;
443 UnityTestCase {
473 UnityTestCase {
444 id: testCase
474 id: testCase
445 name: "OrientedShell"
475 name: "OrientedShell"
446 when: windowShown
476 when: windowShown
448− property Item orientedShell: orientedShellLoader.status === Loader.Ready ? orientedShellLoader.item : null
450− property QtObject topLevelSurfaceList
452 SignalSpy { id: signalSpy }
478 SignalSpy { id: signalSpy }
453 SignalSpy { id: signalSpy2 }
479 SignalSpy { id: signalSpy2 }
@@ -464,62 +490,41 @@ Rectangle {
466 function init() {
492 function init() {
467− if (orientedShellLoader.active) {
468− // happens for the very first test function as shell
469− // is loaded by default
474− function tearDown() {
475− orientedShellLoader.itemDestroyed = false;
476− orientedShellLoader.active = false;
478− tryCompare(orientedShellLoader, "status", Loader.Null);
479− tryCompare(orientedShellLoader, "item", null);
480− // Loader.status might be Loader.Null and Loader.item might be null but the Loader
481− // actually took place. Likely because Loader waits until the next event loop
482− // iteration to do its work. So to ensure the reload, we will wait until the
483− // Shell instance gets destroyed.
484− tryCompare(orientedShellLoader, "itemDestroyed", true);
486− // kill all (fake) running apps
489 while (miceModel.count > 0)
493 while (miceModel.count > 0)
490 MockInputDeviceBackend.removeDevice("/mouse" + (miceModel.count - 1));
494 MockInputDeviceBackend.removeDevice("/mouse" + (miceModel.count - 1));
491 while (touchpadModel.count > 0)
495 while (touchpadModel.count > 0)
492 MockInputDeviceBackend.removeDevice("/touchpad" + (touchpadModel.count - 1));
496 MockInputDeviceBackend.removeDevice("/touchpad" + (touchpadModel.count - 1));
493 while (keyboardsModel.count > 0)
497 while (keyboardsModel.count > 0)
494 MockInputDeviceBackend.removeDevice("/kbd" + (keyboardsModel.count - 1))
498 MockInputDeviceBackend.removeDevice("/kbd" + (keyboardsModel.count - 1))
499+ usageModeSelector.selectStaged();
496− appRepeaterConnections.target = null;
502+ function tearDown() {
497− appRepeaterConnections.itemAddedCallback = null;
503+ // kill all (fake) running apps
498− signalSpy.target = null;
504+ testCase.killApps();
499− signalSpy.signalName = "";
501 LightDM.Greeter.authenticate(""); // reset greeter
505 LightDM.Greeter.authenticate(""); // reset greeter
503− usageModeSelector.selectStaged();
506 function cleanup() {
508 function cleanup() {
507− tryCompare(shell, "waitingOnGreeter", false, 10000); // make sure greeter didn't leave us in disabled state
509+ appRepeaterConnections.target = null;
508− shell = null;
510+ appRepeaterConnections.itemAddedCallback = null;
509− topLevelSurfaceList = null;
511+ signalSpy.target = null;
512+ signalSpy.signalName = "";
511 tearDown();
514 tearDown();
514 function test_appSupportingOnlyPrimaryOrientationMakesPhoneShellStayPut() {
517 function test_appSupportingOnlyPrimaryOrientationMakesPhoneShellStayPut() {
515− loadShell("mako");
518+ var orientedShell = loadShell("mako");
519+ var topLevelSurfaceList = findInvisibleChild(orientedShell, "topLevelSurfaceList");
520+ var shell = findChild(orientedShell, "shell");
517 var primarySurfaceId = topLevelSurfaceList.nextId;
522 var primarySurfaceId = topLevelSurfaceList.nextId;
518 var primaryApp = ApplicationManager.startApplication("primary-oriented-app");
523 var primaryApp = ApplicationManager.startApplication("primary-oriented-app");
519 verify(primaryApp);
524 verify(primaryApp);
520− waitUntilAppWindowIsFullyLoaded(primarySurfaceId);
525+ waitUntilAppWindowIsFullyLoaded(primarySurfaceId, orientedShell);
522− var primaryAppWindow = findAppWindowForSurfaceId(primarySurfaceId);
527+ var primaryAppWindow = findAppWindowForSurfaceId(primarySurfaceId, orientedShell);
523 verify(primaryAppWindow)
528 verify(primaryAppWindow)
524 var primaryDelegate = findChild(shell, "appDelegate_" + primarySurfaceId);
529 var primaryDelegate = findChild(shell, "appDelegate_" + primarySurfaceId);
@@ -528,22 +533,22 @@ Rectangle {
528 compare(primaryApp.supportedOrientations, Qt.PrimaryOrientation);
533 compare(primaryApp.supportedOrientations, Qt.PrimaryOrientation);
530 tryVerify(function(){return primaryDelegate.surface});
535 tryVerify(function(){return primaryDelegate.surface});
531− verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle));
536+ verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle, orientedShell));
533 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
538 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
534− rotateTo(90);
539+ rotateTo(90, orientedShell);
536− verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle));
541+ verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle, orientedShell));
537 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
542 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
539− rotateTo(180);
544+ rotateTo(180, orientedShell);
541− verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle));
546+ verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle, orientedShell));
542 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
547 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
544− rotateTo(270);
549+ rotateTo(270, orientedShell);
546− verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle));
551+ verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle, orientedShell));
547 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
552 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
@@ -554,14 +559,16 @@ Rectangle {
556 function test_appSupportingOnlyPrimaryOrientationWillOnlyRotateInLandscape(data) {
561 function test_appSupportingOnlyPrimaryOrientationWillOnlyRotateInLandscape(data) {
557− loadShell(data.deviceName);
562+ var orientedShell = loadShell(data.deviceName);
563+ var shell = findChild(orientedShell, "shell");
564+ var topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
559 var primarySurfaceId = topLevelSurfaceList.nextId;
566 var primarySurfaceId = topLevelSurfaceList.nextId;
560 var primaryApp = ApplicationManager.startApplication("primary-oriented-app");
567 var primaryApp = ApplicationManager.startApplication("primary-oriented-app");
561 verify(primaryApp);
568 verify(primaryApp);
562− waitUntilAppWindowIsFullyLoaded(primarySurfaceId);
569+ waitUntilAppWindowIsFullyLoaded(primarySurfaceId, orientedShell);
564− var primaryAppWindow = findAppWindowForSurfaceId(primarySurfaceId);
571+ var primaryAppWindow = findAppWindowForSurfaceId(primarySurfaceId, orientedShell);
565 verify(primaryAppWindow)
572 verify(primaryAppWindow)
567 // primary-oriented-app supports only primary orientation
574 // primary-oriented-app supports only primary orientation
@@ -574,22 +581,22 @@ Rectangle {
575 tryCompareFunction(function(){return primaryApp.surfaceList.count > 0;}, true);
582 tryCompareFunction(function(){return primaryApp.surfaceList.count > 0;}, true);
577− tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle)}, true);
584+ tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle, orientedShell)}, true);
578 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
585 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
580− rotateTo(90);
587+ rotateTo(90, orientedShell);
582− tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle)}, true);
589+ tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle, orientedShell)}, true);
583 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
590 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
585− rotateTo(180);
592+ rotateTo(180, orientedShell);
587− tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle + 180)}, true);
594+ tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle + 180, orientedShell)}, true);
588 compare(shell.transformRotationAngle, root.primaryOrientationAngle + 180);
595 compare(shell.transformRotationAngle, root.primaryOrientationAngle + 180);
590− rotateTo(270);
597+ rotateTo(270, orientedShell);
592− tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle + 180)}, true);
599+ tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle + 180, orientedShell)}, true);
593 compare(shell.transformRotationAngle, root.primaryOrientationAngle + 180);
600 compare(shell.transformRotationAngle, root.primaryOrientationAngle + 180);
@@ -601,7 +608,8 @@ Rectangle {
603 function test_greeterRemainsInPrimaryOrientation(data) {
610 function test_greeterRemainsInPrimaryOrientation(data) {
604− loadShell(data.deviceName);
611+ var orientedShell = loadShell(data.deviceName);
612+ var shell = findChild(orientedShell, "shell");
606 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
614 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
607 verify(gmailApp);
615 verify(gmailApp);
@@ -615,17 +623,17 @@ Rectangle {
615 tryCompare(shell, "orientationChangesEnabled", true);
623 tryCompare(shell, "orientationChangesEnabled", true);
617 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
625 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
618− rotateTo(90);
626+ rotateTo(90, orientedShell);
619 tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle + 90);
627 tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle + 90);
621− showGreeter();
629+ showGreeter(orientedShell);
623 tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle);
631 tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle);
624− rotateTo(180);
632+ rotateTo(180, orientedShell);
625 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
633 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
626− rotateTo(270);
634+ rotateTo(270, orientedShell);
627 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
635 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
628− rotateTo(0);
636+ rotateTo(0, orientedShell);
629 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
637 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
@@ -640,7 +648,9 @@ Rectangle {
642 function test_appRotatesWindowContents(data) {
650 function test_appRotatesWindowContents(data) {
643− loadShell(data.deviceName);
651+ var orientedShell = loadShell(data.deviceName);
652+ var shell = findChild(orientedShell, "shell");
653+ var topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
645 if (data.windowed) {
655 if (data.windowed) {
646 usageModeSelector.selectWindowed();
656 usageModeSelector.selectWindowed();
@@ -660,7 +670,7 @@ Rectangle {
660 compare(cameraApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
670 compare(cameraApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
661 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
671 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
663− waitUntilAppWindowIsFullyLoaded(cameraSurfaceId);
673+ waitUntilAppWindowIsFullyLoaded(cameraSurfaceId, orientedShell);
665 var focusChangedSpy = signalSpy;
675 var focusChangedSpy = signalSpy;
666 focusChangedSpy.clear();
676 focusChangedSpy.clear();
@@ -688,7 +698,7 @@ Rectangle {
688 transitionSpy.signalName = "runningChanged";
698 transitionSpy.signalName = "runningChanged";
689 verify(transitionSpy.valid);
699 verify(transitionSpy.valid);
691− rotateTo(90);
701+ rotateTo(90, orientedShell);
693 tryCompare(cameraSurface, "orientationAngle", data.orientationAngleAfterRotation);
703 tryCompare(cameraSurface, "orientationAngle", data.orientationAngleAfterRotation);
@@ -726,7 +736,9 @@ Rectangle {
728 function test_switchingToAppWithDifferentRotation(data) {
738 function test_switchingToAppWithDifferentRotation(data) {
729− loadShell(data.deviceName);
739+ var orientedShell = loadShell(data.deviceName);
740+ var shell = findChild(orientedShell, "shell");
741+ var topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
730 var gmailSurfaceId = topLevelSurfaceList.nextId;
742 var gmailSurfaceId = topLevelSurfaceList.nextId;
731 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
743 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
732 verify(gmailApp);
744 verify(gmailApp);
@@ -736,7 +748,7 @@ Rectangle {
736 compare(gmailApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
748 compare(gmailApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
737 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
749 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
739− waitUntilAppWindowIsFullyLoaded(gmailSurfaceId);
751+ waitUntilAppWindowIsFullyLoaded(gmailSurfaceId, orientedShell);
741 var musicSurfaceId = topLevelSurfaceList.nextId;
753 var musicSurfaceId = topLevelSurfaceList.nextId;
742 var musicApp = ApplicationManager.startApplication("music-app");
754 var musicApp = ApplicationManager.startApplication("music-app");
@@ -751,13 +763,13 @@ Rectangle {
751 compare(musicDelegate.stage, ApplicationInfoInterface.MainStage);
763 compare(musicDelegate.stage, ApplicationInfoInterface.MainStage);
754− waitUntilAppWindowIsFullyLoaded(musicSurfaceId);
766+ waitUntilAppWindowIsFullyLoaded(musicSurfaceId, orientedShell);
755 tryCompare(shell, "orientationChangesEnabled", true);
767 tryCompare(shell, "orientationChangesEnabled", true);
757− rotateTo(90);
769+ rotateTo(90, orientedShell);
758 tryCompare(shell, "transformRotationAngle", data.shellAngleAfterRotation);
770 tryCompare(shell, "transformRotationAngle", data.shellAngleAfterRotation);
760− performEdgeSwipeToSwitchToPreviousApp();
772+ performEdgeSwipeToSwitchToPreviousApp(orientedShell);
762 tryCompare(shell, "mainAppWindowOrientationAngle", data.shellAngleAfterRotation);
774 tryCompare(shell, "mainAppWindowOrientationAngle", data.shellAngleAfterRotation);
763 compare(shell.transformRotationAngle, data.shellAngleAfterRotation);
775 compare(shell.transformRotationAngle, data.shellAngleAfterRotation);
@@ -785,7 +797,9 @@ Rectangle {
785 orientation (Screen.orientation), so they are both equally good alternatives
797 orientation (Screen.orientation), so they are both equally good alternatives
787 function test_rotateToUnsupportedDeviceOrientation(data) {
799 function test_rotateToUnsupportedDeviceOrientation(data) {
788− loadShell("mako");
800+ var orientedShell = loadShell("mako");
801+ var shell = findChild(orientedShell, "shell");
802+ var topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
789 var twitterSurfaceId = topLevelSurfaceList.nextId;
803 var twitterSurfaceId = topLevelSurfaceList.nextId;
790 var twitterApp = ApplicationManager.startApplication("twitter-webapp");
804 var twitterApp = ApplicationManager.startApplication("twitter-webapp");
791 verify(twitterApp);
805 verify(twitterApp);
@@ -795,12 +809,12 @@ Rectangle {
795 compare(twitterApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
809 compare(twitterApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
796 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
810 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
798− waitUntilAppWindowIsFullyLoaded(twitterSurfaceId);
812+ waitUntilAppWindowIsFullyLoaded(twitterSurfaceId, orientedShell);
800− rotateTo(data.rotationAngle);
814+ rotateTo(data.rotationAngle, orientedShell);
801 tryCompare(shell, "transformRotationAngle", data.rotationAngle);
815 tryCompare(shell, "transformRotationAngle", data.rotationAngle);
803− rotateTo(180);
817+ rotateTo(180, orientedShell);
804 tryCompare(shell, "transformRotationAngle", data.rotationAngle);
818 tryCompare(shell, "transformRotationAngle", data.rotationAngle);
806 function test_rotateToUnsupportedDeviceOrientation_data() {
820 function test_rotateToUnsupportedDeviceOrientation_data() {
@@ -811,7 +825,9 @@ Rectangle {
813 function test_launchLandscapeOnlyAppFromPortrait() {
827 function test_launchLandscapeOnlyAppFromPortrait() {
814− loadShell("mako");
828+ var orientedShell = loadShell("mako");
829+ var shell = findChild(orientedShell, "shell");
830+ var topLevelSurfaceList = findInvisibleChild(orientedShell, "topLevelSurfaceList");
815 var weatherSurfaceId = topLevelSurfaceList.nextId;
831 var weatherSurfaceId = topLevelSurfaceList.nextId;
816 var weatherApp = ApplicationManager.startApplication("ubuntu-weather-app");
832 var weatherApp = ApplicationManager.startApplication("ubuntu-weather-app");
817 verify(weatherApp);
833 verify(weatherApp);
@@ -819,7 +835,7 @@ Rectangle {
819 // ensure the mock app is as we expect
835 // ensure the mock app is as we expect
820 compare(weatherApp.supportedOrientations, Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation);
836 compare(weatherApp.supportedOrientations, Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation);
822− waitUntilAppWindowIsFullyLoaded(weatherSurfaceId);
838+ waitUntilAppWindowIsFullyLoaded(weatherSurfaceId, orientedShell);
824 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
840 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
825 waitUntilTransitionsEnd(rotationStates);
841 waitUntilTransitionsEnd(rotationStates);
@@ -851,13 +867,15 @@ Rectangle {
851 have an opacity > 0.
867 have an opacity > 0.
853 function test_greeterStaysAwayAfterRotation() {
869 function test_greeterStaysAwayAfterRotation() {
854− loadShell("mako");
870+ var orientedShell = loadShell("mako");
871+ var shell = findChild(orientedShell, "shell");
872+ var topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
856 // Load an app which only supports primary
874 // Load an app which only supports primary
857 var primarySurfaceId = topLevelSurfaceList.nextId;
875 var primarySurfaceId = topLevelSurfaceList.nextId;
858 var primaryApp = ApplicationManager.startApplication("primary-oriented-app");
876 var primaryApp = ApplicationManager.startApplication("primary-oriented-app");
859 verify(primaryApp);
877 verify(primaryApp);
860− waitUntilAppWindowIsFullyLoaded(primarySurfaceId);
878+ waitUntilAppWindowIsFullyLoaded(primarySurfaceId, orientedShell);
862 var twitterSurfaceId = topLevelSurfaceList.nextId;
880 var twitterSurfaceId = topLevelSurfaceList.nextId;
863 var twitterApp = ApplicationManager.startApplication("twitter-webapp");
881 var twitterApp = ApplicationManager.startApplication("twitter-webapp");
@@ -868,17 +886,17 @@ Rectangle {
868 compare(twitterApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
886 compare(twitterApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
869 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
887 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
871− waitUntilAppWindowIsFullyLoaded(twitterSurfaceId);
889+ waitUntilAppWindowIsFullyLoaded(twitterSurfaceId, orientedShell);
872− waitUntilAppWindowCanRotate(twitterSurfaceId);
890+ waitUntilAppWindowCanRotate(twitterSurfaceId, orientedShell);
874 // go back to primary-oriented-app
892 // go back to primary-oriented-app
875− performEdgeSwipeToSwitchToPreviousApp();
893+ performEdgeSwipeToSwitchToPreviousApp(orientedShell);
877− rotateTo(90);
895+ rotateTo(90, orientedShell);
878 wait(1); // spin the event loop to let all bindings do their thing
896 wait(1); // spin the event loop to let all bindings do their thing
879 tryCompare(shell, "transformRotationAngle", 0);
897 tryCompare(shell, "transformRotationAngle", 0);
881− performEdgeSwipeToShowAppSpread();
899+ performEdgeSwipeToShowAppSpread(shell);
883 // wait until things have settled
901 // wait until things have settled
884 var greeter = findChild(shell, "greeter");
902 var greeter = findChild(shell, "greeter");
@@ -903,7 +921,9 @@ Rectangle {
904 function test_appInSideStageDoesntRotateOnStartUp(data) {
922 function test_appInSideStageDoesntRotateOnStartUp(data) {
905 WindowStateStorage.saveStage("twitter-webapp", ApplicationInfoInterface.SideStage)
923 WindowStateStorage.saveStage("twitter-webapp", ApplicationInfoInterface.SideStage)
906− loadShell(data.deviceName);
924+ var orientedShell = loadShell(data.deviceName);
925+ var shell = findChild(orientedShell, "shell");
926+ var topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
908 var twitterSurfaceId = topLevelSurfaceList.nextId;
928 var twitterSurfaceId = topLevelSurfaceList.nextId;
909 var twitterApp = ApplicationManager.startApplication("twitter-webapp");
929 var twitterApp = ApplicationManager.startApplication("twitter-webapp");
@@ -933,7 +953,8 @@ Rectangle {
935 function test_portraitOnlyAppInSideStage(data) {
955 function test_portraitOnlyAppInSideStage(data) {
936− loadShell(data.deviceName);
956+ var orientedShell = loadShell(data.deviceName);
957+ var shell = findChild(orientedShell, "shell");
938 var dialerDelegate = null;
959 var dialerDelegate = null;
939 verify(appRepeaterConnections.target);
960 verify(appRepeaterConnections.target);
@@ -974,12 +995,13 @@ Rectangle {
976 function test_launchedAppHasActiveFocus(data) {
997 function test_launchedAppHasActiveFocus(data) {
977− loadShell(data.deviceName);
998+ var orientedShell = loadShell(data.deviceName);
999+ var topLevelSurfaceList = findInvisibleChild(orientedShell, "topLevelSurfaceList");
979 var gmailSurfaceId = topLevelSurfaceList.nextId;
1001 var gmailSurfaceId = topLevelSurfaceList.nextId;
980 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
1002 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
981 verify(gmailApp);
1003 verify(gmailApp);
982− waitUntilAppWindowIsFullyLoaded(gmailSurfaceId);
1004+ waitUntilAppWindowIsFullyLoaded(gmailSurfaceId, orientedShell);
984 var gmailSurface = gmailApp.surfaceList.get(0);
1006 var gmailSurface = gmailApp.surfaceList.get(0);
985 verify(gmailSurface);
1007 verify(gmailSurface);
@@ -988,12 +1010,14 @@ Rectangle {
990 function test_launchLandscapeOnlyAppOverPortraitOnlyDashThenSwitchToDash() {
1012 function test_launchLandscapeOnlyAppOverPortraitOnlyDashThenSwitchToDash() {
991− loadShell("mako");
1013+ var orientedShell = loadShell("mako");
1014+ var shell = findChild(orientedShell, "shell");
1015+ var topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
993 var dashSurfaceId = topLevelSurfaceList.nextId;
1017 var dashSurfaceId = topLevelSurfaceList.nextId;
994 var dashApp = ApplicationManager.startApplication("unity8-dash");
1018 var dashApp = ApplicationManager.startApplication("unity8-dash");
995 verify(dashApp);
1019 verify(dashApp);
996− waitUntilAppWindowIsFullyLoaded(dashSurfaceId);
1020+ waitUntilAppWindowIsFullyLoaded(dashSurfaceId, orientedShell);
998 // starts as portrait, as unity8-dash is portrait only
1022 // starts as portrait, as unity8-dash is portrait only
999 tryCompare(shell, "transformRotationAngle", 0);
1023 tryCompare(shell, "transformRotationAngle", 0);
@@ -1005,7 +1029,7 @@ Rectangle {
1005 // ensure the mock app is as we expect
1029 // ensure the mock app is as we expect
1006 compare(weatherApp.supportedOrientations, Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation);
1030 compare(weatherApp.supportedOrientations, Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation);
1008− waitUntilAppWindowIsFullyLoaded(weatherSurfaceId);
1032+ waitUntilAppWindowIsFullyLoaded(weatherSurfaceId, orientedShell);
1010 // should have rotated to landscape
1034 // should have rotated to landscape
1011 tryCompareFunction(function () { return shell.transformRotationAngle == 270
1035 tryCompareFunction(function () { return shell.transformRotationAngle == 270
@@ -1038,13 +1062,13 @@ Rectangle {
1040 function test_attachRemoveInputDevices(data) {
1064 function test_attachRemoveInputDevices(data) {
1041− loadShell("mako")
1065+ var orientedShell = loadShell("mako");
1042− MockInputDeviceBackend.removeDevice("/indicator_kbd0");
1043 var shell = findChild(orientedShell, "shell");
1066 var shell = findChild(orientedShell, "shell");
1067+ MockInputDeviceBackend.removeDevice("/indicator_kbd0");
1044 var inputMethod = findChild(shell, "inputMethod");
1068 var inputMethod = findChild(shell, "inputMethod");
1046− var oldWidth = orientedShellLoader.width;
1070+ var oldWidth = shellRect.width;
1047− orientedShellLoader.width = data.screenWidth;
1071+ shellRect.width = data.screenWidth;
1049 tryCompare(shell, "usageScenario", "phone");
1073 tryCompare(shell, "usageScenario", "phone");
1050 tryCompare(inputMethod, "enabled", true);
1074 tryCompare(inputMethod, "enabled", true);
@@ -1062,17 +1086,17 @@ Rectangle {
1062 tryCompare(oskSettings, "disableHeight", data.expectedMode == "desktop" || data.kbd);
1086 tryCompare(oskSettings, "disableHeight", data.expectedMode == "desktop" || data.kbd);
1064 // Restore width
1088 // Restore width
1065− orientedShellLoader.width = oldWidth;
1089+ shellRect.width = oldWidth;
1068 function test_screenSizeChanges() {
1092 function test_screenSizeChanges() {
1069− loadShell("mako")
1093+ var orientedShell = loadShell("mako");
1070 var shell = findChild(orientedShell, "shell");
1094 var shell = findChild(orientedShell, "shell");
1072 tryCompare(shell, "usageScenario", "phone");
1096 tryCompare(shell, "usageScenario", "phone");
1074 // make screen larger
1098 // make screen larger
1075− orientedShellLoader.width = units.gu(90);
1099+ shellRect.width = units.gu(90);
1076 tryCompare(shell, "usageScenario", "phone");
1100 tryCompare(shell, "usageScenario", "phone");
1078 // plug a mouse
1102 // plug a mouse
@@ -1080,17 +1104,18 @@ Rectangle {
1080 tryCompare(shell, "usageScenario", "desktop");
1104 tryCompare(shell, "usageScenario", "desktop");
1082 // make the screen smaller again, it should go back to staged even though there's still a mouse around
1106 // make the screen smaller again, it should go back to staged even though there's still a mouse around
1083− orientedShellLoader.width = units.gu(40);
1107+ shellRect.width = units.gu(40);
1085 tryCompare(shell, "usageScenario", "phone");
1109 tryCompare(shell, "usageScenario", "phone");
1088 function test_overrideStaged() {
1112 function test_overrideStaged() {
1089− loadShell("mako")
1113+ var orientedShell = loadShell("mako");
1114+ var shell = findChild(orientedShell, "shell");
1091 // make sure we're big enough so that the automatism starts working
1116 // make sure we're big enough so that the automatism starts working
1092− var oldWidth = orientedShellLoader.width;
1117+ var oldWidth = shellRect.width;
1093− orientedShellLoader.width = units.gu(100);
1118+ shellRect.width = units.gu(100);
1095 // start off by plugging a mouse, we should switch to windowed
1120 // start off by plugging a mouse, we should switch to windowed
1096 MockInputDeviceBackend.addMockDevice("/mouse0", InputInfo.Mouse);
1121 MockInputDeviceBackend.addMockDevice("/mouse0", InputInfo.Mouse);
@@ -1117,7 +1142,7 @@ Rectangle {
1117 tryCompare(shell, "usageScenario", "phone");
1142 tryCompare(shell, "usageScenario", "phone");
1119 // Restore width
1144 // Restore width
1120− orientedShellLoader.width = oldWidth;
1145+ shellRect.width = oldWidth;
1123 function test_setsUsageModeOnStartup() {
1148 function test_setsUsageModeOnStartup() {
@@ -1127,17 +1152,19 @@ Rectangle {
1127 compare(unity8Settings.usageMode, "Staged");
1152 compare(unity8Settings.usageMode, "Staged");
1129 // Load shell, and have it pick desktop
1154 // Load shell, and have it pick desktop
1130− loadShell("desktop");
1155+ var orientedShell = loadShell("desktop");
1156+ var shell = findChild(orientedShell, "shell");
1131 compare(shell.usageScenario, "desktop");
1157 compare(shell.usageScenario, "desktop");
1132 compare(unity8Settings.usageMode, "Windowed");
1158 compare(unity8Settings.usageMode, "Windowed");
1135 function test_overrideWindowed() {
1161 function test_overrideWindowed() {
1136− loadShell("mako")
1162+ var orientedShell = loadShell("mako")
1163+ var shell = findChild(orientedShell, "shell");
1138 // make sure we're big enough so that the automatism starts working
1165 // make sure we're big enough so that the automatism starts working
1139− var oldWidth = orientedShellLoader.width;
1166+ var oldWidth = shellRect.width;
1140− orientedShellLoader.width = units.gu(100);
1167+ shellRect.width = units.gu(100);
1142 // No mouse attached... we should be in staged
1169 // No mouse attached... we should be in staged
1143 tryCompare(shell, "usageScenario", "phone");
1170 tryCompare(shell, "usageScenario", "phone");
@@ -1155,7 +1182,7 @@ Rectangle {
1155 tryCompare(shell, "usageScenario", "phone");
1182 tryCompare(shell, "usageScenario", "phone");
1157 // Restore width
1184 // Restore width
1158− orientedShellLoader.width = oldWidth;
1185+ shellRect.width = oldWidth;
@@ -1180,7 +1207,8 @@ Rectangle {
1180 hence the bug.
1207 hence the bug.
1182 function test_phoneWithSpreadInLandscapeWhenGreeterShowsUp() {
1209 function test_phoneWithSpreadInLandscapeWhenGreeterShowsUp() {
1183− loadShell("mako");
1210+ var orientedShell = loadShell("mako");
1211+ var shell = findChild(orientedShell, "shell");
1185 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
1213 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
1186 verify(gmailApp);
1214 verify(gmailApp);
@@ -1193,12 +1221,12 @@ Rectangle {
1193 // wait until it's able to rotate
1221 // wait until it's able to rotate
1194 tryCompare(shell, "orientationChangesEnabled", true);
1222 tryCompare(shell, "orientationChangesEnabled", true);
1196− rotateTo(90);
1224+ rotateTo(90, orientedShell);
1197 tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle + 90);
1225 tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle + 90);
1199− performEdgeSwipeToShowAppSpread();
1227+ performEdgeSwipeToShowAppSpread(shell);
1201− showGreeter();
1229+ showGreeter(orientedShell);
1203 tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle);
1231 tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle);
@@ -1223,22 +1251,24 @@ Rectangle {
1223 - The portrait-only application rotates freely
1251 - The portrait-only application rotates freely
1225 function test_lockPhoneAfterClosingAppInSpreadThenUnlockAndRotate() {
1253 function test_lockPhoneAfterClosingAppInSpreadThenUnlockAndRotate() {
1226− loadShell("mako");
1254+ var orientedShell = loadShell("mako");
1255+ var topLevelSurfaceList = findInvisibleChild(orientedShell, "topLevelSurfaceList");
1256+ var shell = findChild(orientedShell, "shell");
1228 var primarySurfaceId = topLevelSurfaceList.nextId;
1258 var primarySurfaceId = topLevelSurfaceList.nextId;
1229 var primaryApp = ApplicationManager.startApplication("primary-oriented-app");
1259 var primaryApp = ApplicationManager.startApplication("primary-oriented-app");
1230 verify(primaryApp);
1260 verify(primaryApp);
1231− waitUntilAppWindowIsFullyLoaded(primarySurfaceId);
1261+ waitUntilAppWindowIsFullyLoaded(primarySurfaceId, orientedShell);
1233 var gmailSurfaceId = topLevelSurfaceList.nextId;
1263 var gmailSurfaceId = topLevelSurfaceList.nextId;
1234 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
1264 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
1235 verify(gmailApp);
1265 verify(gmailApp);
1237− waitUntilAppWindowIsFullyLoaded(gmailSurfaceId);
1267+ waitUntilAppWindowIsFullyLoaded(gmailSurfaceId, orientedShell);
1239− performEdgeSwipeToShowAppSpread();
1269+ performEdgeSwipeToShowAppSpread(shell);
1241− swipeToCloseCurrentAppInSpread();
1271+ swipeToCloseCurrentAppInSpread(orientedShell);
1243 // press the power key once
1273 // press the power key once
1244 Powerd.setStatus(Powerd.Off, Powerd.Unknown);
1274 Powerd.setStatus(Powerd.Off, Powerd.Unknown);
@@ -1248,23 +1278,24 @@ Rectangle {
1248 // and a second time to turn the display back on
1278 // and a second time to turn the display back on
1249 Powerd.setStatus(Powerd.On, Powerd.Unknown);
1279 Powerd.setStatus(Powerd.On, Powerd.Unknown);
1251− swipeAwayGreeter();
1281+ swipeAwayGreeter(orientedShell);
1253− tryCompareFunction(function() { return isAppSurfaceFocused(primarySurfaceId)}, true, 10000)
1283+ tryCompareFunction(function() { return isAppSurfaceFocused(topLevelSurfaceList, primarySurfaceId)}, true, 10000)
1255 signalSpy.clear();
1285 signalSpy.clear();
1256 signalSpy.target = shell;
1286 signalSpy.target = shell;
1257 signalSpy.signalName = "widthChanged";
1287 signalSpy.signalName = "widthChanged";
1258 verify(signalSpy.valid);
1288 verify(signalSpy.valid);
1260− rotateTo(90);
1290+ rotateTo(90, orientedShell);
1262 // shell shouldn't have change its orientation at any moment
1292 // shell shouldn't have change its orientation at any moment
1263 compare(signalSpy.count, 0);
1293 compare(signalSpy.count, 0);
1266 function test_moveToExternalMonitor() {
1296 function test_moveToExternalMonitor() {
1267− loadShell("flo");
1297+ var orientedShell = loadShell("flo");
1298+ var shell = findChild(orientedShell, "shell");
1269 compare(orientedShell.orientation, Qt.InvertedLandscapeOrientation);
1300 compare(orientedShell.orientation, Qt.InvertedLandscapeOrientation);
1270 compare(shell.transformRotationAngle, 90);
1301 compare(shell.transformRotationAngle, 90);
@@ -1298,7 +1329,9 @@ Rectangle {
1300 function test_portraitOnlyAppInLandscapeDesktop(data) {
1331 function test_portraitOnlyAppInLandscapeDesktop(data) {
1301− loadShell(data.deviceName);
1332+ var orientedShell = loadShell(data.deviceName);
1333+ var topLevelSurfaceList = findInvisibleChild(orientedShell, "topLevelSurfaceList");
1334+ var shell = findChild(orientedShell, "shell");
1304 // setup preconditions (put shell in Desktop mode and landscape)
1337 // setup preconditions (put shell in Desktop mode and landscape)
@@ -1306,8 +1339,8 @@ Rectangle {
1306 usageModeSelector.selectWindowed();
1339 usageModeSelector.selectWindowed();
1308 orientedShell.physicalOrientation = orientedShell.orientations.landscape;
1341 orientedShell.physicalOrientation = orientedShell.orientations.landscape;
1309− waitUntilShellIsInOrientation(orientedShell.orientations.landscape);
1342+ waitUntilShellIsInOrientation(orientedShell.orientations.landscape, orientedShell);
1310− waitForRotationAnimationsToFinish();
1343+ waitForRotationAnimationsToFinish(orientedShell);
1313 // Launch a portrait-only application
1346 // Launch a portrait-only application
@@ -1320,39 +1353,39 @@ Rectangle {
1320 compare(dialerApp.rotatesWindowContents, false);
1353 compare(dialerApp.rotatesWindowContents, false);
1321 compare(dialerApp.supportedOrientations, Qt.PortraitOrientation | Qt.InvertedPortraitOrientation);
1354 compare(dialerApp.supportedOrientations, Qt.PortraitOrientation | Qt.InvertedPortraitOrientation);
1323− waitUntilAppWindowIsFullyLoaded(dialerSurfaceId);
1356+ waitUntilAppWindowIsFullyLoaded(dialerSurfaceId, orientedShell);
1324− waitUntilAppWindowCanRotate(dialerSurfaceId);
1357+ waitUntilAppWindowCanRotate(dialerSurfaceId, orientedShell);
1325− verify(isAppSurfaceFocused(dialerSurfaceId));
1358+ verify(isAppSurfaceFocused(topLevelSurfaceList, dialerSurfaceId));
1328 // check outcome (shell should stay in landscape)
1361 // check outcome (shell should stay in landscape)
1330− waitForRotationAnimationsToFinish();
1363+ waitForRotationAnimationsToFinish(orientedShell);
1331 compare(shell.orientation, orientedShell.orientations.landscape);
1364 compare(shell.orientation, orientedShell.orientations.landscape);
1334 // angle - rotation angle in degrees clockwise, relative to the primary orientation.
1367 // angle - rotation angle in degrees clockwise, relative to the primary orientation.
1335− function rotateTo(angle) {
1368+ function rotateTo(angle, orientedShell) {
1336 switch (angle) {
1369 switch (angle) {
1338− rotate0Button.clicked();
1371+ root.rotate0(orientedShell);
1340 case 90:
1373 case 90:
1341− rotate90Button.clicked();
1374+ root.rotate90(orientedShell);
1343 case 180:
1376 case 180:
1344− rotate180Button.clicked();
1377+ root.rotate180(orientedShell);
1346 case 270:
1379 case 270:
1347− rotate270Button.clicked();
1380+ root.rotate270(orientedShell);
1349 default:
1382 default:
1350 verify(false);
1383 verify(false);
1352− waitForRotationAnimationsToFinish();
1385+ waitForRotationAnimationsToFinish(orientedShell);
1355− function waitForRotationAnimationsToFinish() {
1388+ function waitForRotationAnimationsToFinish(orientedShell) {
1356 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
1389 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
1357 verify(rotationStates.d);
1390 verify(rotationStates.d);
1358 verify(rotationStates.d.stateUpdateTimer);
1391 verify(rotationStates.d.stateUpdateTimer);
@@ -1374,8 +1407,8 @@ Rectangle {
1374 tryCompare(appWindowStates, "state", "surface");
1407 tryCompare(appWindowStates, "state", "surface");
1377− function findAppWindowForSurfaceId(surfaceId) {
1410+ function findAppWindowForSurfaceId(surfaceId, orientedShell) {
1378− var delegate = findChild(shell, "appDelegate_" + surfaceId);
1411+ var delegate = findChild(orientedShell, "appDelegate_" + surfaceId);
1379 verify(delegate);
1412 verify(delegate);
1380 var appWindow = findChild(delegate, "appWindow");
1413 var appWindow = findChild(delegate, "appWindow");
1381 return appWindow;
1414 return appWindow;
@@ -1383,25 +1416,28 @@ Rectangle {
1384 // Wait until the ApplicationWindow for the given Application object is fully loaded
1417 // Wait until the ApplicationWindow for the given Application object is fully loaded
1385 // (ie, the real surface has replaced the splash screen)
1418 // (ie, the real surface has replaced the splash screen)
1386− function waitUntilAppWindowIsFullyLoaded(surfaceId) {
1419+ function waitUntilAppWindowIsFullyLoaded(surfaceId, orientedShell) {
1387− var appWindow = findAppWindowForSurfaceId(surfaceId);
1420+ var appWindow = findAppWindowForSurfaceId(surfaceId, orientedShell);
1388 var appWindowStateGroup = findInvisibleChild(appWindow, "applicationWindowStateGroup");
1421 var appWindowStateGroup = findInvisibleChild(appWindow, "applicationWindowStateGroup");
1389 tryCompareFunction(function() { return appWindowStateGroup.state === "surface" }, true);
1422 tryCompareFunction(function() { return appWindowStateGroup.state === "surface" }, true);
1390 waitUntilTransitionsEnd(appWindowStateGroup);
1423 waitUntilTransitionsEnd(appWindowStateGroup);
1393− function waitUntilAppWindowCanRotate(surfaceId) {
1426+ function waitUntilAppWindowCanRotate(surfaceId, orientedShell) {
1394− var appWindow = findAppWindowForSurfaceId(surfaceId);
1427+ var appWindow = findAppWindowForSurfaceId(surfaceId, orientedShell);
1395 tryCompare(appWindow, "orientationChangesEnabled", true);
1428 tryCompare(appWindow, "orientationChangesEnabled", true);
1398− function waitUntilShellIsInOrientation(orientation) {
1431+ function waitUntilShellIsInOrientation(orientation, orientedShell) {
1432+ var shell = findInvisibleChild(orientedShell, "shell");
1399 tryCompare(shell, "orientation", orientation);
1433 tryCompare(shell, "orientation", orientation);
1400 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
1434 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
1401 waitUntilTransitionsEnd(rotationStates);
1435 waitUntilTransitionsEnd(rotationStates);
1404− function performEdgeSwipeToSwitchToPreviousApp() {
1438+ function performEdgeSwipeToSwitchToPreviousApp(orientedShell) {
1439+ var topLevelSurfaceList = findInvisibleChild(orientedShell, "topLevelSurfaceList");
1440+ var shell = findChild(orientedShell, "shell");
1405 // swipe just enough to ensure an app switch action.
1441 // swipe just enough to ensure an app switch action.
1406 // If we swipe too much we will trigger the spread mode
1442 // If we swipe too much we will trigger the spread mode
1407 // and we don't want that.
1443 // and we don't want that.
@@ -1416,41 +1452,43 @@ Rectangle {
1416 tryCompareFunction(function(){ return topLevelSurfaceList.idAt(0); }, previousSurfaceId);
1452 tryCompareFunction(function(){ return topLevelSurfaceList.idAt(0); }, previousSurfaceId);
1419− function performEdgeSwipeToShowAppSpread() {
1455+ function performEdgeSwipeToShowAppSpread(orientedShell) {
1420− var touchStartY = shell.height / 2;
1456+ var touchStartY = orientedShell.height / 2;
1421− touchFlick(shell,
1457+ touchFlick(orientedShell,
1422− shell.width - 1, touchStartY,
1458+ orientedShell.width - 1, touchStartY,
1423 0, touchStartY);
1459 0, touchStartY);
1425− var stage = findChild(shell, "stage");
1461+ var stage = findChild(orientedShell, "stage");
1426 tryCompare(stage, "state", "spread");
1462 tryCompare(stage, "state", "spread");
1427 waitForRendering(stage);
1463 waitForRendering(stage);
1430− function showPowerDialog() {
1466+ function showPowerDialog(orientedShell) {
1431 var dialogs = findChild(orientedShell, "dialogs");
1467 var dialogs = findChild(orientedShell, "dialogs");
1432 var dialogsPrivate = findInvisibleChild(dialogs, "dialogsPrivate");
1468 var dialogsPrivate = findInvisibleChild(dialogs, "dialogsPrivate");
1433 dialogsPrivate.showPowerDialog();
1469 dialogsPrivate.showPowerDialog();
1436− function swipeAwayGreeter() {
1472+ function swipeAwayGreeter(orientedShell) {
1473+ var shell = findChild(orientedShell, "shell");
1437 var greeter = findChild(shell, "greeter");
1474 var greeter = findChild(shell, "greeter");
1438 tryCompare(greeter, "fullyShown", true);
1476 tryCompare(greeter, "fullyShown", true);
1439 waitForRendering(greeter)
1477 waitForRendering(greeter)
1441 var touchX = shell.width * .75;
1479 var touchX = shell.width * .75;
1442 var touchY = shell.height / 2;
1480 var touchY = shell.height / 2;
1443− touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY);
1481+ touchFlick(shell, touchX, touchY, orientedShell.width * 0.1, touchY);
1445 // wait until the animation has finished
1483 // wait until the animation has finished
1446 tryCompare(greeter, "shown", false);
1484 tryCompare(greeter, "shown", false);
1447 waitForRendering(greeter);
1485 waitForRendering(greeter);
1450− function showGreeter() {
1488+ function showGreeter(orientedShell) {
1451 LightDM.Greeter.showGreeter();
1489 LightDM.Greeter.showGreeter();
1452 // wait until the animation has finished
1490 // wait until the animation has finished
1453− var greeter = findChild(shell, "greeter");
1491+ var greeter = findChild(orientedShell, "greeter");
1454 tryCompare(greeter, "fullyShown", true);
1492 tryCompare(greeter, "fullyShown", true);
@@ -1458,32 +1496,29 @@ Rectangle {
1458 applicationArguments.deviceName = deviceName;
1496 applicationArguments.deviceName = deviceName;
1460 // reload our test subject to get it in a fresh state once again
1498 // reload our test subject to get it in a fresh state once again
1461− orientedShellLoader.active = true;
1499+ var orientedShell = createTemporaryObject(shellComponent, shellRect);
1463− tryCompare(orientedShellLoader, "status", Loader.Ready);
1464− removeTimeConstraintsFromSwipeAreas(orientedShellLoader.item);
1466− shell = findChild(orientedShell, "shell");
1501+ removeTimeConstraintsFromSwipeAreas(orientedShell);
1468− topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
1503+ var shell = findChild(orientedShell, "shell");
1469− verify(topLevelSurfaceList);
1471 tryCompare(shell, "waitingOnGreeter", false); // reset by greeter when ready
1505 tryCompare(shell, "waitingOnGreeter", false); // reset by greeter when ready
1473− waitUntilShellIsInOrientation(root.physicalOrientation0);
1507+ waitUntilShellIsInOrientation(root.physicalOrientation0, orientedShell);
1475− waitForGreeterToStabilize();
1509+ waitForGreeterToStabilize(orientedShell);
1477− swipeAwayGreeter();
1511+ swipeAwayGreeter(orientedShell);
1479 var appRepeater = findChild(shell, "appRepeater");
1513 var appRepeater = findChild(shell, "appRepeater");
1480 if (appRepeater) {
1514 if (appRepeater) {
1481 appRepeaterConnections.target = appRepeater;
1515 appRepeaterConnections.target = appRepeater;
1517+ return orientedShell;
1485− function waitForGreeterToStabilize() {
1520+ function waitForGreeterToStabilize(orientedShell) {
1486− var greeter = findChild(shell, "greeter");
1521+ var greeter = findChild(orientedShell, "greeter");
1487 verify(greeter);
1522 verify(greeter);
1489 var loginList = findChild(greeter, "loginList");
1524 var loginList = findChild(greeter, "loginList");
@@ -1496,7 +1531,7 @@ Rectangle {
1498 // expectedAngle is in orientedShell's coordinate system
1533 // expectedAngle is in orientedShell's coordinate system
1499− function checkAppSurfaceOrientation(item, app, expectedAngle) {
1534+ function checkAppSurfaceOrientation(item, app, expectedAngle, orientedShell) {
1500 var surface = app.surfaceList.get(0);
1535 var surface = app.surfaceList.get(0);
1501 if (!surface) {
1536 if (!surface) {
1502 console.warn("no surface");
1537 console.warn("no surface");
@@ -1539,8 +1574,9 @@ Rectangle {
1539 return null;
1574 return null;
1542− function swipeToCloseCurrentAppInSpread() {
1577+ function swipeToCloseCurrentAppInSpread(orientedShell) {
1578+ var topLevelSurfaceList = findInvisibleChild(orientedShell, "topLevelSurfaceList");
1543− var delegateToClose = findChild(shell, "appDelegate_" + topLevelSurfaceList.idAt(0));
1579+ var delegateToClose = findChild(orientedShell, "appDelegate_" + topLevelSurfaceList.idAt(0));
1544 verify(delegateToClose);
1580 verify(delegateToClose);
1546 var appIdToClose = ApplicationManager.get(0).appId;
1582 var appIdToClose = ApplicationManager.get(0).appId;
@@ -1557,7 +1593,7 @@ Rectangle {
1557 compare(ApplicationManager.findApplication(appIdToClose), null);
1593 compare(ApplicationManager.findApplication(appIdToClose), null);
1560− function isAppSurfaceFocused(surfaceId) {
1596+ function isAppSurfaceFocused(topLevelSurfaceList, surfaceId) {
1561 var index = topLevelSurfaceList.indexForId(surfaceId);
1597 var index = topLevelSurfaceList.indexForId(surfaceId);
1562 var surface = topLevelSurfaceList.surfaceAt(index);
1598 var surface = topLevelSurfaceList.surfaceAt(index);
1563 verify(surface);
1599 verify(surface);
@@ -1572,9 +1608,9 @@ Rectangle {
1574 function test_tabCyclyingInShutdownDialog(data) {
1610 function test_tabCyclyingInShutdownDialog(data) {
1575− loadShell("mako");
1611+ var orientedShell = loadShell("mako");
1577− testCase.showPowerDialog();
1613+ testCase.showPowerDialog(orientedShell);
1579 var dialogs = findChild(orientedShell, "dialogs");
1615 var dialogs = findChild(orientedShell, "dialogs");
1580 var buttons = findChildsByType(dialogs, "Button");
1616 var buttons = findChildsByType(dialogs, "Button");
@@ -1600,9 +1636,9 @@ Rectangle {
1602 function test_escClosesShutdownDialog() {
1638 function test_escClosesShutdownDialog() {
1603− loadShell("mako");
1639+ var orientedShell = loadShell("mako");
1605− testCase.showPowerDialog();
1641+ testCase.showPowerDialog(orientedShell);
1607 var dialogLoader = findChild(orientedShell, "dialogLoader");
1643 var dialogLoader = findChild(orientedShell, "dialogLoader");
1608 tryCompareFunction(function() { return dialogLoader.item !== null }, true);
1644 tryCompareFunction(function() { return dialogLoader.item !== null }, true);
@@ -1613,20 +1649,21 @@ Rectangle {
1615 function test_focusOnShutdownDialogClose() {
1651 function test_focusOnShutdownDialogClose() {
1616− loadShell("manta");
1652+ var orientedShell = loadShell("manta");
1653+ var topLevelSurfaceList = findInvisibleChild(orientedShell, "topLevelSurfaceList");
1617 usageModeSelector.selectWindowed();
1654 usageModeSelector.selectWindowed();
1619 var surfaceId = topLevelSurfaceList.nextId;
1656 var surfaceId = topLevelSurfaceList.nextId;
1620 var app = ApplicationManager.startApplication("twitter-webapp");
1657 var app = ApplicationManager.startApplication("twitter-webapp");
1621− waitUntilAppWindowIsFullyLoaded(surfaceId);
1658+ waitUntilAppWindowIsFullyLoaded(surfaceId, orientedShell);
1623− var primaryAppWindow = findAppWindowForSurfaceId(surfaceId);
1660+ var primaryAppWindow = findAppWindowForSurfaceId(surfaceId, orientedShell);
1624 var surface = app.surfaceList.get(0);
1661 var surface = app.surfaceList.get(0);
1625 var surfaceItem = findSurfaceItem(primaryAppWindow, surface);
1662 var surfaceItem = findSurfaceItem(primaryAppWindow, surface);
1627 compare(window.activeFocusItem, surfaceItem);
1664 compare(window.activeFocusItem, surfaceItem);
1629− testCase.showPowerDialog();
1666+ testCase.showPowerDialog(orientedShell);
1631 var dialogLoader = findChild(orientedShell, "dialogLoader");
1668 var dialogLoader = findChild(orientedShell, "dialogLoader");
1632 tryVerify(function() { return dialogLoader.item !== null });
1669 tryVerify(function() { return dialogLoader.item !== null });
@@ -1637,7 +1674,7 @@ Rectangle {
1637 compare(window.activeFocusItem, surfaceItem);
1674 compare(window.activeFocusItem, surfaceItem);
1639 // Do it twice, our previous solution failed the second time ^_^
1676 // Do it twice, our previous solution failed the second time ^_^
1640− testCase.showPowerDialog();
1677+ testCase.showPowerDialog(orientedShell);
1642 tryVerify(function() { return dialogLoader.item !== null });
1679 tryVerify(function() { return dialogLoader.item !== null });
@@ -1648,7 +1685,8 @@ Rectangle {
1650 function test_tutorialDisabledWithNoTouchscreen() {
1687 function test_tutorialDisabledWithNoTouchscreen() {
1651− loadShell("desktop");
1688+ var orientedShell = loadShell("desktop");
1689+ var shell = findChild(orientedShell, "shell");
1652 usageModeSelector.selectWindowed();
1690 usageModeSelector.selectWindowed();
1654 MockInputDeviceBackend.addMockDevice("/touchscreen", InputInfo.TouchScreen);
1692 MockInputDeviceBackend.addMockDevice("/touchscreen", InputInfo.TouchScreen);