@@ -996,6 +996,60 @@ Rectangle {
996 tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle);
996 tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle);
1000+ Regression test for https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1476757
1003+ 1- have a portrait-only app in foreground (eg unity8-dash)
1004+ 2- launch or switch to some other application
1005+ 3- right-edge swipe to show the apps spread
1006+ 4- swipe up to close the current app (the one from step 2)
1007+ 5- lock the phone (press the power button)
1008+ 6- unlock the phone (press power button again and swipe greeter away)
1009+ * app from step 1 should be on foreground and focused
1013+ - The portrait-only application stays put
1016+ - The portrait-only application rotates freely
1018+ function test_lockPhoneAfterClosingAppInSpreadThenUnlockAndRotate() {
1021+ var gmailApp = ApplicationManager.startApplication("gmail-webapp");
1024+ waitUntilAppSurfaceShowsUp("gmail-webapp");
1026+ performEdgeSwipeToShowAppSpread();
1028+ swipeToCloseCurrentAppInSpread();
1030+ // press the power key once
1031+ Powerd.setStatus(Powerd.Off, Powerd.Unknown);
1032+ var greeter = findChild(shell, "greeter");
1033+ tryCompare(greeter, "fullyShown", true);
1035+ // and a second time to turn the display back on
1036+ Powerd.setStatus(Powerd.On, Powerd.Unknown);
1038+ swipeAwayGreeter();
1040+ verify(isAppSurfaceFocused("unity8-dash"))
1043+ signalSpy.target = shell;
1044+ signalSpy.signalName = "widthChanged";
1045+ verify(signalSpy.valid);
1049+ // shell shouldn't have change its orientation at any moment
1050+ compare(signalSpy.count, 0);
999 // angle - rotation angle in degrees clockwise, relative to the primary orientation.
1053 // angle - rotation angle in degrees clockwise, relative to the primary orientation.
1000 function rotateTo(angle) {
1054 function rotateTo(angle) {
1001 switch (angle) {
1055 switch (angle) {
@@ -1016,6 +1070,12 @@ Rectangle {
1018 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
1072 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
1073+ verify(rotationStates.d);
1074+ verify(rotationStates.d.stateUpdateTimer);
1076+ // wait for the delayed state update to take place, if any
1077+ tryCompare(rotationStates.d.stateUpdateTimer, "running", false);
1019 waitUntilTransitionsEnd(rotationStates);
1079 waitUntilTransitionsEnd(rotationStates);
@@ -1239,7 +1299,6 @@ Rectangle {
1239 var childs = new Array(0);
1299 var childs = new Array(0);
1240 childs.push(obj)
1300 childs.push(obj)
1241 while (childs.length > 0) {
1301 while (childs.length > 0) {
1242− console.log("Checking " + childs[0].objectName);
1243 if (childs[0].objectName === "surfaceItem"
1302 if (childs[0].objectName === "surfaceItem"
1244 && childs[0].surface !== undefined
1303 && childs[0].surface !== undefined
1245 && childs[0].surface === surface) {
1304 && childs[0].surface === surface) {
@@ -1252,5 +1311,51 @@ Rectangle {
1253 return null;
1312 return null;
1315+ function swipeToCloseCurrentAppInSpread() {
1316+ var spreadView = findChild(shell, "spreadView");
1317+ verify(spreadView);
1319+ var delegateToClose = findChild(spreadView, "appDelegate0");
1320+ verify(delegateToClose);
1322+ var appIdToClose = ApplicationManager.get(0).appId;;
1323+ var appCountBefore = ApplicationManager.count;
1325+ // ensure the current app is widely visible by swiping to the right,
1326+ // which will move the app windows accordingly
1328+ shell.width * 0.25, shell.width / 2,
1329+ shell.width, shell.width / 2);
1331+ tryCompare(spreadView, "flicking", false);
1332+ tryCompare(spreadView, "moving", false);
1334+ // Swipe up close to its left edge, as it is the only area of it guaranteed to be exposed
1335+ // in the spread. Eg: its center could be covered by some other delegate.
1336+ touchFlick(delegateToClose,
1337+ 1, delegateToClose.height / 2,
1338+ 1, - delegateToClose.height / 4);
1340+ // ensure it got closed
1341+ tryCompare(ApplicationManager, "count", appCountBefore - 1);
1342+ compare(ApplicationManager.findApplication(appIdToClose), null);
1345+ function isAppSurfaceFocused(appId) {
1346+ var appWindow = findChild(shell, "appWindow_" + appId);
1349+ var app = ApplicationManager.findApplication(appId);
1352+ var surface = app.session.surface;
1355+ var surfaceItem = findSurfaceItem(appWindow, surface);
1356+ verify(surfaceItem);
1358+ return surfaceItem.activeFocus;