on xenial help sign in
merge prereq
commitde040db0035be3241d768106169531fd30182c9a authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 28 Jan 2016, 12:31 (11 years ago) parent93619fa85148c9
2 files changed+49−27
qml/OrientedShell.qml+11−4 tests/qmltests/tst_OrientedShell.qml+38−23
qml/OrientedShell.qml+11−4
@@ -209,11 +209,18 @@ Rectangle {
209209 return "tablet";
210210 }
211211 } else { // automatic
212− if (miceModel.count + touchPadModel.count > 0) {
213− return "desktop";
214− } else {
215− return deviceConfiguration.category;
212+ var longEdgeWidth = Math.max(root.width, root.height)
213+ if (longEdgeWidth > units.gu(120)) {
214+ if (keyboardsModel.count + miceModel.count + touchPadModel.count > 0) {
215+ return "desktop";
216+ }
217+ } else if (longEdgeWidth > units.gu(90)){
218+ if (miceModel.count + touchPadModel.count > 0) {
219+ return "desktop";
220+ }
216221 }
222+
223+ return deviceConfiguration.category;
217224 }
218225 }
219226
tests/qmltests/tst_OrientedShell.qml+38−23
@@ -1001,7 +1001,24 @@ Rectangle {
10011001 tryCompare(shell, "transformRotationAngle", 0);
10021002 }
10031003
1004− function test_attachRemoveInputDevices() {
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+
1021+ function test_attachRemoveInputDevices(data) {
10051022 usageModeSelector.selectAutomatic();
10061023 tryCompare(mockUnity8Settings, "usageMode", "Automatic")
10071024
@@ -1009,35 +1026,33 @@ Rectangle {
10091026 var shell = findChild(orientedShell, "shell");
10101027 var inputMethod = findChild(shell, "inputMethod");
10111028
1029+ var oldWidth = orientedShellLoader.width;
1030+ orientedShellLoader.width = data.screenWidth;
1031+
10121032 tryCompare(shell, "usageScenario", "phone");
10131033 tryCompare(inputMethod, "enabled", true);
10141034 tryCompare(mockOskSettings, "disableHeight", false);
10151035
1016− MockInputDeviceBackend.addMockDevice("/kbd0", InputInfo.Keyboard);
1017− tryCompare(shell, "usageScenario", "phone");
1018− tryCompare(inputMethod, "enabled", false);
1019− tryCompare(mockOskSettings, "disableHeight", true);
1020−
1021− MockInputDeviceBackend.addMockDevice("/mouse0", InputInfo.Mouse);
1022− tryCompare(shell, "usageScenario", "desktop");
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
1036+ if (data.kbd) {
1037+ MockInputDeviceBackend.addMockDevice("/kbd0", InputInfo.Keyboard);
1038+ }
1039+ if (data.mouse) {
1040+ MockInputDeviceBackend.addMockDevice("/mouse0", InputInfo.Mouse);
1041+ }
10301042
1031− MockInputDeviceBackend.removeDevice("/mouse0");
1032− tryCompare(shell, "usageScenario", "phone");
1033− tryCompare(inputMethod, "enabled", true);
1034− tryCompare(mockOskSettings, "disableHeight", false);
1043+ tryCompare(shell, "usageScenario", data.expectedMode);
1044+ tryCompare(inputMethod, "enabled", data.oskExpected);
1045+ tryCompare(mockOskSettings, "disableHeight", data.expectedMode == "desktop" || data.kbd);
10351046
1036− MockInputDeviceBackend.addMockDevice("/touchpad0", InputInfo.TouchPad);
1037− tryCompare(shell, "usageScenario", "desktop");
1047+ if (data.kbd) {
1048+ MockInputDeviceBackend.removeDevice("/kbd0");
1049+ }
1050+ if (data.mouse) {
1051+ MockInputDeviceBackend.removeDevice("/mouse0");
1052+ }
10381053
1039− MockInputDeviceBackend.removeDevice("/touchpad0");
1040− tryCompare(shell, "usageScenario", "phone");
1054+ // Restore width
1055+ orientedShellLoader.width = oldWidth;
10411056 }
10421057
10431058 /*