@@ -23,20 +23,21 @@ import "../../../Launcher"
2323/* Nothing is shown at first. If you drag from left edge you will bring up the
2424 launcher. */
2525Item {
26+ id: root
2627 width: units.gu(50)
27− height: units.gu(81)
28+ height: units.gu(55)
2829
2930 Launcher {
3031 id: launcher
3132 x: 0
3233 y: 0
3334 width: units.gu(40)
34− height: units.gu(81)
35+ height: parent.height
3536
36− property string latestApplicationSelected
37+ property string lastSelectedApplication
3738
3839 onLauncherApplicationSelected: {
39− latestApplicationSelected = desktopFile
40+ lastSelectedApplication = desktopFile
4041 }
4142
4243 property int dashItemSelected_count: 0
@@ -57,10 +58,34 @@ Item {
5758 }
5859 }
5960
61+ UT.UnityTestCase {
62+ id: revealer
63+
64+ function dragLauncherIntoView() {
65+ var startX = launcher.dragAreaWidth/2;
66+ var startY = launcher.height/2;
67+ touchFlick(launcher,
68+ startX, startY,
69+ startX+units.gu(8), startY);
70+
71+ var panel = findChild(launcher, "launcherPanel");
72+ verify(panel != undefined);
73+
74+ // wait until it gets fully extended
75+ tryCompare(panel, "x", 0);
76+ tryCompare(launcher, "state", "visible");
77+ }
78+
79+ function waitUntilLauncherDisappears() {
80+ var panel = findChild(launcher, "launcherPanel");
81+ tryCompare(panel, "x", -panel.width, 1000);
82+ }
83+ }
84+
6085 UT.UnityTestCase {
6186 id: testCase
6287 name: "Launcher"
63− when: windowShown
88+ when: windowShown && initTestCase.completed
6489
6590 // Drag from the left edge of the screen rightwards and check that the launcher
6691 // appears (as if being dragged by the finger/pointer)
@@ -71,7 +96,7 @@ Item {
7196 // it starts out hidden just left of the left launcher edge
7297 compare(panel.x, -panel.width)
7398
74− dragLauncherIntoView()
99+ revealer.dragLauncherIntoView()
75100
76101 // tapping on the center of the screen should dismiss the launcher
77102 mouseClick(launcher, launcher.width/2, launcher.height/2)
@@ -85,20 +110,25 @@ Item {
85110 corresponding desktop file. E.g. clicking on phone icon should yield
86111 launcherApplicationSelected("[...]phone-app.desktop") */
87112 function test_clickingOnAppIconCausesSignalEmission() {
88− launcher.latestApplicationSelected = ""
113+ launcher.lastSelectedApplication = ""
89114
90− dragLauncherIntoView()
115+ revealer.dragLauncherIntoView()
116+
117+ var listView = findChild(launcher, "launcherListView");
118+ listView.flick(0, units.gu(500));
119+ tryCompare(listView, "flicking", false);
91120
92121 var appIcon = findChild(launcher, "launcherDelegate0")
122+
93123 verify(appIcon != undefined)
94124
95125 mouseClick(appIcon, appIcon.width/2, appIcon.height/2)
96126
97− tryCompare(launcher, "latestApplicationSelected",
127+ tryCompare(launcher, "lastSelectedApplication",
98128 "/usr/share/applications/phone-app.desktop")
99129
100130 // Tapping on an application icon also dismisses the launcher
101− waitUntilLauncherDisappears()
131+ revealer.waitUntilLauncherDisappears()
102132 }
103133
104134 /* If I click on the dash icon on the launcher
@@ -106,7 +136,7 @@ Item {
106136 function test_clickingOnDashIconCausesSignalEmission() {
107137 launcher.dashItemSelected_count = 0
108138
109− dragLauncherIntoView()
139+ revealer.dragLauncherIntoView()
110140
111141 var dashIcon = findChild(launcher, "dashItem")
112142 verify(dashIcon != undefined)
@@ -116,30 +146,9 @@ Item {
116146 tryCompare(launcher, "dashItemSelected_count", 1)
117147
118148 // Tapping on the dash icon also dismisses the launcher
119− waitUntilLauncherDisappears()
120− }
121−
122− function dragLauncherIntoView() {
123− var startX = launcher.dragAreaWidth/2
124− var startY = launcher.height/2
125− touchFlick(launcher,
126− startX, startY,
127− startX+units.gu(8), startY)
128−
129− var panel = findChild(launcher, "launcherPanel")
130− verify(panel != undefined)
131−
132− // wait until it gets fully extended
133− tryCompare(panel, "x", 0)
134− tryCompare(launcher, "state", "visible")
135− }
136−
137− function waitUntilLauncherDisappears() {
138− var panel = findChild(launcher, "launcherPanel")
139− tryCompare(panel, "x", -panel.width, 1000)
149+ revealer.waitUntilLauncherDisappears()
140150 }
141151
142−
143152 function test_teaseLauncher_data() {
144153 return [
145154 {tag: "available", available: true},
@@ -164,7 +173,78 @@ Item {
164173 wait(100)
165174 compare(launcher.maxPanelX, -launcher.panelWidth, "Launcher moved even if it shouldn't")
166175 }
167− waitUntilLauncherDisappears();
176+ revealer.waitUntilLauncherDisappears();
177+ launcher.available = true;
178+ }
179+ }
180+
181+ UT.UnityTestCase {
182+ id: clickFlickTestCase
183+ when: windowShown && testCase.completed
184+
185+ function test_clickFlick_data() {
186+ var listView = findChild(launcher, "launcherListView");
187+ return [
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},
192+ ];
193+ }
194+
195+ function test_clickFlick(data) {
196+ launcher.lastSelectedApplication = "";
197+ revealer.dragLauncherIntoView();
198+ var listView = findChild(launcher, "launcherListView");
199+
200+ listView.flick(0, data.flickSpeed);
201+ tryCompare(listView, "flicking", false);
202+
203+ var oldY = listView.contentY;
204+
205+ mouseClick(listView, listView.width / 2, data.clickY);
206+ tryCompare(listView, "flicking", false);
207+
208+ if (data.expectFlick) {
209+ verify(listView.contentY != oldY);
210+ compare(launcher.lastSelectedApplication, "", "Launcher app clicked signal emitted even though it should only flick");
211+ } else {
212+ verify(launcher.lastSelectedApplication != "");
213+ compare(listView.contentY, oldY, "Launcher was flicked even though it should only launch an app");
214+ }
215+
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();
222+ }
223+ }
224+
225+ UT.UnityTestCase {
226+ id: initTestCase
227+ name: "LauncherInit"
228+ when: windowShown
229+
230+ /*
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
235+
236+ function test_initFirstUnfolded() {
237+
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));
241+
242+ var listView = findChild(launcher, "launcherListView");
243+ compare(listView.contentY, -listView.topMargin, "Launcher did not start up with first item unfolded");
244+
245+ // Now do check that snapping is in fact enabled
246+ compare(listView.snapMode, ListView.SnapToItem, "Snapping is not enabled");
168247 }
248+ */
169249 }
170250}