@@ -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
@@ -289,14 +286,15 @@ Rectangle {
289 activeFocusOnPress: false
286 activeFocusOnPress: false
289+ Layout.fillWidth: true
290+ Layout.fillHeight: true
292 text: "Orientation Locked"
291 text: "Orientation Locked"
293− anchors.verticalCenter: parent.verticalCenter
297 text: "Power dialog"
295 text: "Power dialog"
298 activeFocusOnPress: false
296 activeFocusOnPress: false
299− onClicked: { testCase.showPowerDialog(); }
297+ onClicked: { testCase.showPowerDialog(tryShell); }
301 ListItem.ItemSelector {
299 ListItem.ItemSelector {
302 id: deviceNameSelector
300 id: deviceNameSelector
@@ -305,9 +303,9 @@ Rectangle {
305 text: "Device Name"
303 text: "Device Name"
306 model: ["mako", "manta", "flo", "desktop"]
304 model: ["mako", "manta", "flo", "desktop"]
307 onSelectedIndexChanged: {
305 onSelectedIndexChanged: {
308− testCase.tearDown();
306+ destroyShell();
309 applicationArguments.deviceName = model[selectedIndex];
307 applicationArguments.deviceName = model[selectedIndex];
310− orientedShellLoader.active = true;
308+ createTryShell();
313 ListItem.ItemSelector {
311 ListItem.ItemSelector {
@@ -350,10 +348,12 @@ Rectangle {
351+ Layout.fillWidth: true
352+ Layout.fillHeight: true
353 text: "Input Method"
353 text: "Input Method"
354− anchors.verticalCenter: parent.verticalCenter
358 text: Powerd.status === Powerd.On ? "Display ON" : "Display OFF"
358 text: Powerd.status === Powerd.On ? "Display ON" : "Display OFF"
359 activeFocusOnPress: false
359 activeFocusOnPress: false
@@ -438,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;
441 UnityTestCase {
473 UnityTestCase {
442 id: testCase
474 id: testCase
443 name: "OrientedShell"
475 name: "OrientedShell"
444 when: windowShown
476 when: windowShown
446− property Item orientedShell: orientedShellLoader.status === Loader.Ready ? orientedShellLoader.item : null
448− property QtObject topLevelSurfaceList
450 SignalSpy { id: signalSpy }
478 SignalSpy { id: signalSpy }
451 SignalSpy { id: signalSpy2 }
479 SignalSpy { id: signalSpy2 }
@@ -462,62 +490,41 @@ Rectangle {
464 function init() {
492 function init() {
465− if (orientedShellLoader.active) {
466− // happens for the very first test function as shell
467− // is loaded by default
472− function tearDown() {
473− orientedShellLoader.itemDestroyed = false;
474− orientedShellLoader.active = false;
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);
484− // kill all (fake) running apps
487 while (miceModel.count > 0)
493 while (miceModel.count > 0)
488 MockInputDeviceBackend.removeDevice("/mouse" + (miceModel.count - 1));
494 MockInputDeviceBackend.removeDevice("/mouse" + (miceModel.count - 1));
489 while (touchpadModel.count > 0)
495 while (touchpadModel.count > 0)
490 MockInputDeviceBackend.removeDevice("/touchpad" + (touchpadModel.count - 1));
496 MockInputDeviceBackend.removeDevice("/touchpad" + (touchpadModel.count - 1));
491 while (keyboardsModel.count > 0)
497 while (keyboardsModel.count > 0)
492 MockInputDeviceBackend.removeDevice("/kbd" + (keyboardsModel.count - 1))
498 MockInputDeviceBackend.removeDevice("/kbd" + (keyboardsModel.count - 1))
499+ usageModeSelector.selectStaged();
494− appRepeaterConnections.target = null;
502+ function tearDown() {
495− appRepeaterConnections.itemAddedCallback = null;
503+ // kill all (fake) running apps
496− signalSpy.target = null;
504+ testCase.killApps();
497− signalSpy.signalName = "";
499 LightDM.Greeter.authenticate(""); // reset greeter
505 LightDM.Greeter.authenticate(""); // reset greeter
501− usageModeSelector.selectStaged();
504 function cleanup() {
508 function cleanup() {
505− tryCompare(shell, "waitingOnGreeter", false, 10000); // make sure greeter didn't leave us in disabled state
509+ appRepeaterConnections.target = null;
506− shell = null;
510+ appRepeaterConnections.itemAddedCallback = null;
507− topLevelSurfaceList = null;
511+ signalSpy.target = null;
512+ signalSpy.signalName = "";
509 tearDown();
514 tearDown();
512 function test_appSupportingOnlyPrimaryOrientationMakesPhoneShellStayPut() {
517 function test_appSupportingOnlyPrimaryOrientationMakesPhoneShellStayPut() {
513− loadShell("mako");
518+ var orientedShell = loadShell("mako");
519+ var topLevelSurfaceList = findInvisibleChild(orientedShell, "topLevelSurfaceList");
520+ var shell = findChild(orientedShell, "shell");
515 var primarySurfaceId = topLevelSurfaceList.nextId;
522 var primarySurfaceId = topLevelSurfaceList.nextId;
516 var primaryApp = ApplicationManager.startApplication("primary-oriented-app");
523 var primaryApp = ApplicationManager.startApplication("primary-oriented-app");
517 verify(primaryApp);
524 verify(primaryApp);
518− waitUntilAppWindowIsFullyLoaded(primarySurfaceId);
525+ waitUntilAppWindowIsFullyLoaded(primarySurfaceId, orientedShell);
520− var primaryAppWindow = findAppWindowForSurfaceId(primarySurfaceId);
527+ var primaryAppWindow = findAppWindowForSurfaceId(primarySurfaceId, orientedShell);
521 verify(primaryAppWindow)
528 verify(primaryAppWindow)
522 var primaryDelegate = findChild(shell, "appDelegate_" + primarySurfaceId);
529 var primaryDelegate = findChild(shell, "appDelegate_" + primarySurfaceId);
@@ -526,22 +533,22 @@ Rectangle {
526 compare(primaryApp.supportedOrientations, Qt.PrimaryOrientation);
533 compare(primaryApp.supportedOrientations, Qt.PrimaryOrientation);
528 tryVerify(function(){return primaryDelegate.surface});
535 tryVerify(function(){return primaryDelegate.surface});
529− verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle));
536+ verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle, orientedShell));
531 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
538 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
532− rotateTo(90);
539+ rotateTo(90, orientedShell);
534− verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle));
541+ verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle, orientedShell));
535 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
542 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
537− rotateTo(180);
544+ rotateTo(180, orientedShell);
539− verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle));
546+ verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle, orientedShell));
540 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
547 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
542− rotateTo(270);
549+ rotateTo(270, orientedShell);
544− verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle));
551+ verify(checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle, orientedShell));
545 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
552 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
@@ -552,14 +559,16 @@ Rectangle {
554 function test_appSupportingOnlyPrimaryOrientationWillOnlyRotateInLandscape(data) {
561 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");
557 var primarySurfaceId = topLevelSurfaceList.nextId;
566 var primarySurfaceId = topLevelSurfaceList.nextId;
558 var primaryApp = ApplicationManager.startApplication("primary-oriented-app");
567 var primaryApp = ApplicationManager.startApplication("primary-oriented-app");
559 verify(primaryApp);
568 verify(primaryApp);
560− waitUntilAppWindowIsFullyLoaded(primarySurfaceId);
569+ waitUntilAppWindowIsFullyLoaded(primarySurfaceId, orientedShell);
562− var primaryAppWindow = findAppWindowForSurfaceId(primarySurfaceId);
571+ var primaryAppWindow = findAppWindowForSurfaceId(primarySurfaceId, orientedShell);
563 verify(primaryAppWindow)
572 verify(primaryAppWindow)
565 // primary-oriented-app supports only primary orientation
574 // primary-oriented-app supports only primary orientation
@@ -572,22 +581,22 @@ Rectangle {
573 tryCompareFunction(function(){return primaryApp.surfaceList.count > 0;}, true);
582 tryCompareFunction(function(){return primaryApp.surfaceList.count > 0;}, true);
575− tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle)}, true);
584+ tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle, orientedShell)}, true);
576 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
585 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
578− rotateTo(90);
587+ rotateTo(90, orientedShell);
580− tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle)}, true);
589+ tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle, orientedShell)}, true);
581 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
590 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
583− rotateTo(180);
592+ rotateTo(180, orientedShell);
585− tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle + 180)}, true);
594+ tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle + 180, orientedShell)}, true);
586 compare(shell.transformRotationAngle, root.primaryOrientationAngle + 180);
595 compare(shell.transformRotationAngle, root.primaryOrientationAngle + 180);
588− rotateTo(270);
597+ rotateTo(270, orientedShell);
590− tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle + 180)}, true);
599+ tryCompareFunction(function(){return checkAppSurfaceOrientation(primaryAppWindow, primaryApp, root.primaryOrientationAngle + 180, orientedShell)}, true);
591 compare(shell.transformRotationAngle, root.primaryOrientationAngle + 180);
600 compare(shell.transformRotationAngle, root.primaryOrientationAngle + 180);
@@ -599,7 +608,8 @@ Rectangle {
601 function test_greeterRemainsInPrimaryOrientation(data) {
610 function test_greeterRemainsInPrimaryOrientation(data) {
602− loadShell(data.deviceName);
611+ var orientedShell = loadShell(data.deviceName);
612+ var shell = findChild(orientedShell, "shell");
604 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
614 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
605 verify(gmailApp);
615 verify(gmailApp);
@@ -613,17 +623,17 @@ Rectangle {
613 tryCompare(shell, "orientationChangesEnabled", true);
623 tryCompare(shell, "orientationChangesEnabled", true);
615 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
625 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
616− rotateTo(90);
626+ rotateTo(90, orientedShell);
617 tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle + 90);
627 tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle + 90);
619− showGreeter();
629+ showGreeter(orientedShell);
621 tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle);
631 tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle);
622− rotateTo(180);
632+ rotateTo(180, orientedShell);
623 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
633 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
624− rotateTo(270);
634+ rotateTo(270, orientedShell);
625 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
635 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
626− rotateTo(0);
636+ rotateTo(0, orientedShell);
627 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
637 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
@@ -638,7 +648,9 @@ Rectangle {
640 function test_appRotatesWindowContents(data) {
650 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");
643 if (data.windowed) {
655 if (data.windowed) {
644 usageModeSelector.selectWindowed();
656 usageModeSelector.selectWindowed();
@@ -658,7 +670,7 @@ Rectangle {
658 compare(cameraApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
670 compare(cameraApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
659 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
671 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
661− waitUntilAppWindowIsFullyLoaded(cameraSurfaceId);
673+ waitUntilAppWindowIsFullyLoaded(cameraSurfaceId, orientedShell);
663 var focusChangedSpy = signalSpy;
675 var focusChangedSpy = signalSpy;
664 focusChangedSpy.clear();
676 focusChangedSpy.clear();
@@ -686,7 +698,7 @@ Rectangle {
686 transitionSpy.signalName = "runningChanged";
698 transitionSpy.signalName = "runningChanged";
687 verify(transitionSpy.valid);
699 verify(transitionSpy.valid);
689− rotateTo(90);
701+ rotateTo(90, orientedShell);
691 tryCompare(cameraSurface, "orientationAngle", data.orientationAngleAfterRotation);
703 tryCompare(cameraSurface, "orientationAngle", data.orientationAngleAfterRotation);
@@ -724,7 +736,9 @@ Rectangle {
726 function test_switchingToAppWithDifferentRotation(data) {
738 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");
728 var gmailSurfaceId = topLevelSurfaceList.nextId;
742 var gmailSurfaceId = topLevelSurfaceList.nextId;
729 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
743 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
730 verify(gmailApp);
744 verify(gmailApp);
@@ -734,7 +748,7 @@ Rectangle {
734 compare(gmailApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
748 compare(gmailApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
735 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
749 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
737− waitUntilAppWindowIsFullyLoaded(gmailSurfaceId);
751+ waitUntilAppWindowIsFullyLoaded(gmailSurfaceId, orientedShell);
739 var musicSurfaceId = topLevelSurfaceList.nextId;
753 var musicSurfaceId = topLevelSurfaceList.nextId;
740 var musicApp = ApplicationManager.startApplication("music-app");
754 var musicApp = ApplicationManager.startApplication("music-app");
@@ -749,13 +763,13 @@ Rectangle {
749 compare(musicDelegate.stage, ApplicationInfoInterface.MainStage);
763 compare(musicDelegate.stage, ApplicationInfoInterface.MainStage);
752− waitUntilAppWindowIsFullyLoaded(musicSurfaceId);
766+ waitUntilAppWindowIsFullyLoaded(musicSurfaceId, orientedShell);
753 tryCompare(shell, "orientationChangesEnabled", true);
767 tryCompare(shell, "orientationChangesEnabled", true);
755− rotateTo(90);
769+ rotateTo(90, orientedShell);
756 tryCompare(shell, "transformRotationAngle", data.shellAngleAfterRotation);
770 tryCompare(shell, "transformRotationAngle", data.shellAngleAfterRotation);
758− performEdgeSwipeToSwitchToPreviousApp();
772+ performEdgeSwipeToSwitchToPreviousApp(orientedShell);
760 tryCompare(shell, "mainAppWindowOrientationAngle", data.shellAngleAfterRotation);
774 tryCompare(shell, "mainAppWindowOrientationAngle", data.shellAngleAfterRotation);
761 compare(shell.transformRotationAngle, data.shellAngleAfterRotation);
775 compare(shell.transformRotationAngle, data.shellAngleAfterRotation);
@@ -783,7 +797,9 @@ Rectangle {
783 orientation (Screen.orientation), so they are both equally good alternatives
797 orientation (Screen.orientation), so they are both equally good alternatives
785 function test_rotateToUnsupportedDeviceOrientation(data) {
799 function test_rotateToUnsupportedDeviceOrientation(data) {
786− loadShell("mako");
800+ var orientedShell = loadShell("mako");
801+ var shell = findChild(orientedShell, "shell");
802+ var topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
787 var twitterSurfaceId = topLevelSurfaceList.nextId;
803 var twitterSurfaceId = topLevelSurfaceList.nextId;
788 var twitterApp = ApplicationManager.startApplication("twitter-webapp");
804 var twitterApp = ApplicationManager.startApplication("twitter-webapp");
789 verify(twitterApp);
805 verify(twitterApp);
@@ -793,12 +809,12 @@ Rectangle {
793 compare(twitterApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
809 compare(twitterApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
794 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
810 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
796− waitUntilAppWindowIsFullyLoaded(twitterSurfaceId);
812+ waitUntilAppWindowIsFullyLoaded(twitterSurfaceId, orientedShell);
798− rotateTo(data.rotationAngle);
814+ rotateTo(data.rotationAngle, orientedShell);
799 tryCompare(shell, "transformRotationAngle", data.rotationAngle);
815 tryCompare(shell, "transformRotationAngle", data.rotationAngle);
801− rotateTo(180);
817+ rotateTo(180, orientedShell);
802 tryCompare(shell, "transformRotationAngle", data.rotationAngle);
818 tryCompare(shell, "transformRotationAngle", data.rotationAngle);
804 function test_rotateToUnsupportedDeviceOrientation_data() {
820 function test_rotateToUnsupportedDeviceOrientation_data() {
@@ -809,7 +825,9 @@ Rectangle {
811 function test_launchLandscapeOnlyAppFromPortrait() {
827 function test_launchLandscapeOnlyAppFromPortrait() {
812− loadShell("mako");
828+ var orientedShell = loadShell("mako");
829+ var shell = findChild(orientedShell, "shell");
830+ var topLevelSurfaceList = findInvisibleChild(orientedShell, "topLevelSurfaceList");
813 var weatherSurfaceId = topLevelSurfaceList.nextId;
831 var weatherSurfaceId = topLevelSurfaceList.nextId;
814 var weatherApp = ApplicationManager.startApplication("ubuntu-weather-app");
832 var weatherApp = ApplicationManager.startApplication("ubuntu-weather-app");
815 verify(weatherApp);
833 verify(weatherApp);
@@ -817,7 +835,7 @@ Rectangle {
817 // ensure the mock app is as we expect
835 // ensure the mock app is as we expect
818 compare(weatherApp.supportedOrientations, Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation);
836 compare(weatherApp.supportedOrientations, Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation);
820− waitUntilAppWindowIsFullyLoaded(weatherSurfaceId);
838+ waitUntilAppWindowIsFullyLoaded(weatherSurfaceId, orientedShell);
822 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
840 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
823 waitUntilTransitionsEnd(rotationStates);
841 waitUntilTransitionsEnd(rotationStates);
@@ -849,13 +867,15 @@ Rectangle {
849 have an opacity > 0.
867 have an opacity > 0.
851 function test_greeterStaysAwayAfterRotation() {
869 function test_greeterStaysAwayAfterRotation() {
852− loadShell("mako");
870+ var orientedShell = loadShell("mako");
871+ var shell = findChild(orientedShell, "shell");
872+ var topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
854 // Load an app which only supports primary
874 // Load an app which only supports primary
855 var primarySurfaceId = topLevelSurfaceList.nextId;
875 var primarySurfaceId = topLevelSurfaceList.nextId;
856 var primaryApp = ApplicationManager.startApplication("primary-oriented-app");
876 var primaryApp = ApplicationManager.startApplication("primary-oriented-app");
857 verify(primaryApp);
877 verify(primaryApp);
858− waitUntilAppWindowIsFullyLoaded(primarySurfaceId);
878+ waitUntilAppWindowIsFullyLoaded(primarySurfaceId, orientedShell);
860 var twitterSurfaceId = topLevelSurfaceList.nextId;
880 var twitterSurfaceId = topLevelSurfaceList.nextId;
861 var twitterApp = ApplicationManager.startApplication("twitter-webapp");
881 var twitterApp = ApplicationManager.startApplication("twitter-webapp");
@@ -866,17 +886,17 @@ Rectangle {
866 compare(twitterApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
886 compare(twitterApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
867 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
887 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
869− waitUntilAppWindowIsFullyLoaded(twitterSurfaceId);
889+ waitUntilAppWindowIsFullyLoaded(twitterSurfaceId, orientedShell);
870− waitUntilAppWindowCanRotate(twitterSurfaceId);
890+ waitUntilAppWindowCanRotate(twitterSurfaceId, orientedShell);
872 // go back to primary-oriented-app
892 // go back to primary-oriented-app
873− performEdgeSwipeToSwitchToPreviousApp();
893+ performEdgeSwipeToSwitchToPreviousApp(orientedShell);
875− rotateTo(90);
895+ rotateTo(90, orientedShell);
876 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
877 tryCompare(shell, "transformRotationAngle", 0);
897 tryCompare(shell, "transformRotationAngle", 0);
879− performEdgeSwipeToShowAppSpread();
899+ performEdgeSwipeToShowAppSpread(shell);
881 // wait until things have settled
901 // wait until things have settled
882 var greeter = findChild(shell, "greeter");
902 var greeter = findChild(shell, "greeter");
@@ -901,7 +921,9 @@ Rectangle {
902 function test_appInSideStageDoesntRotateOnStartUp(data) {
922 function test_appInSideStageDoesntRotateOnStartUp(data) {
903 WindowStateStorage.saveStage("twitter-webapp", ApplicationInfoInterface.SideStage)
923 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");
906 var twitterSurfaceId = topLevelSurfaceList.nextId;
928 var twitterSurfaceId = topLevelSurfaceList.nextId;
907 var twitterApp = ApplicationManager.startApplication("twitter-webapp");
929 var twitterApp = ApplicationManager.startApplication("twitter-webapp");
@@ -931,7 +953,8 @@ Rectangle {
933 function test_portraitOnlyAppInSideStage(data) {
955 function test_portraitOnlyAppInSideStage(data) {
934− loadShell(data.deviceName);
956+ var orientedShell = loadShell(data.deviceName);
957+ var shell = findChild(orientedShell, "shell");
936 var dialerDelegate = null;
959 var dialerDelegate = null;
937 verify(appRepeaterConnections.target);
960 verify(appRepeaterConnections.target);
@@ -972,12 +995,13 @@ Rectangle {
974 function test_launchedAppHasActiveFocus(data) {
997 function test_launchedAppHasActiveFocus(data) {
975− loadShell(data.deviceName);
998+ var orientedShell = loadShell(data.deviceName);
999+ var topLevelSurfaceList = findInvisibleChild(orientedShell, "topLevelSurfaceList");
977 var gmailSurfaceId = topLevelSurfaceList.nextId;
1001 var gmailSurfaceId = topLevelSurfaceList.nextId;
978 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
1002 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
979 verify(gmailApp);
1003 verify(gmailApp);
980− waitUntilAppWindowIsFullyLoaded(gmailSurfaceId);
1004+ waitUntilAppWindowIsFullyLoaded(gmailSurfaceId, orientedShell);
982 var gmailSurface = gmailApp.surfaceList.get(0);
1006 var gmailSurface = gmailApp.surfaceList.get(0);
983 verify(gmailSurface);
1007 verify(gmailSurface);
@@ -986,12 +1010,14 @@ Rectangle {
988 function test_launchLandscapeOnlyAppOverPortraitOnlyDashThenSwitchToDash() {
1012 function test_launchLandscapeOnlyAppOverPortraitOnlyDashThenSwitchToDash() {
989− loadShell("mako");
1013+ var orientedShell = loadShell("mako");
1014+ var shell = findChild(orientedShell, "shell");
1015+ var topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
991 var dashSurfaceId = topLevelSurfaceList.nextId;
1017 var dashSurfaceId = topLevelSurfaceList.nextId;
992 var dashApp = ApplicationManager.startApplication("unity8-dash");
1018 var dashApp = ApplicationManager.startApplication("unity8-dash");
993 verify(dashApp);
1019 verify(dashApp);
994− waitUntilAppWindowIsFullyLoaded(dashSurfaceId);
1020+ waitUntilAppWindowIsFullyLoaded(dashSurfaceId, orientedShell);
996 // starts as portrait, as unity8-dash is portrait only
1022 // starts as portrait, as unity8-dash is portrait only
997 tryCompare(shell, "transformRotationAngle", 0);
1023 tryCompare(shell, "transformRotationAngle", 0);
@@ -1003,7 +1029,7 @@ Rectangle {
1003 // ensure the mock app is as we expect
1029 // ensure the mock app is as we expect
1004 compare(weatherApp.supportedOrientations, Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation);
1030 compare(weatherApp.supportedOrientations, Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation);
1006− waitUntilAppWindowIsFullyLoaded(weatherSurfaceId);
1032+ waitUntilAppWindowIsFullyLoaded(weatherSurfaceId, orientedShell);
1008 // should have rotated to landscape
1034 // should have rotated to landscape
1009 tryCompareFunction(function () { return shell.transformRotationAngle == 270
1035 tryCompareFunction(function () { return shell.transformRotationAngle == 270
@@ -1036,13 +1062,13 @@ Rectangle {
1038 function test_attachRemoveInputDevices(data) {
1064 function test_attachRemoveInputDevices(data) {
1039− loadShell("mako")
1065+ var orientedShell = loadShell("mako");
1040− MockInputDeviceBackend.removeDevice("/indicator_kbd0");
1041 var shell = findChild(orientedShell, "shell");
1066 var shell = findChild(orientedShell, "shell");
1067+ MockInputDeviceBackend.removeDevice("/indicator_kbd0");
1042 var inputMethod = findChild(shell, "inputMethod");
1068 var inputMethod = findChild(shell, "inputMethod");
1044− var oldWidth = orientedShellLoader.width;
1070+ var oldWidth = shellRect.width;
1045− orientedShellLoader.width = data.screenWidth;
1071+ shellRect.width = data.screenWidth;
1047 tryCompare(shell, "usageScenario", "phone");
1073 tryCompare(shell, "usageScenario", "phone");
1048 tryCompare(inputMethod, "enabled", true);
1074 tryCompare(inputMethod, "enabled", true);
@@ -1060,17 +1086,17 @@ Rectangle {
1060 tryCompare(oskSettings, "disableHeight", data.expectedMode == "desktop" || data.kbd);
1086 tryCompare(oskSettings, "disableHeight", data.expectedMode == "desktop" || data.kbd);
1062 // Restore width
1088 // Restore width
1063− orientedShellLoader.width = oldWidth;
1089+ shellRect.width = oldWidth;
1066 function test_screenSizeChanges() {
1092 function test_screenSizeChanges() {
1067− loadShell("mako")
1093+ var orientedShell = loadShell("mako");
1068 var shell = findChild(orientedShell, "shell");
1094 var shell = findChild(orientedShell, "shell");
1070 tryCompare(shell, "usageScenario", "phone");
1096 tryCompare(shell, "usageScenario", "phone");
1072 // make screen larger
1098 // make screen larger
1073− orientedShellLoader.width = units.gu(90);
1099+ shellRect.width = units.gu(90);
1074 tryCompare(shell, "usageScenario", "phone");
1100 tryCompare(shell, "usageScenario", "phone");
1076 // plug a mouse
1102 // plug a mouse
@@ -1078,17 +1104,18 @@ Rectangle {
1078 tryCompare(shell, "usageScenario", "desktop");
1104 tryCompare(shell, "usageScenario", "desktop");
1080 // 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
1081− orientedShellLoader.width = units.gu(40);
1107+ shellRect.width = units.gu(40);
1083 tryCompare(shell, "usageScenario", "phone");
1109 tryCompare(shell, "usageScenario", "phone");
1086 function test_overrideStaged() {
1112 function test_overrideStaged() {
1087− loadShell("mako")
1113+ var orientedShell = loadShell("mako");
1114+ var shell = findChild(orientedShell, "shell");
1089 // 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
1090− var oldWidth = orientedShellLoader.width;
1117+ var oldWidth = shellRect.width;
1091− orientedShellLoader.width = units.gu(100);
1118+ shellRect.width = units.gu(100);
1093 // start off by plugging a mouse, we should switch to windowed
1120 // start off by plugging a mouse, we should switch to windowed
1094 MockInputDeviceBackend.addMockDevice("/mouse0", InputInfo.Mouse);
1121 MockInputDeviceBackend.addMockDevice("/mouse0", InputInfo.Mouse);
@@ -1115,7 +1142,7 @@ Rectangle {
1115 tryCompare(shell, "usageScenario", "phone");
1142 tryCompare(shell, "usageScenario", "phone");
1117 // Restore width
1144 // Restore width
1118− orientedShellLoader.width = oldWidth;
1145+ shellRect.width = oldWidth;
1121 function test_setsUsageModeOnStartup() {
1148 function test_setsUsageModeOnStartup() {
@@ -1125,17 +1152,19 @@ Rectangle {
1125 compare(unity8Settings.usageMode, "Staged");
1152 compare(unity8Settings.usageMode, "Staged");
1127 // Load shell, and have it pick desktop
1154 // Load shell, and have it pick desktop
1128− loadShell("desktop");
1155+ var orientedShell = loadShell("desktop");
1156+ var shell = findChild(orientedShell, "shell");
1129 compare(shell.usageScenario, "desktop");
1157 compare(shell.usageScenario, "desktop");
1130 compare(unity8Settings.usageMode, "Windowed");
1158 compare(unity8Settings.usageMode, "Windowed");
1133 function test_overrideWindowed() {
1161 function test_overrideWindowed() {
1134− loadShell("mako")
1162+ var orientedShell = loadShell("mako")
1163+ var shell = findChild(orientedShell, "shell");
1136 // 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
1137− var oldWidth = orientedShellLoader.width;
1166+ var oldWidth = shellRect.width;
1138− orientedShellLoader.width = units.gu(100);
1167+ shellRect.width = units.gu(100);
1140 // No mouse attached... we should be in staged
1169 // No mouse attached... we should be in staged
1141 tryCompare(shell, "usageScenario", "phone");
1170 tryCompare(shell, "usageScenario", "phone");
@@ -1153,7 +1182,7 @@ Rectangle {
1153 tryCompare(shell, "usageScenario", "phone");
1182 tryCompare(shell, "usageScenario", "phone");
1155 // Restore width
1184 // Restore width
1156− orientedShellLoader.width = oldWidth;
1185+ shellRect.width = oldWidth;
@@ -1178,7 +1207,8 @@ Rectangle {
1178 hence the bug.
1207 hence the bug.
1180 function test_phoneWithSpreadInLandscapeWhenGreeterShowsUp() {
1209 function test_phoneWithSpreadInLandscapeWhenGreeterShowsUp() {
1181− loadShell("mako");
1210+ var orientedShell = loadShell("mako");
1211+ var shell = findChild(orientedShell, "shell");
1183 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
1213 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
1184 verify(gmailApp);
1214 verify(gmailApp);
@@ -1191,12 +1221,12 @@ Rectangle {
1191 // wait until it's able to rotate
1221 // wait until it's able to rotate
1192 tryCompare(shell, "orientationChangesEnabled", true);
1222 tryCompare(shell, "orientationChangesEnabled", true);
1194− rotateTo(90);
1224+ rotateTo(90, orientedShell);
1195 tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle + 90);
1225 tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle + 90);
1197− performEdgeSwipeToShowAppSpread();
1227+ performEdgeSwipeToShowAppSpread(shell);
1199− showGreeter();
1229+ showGreeter(orientedShell);
1201 tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle);
1231 tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle);
@@ -1221,22 +1251,24 @@ Rectangle {
1221 - The portrait-only application rotates freely
1251 - The portrait-only application rotates freely
1223 function test_lockPhoneAfterClosingAppInSpreadThenUnlockAndRotate() {
1253 function test_lockPhoneAfterClosingAppInSpreadThenUnlockAndRotate() {
1224− loadShell("mako");
1254+ var orientedShell = loadShell("mako");
1255+ var topLevelSurfaceList = findInvisibleChild(orientedShell, "topLevelSurfaceList");
1256+ var shell = findChild(orientedShell, "shell");
1226 var primarySurfaceId = topLevelSurfaceList.nextId;
1258 var primarySurfaceId = topLevelSurfaceList.nextId;
1227 var primaryApp = ApplicationManager.startApplication("primary-oriented-app");
1259 var primaryApp = ApplicationManager.startApplication("primary-oriented-app");
1228 verify(primaryApp);
1260 verify(primaryApp);
1229− waitUntilAppWindowIsFullyLoaded(primarySurfaceId);
1261+ waitUntilAppWindowIsFullyLoaded(primarySurfaceId, orientedShell);
1231 var gmailSurfaceId = topLevelSurfaceList.nextId;
1263 var gmailSurfaceId = topLevelSurfaceList.nextId;
1232 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
1264 var gmailApp = ApplicationManager.startApplication("gmail-webapp");
1233 verify(gmailApp);
1265 verify(gmailApp);
1235− waitUntilAppWindowIsFullyLoaded(gmailSurfaceId);
1267+ waitUntilAppWindowIsFullyLoaded(gmailSurfaceId, orientedShell);
1237− performEdgeSwipeToShowAppSpread();
1269+ performEdgeSwipeToShowAppSpread(shell);
1239− swipeToCloseCurrentAppInSpread();
1271+ swipeToCloseCurrentAppInSpread(orientedShell);
1241 // press the power key once
1273 // press the power key once
1242 Powerd.setStatus(Powerd.Off, Powerd.Unknown);
1274 Powerd.setStatus(Powerd.Off, Powerd.Unknown);
@@ -1246,23 +1278,24 @@ Rectangle {
1246 // and a second time to turn the display back on
1278 // and a second time to turn the display back on
1247 Powerd.setStatus(Powerd.On, Powerd.Unknown);
1279 Powerd.setStatus(Powerd.On, Powerd.Unknown);
1249− swipeAwayGreeter();
1281+ swipeAwayGreeter(orientedShell);
1251− tryCompareFunction(function() { return isAppSurfaceFocused(primarySurfaceId)}, true, 10000)
1283+ tryCompareFunction(function() { return isAppSurfaceFocused(topLevelSurfaceList, primarySurfaceId)}, true, 10000)
1253 signalSpy.clear();
1285 signalSpy.clear();
1254 signalSpy.target = shell;
1286 signalSpy.target = shell;
1255 signalSpy.signalName = "widthChanged";
1287 signalSpy.signalName = "widthChanged";
1256 verify(signalSpy.valid);
1288 verify(signalSpy.valid);
1258− rotateTo(90);
1290+ rotateTo(90, orientedShell);
1260 // shell shouldn't have change its orientation at any moment
1292 // shell shouldn't have change its orientation at any moment
1261 compare(signalSpy.count, 0);
1293 compare(signalSpy.count, 0);
1264 function test_moveToExternalMonitor() {
1296 function test_moveToExternalMonitor() {
1265− loadShell("flo");
1297+ var orientedShell = loadShell("flo");
1298+ var shell = findChild(orientedShell, "shell");
1267 compare(orientedShell.orientation, Qt.InvertedLandscapeOrientation);
1300 compare(orientedShell.orientation, Qt.InvertedLandscapeOrientation);
1268 compare(shell.transformRotationAngle, 90);
1301 compare(shell.transformRotationAngle, 90);
@@ -1296,7 +1329,9 @@ Rectangle {
1298 function test_portraitOnlyAppInLandscapeDesktop(data) {
1331 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");
1302 // setup preconditions (put shell in Desktop mode and landscape)
1337 // setup preconditions (put shell in Desktop mode and landscape)
@@ -1304,8 +1339,8 @@ Rectangle {
1304 usageModeSelector.selectWindowed();
1339 usageModeSelector.selectWindowed();
1306 orientedShell.physicalOrientation = orientedShell.orientations.landscape;
1341 orientedShell.physicalOrientation = orientedShell.orientations.landscape;
1307− waitUntilShellIsInOrientation(orientedShell.orientations.landscape);
1342+ waitUntilShellIsInOrientation(orientedShell.orientations.landscape, orientedShell);
1308− waitForRotationAnimationsToFinish();
1343+ waitForRotationAnimationsToFinish(orientedShell);
1311 // Launch a portrait-only application
1346 // Launch a portrait-only application
@@ -1318,39 +1353,39 @@ Rectangle {
1318 compare(dialerApp.rotatesWindowContents, false);
1353 compare(dialerApp.rotatesWindowContents, false);
1319 compare(dialerApp.supportedOrientations, Qt.PortraitOrientation | Qt.InvertedPortraitOrientation);
1354 compare(dialerApp.supportedOrientations, Qt.PortraitOrientation | Qt.InvertedPortraitOrientation);
1321− waitUntilAppWindowIsFullyLoaded(dialerSurfaceId);
1356+ waitUntilAppWindowIsFullyLoaded(dialerSurfaceId, orientedShell);
1322− waitUntilAppWindowCanRotate(dialerSurfaceId);
1357+ waitUntilAppWindowCanRotate(dialerSurfaceId, orientedShell);
1323− verify(isAppSurfaceFocused(dialerSurfaceId));
1358+ verify(isAppSurfaceFocused(topLevelSurfaceList, dialerSurfaceId));
1326 // check outcome (shell should stay in landscape)
1361 // check outcome (shell should stay in landscape)
1328− waitForRotationAnimationsToFinish();
1363+ waitForRotationAnimationsToFinish(orientedShell);
1329 compare(shell.orientation, orientedShell.orientations.landscape);
1364 compare(shell.orientation, orientedShell.orientations.landscape);
1332 // angle - rotation angle in degrees clockwise, relative to the primary orientation.
1367 // angle - rotation angle in degrees clockwise, relative to the primary orientation.
1333− function rotateTo(angle) {
1368+ function rotateTo(angle, orientedShell) {
1334 switch (angle) {
1369 switch (angle) {
1336− rotate0Button.clicked();
1371+ root.rotate0(orientedShell);
1338 case 90:
1373 case 90:
1339− rotate90Button.clicked();
1374+ root.rotate90(orientedShell);
1341 case 180:
1376 case 180:
1342− rotate180Button.clicked();
1377+ root.rotate180(orientedShell);
1344 case 270:
1379 case 270:
1345− rotate270Button.clicked();
1380+ root.rotate270(orientedShell);
1347 default:
1382 default:
1348 verify(false);
1383 verify(false);
1350− waitForRotationAnimationsToFinish();
1385+ waitForRotationAnimationsToFinish(orientedShell);
1353− function waitForRotationAnimationsToFinish() {
1388+ function waitForRotationAnimationsToFinish(orientedShell) {
1354 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
1389 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
1355 verify(rotationStates.d);
1390 verify(rotationStates.d);
1356 verify(rotationStates.d.stateUpdateTimer);
1391 verify(rotationStates.d.stateUpdateTimer);
@@ -1372,8 +1407,8 @@ Rectangle {
1372 tryCompare(appWindowStates, "state", "surface");
1407 tryCompare(appWindowStates, "state", "surface");
1375− function findAppWindowForSurfaceId(surfaceId) {
1410+ function findAppWindowForSurfaceId(surfaceId, orientedShell) {
1376− var delegate = findChild(shell, "appDelegate_" + surfaceId);
1411+ var delegate = findChild(orientedShell, "appDelegate_" + surfaceId);
1377 verify(delegate);
1412 verify(delegate);
1378 var appWindow = findChild(delegate, "appWindow");
1413 var appWindow = findChild(delegate, "appWindow");
1379 return appWindow;
1414 return appWindow;
@@ -1381,25 +1416,28 @@ Rectangle {
1382 // 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
1383 // (ie, the real surface has replaced the splash screen)
1418 // (ie, the real surface has replaced the splash screen)
1384− function waitUntilAppWindowIsFullyLoaded(surfaceId) {
1419+ function waitUntilAppWindowIsFullyLoaded(surfaceId, orientedShell) {
1385− var appWindow = findAppWindowForSurfaceId(surfaceId);
1420+ var appWindow = findAppWindowForSurfaceId(surfaceId, orientedShell);
1386 var appWindowStateGroup = findInvisibleChild(appWindow, "applicationWindowStateGroup");
1421 var appWindowStateGroup = findInvisibleChild(appWindow, "applicationWindowStateGroup");
1387 tryCompareFunction(function() { return appWindowStateGroup.state === "surface" }, true);
1422 tryCompareFunction(function() { return appWindowStateGroup.state === "surface" }, true);
1388 waitUntilTransitionsEnd(appWindowStateGroup);
1423 waitUntilTransitionsEnd(appWindowStateGroup);
1391− function waitUntilAppWindowCanRotate(surfaceId) {
1426+ function waitUntilAppWindowCanRotate(surfaceId, orientedShell) {
1392− var appWindow = findAppWindowForSurfaceId(surfaceId);
1427+ var appWindow = findAppWindowForSurfaceId(surfaceId, orientedShell);
1393 tryCompare(appWindow, "orientationChangesEnabled", true);
1428 tryCompare(appWindow, "orientationChangesEnabled", true);
1396− function waitUntilShellIsInOrientation(orientation) {
1431+ function waitUntilShellIsInOrientation(orientation, orientedShell) {
1432+ var shell = findInvisibleChild(orientedShell, "shell");
1397 tryCompare(shell, "orientation", orientation);
1433 tryCompare(shell, "orientation", orientation);
1398 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
1434 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
1399 waitUntilTransitionsEnd(rotationStates);
1435 waitUntilTransitionsEnd(rotationStates);
1402− function performEdgeSwipeToSwitchToPreviousApp() {
1438+ function performEdgeSwipeToSwitchToPreviousApp(orientedShell) {
1439+ var topLevelSurfaceList = findInvisibleChild(orientedShell, "topLevelSurfaceList");
1440+ var shell = findChild(orientedShell, "shell");
1403 // swipe just enough to ensure an app switch action.
1441 // swipe just enough to ensure an app switch action.
1404 // If we swipe too much we will trigger the spread mode
1442 // If we swipe too much we will trigger the spread mode
1405 // and we don't want that.
1443 // and we don't want that.
@@ -1414,41 +1452,43 @@ Rectangle {
1414 tryCompareFunction(function(){ return topLevelSurfaceList.idAt(0); }, previousSurfaceId);
1452 tryCompareFunction(function(){ return topLevelSurfaceList.idAt(0); }, previousSurfaceId);
1417− function performEdgeSwipeToShowAppSpread() {
1455+ function performEdgeSwipeToShowAppSpread(orientedShell) {
1418− var touchStartY = shell.height / 2;
1456+ var touchStartY = orientedShell.height / 2;
1419− touchFlick(shell,
1457+ touchFlick(orientedShell,
1420− shell.width - 1, touchStartY,
1458+ orientedShell.width - 1, touchStartY,
1421 0, touchStartY);
1459 0, touchStartY);
1423− var stage = findChild(shell, "stage");
1461+ var stage = findChild(orientedShell, "stage");
1424 tryCompare(stage, "state", "spread");
1462 tryCompare(stage, "state", "spread");
1425 waitForRendering(stage);
1463 waitForRendering(stage);
1428− function showPowerDialog() {
1466+ function showPowerDialog(orientedShell) {
1429 var dialogs = findChild(orientedShell, "dialogs");
1467 var dialogs = findChild(orientedShell, "dialogs");
1430 var dialogsPrivate = findInvisibleChild(dialogs, "dialogsPrivate");
1468 var dialogsPrivate = findInvisibleChild(dialogs, "dialogsPrivate");
1431 dialogsPrivate.showPowerDialog();
1469 dialogsPrivate.showPowerDialog();
1434− function swipeAwayGreeter() {
1472+ function swipeAwayGreeter(orientedShell) {
1473+ var shell = findChild(orientedShell, "shell");
1435 var greeter = findChild(shell, "greeter");
1474 var greeter = findChild(shell, "greeter");
1436 tryCompare(greeter, "fullyShown", true);
1476 tryCompare(greeter, "fullyShown", true);
1437 waitForRendering(greeter)
1477 waitForRendering(greeter)
1439 var touchX = shell.width * .75;
1479 var touchX = shell.width * .75;
1440 var touchY = shell.height / 2;
1480 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);
1443 // wait until the animation has finished
1483 // wait until the animation has finished
1444 tryCompare(greeter, "shown", false);
1484 tryCompare(greeter, "shown", false);
1445 waitForRendering(greeter);
1485 waitForRendering(greeter);
1448− function showGreeter() {
1488+ function showGreeter(orientedShell) {
1449 LightDM.Greeter.showGreeter();
1489 LightDM.Greeter.showGreeter();
1450 // wait until the animation has finished
1490 // wait until the animation has finished
1451− var greeter = findChild(shell, "greeter");
1491+ var greeter = findChild(orientedShell, "greeter");
1452 tryCompare(greeter, "fullyShown", true);
1492 tryCompare(greeter, "fullyShown", true);
@@ -1456,32 +1496,29 @@ Rectangle {
1456 applicationArguments.deviceName = deviceName;
1496 applicationArguments.deviceName = deviceName;
1458 // 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
1459− orientedShellLoader.active = true;
1499+ var orientedShell = createTemporaryObject(shellComponent, shellRect);
1461− tryCompare(orientedShellLoader, "status", Loader.Ready);
1462− removeTimeConstraintsFromSwipeAreas(orientedShellLoader.item);
1464− shell = findChild(orientedShell, "shell");
1501+ removeTimeConstraintsFromSwipeAreas(orientedShell);
1466− topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
1503+ var shell = findChild(orientedShell, "shell");
1467− verify(topLevelSurfaceList);
1469 tryCompare(shell, "waitingOnGreeter", false); // reset by greeter when ready
1505 tryCompare(shell, "waitingOnGreeter", false); // reset by greeter when ready
1471− waitUntilShellIsInOrientation(root.physicalOrientation0);
1507+ waitUntilShellIsInOrientation(root.physicalOrientation0, orientedShell);
1473− waitForGreeterToStabilize();
1509+ waitForGreeterToStabilize(orientedShell);
1475− swipeAwayGreeter();
1511+ swipeAwayGreeter(orientedShell);
1477 var appRepeater = findChild(shell, "appRepeater");
1513 var appRepeater = findChild(shell, "appRepeater");
1478 if (appRepeater) {
1514 if (appRepeater) {
1479 appRepeaterConnections.target = appRepeater;
1515 appRepeaterConnections.target = appRepeater;
1517+ return orientedShell;
1483− function waitForGreeterToStabilize() {
1520+ function waitForGreeterToStabilize(orientedShell) {
1484− var greeter = findChild(shell, "greeter");
1521+ var greeter = findChild(orientedShell, "greeter");
1485 verify(greeter);
1522 verify(greeter);
1487 var loginList = findChild(greeter, "loginList");
1524 var loginList = findChild(greeter, "loginList");
@@ -1494,7 +1531,7 @@ Rectangle {
1496 // expectedAngle is in orientedShell's coordinate system
1533 // expectedAngle is in orientedShell's coordinate system
1497− function checkAppSurfaceOrientation(item, app, expectedAngle) {
1534+ function checkAppSurfaceOrientation(item, app, expectedAngle, orientedShell) {
1498 var surface = app.surfaceList.get(0);
1535 var surface = app.surfaceList.get(0);
1499 if (!surface) {
1536 if (!surface) {
1500 console.warn("no surface");
1537 console.warn("no surface");
@@ -1537,8 +1574,9 @@ Rectangle {
1537 return null;
1574 return null;
1540− function swipeToCloseCurrentAppInSpread() {
1577+ function swipeToCloseCurrentAppInSpread(orientedShell) {
1578+ var topLevelSurfaceList = findInvisibleChild(orientedShell, "topLevelSurfaceList");
1541− var delegateToClose = findChild(shell, "appDelegate_" + topLevelSurfaceList.idAt(0));
1579+ var delegateToClose = findChild(orientedShell, "appDelegate_" + topLevelSurfaceList.idAt(0));
1542 verify(delegateToClose);
1580 verify(delegateToClose);
1544 var appIdToClose = ApplicationManager.get(0).appId;
1582 var appIdToClose = ApplicationManager.get(0).appId;
@@ -1555,7 +1593,7 @@ Rectangle {
1555 compare(ApplicationManager.findApplication(appIdToClose), null);
1593 compare(ApplicationManager.findApplication(appIdToClose), null);
1558− function isAppSurfaceFocused(surfaceId) {
1596+ function isAppSurfaceFocused(topLevelSurfaceList, surfaceId) {
1559 var index = topLevelSurfaceList.indexForId(surfaceId);
1597 var index = topLevelSurfaceList.indexForId(surfaceId);
1560 var surface = topLevelSurfaceList.surfaceAt(index);
1598 var surface = topLevelSurfaceList.surfaceAt(index);
1561 verify(surface);
1599 verify(surface);
@@ -1570,9 +1608,9 @@ Rectangle {
1572 function test_tabCyclyingInShutdownDialog(data) {
1610 function test_tabCyclyingInShutdownDialog(data) {
1573− loadShell("mako");
1611+ var orientedShell = loadShell("mako");
1575− testCase.showPowerDialog();
1613+ testCase.showPowerDialog(orientedShell);
1577 var dialogs = findChild(orientedShell, "dialogs");
1615 var dialogs = findChild(orientedShell, "dialogs");
1578 var buttons = findChildsByType(dialogs, "Button");
1616 var buttons = findChildsByType(dialogs, "Button");
@@ -1598,9 +1636,9 @@ Rectangle {
1600 function test_escClosesShutdownDialog() {
1638 function test_escClosesShutdownDialog() {
1601− loadShell("mako");
1639+ var orientedShell = loadShell("mako");
1603− testCase.showPowerDialog();
1641+ testCase.showPowerDialog(orientedShell);
1605 var dialogLoader = findChild(orientedShell, "dialogLoader");
1643 var dialogLoader = findChild(orientedShell, "dialogLoader");
1606 tryCompareFunction(function() { return dialogLoader.item !== null }, true);
1644 tryCompareFunction(function() { return dialogLoader.item !== null }, true);
@@ -1611,20 +1649,21 @@ Rectangle {
1613 function test_focusOnShutdownDialogClose() {
1651 function test_focusOnShutdownDialogClose() {
1614− loadShell("manta");
1652+ var orientedShell = loadShell("manta");
1653+ var topLevelSurfaceList = findInvisibleChild(orientedShell, "topLevelSurfaceList");
1615 usageModeSelector.selectWindowed();
1654 usageModeSelector.selectWindowed();
1617 var surfaceId = topLevelSurfaceList.nextId;
1656 var surfaceId = topLevelSurfaceList.nextId;
1618 var app = ApplicationManager.startApplication("twitter-webapp");
1657 var app = ApplicationManager.startApplication("twitter-webapp");
1619− waitUntilAppWindowIsFullyLoaded(surfaceId);
1658+ waitUntilAppWindowIsFullyLoaded(surfaceId, orientedShell);
1621− var primaryAppWindow = findAppWindowForSurfaceId(surfaceId);
1660+ var primaryAppWindow = findAppWindowForSurfaceId(surfaceId, orientedShell);
1622 var surface = app.surfaceList.get(0);
1661 var surface = app.surfaceList.get(0);
1623 var surfaceItem = findSurfaceItem(primaryAppWindow, surface);
1662 var surfaceItem = findSurfaceItem(primaryAppWindow, surface);
1625 compare(window.activeFocusItem, surfaceItem);
1664 compare(window.activeFocusItem, surfaceItem);
1627− testCase.showPowerDialog();
1666+ testCase.showPowerDialog(orientedShell);
1629 var dialogLoader = findChild(orientedShell, "dialogLoader");
1668 var dialogLoader = findChild(orientedShell, "dialogLoader");
1630 tryVerify(function() { return dialogLoader.item !== null });
1669 tryVerify(function() { return dialogLoader.item !== null });
@@ -1635,7 +1674,7 @@ Rectangle {
1635 compare(window.activeFocusItem, surfaceItem);
1674 compare(window.activeFocusItem, surfaceItem);
1637 // Do it twice, our previous solution failed the second time ^_^
1676 // Do it twice, our previous solution failed the second time ^_^
1638− testCase.showPowerDialog();
1677+ testCase.showPowerDialog(orientedShell);
1640 tryVerify(function() { return dialogLoader.item !== null });
1679 tryVerify(function() { return dialogLoader.item !== null });
@@ -1646,7 +1685,8 @@ Rectangle {
1648 function test_tutorialDisabledWithNoTouchscreen() {
1687 function test_tutorialDisabledWithNoTouchscreen() {
1649− loadShell("desktop");
1688+ var orientedShell = loadShell("desktop");
1689+ var shell = findChild(orientedShell, "shell");
1650 usageModeSelector.selectWindowed();
1690 usageModeSelector.selectWindowed();
1652 MockInputDeviceBackend.addMockDevice("/touchscreen", InputInfo.TouchScreen);
1692 MockInputDeviceBackend.addMockDevice("/touchscreen", InputInfo.TouchScreen);