@@ -1,5 +1,5 @@
2− * Copyright 2013 Canonical Ltd.
2+ * Copyright 2013-2014 Canonical Ltd.
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -28,25 +28,49 @@ Item {
28 width: units.gu(50)
28 width: units.gu(50)
29 height: units.gu(55)
29 height: units.gu(55)
34+ property bool itemDestroyed: false
35+ sourceComponent: Component {
31− Launcher {
36+ Launcher {
32− id: launcher
37+ id: launcher
35− width: units.gu(40)
40+ width: units.gu(40)
36− height: parent.height
41+ height: root.height
43+ property string lastSelectedApplication
45+ onLauncherApplicationSelected: {
46+ lastSelectedApplication = appId
38− property string lastSelectedApplication
49+ property int showDashHome_count: 0
51+ showDashHome_count++;
40− onLauncherApplicationSelected: {
54+ property int maxPanelX: 0
41− lastSelectedApplication = appId
44− property int showDashHome_count: 0
56+ Connections {
45− onShowDashHome: {
57+ target: testCase.findChild(launcher, "launcherPanel")
46− showDashHome_count++;
49− property int maxPanelX: 0
59+ onXChanged: {
60+ if (target.x > launcher.maxPanelX) {
61+ launcher.maxPanelX = target.x;
66+ Component.onCompleted: {
67+ launcherLoader.itemDestroyed = false;
69+ Component.onDestruction: {
70+ launcherLoader.itemDestroyed = true;
52 SignalSpy {
76 SignalSpy {
@@ -54,19 +78,40 @@ Item {
54 target: LauncherModel
78 target: LauncherModel
57− Connections {
81+ UT.UnityTestCase {
58− target: testCase.findChild(launcher, "launcherPanel")
82+ id: testCase
60− onXChanged: {
86+ property Item launcher: launcherLoader.status === Loader.Ready ? launcherLoader.item : null
61− if (target.x > launcher.maxPanelX) {
87+ function cleanup() {
62− launcher.maxPanelX = target.x;
88+ launcherLoader.active = false;
63− }
89+ // Loader.status might be Loader.Null and Loader.item might be null but the Loader
90+ // item might still be alive. So if we set Loader.active back to true
91+ // again right now we will get the very same Shell instance back. So no reload
92+ // actually took place. Likely because Loader waits until the next event loop
93+ // iteration to do its work. So to ensure the reload, we will wait until the
94+ // Shell instance gets destroyed.
95+ tryCompare(launcherLoader, "itemDestroyed", true);
96+ launcherLoader.active = true;
65− }
98+ function init() {
99+ var listView = findChild(launcher, "launcherListView");
100+ // wait for it to settle before doing the flick. Otherwise the flick
102+ // On startup that listView is already moving. maybe because of its contents
103+ // growing while populating it with icons etc.
104+ tryCompare(listView, "flicking", false);
67− UT.UnityTestCase {
106+ // Make sure noone changed the height of the window. The issue this test case
68− id: revealer
107+ // is verifying only happens on certain heights of the Launcher
69− when: windowShown
108+ compare(root.height, units.gu(55));
110+ compare(listView.contentY, -listView.topMargin, "Launcher did not start up with first item unfolded");
112+ // Now do check that snapping is in fact enabled
113+ compare(listView.snapMode, ListView.SnapToItem, "Snapping is not enabled");
71 function dragLauncherIntoView() {
116 function dragLauncherIntoView() {
72 var startX = launcher.dragAreaWidth/2;
117 var startX = launcher.dragAreaWidth/2;
@@ -87,22 +132,11 @@ Item {
87 var panel = findChild(launcher, "launcherPanel");
132 var panel = findChild(launcher, "launcherPanel");
88 tryCompare(panel, "x", -panel.width, 1000);
133 tryCompare(panel, "x", -panel.width, 1000);
95− when: windowShown && initTestCase.completed
98− mouseClick(root, root.width / 2, root.height / 2);
99− revealer.waitUntilLauncherDisappears();
102 // Drag from the left edge of the screen rightwards and check that the launcher
136 // Drag from the left edge of the screen rightwards and check that the launcher
103 // appears (as if being dragged by the finger/pointer)
137 // appears (as if being dragged by the finger/pointer)
104 function test_dragLeftEdgeToRevealLauncherAndTapCenterToDismiss() {
138 function test_dragLeftEdgeToRevealLauncherAndTapCenterToDismiss() {
105− revealer.waitUntilLauncherDisappears();
139+ waitUntilLauncherDisappears();
107 var panel = findChild(launcher, "launcherPanel")
141 var panel = findChild(launcher, "launcherPanel")
108 verify(panel != undefined)
142 verify(panel != undefined)
@@ -110,7 +144,7 @@ Item {
110 // it starts out hidden just left of the left launcher edge
144 // it starts out hidden just left of the left launcher edge
111 compare(panel.x, -panel.width)
145 compare(panel.x, -panel.width)
113− revealer.dragLauncherIntoView()
147+ dragLauncherIntoView()
115 // tapping on the center of the screen should dismiss the launcher
149 // tapping on the center of the screen should dismiss the launcher
116 mouseClick(launcher, launcher.width/2, launcher.height/2)
150 mouseClick(launcher, launcher.width/2, launcher.height/2)
@@ -124,7 +158,7 @@ Item {
124 corresponding desktop file. E.g. clicking on phone icon should yield
158 corresponding desktop file. E.g. clicking on phone icon should yield
125 launcherApplicationSelected("[...]dialer-app.desktop") */
159 launcherApplicationSelected("[...]dialer-app.desktop") */
126 function test_clickingOnAppIconCausesSignalEmission() {
160 function test_clickingOnAppIconCausesSignalEmission() {
127− revealer.dragLauncherIntoView();
161+ dragLauncherIntoView();
128 launcher.lastSelectedApplication = ""
162 launcher.lastSelectedApplication = ""
130 var listView = findChild(launcher, "launcherListView");
164 var listView = findChild(launcher, "launcherListView");
@@ -140,7 +174,7 @@ Item {
140 "dialer-app")
174 "dialer-app")
142 // Tapping on an application icon also dismisses the launcher
176 // Tapping on an application icon also dismisses the launcher
143− revealer.waitUntilLauncherDisappears()
177+ waitUntilLauncherDisappears()
146 /* If I click on the dash icon on the launcher
180 /* If I click on the dash icon on the launcher
@@ -148,7 +182,7 @@ Item {
148 function test_clickingOnDashIconCausesSignalEmission() {
182 function test_clickingOnDashIconCausesSignalEmission() {
149 launcher.showDashHome_count = 0
183 launcher.showDashHome_count = 0
151− revealer.dragLauncherIntoView()
185+ dragLauncherIntoView()
153 var dashIcon = findChild(launcher, "dashItem")
187 var dashIcon = findChild(launcher, "dashItem")
154 verify(dashIcon != undefined)
188 verify(dashIcon != undefined)
@@ -158,7 +192,7 @@ Item {
158 tryCompare(launcher, "showDashHome_count", 1)
192 tryCompare(launcher, "showDashHome_count", 1)
160 // Tapping on the dash icon also dismisses the launcher
194 // Tapping on the dash icon also dismisses the launcher
161− revealer.waitUntilLauncherDisappears()
195+ waitUntilLauncherDisappears()
164 function test_teaseLauncher_data() {
198 function test_teaseLauncher_data() {
@@ -185,12 +219,12 @@ Item {
185 wait(100)
219 wait(100)
186 compare(launcher.maxPanelX, -launcher.panelWidth, "Launcher moved even if it shouldn't")
220 compare(launcher.maxPanelX, -launcher.panelWidth, "Launcher moved even if it shouldn't")
188− revealer.waitUntilLauncherDisappears();
222+ waitUntilLauncherDisappears();
189 launcher.available = true;
223 launcher.available = true;
192 function test_countEmblems() {
226 function test_countEmblems() {
193− revealer.dragLauncherIntoView();
227+ dragLauncherIntoView();
194 var launcherListView = findChild(launcher, "launcherListView");
228 var launcherListView = findChild(launcher, "launcherListView");
195 for (var i = 0; i < launcherListView.count; ++i) {
229 for (var i = 0; i < launcherListView.count; ++i) {
196 var delegate = findChild(launcherListView, "launcherDelegate" + i)
230 var delegate = findChild(launcherListView, "launcherDelegate" + i)
@@ -201,7 +235,7 @@ Item {
203 function test_progressOverlays() {
237 function test_progressOverlays() {
204− revealer.dragLauncherIntoView();
238+ dragLauncherIntoView();
205 var launcherListView = findChild(launcher, "launcherListView");
239 var launcherListView = findChild(launcher, "launcherListView");
206 for (var i = 0; i < launcherListView.count; ++i) {
240 for (var i = 0; i < launcherListView.count; ++i) {
207 var delegate = findChild(launcherListView, "launcherDelegate" + i)
241 var delegate = findChild(launcherListView, "launcherDelegate" + i)
@@ -210,18 +244,13 @@ Item {
212 function test_focusedHighlight() {
246 function test_focusedHighlight() {
213− revealer.dragLauncherIntoView();
247+ dragLauncherIntoView();
214 var launcherListView = findChild(launcher, "launcherListView");
248 var launcherListView = findChild(launcher, "launcherListView");
215 for (var i = 0; i < launcherListView.count; ++i) {
249 for (var i = 0; i < launcherListView.count; ++i) {
216 var delegate = findChild(launcherListView, "launcherDelegate" + i)
250 var delegate = findChild(launcherListView, "launcherDelegate" + i)
217 compare(findChild(delegate, "focusedHighlight").visible, LauncherModel.get(i).focused)
251 compare(findChild(delegate, "focusedHighlight").visible, LauncherModel.get(i).focused)
223− id: clickFlickTestCase
224− when: windowShown && testCase.completed
226 function test_clickFlick_data() {
255 function test_clickFlick_data() {
227 var listView = findChild(launcher, "launcherListView");
256 var listView = findChild(launcher, "launcherListView");
@@ -235,7 +264,7 @@ Item {
236 function test_clickFlick(data) {
265 function test_clickFlick(data) {
237 launcher.lastSelectedApplication = "";
266 launcher.lastSelectedApplication = "";
238− revealer.dragLauncherIntoView();
267+ dragLauncherIntoView();
239 var listView = findChild(launcher, "launcherListView");
268 var listView = findChild(launcher, "launcherListView");
241 listView.flick(0, data.flickSpeed);
270 listView.flick(0, data.flickSpeed);
@@ -253,44 +282,7 @@ Item {
253 verify(launcher.lastSelectedApplication != "");
282 verify(launcher.lastSelectedApplication != "");
254 compare(listView.contentY, oldY, "Launcher was flicked even though it should only launch an app");
283 compare(listView.contentY, oldY, "Launcher was flicked even though it should only launch an app");
257− // Restore position on top
258− listView.flick(0, units.gu(200));
259− tryCompare(listView, "flicking", false)
260− // Click somewhere in the empty space to make it hide in case it isn't
261− mouseClick(launcher, launcher.width - units.gu(1), units.gu(1));
262− revealer.waitUntilLauncherDisappears();
268− name: "LauncherInit"
271− function initTestCase() {
272− var listView = findChild(launcher, "launcherListView");
273− tryCompare(listView, "flicking", false)
276− function test_initFirstUnfolded() {
278− // Make sure noone changed the height of the window. The issue this test case
279− // is verifying only happens on certain heights of the Launcher
280− compare(root.height, units.gu(55));
282− var listView = findChild(launcher, "launcherListView");
283− compare(listView.contentY, -listView.topMargin, "Launcher did not start up with first item unfolded");
285− // Now do check that snapping is in fact enabled
286− compare(listView.snapMode, ListView.SnapToItem, "Snapping is not enabled");
292− name: "Drag and Drop"
293− when: windowShown && initTestCase.completed
295 function test_dragndrop_data() {
287 function test_dragndrop_data() {
@@ -301,7 +293,7 @@ Item {
303 function test_dragndrop(data) {
295 function test_dragndrop(data) {
304− revealer.dragLauncherIntoView();
296+ dragLauncherIntoView();
305 var draggedItem = findChild(launcher, "launcherDelegate4")
297 var draggedItem = findChild(launcher, "launcherDelegate4")
306 var item0 = findChild(launcher, "launcherDelegate0")
298 var item0 = findChild(launcher, "launcherDelegate0")
307 var fakeDragItem = findChild(launcher, "fakeDragItem")
299 var fakeDragItem = findChild(launcher, "fakeDragItem")
@@ -366,11 +358,11 @@ Item {
367 // Click somewhere in the empty space to make it hide in case it isn't
359 // Click somewhere in the empty space to make it hide in case it isn't
368 mouseClick(launcher, launcher.width - units.gu(1), units.gu(1));
360 mouseClick(launcher, launcher.width - units.gu(1), units.gu(1));
369− revealer.waitUntilLauncherDisappears();
361+ waitUntilLauncherDisappears();
372 function test_quicklist_dismiss() {
364 function test_quicklist_dismiss() {
373− revealer.dragLauncherIntoView();
365+ dragLauncherIntoView();
374 var draggedItem = findChild(launcher, "launcherDelegate5")
366 var draggedItem = findChild(launcher, "launcherDelegate5")
375 var item0 = findChild(launcher, "launcherDelegate0")
367 var item0 = findChild(launcher, "launcherDelegate0")
376 var fakeDragItem = findChild(launcher, "fakeDragItem")
368 var fakeDragItem = findChild(launcher, "fakeDragItem")
@@ -401,7 +393,7 @@ Item {
403 function test_quicklist_positioning(data) {
395 function test_quicklist_positioning(data) {
404− revealer.dragLauncherIntoView();
396+ dragLauncherIntoView();
405 var quickList = findChild(launcher, "quickList")
397 var quickList = findChild(launcher, "quickList")
406 var draggedItem = findChild(launcher, "launcherDelegate" + data.itemIndex)
398 var draggedItem = findChild(launcher, "launcherDelegate" + data.itemIndex)
407 var quickListShape = findChild(launcher, "quickListShape")
399 var quickListShape = findChild(launcher, "quickListShape")
@@ -428,7 +420,7 @@ Item {
429 // Click somewhere in the empty space to dismiss the launcher
421 // Click somewhere in the empty space to dismiss the launcher
430 mouseClick(launcher, launcher.width - units.gu(1), units.gu(1));
422 mouseClick(launcher, launcher.width - units.gu(1), units.gu(1));
431− revealer.waitUntilLauncherDisappears()
423+ waitUntilLauncherDisappears()
434 function test_quicklist_click_data() {
426 function test_quicklist_click_data() {
@@ -439,7 +431,7 @@ Item {
441 function test_quicklist_click(data) {
433 function test_quicklist_click(data) {
442− revealer.dragLauncherIntoView();
434+ dragLauncherIntoView();
443 var clickedItem = findChild(launcher, "launcherDelegate5")
435 var clickedItem = findChild(launcher, "launcherDelegate5")
444 var quickList = findChild(launcher, "quickList")
436 var quickList = findChild(launcher, "quickList")
445 var quickListShape = findChild(launcher, "quickListShape")
437 var quickListShape = findChild(launcher, "quickListShape")