@@ -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;
@@ -457,6 +460,8 @@ Rectangle {
457460 signalSpy.signalName = "";
458461
459462 LightDM.Greeter.authenticate(""); // reset greeter
463+
464+ usageModeSelector.selectStaged();
460465 }
461466
462467 function cleanup() {
@@ -1014,7 +1019,7 @@ Rectangle {
10141019 }
10151020
10161021 function test_attachRemoveInputDevices(data) {
1017− usageModeSelector.selectedIndex = 2;
1022+ usageModeSelector.selectAutomatic();
10181023 tryCompare(mockUnity8Settings, "usageMode", "Automatic")
10191024
10201025 loadShell("mako")
@@ -1158,6 +1163,61 @@ Rectangle {
11581163 tryCompare(shell, "transformRotationAngle" , 0);
11591164 }
11601165
1166+ /*
1167+ Regression test for https://launchpad.net/bugs/1515977
1168+
1169+ Preconditions:
1170+ UI in Desktop mode and landscape
1171+
1172+ Steps:
1173+ - Launch a portrait-only application
1174+
1175+ Expected outcome:
1176+ - Shell stays in landscape
1177+
1178+ Buggy outcome:
1179+ - Shell would rotate to portrait as the newly-focused app doesn't support landscape
1180+ */
1181+ function test_portraitOnlyAppInLandscapeDesktop_data() {
1182+ return [
1183+ {tag: "mako", deviceName: "mako"},
1184+ {tag: "manta", deviceName: "manta"},
1185+ {tag: "flo", deviceName: "flo"}
1186+ ];
1187+ }
1188+ function test_portraitOnlyAppInLandscapeDesktop(data) {
1189+ loadShell(data.deviceName);
1190+
1191+ ////
1192+ // setup preconditions (put shell in Desktop mode and landscape)
1193+
1194+ usageModeSelector.selectWindowed();
1195+
1196+ orientedShell.physicalOrientation = orientedShell.orientations.landscape;
1197+ waitUntilShellIsInOrientation(orientedShell.orientations.landscape);
1198+ waitForRotationAnimationsToFinish();
1199+
1200+ ////
1201+ // Launch a portrait-only application
1202+
1203+ var dialerApp = ApplicationManager.startApplication("dialer-app");
1204+ verify(dialerApp);
1205+
1206+ // ensure the mock dialer-app is as we expect
1207+ compare(dialerApp.rotatesWindowContents, false);
1208+ compare(dialerApp.supportedOrientations, Qt.PortraitOrientation | Qt.InvertedPortraitOrientation);
1209+
1210+ waitUntilAppSurfaceShowsUp("dialer-app");
1211+ waitUntilAppWindowCanRotate("dialer-app");
1212+ verify(isAppSurfaceFocused("dialer-app"));
1213+
1214+ ////
1215+ // check outcome (shell should stay in landscape)
1216+
1217+ waitForRotationAnimationsToFinish();
1218+ compare(shell.orientation, orientedShell.orientations.landscape);
1219+ }
1220+
11611221 // angle - rotation angle in degrees clockwise, relative to the primary orientation.
11621222 function rotateTo(angle) {
11631223 switch (angle) {
@@ -1176,7 +1236,10 @@ Rectangle {
11761236 default:
11771237 verify(false);
11781238 }
1239+ waitForRotationAnimationsToFinish();
1240+ }
11791241
1242+ function waitForRotationAnimationsToFinish() {
11801243 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
11811244 verify(rotationStates.d);
11821245 verify(rotationStates.d.stateUpdateTimer);