on xenial help sign in
added tests for the clickFlick feature
46f863cMichael Zanetti
Launcher/LauncherPanel.qml+1
@@ -100,6 +100,7 @@ Item {
100 height: parent.height - dashItem.height - parent.spacing*2
100 height: parent.height - dashItem.height - parent.spacing*2
101 ListView {
101 ListView {
102 id: launcherListView
102 id: launcherListView
103+ objectName: "launcherListView"
103 anchors.fill: parent
104 anchors.fill: parent
104 anchors.topMargin: -itemSize
105 anchors.topMargin: -itemSize
105 anchors.bottomMargin: -itemSize
106 anchors.bottomMargin: -itemSize
tests/qmltests/Launcher/tst_Launcher.qml+90−34
@@ -24,19 +24,19 @@ import "../../../Launcher"
24 launcher. */
24 launcher. */
25Item {
25Item {
26 width: units.gu(50)
26 width: units.gu(50)
27− height: units.gu(81)
27+ height: units.gu(50)
28
28
29 Launcher {
29 Launcher {
30 id: launcher
30 id: launcher
31 x: 0
31 x: 0
32 y: 0
32 y: 0
33 width: units.gu(40)
33 width: units.gu(40)
34− height: units.gu(81)
34+ height: parent.height
35
35
36− property string latestApplicationSelected
36+ property string lastSelectedApplication
37
37
38 onLauncherApplicationSelected: {
38 onLauncherApplicationSelected: {
39− latestApplicationSelected = desktopFile
39+ lastSelectedApplication = desktopFile
40 }
40 }
41
41
42 property int dashItemSelected_count: 0
42 property int dashItemSelected_count: 0
@@ -57,10 +57,35 @@ Item {
57 }
57 }
58 }
58 }
59
59
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+
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
64
89
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)
73
98
74− dragLauncherIntoView()
99+ revealer.dragLauncherIntoView()
75
100
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,20 @@ 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 = ""
89
114
90− dragLauncherIntoView()
115+ revealer.dragLauncherIntoView()
91
116
92 var appIcon = findChild(launcher, "launcherDelegate0")
117 var appIcon = findChild(launcher, "launcherDelegate0")
93 verify(appIcon != undefined)
118 verify(appIcon != undefined)
94
119
95 mouseClick(appIcon, appIcon.width/2, appIcon.height/2)
120 mouseClick(appIcon, appIcon.width/2, appIcon.height/2)
96
121
97− tryCompare(launcher, "latestApplicationSelected",
122+ tryCompare(launcher, "lastSelectedApplication",
98 "/usr/share/applications/phone-app.desktop")
123 "/usr/share/applications/phone-app.desktop")
99
124
100 // Tapping on an application icon also dismisses the launcher
125 // Tapping on an application icon also dismisses the launcher
101− waitUntilLauncherDisappears()
126+ revealer.waitUntilLauncherDisappears()
102 }
127 }
103
128
104 /* If I click on the dash icon on the launcher
129 /* If I click on the dash icon on the launcher
@@ -106,7 +131,7 @@ Item {
106 function test_clickingOnDashIconCausesSignalEmission() {
131 function test_clickingOnDashIconCausesSignalEmission() {
107 launcher.dashItemSelected_count = 0
132 launcher.dashItemSelected_count = 0
108
133
109− dragLauncherIntoView()
134+ revealer.dragLauncherIntoView()
110
135
111 var dashIcon = findChild(launcher, "dashItem")
136 var dashIcon = findChild(launcher, "dashItem")
112 verify(dashIcon != undefined)
137 verify(dashIcon != undefined)
@@ -116,30 +141,9 @@ Item {
116 tryCompare(launcher, "dashItemSelected_count", 1)
141 tryCompare(launcher, "dashItemSelected_count", 1)
117
142
118 // Tapping on the dash icon also dismisses the launcher
143 // Tapping on the dash icon also dismisses the launcher
119− waitUntilLauncherDisappears()
144+ revealer.waitUntilLauncherDisappears()
120 }
145 }
121
146
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−
143 function test_teaseLauncher_data() {
147 function test_teaseLauncher_data() {
144 return [
148 return [
145 {tag: "available", available: true},
149 {tag: "available", available: true},
@@ -164,7 +168,59 @@ Item {
164 wait(100)
168 wait(100)
165 compare(launcher.maxPanelX, -launcher.panelWidth, "Launcher moved even if it shouldn't")
169 compare(launcher.maxPanelX, -launcher.panelWidth, "Launcher moved even if it shouldn't")
166 }
170 }
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");
168 }
224 }
169 }
225 }
170}
226}