on xenial help sign in
Improve Launcher tests, making them more reliable

Approved by: Michael Zanetti, PS Jenkins bot

commit9f7617d4611286e92bffaad28cab06b77dedfd8f authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateWed 11 Feb 2015, 17:11 (12 years ago) parent9f25efe5f946a1
1 file changed+29−16
tests/qmltests/Launcher/tst_Launcher.qml+29−16
tests/qmltests/Launcher/tst_Launcher.qml+29−16
@@ -153,6 +153,18 @@ Item {
153153 tryCompare(panel, "x", -panel.width, 1000);
154154 }
155155
156+ function positionLauncherListAtBeginning() {
157+ var listView = testCase.findChild(launcherLoader.item, "launcherListView");
158+ listView.contentY = -listView.topMargin;
159+ }
160+ function positionLauncherListAtEnd() {
161+ var listView = testCase.findChild(launcherLoader.item, "launcherListView");
162+ if ((listView.contentHeight + listView.topMargin + listView.bottomMargin) > listView.height) {
163+ listView.contentY = listView.topMargin + listView.contentHeight
164+ - listView.height;
165+ }
166+ }
167+
156168 // Drag from the left edge of the screen rightwards and check that the launcher
157169 // appears (as if being dragged by the finger/pointer)
158170 function test_dragLeftEdgeToRevealLauncherAndTapCenterToDismiss() {
@@ -179,22 +191,22 @@ Item {
179191 launcherApplicationSelected("[...]dialer-app.desktop") */
180192 function test_clickingOnAppIconCausesSignalEmission() {
181193 dragLauncherIntoView();
182− launcher.lastSelectedApplication = ""
194+ launcher.lastSelectedApplication = "";
195+ launcher.inverted = false;
183196
184− var listView = findChild(launcher, "launcherListView");
185− listView.positionViewAtEnd();
197+ positionLauncherListAtBeginning();
186198
187− var appIcon = findChild(launcher, "launcherDelegate0")
199+ var appIcon = findChild(launcher, "launcherDelegate0");
188200
189− verify(appIcon != undefined)
201+ verify(appIcon != undefined);
190202
191− mouseClick(appIcon)
203+ mouseClick(appIcon);
192204
193205 tryCompare(launcher, "lastSelectedApplication",
194− "dialer-app")
206+ appIcon.appId);
195207
196208 // Tapping on an application icon also dismisses the launcher
197− waitUntilLauncherDisappears()
209+ waitUntilLauncherDisappears();
198210 }
199211
200212 /* If I click on the dash icon on the launcher
@@ -290,25 +302,26 @@ Item {
290302 function test_clickFlick_data() {
291303 var listView = findChild(launcher, "launcherListView");
292304 return [
293− {tag: "unfolded top", positionViewAtBeginning: false,
305+ {tag: "unfolded top", positionViewAtBeginning: true,
294306 clickY: listView.topMargin + units.gu(2),
295307 expectFlick: false},
296308
297− {tag: "folded top", positionViewAtBeginning: true,
309+ {tag: "folded top", positionViewAtBeginning: false,
298310 clickY: listView.topMargin + units.gu(2),
299311 expectFlick: true},
300312
301− {tag: "unfolded bottom", positionViewAtBeginning: true,
313+ {tag: "unfolded bottom", positionViewAtBeginning: false,
302314 clickY: listView.height - listView.topMargin - units.gu(1),
303315 expectFlick: false},
304316
305− {tag: "folded bottom", positionViewAtBeginning: false,
317+ {tag: "folded bottom", positionViewAtBeginning: true,
306318 clickY: listView.height - listView.topMargin - units.gu(1),
307319 expectFlick: true},
308320 ];
309321 }
310322
311323 function test_clickFlick(data) {
324+ launcher.inverted = false;
312325 launcher.lastSelectedApplication = "";
313326 dragLauncherIntoView();
314327 var listView = findChild(launcher, "launcherListView");
@@ -318,9 +331,9 @@ Item {
318331 // So for stability's sake we just put the listView in the position
319332 // we want to to actually start doing what this tests intends to check.
320333 if (data.positionViewAtBeginning) {
321− listView.positionViewAtBeginning();
334+ positionLauncherListAtBeginning();
322335 } else {
323− listView.positionViewAtEnd();
336+ positionLauncherListAtEnd();
324337 }
325338 tryCompare(listView, "flicking", false);
326339
@@ -455,9 +468,9 @@ Item {
455468 // Position launcher to where we need it
456469 var listView = findChild(launcher, "launcherListView");
457470 if (data.flickTo == "top") {
458− listView.positionViewAtEnd();
471+ positionLauncherListAtBeginning();
459472 } else {
460− listView.positionViewAtBeginning();
473+ positionLauncherListAtEnd();
461474 }
462475
463476 // Doing longpress