@@ -24,19 +24,19 @@ import "../../../Launcher"
2424 launcher. */
2525Item {
2626 width: units.gu(50)
27− height: units.gu(81)
27+ height: units.gu(50)
2828
2929 Launcher {
3030 id: launcher
3131 x: 0
3232 y: 0
3333 width: units.gu(40)
34− height: units.gu(81)
34+ height: parent.height
3535
36− property string latestApplicationSelected
36+ property string lastSelectedApplication
3737
3838 onLauncherApplicationSelected: {
39− latestApplicationSelected = desktopFile
39+ lastSelectedApplication = desktopFile
4040 }
4141
4242 property int dashItemSelected_count: 0
@@ -57,10 +57,35 @@ Item {
5757 }
5858 }
5959
60+ UT.UnityTestCase {
61+ id: revealer
62+
63+ function dragLauncherIntoView() {
64+ var startX = launcher.dragAreaWidth/2
65+ var startY = launcher.height/2
66+ touchFlick(launcher,
67+ startX, startY,
68+ startX+units.gu(8), startY)
69+
70+ var panel = findChild(launcher, "launcherPanel")
71+ verify(panel != undefined)
72+
73+ // wait until it gets fully extended
74+ tryCompare(panel, "x", 0)
75+ tryCompare(launcher, "state", "visible")
76+ }
77+
78+ function waitUntilLauncherDisappears() {
79+ var panel = findChild(launcher, "launcherPanel")
80+ tryCompare(panel, "x", -panel.width, 1000)
81+ }
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,20 @@ 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()
91116
92117 var appIcon = findChild(launcher, "launcherDelegate0")
93118 verify(appIcon != undefined)
94119
95120 mouseClick(appIcon, appIcon.width/2, appIcon.height/2)
96121
97− tryCompare(launcher, "latestApplicationSelected",
122+ tryCompare(launcher, "lastSelectedApplication",
98123 "/usr/share/applications/phone-app.desktop")
99124
100125 // Tapping on an application icon also dismisses the launcher
101− waitUntilLauncherDisappears()
126+ revealer.waitUntilLauncherDisappears()
102127 }
103128
104129 /* If I click on the dash icon on the launcher
@@ -106,7 +131,7 @@ Item {
106131 function test_clickingOnDashIconCausesSignalEmission() {
107132 launcher.dashItemSelected_count = 0
108133
109− dragLauncherIntoView()
134+ revealer.dragLauncherIntoView()
110135
111136 var dashIcon = findChild(launcher, "dashItem")
112137 verify(dashIcon != undefined)
@@ -116,30 +141,9 @@ Item {
116141 tryCompare(launcher, "dashItemSelected_count", 1)
117142
118143 // Tapping on the dash icon also dismisses the launcher
119− waitUntilLauncherDisappears()
144+ revealer.waitUntilLauncherDisappears()
120145 }
121146
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)
140− }
141−
142−
143147 function test_teaseLauncher_data() {
144148 return [
145149 {tag: "available", available: true},
@@ -164,7 +168,59 @@ Item {
164168 wait(100)
165169 compare(launcher.maxPanelX, -launcher.panelWidth, "Launcher moved even if it shouldn't")
166170 }
167− waitUntilLauncherDisappears();
171+ revealer.waitUntilLauncherDisappears();
172+ launcher.available = true;
173+ }
174+ }
175+
176+ UT.UnityTestCase {
177+ id: clickFlickTestCase
178+ when: windowShown && testCase.completed
179+
180+ function test_clickFlick_data() {
181+ var listView = findChild(launcher, "launcherListView");
182+ return [
183+ {tag: "unfolded top", flickSpeed: units.gu(200), clickY: listView.topMargin + units.gu(2), expectFlick: false},
184+ {tag: "folded top", flickSpeed: -units.gu(200), clickY: listView.topMargin + units.gu(2), expectFlick: true},
185+ {tag: "unfolded bottom", flickSpeed: -units.gu(200), clickY: listView.height - listView.topMargin - units.gu(1), expectFlick: false},
186+ {tag: "folded bottom", flickSpeed: units.gu(200), clickY: listView.height - listView.topMargin - units.gu(1), expectFlick: true},
187+ ];
188+ }
189+
190+ function test_clickFlick(data) {
191+ launcher.lastSelectedApplication = ""
192+ revealer.dragLauncherIntoView();
193+ var listView = findChild(launcher, "launcherListView");
194+
195+ listView.flick(0, data.flickSpeed);
196+ tryCompare(listView, "flicking", false);
197+
198+ var oldY = listView.contentY;
199+
200+ mouseClick(listView, listView.width / 2, data.clickY);
201+ tryCompare(listView, "flicking", false)
202+
203+ if (data.expectFlick) {
204+ verify(listView.contentY != oldY);
205+ compare(launcher.lastSelectedApplication, "", "Launcher app clicked signal emitted even though it should only flick");
206+ } else {
207+ verify(launcher.lastSelectedApplication != "");
208+ compare(listView.contentY, oldY, "Launcher was flicked even though it should only launch an app");
209+ }
210+ // Click somewhere in the empty space to make it hide in case it isn't
211+ mouseClick(launcher, launcher.width - units.gu(1), units.gu(1));
212+ revealer.waitUntilLauncherDisappears();
213+ }
214+ }
215+
216+ UT.UnityTestCase {
217+ id: initTestCase
218+ name: "LauncherInit"
219+ when: windowShown
220+
221+ function test_initFirstUnfolded() {
222+ var listView = findChild(launcher, "launcherListView");
223+ compare(listView.contentY, -listView.topMargin, "Launcher did not start up with first item unfolded");
168224 }
169225 }
170226}