on xenial help sign in
merge prereq
de040dbMichael Zanetti
qml/OrientedShell.qml+11−4
@@ -209,11 +209,18 @@ Rectangle {
209 return "tablet";
209 return "tablet";
210 }
210 }
211 } else { // automatic
211 } else { // automatic
212+ var longEdgeWidth = Math.max(root.width, root.height)
213+ if (longEdgeWidth > units.gu(120)) {
212− if (miceModel.count + touchPadModel.count > 0) {
214+ if (keyboardsModel.count + miceModel.count + touchPadModel.count > 0) {
213− return "desktop";
215+ return "desktop";
214− } else {
216+ }
215− return deviceConfiguration.category;
217+ } else if (longEdgeWidth > units.gu(90)){
218+ if (miceModel.count + touchPadModel.count > 0) {
219+ return "desktop";
220+ }
216 }
221 }
222+
223+ return deviceConfiguration.category;
217 }
224 }
218 }
225 }
219
226
tests/qmltests/tst_OrientedShell.qml+38−23
@@ -1001,7 +1001,24 @@ Rectangle {
1001 tryCompare(shell, "transformRotationAngle", 0);
1001 tryCompare(shell, "transformRotationAngle", 0);
1002 }
1002 }
1003
1003
1004+ function test_attachRemoveInputDevices_data() {
1005+ return [
1006+ { tag: "small screen, no devices", screenWidth: units.gu(50), mouse: false, kbd: false, expectedMode: "phone", oskExpected: true },
1007+ { tag: "medium screen, no devices", screenWidth: units.gu(100), mouse: false, kbd: false, expectedMode: "phone", oskExpected: true },
1008+ { tag: "big screen, no devices", screenWidth: units.gu(200), mouse: false, kbd: false, expectedMode: "phone", oskExpected: true },
1009+ { tag: "small screen, mouse", screenWidth: units.gu(50), mouse: true, kbd: false, expectedMode: "phone", oskExpected: true },
1010+ { tag: "medium screen, mouse", screenWidth: units.gu(100), mouse: true, kbd: false, expectedMode: "desktop", oskExpected: true },
1011+ { tag: "big screen, mouse", screenWidth: units.gu(200), mouse: true, kbd: false, expectedMode: "desktop", oskExpected: true },
1012+ { tag: "small screen, kbd", screenWidth: units.gu(50), mouse: false, kbd: true, expectedMode: "phone", oskExpected: false },
1013+ { 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 },
1015+ { tag: "small screen, mouse & kbd", screenWidth: units.gu(50), mouse: true, kbd: true, expectedMode: "phone", oskExpected: false },
1016+ { tag: "medium screen, mouse & kbd", screenWidth: units.gu(100), mouse: true, kbd: true, expectedMode: "desktop", oskExpected: false },
1017+ { tag: "big screen, mouse & kbd", screenWidth: units.gu(200), mouse: true, kbd: true, expectedMode: "desktop", oskExpected: false },
1018+ ]
1019+ }
1020+
1004− function test_attachRemoveInputDevices() {
1021+ function test_attachRemoveInputDevices(data) {
1005 usageModeSelector.selectAutomatic();
1022 usageModeSelector.selectAutomatic();
1006 tryCompare(mockUnity8Settings, "usageMode", "Automatic")
1023 tryCompare(mockUnity8Settings, "usageMode", "Automatic")
1007
1024
@@ -1009,35 +1026,33 @@ Rectangle {
1009 var shell = findChild(orientedShell, "shell");
1026 var shell = findChild(orientedShell, "shell");
1010 var inputMethod = findChild(shell, "inputMethod");
1027 var inputMethod = findChild(shell, "inputMethod");
1011
1028
1029+ var oldWidth = orientedShellLoader.width;
1030+ orientedShellLoader.width = data.screenWidth;
1031+
1012 tryCompare(shell, "usageScenario", "phone");
1032 tryCompare(shell, "usageScenario", "phone");
1013 tryCompare(inputMethod, "enabled", true);
1033 tryCompare(inputMethod, "enabled", true);
1014 tryCompare(mockOskSettings, "disableHeight", false);
1034 tryCompare(mockOskSettings, "disableHeight", false);
1015
1035
1036+ if (data.kbd) {
1016− MockInputDeviceBackend.addMockDevice("/kbd0", InputInfo.Keyboard);
1037+ MockInputDeviceBackend.addMockDevice("/kbd0", InputInfo.Keyboard);
1017− tryCompare(shell, "usageScenario", "phone");
1038+ }
1018− tryCompare(inputMethod, "enabled", false);
1039+ if (data.mouse) {
1019− tryCompare(mockOskSettings, "disableHeight", true);
1020−
1021− MockInputDeviceBackend.addMockDevice("/mouse0", InputInfo.Mouse);
1040+ MockInputDeviceBackend.addMockDevice("/mouse0", InputInfo.Mouse);
1022− tryCompare(shell, "usageScenario", "desktop");
1041+ }
1023− tryCompare(inputMethod, "enabled", false);
1024− tryCompare(mockOskSettings, "disableHeight", true);
1025−
1026− MockInputDeviceBackend.removeDevice("/kbd0");
1027− tryCompare(shell, "usageScenario", "desktop");
1028− tryCompare(inputMethod, "enabled", true);
1029− tryCompare(mockOskSettings, "disableHeight", true); // Still in windowed mode
1030
1042
1031− MockInputDeviceBackend.removeDevice("/mouse0");
1032− tryCompare(shell, "usageScenario", "phone");
1043+ tryCompare(shell, "usageScenario", data.expectedMode);
1033− tryCompare(inputMethod, "enabled", true);
1044+ tryCompare(inputMethod, "enabled", data.oskExpected);
1034− tryCompare(mockOskSettings, "disableHeight", false);
1045+ tryCompare(mockOskSettings, "disableHeight", data.expectedMode == "desktop" || data.kbd);
1035
1046
1047+ if (data.kbd) {
1036− MockInputDeviceBackend.addMockDevice("/touchpad0", InputInfo.TouchPad);
1048+ MockInputDeviceBackend.removeDevice("/kbd0");
1037− tryCompare(shell, "usageScenario", "desktop");
1049+ }
1050+ if (data.mouse) {
1051+ MockInputDeviceBackend.removeDevice("/mouse0");
1052+ }
1038
1053
1039− MockInputDeviceBackend.removeDevice("/touchpad0");
1054+ // Restore width
1040− tryCompare(shell, "usageScenario", "phone");
1055+ orientedShellLoader.width = oldWidth;
1041 }
1056 }
1042
1057
1043 /*
1058 /*