on xenial help sign in
add a test for updating the usage mode if the screen size changes
commit0ddf010c1bb08abe182119fdff8402ccbb897184 authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 2 Aug 2016, 17:11 (10 years ago) parent2ec6ba2
2 files changed+21−1
qml/OrientedShell.qml+1−1 tests/qmltests/tst_OrientedShell.qml+20
qml/OrientedShell.qml+1−1
@@ -105,7 +105,7 @@ Item {
105105 if (unity8Settings.usageMode === undefined)
106106 return; // gsettings isn't loaded yet, we'll try again in Component.onCompleted
107107
108− console.log("Pointer input devices changed:", pointerInputDevices, "current mode:", unity8Settings.usageMode, "old device count", miceModel.oldCount + touchPadModel.oldCount, "root width:", root.width / units.gu(1), "height:", root.height / units.gu(1))
108+ console.log("Calculating new usage mode. Pointer devices:", pointerInputDevices, "current mode:", unity8Settings.usageMode, "old device count", miceModel.oldCount + touchPadModel.oldCount, "root width:", root.width / units.gu(1), "height:", root.height / units.gu(1))
109109 if (unity8Settings.usageMode === "Windowed") {
110110 if (Math.min(root.width, root.height) > units.gu(60)) {
111111 if (pointerInputDevices === 0) {
tests/qmltests/tst_OrientedShell.qml+20
@@ -1142,6 +1142,26 @@ Rectangle {
11421142 orientedShellLoader.width = oldWidth;
11431143 }
11441144
1145+ function test_screenSizeChanges() {
1146+ loadShell("mako")
1147+ var shell = findChild(orientedShell, "shell");
1148+
1149+ tryCompare(shell, "usageScenario", "phone");
1150+
1151+ // make screen larger
1152+ orientedShellLoader.width = units.gu(90);
1153+ tryCompare(shell, "usageScenario", "phone");
1154+
1155+ // plug a mouse
1156+ MockInputDeviceBackend.addMockDevice("/mouse0", InputInfo.Mouse);
1157+ tryCompare(shell, "usageScenario", "desktop");
1158+
1159+ // make the screen smaller again, it should go back to staged even though there's still a mouse around
1160+ orientedShellLoader.width = units.gu(40);
1161+
1162+ tryCompare(shell, "usageScenario", "phone");
1163+ }
1164+
11451165 function test_overrideStaged() {
11461166 loadShell("mako")
11471167