on xenial help sign in
fix and extend the ModeSwitchWarningDialog tests
commitb20e9b44d5cbe0cd48d1c515a4e8dd02530ba5fb authorLukáš Tinkl <lukas.tinkl@canonical.com> dateFri 15 Jul 2016, 21:37 (10 years ago) parent826ea86
2 files changed+15−8
qml/Components/Dialogs.qml+2−1 tests/qmltests/tst_Shell.qml+13−7
qml/Components/Dialogs.qml+2−1
@@ -41,6 +41,7 @@ Item {
4141 }
4242 }
4343 property string usageScenario
44+ property size screenSize: Qt.size(Screen.width, Screen.height)
4445
4546 signal powerOffClicked();
4647
@@ -51,7 +52,7 @@ Item {
5152 onUsageScenarioChanged: {
5253 // if we let the user switch manually to desktop mode, don't display the warning dialog
5354 // 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);
5556
5657 if (usageScenario != "desktop" && legacyAppsModel.count > 0 && !d.modeSwitchWarningPopup && !isTabletSize) {
5758 var comp = Qt.createComponent(Qt.resolvedUrl("ModeSwitchWarningDialog.qml"))
tests/qmltests/tst_Shell.qml+13−7
@@ -2154,8 +2154,10 @@ Rectangle {
21542154
21552155 function test_switchToStagedForcesLegacyAppClosing_data() {
21562156 return [
2157− {tag: "forceClose", replug: false },
2158− {tag: "replug", replug: true }
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)) },
2160+ {tag: "replug+tablet", replug: true, tabletMode: true, screenSize: Qt.size(units.gu(90), units.gu(65)) }
21592161 ];
21602162 }
21612163
@@ -2164,6 +2166,11 @@ Rectangle {
21642166 shell.usageScenario = "desktop"
21652167 waitForRendering(shell);
21662168
2169+ // setup some screen size
2170+ var dialogs = findChild(root, "dialogs");
2171+ verify(dialogs);
2172+ dialogs.screenSize = data.screenSize;
2173+
21672174 ApplicationManager.startApplication("camera-app")
21682175
21692176 shell.usageScenario = "phone"
@@ -2182,14 +2189,13 @@ Rectangle {
21822189 shell.usageScenario = "phone"
21832190 waitForRendering(shell);
21842191
2185− // The popup must appear now
2192+ // The popup must appear now, unless in "tablet" mode
21862193 popup = findChild(root, "modeSwitchWarningDialog");
2187− compare(popup !== null, true);
2194+ compare(popup !== null, !data.tabletMode);
21882195
2189− if (data.replug) {
2196+ if (data.replug || data.tabletMode) {
21902197 shell.usageScenario = "desktop"
21912198 waitForRendering(shell);
2192−
21932199 } else {
21942200 var forceCloseButton = findChild(popup, "forceCloseButton");
21952201 mouseClick(forceCloseButton, forceCloseButton.width / 2, forceCloseButton.height / 2);
@@ -2200,7 +2206,7 @@ Rectangle {
22002206 popup = findChild(root, "modeSwitchWarningDialog");
22012207 tryCompareFunction(function() { return popup === null}, true);
22022208
2203− if (data.replug) {
2209+ if (data.replug || data.tabletMode) {
22042210 // Libreoffice must still be running
22052211 compare(ApplicationManager.findApplication("libreoffice") !== null, true);
22062212 } else {