@@ -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() {
@@ -1014,7 +1019,7 @@ Rectangle {
1016 function test_attachRemoveInputDevices(data) {
1021 function test_attachRemoveInputDevices(data) {
1017− usageModeSelector.selectedIndex = 2;
1022+ usageModeSelector.selectAutomatic();
1018 tryCompare(mockUnity8Settings, "usageMode", "Automatic")
1023 tryCompare(mockUnity8Settings, "usageMode", "Automatic")
1020 loadShell("mako")
1025 loadShell("mako")
@@ -1158,6 +1163,61 @@ Rectangle {
1158 tryCompare(shell, "transformRotationAngle" , 0);
1163 tryCompare(shell, "transformRotationAngle" , 0);
1167+ Regression test for https://launchpad.net/bugs/1515977
1170+ UI in Desktop mode and landscape
1173+ - Launch a portrait-only application
1176+ - Shell stays in landscape
1179+ - Shell would rotate to portrait as the newly-focused app doesn't support landscape
1181+ function test_portraitOnlyAppInLandscapeDesktop_data() {
1183+ {tag: "mako", deviceName: "mako"},
1184+ {tag: "manta", deviceName: "manta"},
1185+ {tag: "flo", deviceName: "flo"}
1188+ function test_portraitOnlyAppInLandscapeDesktop(data) {
1189+ loadShell(data.deviceName);
1192+ // setup preconditions (put shell in Desktop mode and landscape)
1194+ usageModeSelector.selectWindowed();
1196+ orientedShell.physicalOrientation = orientedShell.orientations.landscape;
1197+ waitUntilShellIsInOrientation(orientedShell.orientations.landscape);
1198+ waitForRotationAnimationsToFinish();
1201+ // Launch a portrait-only application
1203+ var dialerApp = ApplicationManager.startApplication("dialer-app");
1206+ // ensure the mock dialer-app is as we expect
1207+ compare(dialerApp.rotatesWindowContents, false);
1208+ compare(dialerApp.supportedOrientations, Qt.PortraitOrientation | Qt.InvertedPortraitOrientation);
1210+ waitUntilAppSurfaceShowsUp("dialer-app");
1211+ waitUntilAppWindowCanRotate("dialer-app");
1212+ verify(isAppSurfaceFocused("dialer-app"));
1215+ // check outcome (shell should stay in landscape)
1217+ waitForRotationAnimationsToFinish();
1218+ compare(shell.orientation, orientedShell.orientations.landscape);
1161 // angle - rotation angle in degrees clockwise, relative to the primary orientation.
1221 // angle - rotation angle in degrees clockwise, relative to the primary orientation.
1162 function rotateTo(angle) {
1222 function rotateTo(angle) {
1163 switch (angle) {
1223 switch (angle) {
@@ -1176,7 +1236,10 @@ Rectangle {
1176 default:
1236 default:
1177 verify(false);
1237 verify(false);
1239+ waitForRotationAnimationsToFinish();
1242+ function waitForRotationAnimationsToFinish() {
1180 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
1243 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
1181 verify(rotationStates.d);
1244 verify(rotationStates.d);
1182 verify(rotationStates.d.stateUpdateTimer);
1245 verify(rotationStates.d.stateUpdateTimer);