on xenial help sign in
Make tst_Launcher stable
commit50d25ebfba25a07b666cf0fc744f43c306cf9eb6 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateFri 3 Oct 2014, 09:42 (12 years ago) parent84a0589
2 files changed+31−6
qml/Launcher/Launcher.qml+2−1 tests/qmltests/Launcher/tst_Launcher.qml+29−5
qml/Launcher/Launcher.qml+2−1
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2013-2014 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -76,6 +76,7 @@ Item {
7676
7777 Timer {
7878 id: dismissTimer
79+ objectName: "dismissTimer"
7980 interval: 5000
8081 onTriggered: {
8182 if (!panel.preventHiding) {
tests/qmltests/Launcher/tst_Launcher.qml+29−5
@@ -111,6 +111,11 @@ Item {
111111
112112 // Now do check that snapping is in fact enabled
113113 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
114119 }
115120
116121 function dragLauncherIntoView() {
@@ -255,10 +260,21 @@ Item {
255260 function test_clickFlick_data() {
256261 var listView = findChild(launcher, "launcherListView");
257262 return [
258− {tag: "unfolded top", flickSpeed: units.gu(200), clickY: listView.topMargin + units.gu(2), expectFlick: false},
259− {tag: "folded top", flickSpeed: -units.gu(200), clickY: listView.topMargin + units.gu(2), expectFlick: true},
260− {tag: "unfolded bottom", flickSpeed: -units.gu(200), clickY: listView.height - listView.topMargin - units.gu(1), expectFlick: false},
261− {tag: "folded bottom", flickSpeed: units.gu(200), clickY: listView.height - listView.topMargin - units.gu(1), expectFlick: true},
263+ {tag: "unfolded top", positionViewAtBeginning: false,
264+ clickY: listView.topMargin + units.gu(2),
265+ expectFlick: false},
266+
267+ {tag: "folded top", positionViewAtBeginning: true,
268+ clickY: listView.topMargin + units.gu(2),
269+ expectFlick: true},
270+
271+ {tag: "unfolded bottom", positionViewAtBeginning: true,
272+ clickY: listView.height - listView.topMargin - units.gu(1),
273+ expectFlick: false},
274+
275+ {tag: "folded bottom", positionViewAtBeginning: false,
276+ clickY: listView.height - listView.topMargin - units.gu(1),
277+ expectFlick: true},
262278 ];
263279 }
264280
@@ -267,7 +283,15 @@ Item {
267283 dragLauncherIntoView();
268284 var listView = findChild(launcher, "launcherListView");
269285
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+ }
271295 tryCompare(listView, "flicking", false);
272296
273297 var oldY = listView.contentY;