@@ -15,7 +15,8 @@
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18−import QtQuick 2.4
18+import QtQuick 2.7
19+import QtQuick.Window 2.4
19import QtTest 1.0
20import QtTest 1.0
20import AccountsService 0.1
21import AccountsService 0.1
21import GSettings 1.0
22import GSettings 1.0
@@ -51,14 +52,13 @@ Rectangle {
51 Component.onCompleted: {
52 Component.onCompleted: {
52 // must set the mock mode before loading the Shell
53 // must set the mock mode before loading the Shell
53 LightDMController.userMode = "single";
54 LightDMController.userMode = "single";
54− shellLoader.active = true;
57 ApplicationMenuDataLoader {
57 ApplicationMenuDataLoader {
58 id: appMenuData
58 id: appMenuData
61− property var shell: shellLoader.item ? shellLoader.item : null
61+ property var shell: null
62 onShellChanged: {
62 onShellChanged: {
63 if (shell) {
63 if (shell) {
64 topLevelSurfaceList = testCase.findInvisibleChild(shell, "topLevelSurfaceList");
64 topLevelSurfaceList = testCase.findInvisibleChild(shell, "topLevelSurfaceList");
@@ -71,14 +71,33 @@ Rectangle {
72 property var topLevelSurfaceList: null
72 property var topLevelSurfaceList: null
80+ usageScenario: usageScenarioSelector.model[usageScenarioSelector.selectedIndex]
83+ orientation: shellRect.shellOrientation
84+ orientations: Orientations {
85+ native_: shellRect.nativeOrientation
86+ primary: shellRect.primaryOrientation
75 id: shellContainer
94 id: shellContainer
76 anchors.left: root.left
95 anchors.left: root.left
77 anchors.right: controls.left
96 anchors.right: controls.left
78 anchors.top: root.top
97 anchors.top: root.top
79 anchors.bottom: root.bottom
98 anchors.bottom: root.bottom
80− Loader {
99+ Rectangle {
81− id: shellLoader
100+ id: shellRect
82 focus: true
101 focus: true
84 anchors.centerIn: parent
103 anchors.centerIn: parent
@@ -93,7 +112,7 @@ Rectangle {
94 name: "phone"
113 name: "phone"
95 PropertyChanges {
114 PropertyChanges {
96− target: shellLoader
115+ target: shellRect
97 width: units.gu(40)
116 width: units.gu(40)
98 height: units.gu(71)
117 height: units.gu(71)
@@ -101,7 +120,7 @@ Rectangle {
102 name: "tablet"
121 name: "tablet"
103 PropertyChanges {
122 PropertyChanges {
104− target: shellLoader
123+ target: shellRect
105 width: units.gu(100)
124 width: units.gu(100)
106 height: units.gu(71)
125 height: units.gu(71)
107 shellOrientation: Qt.LandscapeOrientation
126 shellOrientation: Qt.LandscapeOrientation
@@ -112,7 +131,7 @@ Rectangle {
113 name: "desktop"
132 name: "desktop"
114 PropertyChanges {
133 PropertyChanges {
115− target: shellLoader
134+ target: shellRect
116 width: shellContainer.width
135 width: shellContainer.width
117 height: shellContainer.height
136 height: shellContainer.height
@@ -122,28 +141,6 @@ Rectangle {
127− property bool itemDestroyed: false
128− sourceComponent: Component {
132− usageScenario: usageScenarioSelector.model[usageScenarioSelector.selectedIndex]
134− nativeHeight: height
135− orientation: shellLoader.shellOrientation
136− orientations: Orientations {
137− native_: shellLoader.nativeOrientation
138− primary: shellLoader.primaryOrientation
140− mode: shellLoader.mode
141− hasTouchscreen: true
142− Component.onDestruction: {
143− shellLoader.itemDestroyed = true;
@@ -170,14 +167,24 @@ Rectangle {
170 spacing: units.gu(1)
167 spacing: units.gu(1)
171 anchors { left: parent.left; right: parent.right }
168 anchors { left: parent.left; right: parent.right }
173+ if (shell === null) {
174+ shell = shellComponent.createObject(shellRect);
174 text: "Show Greeter"
181 text: "Show Greeter"
175 activeFocusOnPress: false
182 activeFocusOnPress: false
176 onClicked: {
183 onClicked: {
177− if (shellLoader.status !== Loader.Ready)
184+ if (shell === null)
180− var greeter = shellLoader.item.greeter;
187+ var greeter = shell.greeter;
181 if (!greeter.shown) {
188 if (!greeter.shown) {
182 LightDM.Greeter.showGreeter();
189 LightDM.Greeter.showGreeter();
@@ -187,10 +194,10 @@ Rectangle {
187 text: "Hide Greeter"
194 text: "Hide Greeter"
188 activeFocusOnPress: false
195 activeFocusOnPress: false
189 onClicked: {
196 onClicked: {
190− if (shellLoader.status !== Loader.Ready)
197+ if (shell === null)
193− var greeter = shellLoader.item.greeter;
200+ var greeter = shell.greeter;
194 if (greeter.shown) {
201 if (greeter.shown) {
195 greeter.hide()
202 greeter.hide()
@@ -200,7 +207,7 @@ Rectangle {
200 text: callManager.foregroundCall ? "Hide Call" : "Show Call"
207 text: callManager.foregroundCall ? "Hide Call" : "Show Call"
201 activeFocusOnPress: false
208 activeFocusOnPress: false
202 onClicked: {
209 onClicked: {
203− if (shellLoader.status !== Loader.Ready)
210+ if (shell === null)
206 callManager.foregroundCall = callManager.foregroundCall ? null : phoneCall;
213 callManager.foregroundCall = callManager.foregroundCall ? null : phoneCall;
@@ -210,10 +217,10 @@ Rectangle {
210 text: "Show Launcher"
217 text: "Show Launcher"
211 activeFocusOnPress: false
218 activeFocusOnPress: false
212 onClicked: {
219 onClicked: {
213− if (shellLoader.status !== Loader.Ready)
220+ if (shell === null)
216− var launcher = testCase.findChild(shellLoader.item, "launcher");
223+ var launcher = testCase.findChild(shell, "launcher");
217 launcher.state = "visible";
224 launcher.state = "visible";
@@ -222,7 +229,7 @@ Rectangle {
222 activeFocusOnPress: false
229 activeFocusOnPress: false
223 onClicked: {
230 onClicked: {
224 var childs = new Array(0);
231 var childs = new Array(0);
225− childs.push(shellLoader.item)
232+ childs.push(shell)
226 while (childs.length > 0) {
233 while (childs.length > 0) {
227 if (childs[0].activeFocus && childs[0].focus && childs[0].objectName != "shell") {
234 if (childs[0].activeFocus && childs[0].focus && childs[0].objectName != "shell") {
228 console.log("Active focus is on item:", childs[0]);
235 console.log("Active focus is on item:", childs[0]);
@@ -248,7 +255,7 @@ Rectangle {
248 onSelectedIndexChanged: {
255 onSelectedIndexChanged: {
249 testCase.tearDown();
256 testCase.tearDown();
250 LightDMController.userMode = model[selectedIndex];
257 LightDMController.userMode = model[selectedIndex];
251− shellLoader.active = true;
258+ testCase.init();
@@ -261,7 +268,7 @@ Rectangle {
261 activeFocusOnPress: false
268 activeFocusOnPress: false
262 model: ["phone", "tablet", "desktop"]
269 model: ["phone", "tablet", "desktop"]
263 onSelectedIndexChanged: {
270 onSelectedIndexChanged: {
264− shellLoader.state = model[selectedIndex];
271+ shellRect.state = model[selectedIndex];
@@ -419,19 +426,19 @@ Rectangle {
419 if (guard) return;
426 if (guard) return;
420 guard = true;
427 guard = true;
421 testCase.tearDown();
428 testCase.tearDown();
422− shellLoader.mode = model[selectedIndex];
429+ shellRect.mode = model[selectedIndex];
423− shellLoader.active = true;
430+ testCase.init();
424 guard = false;
431 guard = false;
426 Connections {
433 Connections {
427− target: shellLoader
434+ target: shellRect
428 onModeChanged: {
435 onModeChanged: {
429 if (shellModeSelector.guard) {
436 if (shellModeSelector.guard) {
432 shellModeSelector.guard = true;
439 shellModeSelector.guard = true;
433 for (var i = 0; i < 3; i++) {
440 for (var i = 0; i < 3; i++) {
434− if (shellModeSelector.model[i] === shellLoader.mode) {
441+ if (shellModeSelector.model[i] === shellRect.mode) {
435 shellModeSelector.selectedIndex = i;
442 shellModeSelector.selectedIndex = i;
@@ -556,17 +563,26 @@ Rectangle {
556 name: "Shell"
563 name: "Shell"
557 when: windowShown
564 when: windowShown
559− property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null
561 function initTestCase() {
566 function initTestCase() {
567+ // FIXME: The first shell created in the testcase sometimes doesn't
568+ // receive Alt keypresses. Creating and destroying a shell seems
570+ var localShell = createTemporaryObject(shellComponent, shellRect);
571+ localShell.destroy();
562 tearDown();
572 tearDown();
565 function init() {
575 function init() {
566 mouseMove(root, 0, 0);
576 mouseMove(root, 0, 0);
577+ keyRelease(Qt.Key_Alt);
578+ keyRelease(Qt.Key_Control);
579+ keyRelease(Qt.Key_Super_L);
569 function cleanup() {
582 function cleanup() {
583+ var keyMapper = testCase.findChild(shellContainer, "physicalKeysMapper");
584+ keyMapper.controlInsteadOfAlt = false;
585+ keyMapper.controlInsteadOfSuper = false;
570 waitForRendering(shell);
586 waitForRendering(shell);
571 mouseEmulation.checked = true;
587 mouseEmulation.checked = true;
572 tryCompare(shell, "waitingOnGreeter", false); // make sure greeter didn't leave us in disabled state
588 tryCompare(shell, "waitingOnGreeter", false); // make sure greeter didn't leave us in disabled state
@@ -580,10 +596,9 @@ Rectangle {
580 apps = 0;
596 apps = 0;
583− shellLoader.state = formFactor;
599+ shellRect.state = formFactor;
584− shellLoader.active = true;
600+ shell = createTemporaryObject(shellComponent, shellRect);
585− tryCompare(shellLoader, "status", Loader.Ready);
586− removeTimeConstraintsFromSwipeAreas(shellLoader.item);
601+ removeTimeConstraintsFromSwipeAreas(shell);
587 tryCompare(shell, "waitingOnGreeter", false); // reset by greeter when ready
602 tryCompare(shell, "waitingOnGreeter", false); // reset by greeter when ready
589 sessionSpy.target = shell.greeter;
604 sessionSpy.target = shell.greeter;
@@ -606,6 +621,8 @@ Rectangle {
606 stage = findChild(shell, "stage");
621 stage = findChild(shell, "stage");
608 addApps(apps);
623 addApps(apps);
625+ waitForRendering(shell);
611 function addApps(count) {
628 function addApps(count) {
@@ -636,20 +653,6 @@ Rectangle {
636 function tearDown() {
653 function tearDown() {
637 launcherShowDashHomeSpy.target = null;
654 launcherShowDashHomeSpy.target = null;
639− shellLoader.itemDestroyed = false;
641− shellLoader.active = false;
643− tryCompare(shellLoader, "status", Loader.Null);
644− tryCompare(shellLoader, "item", null);
645− // Loader.status might be Loader.Null and Loader.item might be null but the Loader
646− // item might still be alive. So if we set Loader.active back to true
647− // again right now we will get the very same Shell instance back. So no reload
648− // actually took place. Likely because Loader waits until the next event loop
649− // iteration to do its work. So to ensure the reload, we will wait until the
650− // Shell instance gets destroyed.
651− tryCompare(shellLoader, "itemDestroyed", true);
653 LightDMController.reset();
656 LightDMController.reset();
654 setLightDMMockMode("single"); // these tests default to "single"
657 setLightDMMockMode("single"); // these tests default to "single"
@@ -657,7 +660,7 @@ Rectangle {
657 AccountsService.demoEdgesCompleted = [];
660 AccountsService.demoEdgesCompleted = [];
658 AccountsService.backgroundFile = "";
661 AccountsService.backgroundFile = "";
659 Wizard.System.wizardEnabled = false;
662 Wizard.System.wizardEnabled = false;
660− shellLoader.mode = "full-greeter";
663+ shellRect.mode = "full-greeter";
662 // kill all (fake) running apps
665 // kill all (fake) running apps
663 killApps();
666 killApps();
@@ -1647,8 +1650,9 @@ Rectangle {
1648 var spreadItem = findChild(shell, "spreadItem");
1651 var spreadItem = findChild(shell, "spreadItem");
1649 verify(spreadItem !== null);
1652 verify(spreadItem !== null);
1653+ waitForRendering(shell);
1651− keyPress(Qt.Key_Alt)
1655+ keyPress(Qt.Key_Alt);
1652 keyClick(Qt.Key_Tab);
1656 keyClick(Qt.Key_Tab);
1653 tryCompare(spreadItem, "highlightedIndex", 1);
1657 tryCompare(spreadItem, "highlightedIndex", 1);
@@ -2406,7 +2410,7 @@ Rectangle {
2408 function test_greeterModeBroadcastsApp() {
2412 function test_greeterModeBroadcastsApp() {
2409− shellLoader.mode = "greeter";
2413+ shellRect.mode = "greeter";
2410 setLightDMMockMode("single-pin");
2414 setLightDMMockMode("single-pin");
2411 loadShell("phone");
2415 loadShell("phone");
2412 waitForRendering(shell);
2416 waitForRendering(shell);
@@ -2424,7 +2428,7 @@ Rectangle {
2426 function test_greeterModeBroadcastsHome() {
2430 function test_greeterModeBroadcastsHome() {
2427− shellLoader.mode = "greeter";
2431+ shellRect.mode = "greeter";
2428 setLightDMMockMode("single-pin");
2432 setLightDMMockMode("single-pin");
2429 loadShell("phone");
2433 loadShell("phone");
2430 waitForRendering(shell);
2434 waitForRendering(shell);
@@ -2445,7 +2449,7 @@ Rectangle {
2447 function test_greeterModeDispatchesURL() {
2451 function test_greeterModeDispatchesURL() {
2448− shellLoader.mode = "greeter";
2452+ shellRect.mode = "greeter";
2449 setLightDMMockMode("single-pin");
2453 setLightDMMockMode("single-pin");
2450 loadShell("phone");
2454 loadShell("phone");
2451 waitForRendering(shell);
2455 waitForRendering(shell);
@@ -2501,7 +2505,7 @@ Rectangle {
2501 tryCompare(appSurface, "keymap", "fr");
2505 tryCompare(appSurface, "keymap", "fr");
2503 // go to e.g. desktop stage
2507 // go to e.g. desktop stage
2504− shellLoader.state = "desktop";
2508+ shellRect.state = "desktop";
2505 shell.usageScenario = "desktop";
2509 shell.usageScenario = "desktop";
2506 waitForRendering(shell);
2510 waitForRendering(shell);
@@ -2574,7 +2578,7 @@ Rectangle {
2576 function test_fullShellModeHasNoInitialGreeter() {
2580 function test_fullShellModeHasNoInitialGreeter() {
2577− shellLoader.mode = "full-shell";
2581+ shellRect.mode = "full-shell";
2578 loadShell("phone");
2582 loadShell("phone");
2579 setLightDMMockMode("single-pin");
2583 setLightDMMockMode("single-pin");
2580 waitForRendering(shell);
2584 waitForRendering(shell);
@@ -3309,7 +3313,7 @@ Rectangle {
3310 function test_launcherLockedWhenNoAppsRunning(data) {
3314 function test_launcherLockedWhenNoAppsRunning(data) {
3311 loadShell(data.shell, 0);
3315 loadShell(data.shell, 0);
3312− shellLoader.state = data.formFactor;
3316+ shellRect.state = data.formFactor;
3313 var launcher = findChild(shell, "launcher");
3317 var launcher = findChild(shell, "launcher");
3314 var inputMethod = findChild(shell, "inputMethod");
3318 var inputMethod = findChild(shell, "inputMethod");
3315 GSettingsController.setAutohideLauncher(!data.launcherLocked);
3319 GSettingsController.setAutohideLauncher(!data.launcherLocked);