@@ -47,6 +47,10 @@ Rectangle {
4747 QtObject {
4848 id: mockUnity8Settings
4949 property string usageMode: usageModeSelector.model[usageModeSelector.selectedIndex]
50+ onUsageModeChanged: {
51+print("usage mode changed", usageMode);
52+ usageModeSelector.selectedIndex = usageModeSelector.model.indexOf(usageMode)
53+ }
5054 }
5155
5256 QtObject{
@@ -295,6 +299,10 @@ Rectangle {
295299 function selectStaged() {selectedIndex = 0;}
296300 function selectWindowed() {selectedIndex = 1;}
297301 function selectAutomatic() {selectedIndex = 2;}
302+ onSelectedIndexChanged: {
303+ print("usageModeSelector index changed", selectedIndex)
304+ mockUnity8Settings.usageMode = usageModeSelector.model[usageModeSelector.selectedIndex]
305+ }
298306 }
299307 MouseTouchEmulationCheckbox {
300308 checked: true
@@ -1011,7 +1019,7 @@ Rectangle {
10111019 { tag: "big screen, mouse", screenWidth: units.gu(200), mouse: true, kbd: false, expectedMode: "desktop", oskExpected: true },
10121020 { tag: "small screen, kbd", screenWidth: units.gu(50), mouse: false, kbd: true, expectedMode: "phone", oskExpected: false },
10131021 { tag: "medium screen, kbd", screenWidth: units.gu(100), mouse: false, kbd: true, expectedMode: "phone", oskExpected: false },
1014− { tag: "big screen, kbd", screenWidth: units.gu(200), mouse: false, kbd: true, expectedMode: "desktop", oskExpected: false },
1022+ { tag: "big screen, kbd", screenWidth: units.gu(200), mouse: false, kbd: true, expectedMode: "phone", oskExpected: false },
10151023 { tag: "small screen, mouse & kbd", screenWidth: units.gu(50), mouse: true, kbd: true, expectedMode: "phone", oskExpected: false },
10161024 { tag: "medium screen, mouse & kbd", screenWidth: units.gu(100), mouse: true, kbd: true, expectedMode: "desktop", oskExpected: false },
10171025 { tag: "big screen, mouse & kbd", screenWidth: units.gu(200), mouse: true, kbd: true, expectedMode: "desktop", oskExpected: false },
@@ -1019,9 +1027,6 @@ Rectangle {
10191027 }
10201028
10211029 function test_attachRemoveInputDevices(data) {
1022− usageModeSelector.selectAutomatic();
1023− tryCompare(mockUnity8Settings, "usageMode", "Automatic")
1024−
10251030 loadShell("mako")
10261031 var shell = findChild(orientedShell, "shell");
10271032 var inputMethod = findChild(shell, "inputMethod");
@@ -1055,6 +1060,67 @@ Rectangle {
10551060 orientedShellLoader.width = oldWidth;
10561061 }
10571062
1063+ function test_overrideStaged() {
1064+ loadShell("mako")
1065+
1066+ // make sure we're big enough so that the automatism starts working
1067+ var oldWidth = orientedShellLoader.width;
1068+ orientedShellLoader.width = units.gu(100);
1069+
1070+ // start off by plugging a mouse, we should switch to windowed
1071+ MockInputDeviceBackend.addMockDevice("/mouse0", InputInfo.Mouse);
1072+ tryCompare(shell, "usageScenario", "desktop");
1073+
1074+ // Use the toggle to go back to Staged
1075+ usageModeSelector.selectStaged();
1076+ tryCompare(shell, "usageScenario", "phone");
1077+
1078+ // attach a second mouse, we should switch again
1079+ MockInputDeviceBackend.addMockDevice("/mouse1", InputInfo.Mouse);
1080+ tryCompare(shell, "usageScenario", "desktop");
1081+
1082+ // Remove one mouse again, stay in windowed as there is another
1083+ MockInputDeviceBackend.removeDevice("/mouse1");
1084+ tryCompare(shell, "usageScenario", "desktop");
1085+
1086+ // use the toggle again
1087+ usageModeSelector.selectStaged();
1088+ tryCompare(shell, "usageScenario", "phone");
1089+
1090+ // Remove the other mouse again, stay in staged
1091+ MockInputDeviceBackend.removeDevice("/mouse0");
1092+ tryCompare(shell, "usageScenario", "phone");
1093+
1094+ // Restore width
1095+ orientedShellLoader.width = oldWidth;
1096+ }
1097+
1098+ function test_overrideWindowed() {
1099+ loadShell("mako")
1100+
1101+ // make sure we're big enough so that the automatism starts working
1102+ var oldWidth = orientedShellLoader.width;
1103+ orientedShellLoader.width = units.gu(100);
1104+
1105+ // No mouse attached... we should be in staged
1106+ tryCompare(shell, "usageScenario", "phone");
1107+
1108+ // use the toggle to go to windowed
1109+ usageModeSelector.selectWindowed();
1110+ tryCompare(shell, "usageScenario", "desktop");
1111+
1112+ // Connect a mouse, stay in windowed
1113+ MockInputDeviceBackend.addMockDevice("/mouse0", InputInfo.Mouse);
1114+ tryCompare(shell, "usageScenario", "desktop");
1115+
1116+ // Remove the mouse again, we should go to staged
1117+ MockInputDeviceBackend.removeDevice("/mouse0");
1118+ tryCompare(shell, "usageScenario", "phone");
1119+
1120+ // Restore width
1121+ orientedShellLoader.width = oldWidth;
1122+ }
1123+
10581124 /*
10591125 Regression test for https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1471609
10601126