@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2015 Canonical, Ltd.
2+ * Copyright (C) 2015-2016 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -292,6 +292,9 @@ Rectangle {
292292 activeFocusOnPress: false
293293 text: "Usage Mode"
294294 model: ["Staged", "Windowed", "Automatic"]
295+ function selectStaged() {selectedIndex = 0;}
296+ function selectWindowed() {selectedIndex = 1;}
297+ function selectAutomatic() {selectedIndex = 2;}
295298 }
296299 MouseTouchEmulationCheckbox {
297300 checked: true
@@ -393,7 +396,7 @@ Rectangle {
393396 activeFocusOnPress: false
394397 property string prevDevName: "mako"
395398 onClicked: {
396− usageModeSelector.selectedIndex = 2; // "Automatic"
399+ usageModeSelector.selectAutomatic();
397400
398401 if (applicationArguments.deviceName === "desktop") {
399402 applicationArguments.deviceName = prevDevName;
@@ -997,7 +1000,7 @@ Rectangle {
9971000 }
9981001
9991002 function test_attachRemoveInputDevices() {
1000− usageModeSelector.selectedIndex = 2;
1003+ usageModeSelector.selectAutomatic();
10011004 tryCompare(mockUnity8Settings, "usageMode", "Automatic")
10021005
10031006 loadShell("mako")
@@ -1140,6 +1143,61 @@ Rectangle {
11401143 tryCompare(shell, "transformRotationAngle" , 0);
11411144 }
11421145
1146+ /*
1147+ Regression test for https://launchpad.net/bugs/1515977
1148+
1149+ Preconditions:
1150+ UI in Desktop mode and landscape
1151+
1152+ Steps:
1153+ - Launch a portrait-only application
1154+
1155+ Expected outcome:
1156+ - Shell stays in landscape
1157+
1158+ Buggy outcome:
1159+ - Shell would rotate to portrait as the newly-focused app doesn't support landscape
1160+ */
1161+ function test_portraitOnlyAppInLandscapeDesktop_data() {
1162+ return [
1163+ {tag: "mako", deviceName: "mako"},
1164+ {tag: "manta", deviceName: "manta"},
1165+ {tag: "flo", deviceName: "flo"}
1166+ ];
1167+ }
1168+ function test_portraitOnlyAppInLandscapeDesktop(data) {
1169+ loadShell(data.deviceName);
1170+
1171+ ////
1172+ // setup preconditions (put shell in Desktop mode and landscape)
1173+
1174+ usageModeSelector.selectWindowed();
1175+
1176+ orientedShell.physicalOrientation = orientedShell.orientations.landscape;
1177+ waitUntilShellIsInOrientation(orientedShell.orientations.landscape);
1178+ waitForRotationAnimationsToFinish();
1179+
1180+ ////
1181+ // Launch a portrait-only application
1182+
1183+ var dialerApp = ApplicationManager.startApplication("dialer-app");
1184+ verify(dialerApp);
1185+
1186+ // ensure the mock dialer-app is as we expect
1187+ compare(dialerApp.rotatesWindowContents, false);
1188+ compare(dialerApp.supportedOrientations, Qt.PortraitOrientation | Qt.InvertedPortraitOrientation);
1189+
1190+ waitUntilAppSurfaceShowsUp("dialer-app");
1191+ waitUntilAppWindowCanRotate("dialer-app");
1192+ verify(isAppSurfaceFocused("dialer-app"));
1193+
1194+ ////
1195+ // check outcome (shell should stay in landscape)
1196+
1197+ waitForRotationAnimationsToFinish();
1198+ compare(shell.orientation, orientedShell.orientations.landscape);
1199+ }
1200+
11431201 // angle - rotation angle in degrees clockwise, relative to the primary orientation.
11441202 function rotateTo(angle) {
11451203 switch (angle) {
@@ -1158,7 +1216,10 @@ Rectangle {
11581216 default:
11591217 verify(false);
11601218 }
1219+ waitForRotationAnimationsToFinish();
1220+ }
11611221
1222+ function waitForRotationAnimationsToFinish() {
11621223 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
11631224 verify(rotationStates.d);
11641225 verify(rotationStates.d.stateUpdateTimer);