on xenial help sign in
fix and extend the ModeSwitchWarningDialog tests
b20e9b4Lukáš Tinkl
qml/Components/Dialogs.qml+2−1
@@ -41,6 +41,7 @@ Item {
41 }
41 }
42 }
42 }
43 property string usageScenario
43 property string usageScenario
44+ property size screenSize: Qt.size(Screen.width, Screen.height)
44
45
45 signal powerOffClicked();
46 signal powerOffClicked();
46
47
@@ -51,7 +52,7 @@ Item {
51 onUsageScenarioChanged: {
52 onUsageScenarioChanged: {
52 // if we let the user switch manually to desktop mode, don't display the warning dialog
53 // if we let the user switch manually to desktop mode, don't display the warning dialog
53 // see MenuItemFactory.qml, for the Desktop Mode switch logic
54 // see MenuItemFactory.qml, for the Desktop Mode switch logic
54− var isTabletSize = Math.min(Screen.width, Screen.height) > units.gu(60);
55+ var isTabletSize = Math.min(screenSize.width, screenSize.height) > units.gu(60);
55
56
56 if (usageScenario != "desktop" && legacyAppsModel.count > 0 && !d.modeSwitchWarningPopup && !isTabletSize) {
57 if (usageScenario != "desktop" && legacyAppsModel.count > 0 && !d.modeSwitchWarningPopup && !isTabletSize) {
57 var comp = Qt.createComponent(Qt.resolvedUrl("ModeSwitchWarningDialog.qml"))
58 var comp = Qt.createComponent(Qt.resolvedUrl("ModeSwitchWarningDialog.qml"))
tests/qmltests/tst_Shell.qml+13−7
@@ -2154,8 +2154,10 @@ Rectangle {
2154
2154
2155 function test_switchToStagedForcesLegacyAppClosing_data() {
2155 function test_switchToStagedForcesLegacyAppClosing_data() {
2156 return [
2156 return [
2157− {tag: "forceClose", replug: false },
2157+ {tag: "forceClose", replug: false, tabletMode: false, screenSize: Qt.size(units.gu(20), units.gu(40)) },
2158+ {tag: "replug", replug: true, tabletMode: false, screenSize: Qt.size(units.gu(20), units.gu(40)) },
2159+ {tag: "forceClose+tablet", replug: false, tabletMode: true, screenSize: Qt.size(units.gu(90), units.gu(65)) },
2158− {tag: "replug", replug: true }
2160+ {tag: "replug+tablet", replug: true, tabletMode: true, screenSize: Qt.size(units.gu(90), units.gu(65)) }
2159 ];
2161 ];
2160 }
2162 }
2161
2163
@@ -2164,6 +2166,11 @@ Rectangle {
2164 shell.usageScenario = "desktop"
2166 shell.usageScenario = "desktop"
2165 waitForRendering(shell);
2167 waitForRendering(shell);
2166
2168
2169+ // setup some screen size
2170+ var dialogs = findChild(root, "dialogs");
2171+ verify(dialogs);
2172+ dialogs.screenSize = data.screenSize;
2173+
2167 ApplicationManager.startApplication("camera-app")
2174 ApplicationManager.startApplication("camera-app")
2168
2175
2169 shell.usageScenario = "phone"
2176 shell.usageScenario = "phone"
@@ -2182,14 +2189,13 @@ Rectangle {
2182 shell.usageScenario = "phone"
2189 shell.usageScenario = "phone"
2183 waitForRendering(shell);
2190 waitForRendering(shell);
2184
2191
2185− // The popup must appear now
2192+ // The popup must appear now, unless in "tablet" mode
2186 popup = findChild(root, "modeSwitchWarningDialog");
2193 popup = findChild(root, "modeSwitchWarningDialog");
2187− compare(popup !== null, true);
2194+ compare(popup !== null, !data.tabletMode);
2188
2195
2189− if (data.replug) {
2196+ if (data.replug || data.tabletMode) {
2190 shell.usageScenario = "desktop"
2197 shell.usageScenario = "desktop"
2191 waitForRendering(shell);
2198 waitForRendering(shell);
2192−
2193 } else {
2199 } else {
2194 var forceCloseButton = findChild(popup, "forceCloseButton");
2200 var forceCloseButton = findChild(popup, "forceCloseButton");
2195 mouseClick(forceCloseButton, forceCloseButton.width / 2, forceCloseButton.height / 2);
2201 mouseClick(forceCloseButton, forceCloseButton.width / 2, forceCloseButton.height / 2);
@@ -2200,7 +2206,7 @@ Rectangle {
2200 popup = findChild(root, "modeSwitchWarningDialog");
2206 popup = findChild(root, "modeSwitchWarningDialog");
2201 tryCompareFunction(function() { return popup === null}, true);
2207 tryCompareFunction(function() { return popup === null}, true);
2202
2208
2203− if (data.replug) {
2209+ if (data.replug || data.tabletMode) {
2204 // Libreoffice must still be running
2210 // Libreoffice must still be running
2205 compare(ApplicationManager.findApplication("libreoffice") !== null, true);
2211 compare(ApplicationManager.findApplication("libreoffice") !== null, true);
2206 } else {
2212 } else {