@@ -23,20 +23,21 @@ import "../../../Launcher"
23/* Nothing is shown at first. If you drag from left edge you will bring up the
23/* Nothing is shown at first. If you drag from left edge you will bring up the
24 launcher. */
24 launcher. */
26 width: units.gu(50)
27 width: units.gu(50)
27− height: units.gu(81)
28+ height: units.gu(55)
29 Launcher {
30 Launcher {
30 id: launcher
31 id: launcher
33 width: units.gu(40)
34 width: units.gu(40)
34− height: units.gu(81)
35+ height: parent.height
36− property string latestApplicationSelected
37+ property string lastSelectedApplication
38 onLauncherApplicationSelected: {
39 onLauncherApplicationSelected: {
39− latestApplicationSelected = desktopFile
40+ lastSelectedApplication = desktopFile
42 property int dashItemSelected_count: 0
43 property int dashItemSelected_count: 0
@@ -57,10 +58,34 @@ Item {
64+ function dragLauncherIntoView() {
65+ var startX = launcher.dragAreaWidth/2;
66+ var startY = launcher.height/2;
69+ startX+units.gu(8), startY);
71+ var panel = findChild(launcher, "launcherPanel");
72+ verify(panel != undefined);
74+ // wait until it gets fully extended
75+ tryCompare(panel, "x", 0);
76+ tryCompare(launcher, "state", "visible");
79+ function waitUntilLauncherDisappears() {
80+ var panel = findChild(launcher, "launcherPanel");
81+ tryCompare(panel, "x", -panel.width, 1000);
60 UT.UnityTestCase {
85 UT.UnityTestCase {
61 id: testCase
86 id: testCase
62 name: "Launcher"
87 name: "Launcher"
63− when: windowShown
88+ when: windowShown && initTestCase.completed
65 // Drag from the left edge of the screen rightwards and check that the launcher
90 // Drag from the left edge of the screen rightwards and check that the launcher
66 // appears (as if being dragged by the finger/pointer)
91 // appears (as if being dragged by the finger/pointer)
@@ -71,7 +96,7 @@ Item {
71 // it starts out hidden just left of the left launcher edge
96 // it starts out hidden just left of the left launcher edge
72 compare(panel.x, -panel.width)
97 compare(panel.x, -panel.width)
74− dragLauncherIntoView()
99+ revealer.dragLauncherIntoView()
76 // tapping on the center of the screen should dismiss the launcher
101 // tapping on the center of the screen should dismiss the launcher
77 mouseClick(launcher, launcher.width/2, launcher.height/2)
102 mouseClick(launcher, launcher.width/2, launcher.height/2)
@@ -85,20 +110,25 @@ Item {
85 corresponding desktop file. E.g. clicking on phone icon should yield
110 corresponding desktop file. E.g. clicking on phone icon should yield
86 launcherApplicationSelected("[...]phone-app.desktop") */
111 launcherApplicationSelected("[...]phone-app.desktop") */
87 function test_clickingOnAppIconCausesSignalEmission() {
112 function test_clickingOnAppIconCausesSignalEmission() {
88− launcher.latestApplicationSelected = ""
113+ launcher.lastSelectedApplication = ""
90− dragLauncherIntoView()
115+ revealer.dragLauncherIntoView()
117+ var listView = findChild(launcher, "launcherListView");
118+ listView.flick(0, units.gu(500));
119+ tryCompare(listView, "flicking", false);
92 var appIcon = findChild(launcher, "launcherDelegate0")
121 var appIcon = findChild(launcher, "launcherDelegate0")
93 verify(appIcon != undefined)
123 verify(appIcon != undefined)
95 mouseClick(appIcon, appIcon.width/2, appIcon.height/2)
125 mouseClick(appIcon, appIcon.width/2, appIcon.height/2)
97− tryCompare(launcher, "latestApplicationSelected",
127+ tryCompare(launcher, "lastSelectedApplication",
98 "/usr/share/applications/phone-app.desktop")
128 "/usr/share/applications/phone-app.desktop")
100 // Tapping on an application icon also dismisses the launcher
130 // Tapping on an application icon also dismisses the launcher
101− waitUntilLauncherDisappears()
131+ revealer.waitUntilLauncherDisappears()
104 /* If I click on the dash icon on the launcher
134 /* If I click on the dash icon on the launcher
@@ -106,7 +136,7 @@ Item {
106 function test_clickingOnDashIconCausesSignalEmission() {
136 function test_clickingOnDashIconCausesSignalEmission() {
107 launcher.dashItemSelected_count = 0
137 launcher.dashItemSelected_count = 0
109− dragLauncherIntoView()
139+ revealer.dragLauncherIntoView()
111 var dashIcon = findChild(launcher, "dashItem")
141 var dashIcon = findChild(launcher, "dashItem")
112 verify(dashIcon != undefined)
142 verify(dashIcon != undefined)
@@ -116,30 +146,9 @@ Item {
116 tryCompare(launcher, "dashItemSelected_count", 1)
146 tryCompare(launcher, "dashItemSelected_count", 1)
118 // Tapping on the dash icon also dismisses the launcher
148 // Tapping on the dash icon also dismisses the launcher
119− waitUntilLauncherDisappears()
122− function dragLauncherIntoView() {
123− var startX = launcher.dragAreaWidth/2
124− var startY = launcher.height/2
125− touchFlick(launcher,
127− startX+units.gu(8), startY)
129− var panel = findChild(launcher, "launcherPanel")
130− verify(panel != undefined)
132− // wait until it gets fully extended
133− tryCompare(panel, "x", 0)
134− tryCompare(launcher, "state", "visible")
137− function waitUntilLauncherDisappears() {
149+ revealer.waitUntilLauncherDisappears()
138− var panel = findChild(launcher, "launcherPanel")
139− tryCompare(panel, "x", -panel.width, 1000)
143 function test_teaseLauncher_data() {
152 function test_teaseLauncher_data() {
145 {tag: "available", available: true},
154 {tag: "available", available: true},
@@ -164,7 +173,78 @@ Item {
164 wait(100)
173 wait(100)
165 compare(launcher.maxPanelX, -launcher.panelWidth, "Launcher moved even if it shouldn't")
174 compare(launcher.maxPanelX, -launcher.panelWidth, "Launcher moved even if it shouldn't")
167− waitUntilLauncherDisappears();
176+ revealer.waitUntilLauncherDisappears();
177+ launcher.available = true;
182+ id: clickFlickTestCase
183+ when: windowShown && testCase.completed
185+ function test_clickFlick_data() {
186+ var listView = findChild(launcher, "launcherListView");
188+ {tag: "unfolded top", flickSpeed: units.gu(200), clickY: listView.topMargin + units.gu(2), expectFlick: false},
189+ {tag: "folded top", flickSpeed: -units.gu(200), clickY: listView.topMargin + units.gu(2), expectFlick: true},
190+ {tag: "unfolded bottom", flickSpeed: -units.gu(200), clickY: listView.height - listView.topMargin - units.gu(1), expectFlick: false},
191+ {tag: "folded bottom", flickSpeed: units.gu(200), clickY: listView.height - listView.topMargin - units.gu(1), expectFlick: true},
195+ function test_clickFlick(data) {
196+ launcher.lastSelectedApplication = "";
197+ revealer.dragLauncherIntoView();
198+ var listView = findChild(launcher, "launcherListView");
200+ listView.flick(0, data.flickSpeed);
201+ tryCompare(listView, "flicking", false);
203+ var oldY = listView.contentY;
205+ mouseClick(listView, listView.width / 2, data.clickY);
206+ tryCompare(listView, "flicking", false);
208+ if (data.expectFlick) {
209+ verify(listView.contentY != oldY);
210+ compare(launcher.lastSelectedApplication, "", "Launcher app clicked signal emitted even though it should only flick");
212+ verify(launcher.lastSelectedApplication != "");
213+ compare(listView.contentY, oldY, "Launcher was flicked even though it should only launch an app");
216+ // Restore position on top
217+ listView.flick(0, units.gu(200));
218+ tryCompare(listView, "flicking", false)
219+ // Click somewhere in the empty space to make it hide in case it isn't
220+ mouseClick(launcher, launcher.width - units.gu(1), units.gu(1));
221+ revealer.waitUntilLauncherDisappears();
227+ name: "LauncherInit"
231+ * FIXME: There is a bug in ListView which makes it snap to an item
232+ * instead of the edge at startup. Enable this test once our patch for
233+ * ListView has landed upstream.
234+ * https://bugreports.qt-project.org/browse/QTBUG-32251
236+ function test_initFirstUnfolded() {
238+ // Make sure noone changed the height of the window. The issue this test case
239+ // is verifying only happens on certain heights of the Launcher
240+ compare(root.height, units.gu(55));
242+ var listView = findChild(launcher, "launcherListView");
243+ compare(listView.contentY, -listView.topMargin, "Launcher did not start up with first item unfolded");
245+ // Now do check that snapping is in fact enabled
246+ compare(listView.snapMode, ListView.SnapToItem, "Snapping is not enabled");