on xenial help sign in
Make revealByEdgePush more stable

We make the dismissTimer bigger temporarily to make sure it does not interfere Also added a new test that actually checks the dismissTimer is ignored by the mouse being over the launcher Approved by: Unity8 CI Bot, Daniel d'Andrada

commit293f8c1b2403f21791e24456f825a870dc30c527 authorAlbert Astals Cid <albert.astals@canonical.com> dateFri 29 Jan 2016, 11:51 (11 years ago) parentd0613808d07e0d
4 files changed+80−28
qml/Launcher/Launcher.qml+18−19 tests/qmltests/Launcher/tst_Launcher.qml+24 tests/qmltests/tst_Shell.qml+19−4 tests/qmltests/tst_ShellWithPin.qml+19−5
qml/Launcher/Launcher.qml+18−19
@@ -51,9 +51,9 @@ Item {
5151
5252 onStateChanged: {
5353 if (state == "") {
54− dismissTimer.stop()
54+ panel.dismissTimer.stop()
5555 } else {
56− dismissTimer.restart()
56+ panel.dismissTimer.restart()
5757 }
5858 }
5959
@@ -96,21 +96,6 @@ Item {
9696 property string mode: "teasing"
9797 }
9898
99− Timer {
100− id: dismissTimer
101− objectName: "dismissTimer"
102− interval: 500
103− onTriggered: {
104− if (root.autohideEnabled) {
105− if (!panel.preventHiding) {
106− root.state = ""
107− } else {
108− dismissTimer.restart()
109− }
110− }
111− }
112− }
113−
11499 // Because the animation on x is disabled while dragging
115100 // switching state directly in the drag handlers would not animate
116101 // the completion of the hide/reveal gesture. Lets update the state
@@ -238,6 +223,20 @@ Item {
238223 visible: root.x > 0 || x > -width || dragArea.pressed
239224 model: LauncherModel
240225
226+ property var dismissTimer: Timer { interval: 500 }
227+ Connections {
228+ target: panel.dismissTimer
229+ onTriggered: {
230+ if (root.autohideEnabled) {
231+ if (!panel.preventHiding) {
232+ root.state = ""
233+ } else {
234+ panel.dismissTimer.restart()
235+ }
236+ }
237+ }
238+ }
239+
241240 property bool animate: true
242241
243242 onApplicationSelected: {
@@ -250,8 +249,8 @@ Item {
250249 }
251250
252251 onPreventHidingChanged: {
253− if (dismissTimer.running) {
254− dismissTimer.restart();
252+ if (panel.dismissTimer.running) {
253+ panel.dismissTimer.restart();
255254 }
256255 }
257256
tests/qmltests/Launcher/tst_Launcher.qml+24
@@ -159,6 +159,20 @@ Item {
159159 target: LauncherModel
160160 }
161161
162+ Item {
163+ id: fakeDismissTimer
164+ property bool running: false
165+ signal triggered
166+
167+ function stop() {
168+ running = false;
169+ }
170+
171+ function restart() {
172+ running = true;
173+ }
174+ }
175+
162176 UnityTestCase {
163177 id: testCase
164178 name: "Launcher"
@@ -177,6 +191,11 @@ Item {
177191 launcherLoader.active = true;
178192 }
179193 function init() {
194+ var panel = findChild(launcher, "launcherPanel");
195+ verify(!!panel);
196+
197+ panel.dismissTimer = fakeDismissTimer;
198+
180199 // Make sure we don't start the test with the mouse hovering the launcher
181200 mouseMove(root, root.width, root.height / 2);
182201
@@ -897,6 +916,11 @@ Item {
897916 // Now move the mouse away and make sure it hides in less than a second
898917 mouseMove(root, root.width, root.height / 2)
899918
919+ // trigger the hide timer
920+ compare(fakeDismissTimer.running, true);
921+ fakeDismissTimer.triggered();
922+ tryCompare(panel, "x", 0);
923+
900924 tryCompare(launcher, "state", "", 1000, "Launcher didn't hide after moving mouse away from it");
901925 waitUntilLauncherDisappears();
902926 }
tests/qmltests/tst_Shell.qml+19−4
@@ -296,6 +296,20 @@ Rectangle {
296296 phoneNumber: "+447812221111"
297297 }
298298
299+ Item {
300+ id: fakeDismissTimer
301+ property bool running: false
302+ signal triggered
303+
304+ function stop() {
305+ running = false;
306+ }
307+
308+ function restart() {
309+ running = true;
310+ }
311+ }
312+
299313 UnityTestCase {
300314 id: testCase
301315 name: "Shell"
@@ -333,6 +347,11 @@ Rectangle {
333347 var launcher = findChild(shell, "launcher");
334348 launcherShowDashHomeSpy.target = launcher;
335349
350+ var panel = findChild(launcher, "launcherPanel");
351+ verify(!!panel);
352+
353+ panel.dismissTimer = fakeDismissTimer;
354+
336355 waitForGreeterToStabilize();
337356 }
338357
@@ -1240,10 +1259,6 @@ Rectangle {
12401259
12411260 var launcher = findChild(shell, "launcher");
12421261
1243− // ensure the launcher dimissal timer never gets triggered during the test run
1244− var dismissTimer = findInvisibleChild(launcher, "dismissTimer");
1245− dismissTimer.interval = 60 * 60 * 1000;
1246−
12471262 dragLauncherIntoView();
12481263
12491264 // Emulate a tap with a finger, where the touch position drifts during the tap.
tests/qmltests/tst_ShellWithPin.qml+19−5
@@ -128,6 +128,20 @@ Item {
128128 phoneNumber: "+447812221111"
129129 }
130130
131+ Item {
132+ id: fakeDismissTimer
133+ property bool running: false
134+ signal triggered
135+
136+ function stop() {
137+ running = false;
138+ }
139+
140+ function restart() {
141+ running = true;
142+ }
143+ }
144+
131145 UT.UnityTestCase {
132146 id: testCase
133147 name: "ShellWithPin"
@@ -143,6 +157,11 @@ Item {
143157 waitForLockscreen()
144158 greeter.failedLoginsDelayAttempts = -1;
145159 greeter.maxFailedLogins = -1;
160+
161+ var launcher = findChild(shell, "launcher");
162+ var panel = findChild(launcher, "launcherPanel");
163+ verify(!!panel);
164+ panel.dismissTimer = fakeDismissTimer;
146165 }
147166
148167 function cleanup() {
@@ -565,11 +584,6 @@ Item {
565584 tryCompare(coverPage, "showProgress", 1);
566585
567586 var launcher = testCase.findChild(shell, "launcher")
568− {
569− var dismissTimer = testCase.findInvisibleChild(launcher, "dismissTimer");
570− // effectively disable the dismiss timer
571− dismissTimer.interval = 24 * 60 * 60 * 1000 // 24 hours
572− }
573587 var launcherPanel = testCase.findChild(launcher, "launcherPanel");
574588
575589 var toX = shell.width * 0.45;