on xenial help sign in
Make tst_Launcher stable
50d25ebDaniel d'Andrada
qml/Launcher/Launcher.qml+2−1
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2013-2014 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -76,6 +76,7 @@ Item {
76
76
77 Timer {
77 Timer {
78 id: dismissTimer
78 id: dismissTimer
79+ objectName: "dismissTimer"
79 interval: 5000
80 interval: 5000
80 onTriggered: {
81 onTriggered: {
81 if (!panel.preventHiding) {
82 if (!panel.preventHiding) {
tests/qmltests/Launcher/tst_Launcher.qml+29−5
@@ -111,6 +111,11 @@ Item {
111
111
112 // Now do check that snapping is in fact enabled
112 // Now do check that snapping is in fact enabled
113 compare(listView.snapMode, ListView.SnapToItem, "Snapping is not enabled");
113 compare(listView.snapMode, ListView.SnapToItem, "Snapping is not enabled");
114+
115+ // Tests can be run in a reaaaaally slow environment or machine. Thus ensure
116+ // the dismissTimer doesn't time out inadvertently.
117+ var dismissTimer = findInvisibleChild(launcher, "dismissTimer");
118+ dismissTimer.interval = 60 * 60 * 1000; // one hour
114 }
119 }
115
120
116 function dragLauncherIntoView() {
121 function dragLauncherIntoView() {
@@ -255,10 +260,21 @@ Item {
255 function test_clickFlick_data() {
260 function test_clickFlick_data() {
256 var listView = findChild(launcher, "launcherListView");
261 var listView = findChild(launcher, "launcherListView");
257 return [
262 return [
263+ {tag: "unfolded top", positionViewAtBeginning: false,
258− {tag: "unfolded top", flickSpeed: units.gu(200), clickY: listView.topMargin + units.gu(2), expectFlick: false},
264+ clickY: listView.topMargin + units.gu(2),
265+ expectFlick: false},
266+
267+ {tag: "folded top", positionViewAtBeginning: true,
259− {tag: "folded top", flickSpeed: -units.gu(200), clickY: listView.topMargin + units.gu(2), expectFlick: true},
268+ clickY: listView.topMargin + units.gu(2),
269+ expectFlick: true},
270+
271+ {tag: "unfolded bottom", positionViewAtBeginning: true,
260− {tag: "unfolded bottom", flickSpeed: -units.gu(200), clickY: listView.height - listView.topMargin - units.gu(1), expectFlick: false},
272+ clickY: listView.height - listView.topMargin - units.gu(1),
273+ expectFlick: false},
274+
275+ {tag: "folded bottom", positionViewAtBeginning: false,
261− {tag: "folded bottom", flickSpeed: units.gu(200), clickY: listView.height - listView.topMargin - units.gu(1), expectFlick: true},
276+ clickY: listView.height - listView.topMargin - units.gu(1),
277+ expectFlick: true},
262 ];
278 ];
263 }
279 }
264
280
@@ -267,7 +283,15 @@ Item {
267 dragLauncherIntoView();
283 dragLauncherIntoView();
268 var listView = findChild(launcher, "launcherListView");
284 var listView = findChild(launcher, "launcherListView");
269
285
270− listView.flick(0, data.flickSpeed);
286+ // flicking is unreliable. sometimes it works, sometimes the
287+ // list view moves just a tiny bit or not at all, making tests fail.
288+ // So for stability's sake we just put the listView in the position
289+ // we want to to actually start doing what this tests intends to check.
290+ if (data.positionViewAtBeginning) {
291+ listView.positionViewAtBeginning();
292+ } else {
293+ listView.positionViewAtEnd();
294+ }
271 tryCompare(listView, "flicking", false);
295 tryCompare(listView, "flicking", false);
272
296
273 var oldY = listView.contentY;
297 var oldY = listView.contentY;