@@ -1,5 +1,5 @@
2− * Copyright (C) 2015 Canonical, Ltd.
2+ * Copyright (C) 2015-2016 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -292,6 +292,9 @@ Rectangle {
292 activeFocusOnPress: false
292 activeFocusOnPress: false
293 text: "Usage Mode"
293 text: "Usage Mode"
294 model: ["Staged", "Windowed", "Automatic"]
294 model: ["Staged", "Windowed", "Automatic"]
295+ function selectStaged() {selectedIndex = 0;}
296+ function selectWindowed() {selectedIndex = 1;}
297+ function selectAutomatic() {selectedIndex = 2;}
296 MouseTouchEmulationCheckbox {
299 MouseTouchEmulationCheckbox {
297 checked: true
300 checked: true
@@ -393,7 +396,7 @@ Rectangle {
393 activeFocusOnPress: false
396 activeFocusOnPress: false
394 property string prevDevName: "mako"
397 property string prevDevName: "mako"
395 onClicked: {
398 onClicked: {
396− usageModeSelector.selectedIndex = 2; // "Automatic"
399+ usageModeSelector.selectAutomatic();
398 if (applicationArguments.deviceName === "desktop") {
401 if (applicationArguments.deviceName === "desktop") {
399 applicationArguments.deviceName = prevDevName;
402 applicationArguments.deviceName = prevDevName;
@@ -457,6 +460,8 @@ Rectangle {
457 signalSpy.signalName = "";
460 signalSpy.signalName = "";
459 LightDM.Greeter.authenticate(""); // reset greeter
462 LightDM.Greeter.authenticate(""); // reset greeter
464+ usageModeSelector.selectStaged();
462 function cleanup() {
467 function cleanup() {
@@ -997,7 +1002,7 @@ Rectangle {
999 function test_attachRemoveInputDevices() {
1004 function test_attachRemoveInputDevices() {
1000− usageModeSelector.selectedIndex = 2;
1005+ usageModeSelector.selectAutomatic();
1001 tryCompare(mockUnity8Settings, "usageMode", "Automatic")
1006 tryCompare(mockUnity8Settings, "usageMode", "Automatic")
1003 loadShell("mako")
1008 loadShell("mako")
@@ -1146,6 +1151,61 @@ Rectangle {
1146 tryCompare(shell, "transformRotationAngle" , 0);
1151 tryCompare(shell, "transformRotationAngle" , 0);
1155+ Regression test for https://launchpad.net/bugs/1515977
1158+ UI in Desktop mode and landscape
1161+ - Launch a portrait-only application
1164+ - Shell stays in landscape
1167+ - Shell would rotate to portrait as the newly-focused app doesn't support landscape
1169+ function test_portraitOnlyAppInLandscapeDesktop_data() {
1171+ {tag: "mako", deviceName: "mako"},
1172+ {tag: "manta", deviceName: "manta"},
1173+ {tag: "flo", deviceName: "flo"}
1176+ function test_portraitOnlyAppInLandscapeDesktop(data) {
1177+ loadShell(data.deviceName);
1180+ // setup preconditions (put shell in Desktop mode and landscape)
1182+ usageModeSelector.selectWindowed();
1184+ orientedShell.physicalOrientation = orientedShell.orientations.landscape;
1185+ waitUntilShellIsInOrientation(orientedShell.orientations.landscape);
1186+ waitForRotationAnimationsToFinish();
1189+ // Launch a portrait-only application
1191+ var dialerApp = ApplicationManager.startApplication("dialer-app");
1194+ // ensure the mock dialer-app is as we expect
1195+ compare(dialerApp.rotatesWindowContents, false);
1196+ compare(dialerApp.supportedOrientations, Qt.PortraitOrientation | Qt.InvertedPortraitOrientation);
1198+ waitUntilAppSurfaceShowsUp("dialer-app");
1199+ waitUntilAppWindowCanRotate("dialer-app");
1200+ verify(isAppSurfaceFocused("dialer-app"));
1203+ // check outcome (shell should stay in landscape)
1205+ waitForRotationAnimationsToFinish();
1206+ compare(shell.orientation, orientedShell.orientations.landscape);
1149 // angle - rotation angle in degrees clockwise, relative to the primary orientation.
1209 // angle - rotation angle in degrees clockwise, relative to the primary orientation.
1150 function rotateTo(angle) {
1210 function rotateTo(angle) {
1151 switch (angle) {
1211 switch (angle) {
@@ -1164,7 +1224,10 @@ Rectangle {
1164 default:
1224 default:
1165 verify(false);
1225 verify(false);
1227+ waitForRotationAnimationsToFinish();
1230+ function waitForRotationAnimationsToFinish() {
1168 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
1231 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
1169 verify(rotationStates.d);
1232 verify(rotationStates.d);
1170 verify(rotationStates.d.stateUpdateTimer);
1233 verify(rotationStates.d.stateUpdateTimer);