@@ -47,6 +47,9 @@ Rectangle {
4747 QtObject {
4848 id: mockUnity8Settings
4949 property string usageMode: usageModeSelector.model[usageModeSelector.selectedIndex]
50+ onUsageModeChanged: {
51+ usageModeSelector.selectedIndex = usageModeSelector.model.indexOf(usageMode)
52+ }
5053 }
5154
5255 QtObject{
@@ -307,6 +310,9 @@ Rectangle {
307310 function selectStaged() {selectedIndex = 0;}
308311 function selectWindowed() {selectedIndex = 1;}
309312 function selectAutomatic() {selectedIndex = 2;}
313+ onSelectedIndexChanged: {
314+ mockUnity8Settings.usageMode = usageModeSelector.model[usageModeSelector.selectedIndex]
315+ }
310316 }
311317 MouseTouchEmulationCheckbox {
312318 checked: true
@@ -1058,7 +1064,7 @@ Rectangle {
10581064 { tag: "big screen, mouse", screenWidth: units.gu(200), mouse: true, kbd: false, expectedMode: "desktop", oskExpected: true },
10591065 { tag: "small screen, kbd", screenWidth: units.gu(50), mouse: false, kbd: true, expectedMode: "phone", oskExpected: false },
10601066 { tag: "medium screen, kbd", screenWidth: units.gu(100), mouse: false, kbd: true, expectedMode: "phone", oskExpected: false },
1061− { tag: "big screen, kbd", screenWidth: units.gu(200), mouse: false, kbd: true, expectedMode: "desktop", oskExpected: false },
1067+ { tag: "big screen, kbd", screenWidth: units.gu(200), mouse: false, kbd: true, expectedMode: "phone", oskExpected: false },
10621068 { tag: "small screen, mouse & kbd", screenWidth: units.gu(50), mouse: true, kbd: true, expectedMode: "phone", oskExpected: false },
10631069 { tag: "medium screen, mouse & kbd", screenWidth: units.gu(100), mouse: true, kbd: true, expectedMode: "desktop", oskExpected: false },
10641070 { tag: "big screen, mouse & kbd", screenWidth: units.gu(200), mouse: true, kbd: true, expectedMode: "desktop", oskExpected: false },
@@ -1066,9 +1072,6 @@ Rectangle {
10661072 }
10671073
10681074 function test_attachRemoveInputDevices(data) {
1069− usageModeSelector.selectAutomatic();
1070− tryCompare(mockUnity8Settings, "usageMode", "Automatic")
1071−
10721075 loadShell("mako")
10731076 var shell = findChild(orientedShell, "shell");
10741077 var inputMethod = findChild(shell, "inputMethod");
@@ -1102,6 +1105,67 @@ Rectangle {
11021105 orientedShellLoader.width = oldWidth;
11031106 }
11041107
1108+ function test_overrideStaged() {
1109+ loadShell("mako")
1110+
1111+ // make sure we're big enough so that the automatism starts working
1112+ var oldWidth = orientedShellLoader.width;
1113+ orientedShellLoader.width = units.gu(100);
1114+
1115+ // start off by plugging a mouse, we should switch to windowed
1116+ MockInputDeviceBackend.addMockDevice("/mouse0", InputInfo.Mouse);
1117+ tryCompare(shell, "usageScenario", "desktop");
1118+
1119+ // Use the toggle to go back to Staged
1120+ usageModeSelector.selectStaged();
1121+ tryCompare(shell, "usageScenario", "phone");
1122+
1123+ // attach a second mouse, we should switch again
1124+ MockInputDeviceBackend.addMockDevice("/mouse1", InputInfo.Mouse);
1125+ tryCompare(shell, "usageScenario", "desktop");
1126+
1127+ // Remove one mouse again, stay in windowed as there is another
1128+ MockInputDeviceBackend.removeDevice("/mouse1");
1129+ tryCompare(shell, "usageScenario", "desktop");
1130+
1131+ // use the toggle again
1132+ usageModeSelector.selectStaged();
1133+ tryCompare(shell, "usageScenario", "phone");
1134+
1135+ // Remove the other mouse again, stay in staged
1136+ MockInputDeviceBackend.removeDevice("/mouse0");
1137+ tryCompare(shell, "usageScenario", "phone");
1138+
1139+ // Restore width
1140+ orientedShellLoader.width = oldWidth;
1141+ }
1142+
1143+ function test_overrideWindowed() {
1144+ loadShell("mako")
1145+
1146+ // make sure we're big enough so that the automatism starts working
1147+ var oldWidth = orientedShellLoader.width;
1148+ orientedShellLoader.width = units.gu(100);
1149+
1150+ // No mouse attached... we should be in staged
1151+ tryCompare(shell, "usageScenario", "phone");
1152+
1153+ // use the toggle to go to windowed
1154+ usageModeSelector.selectWindowed();
1155+ tryCompare(shell, "usageScenario", "desktop");
1156+
1157+ // Connect a mouse, stay in windowed
1158+ MockInputDeviceBackend.addMockDevice("/mouse0", InputInfo.Mouse);
1159+ tryCompare(shell, "usageScenario", "desktop");
1160+
1161+ // Remove the mouse again, we should go to staged
1162+ MockInputDeviceBackend.removeDevice("/mouse0");
1163+ tryCompare(shell, "usageScenario", "phone");
1164+
1165+ // Restore width
1166+ orientedShellLoader.width = oldWidth;
1167+ }
1168+
11051169 /*
11061170 Regression test for https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1471609
11071171