on xenial help sign in
fix launcher not reacting to first click when revealed by mouse hover, add tests

Approved by: Daniel d'Andrada

commit9a6aaeb71e2adae3b69bb4eafbc4429b48c26a4d authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 18 Mar 2015, 10:16 (12 years ago) parente1cc92810212b0
2 files changed+52−7
qml/Launcher/Launcher.qml+1−1 tests/qmltests/Launcher/tst_Launcher.qml+51−6
qml/Launcher/Launcher.qml+1−1
@@ -203,7 +203,7 @@ Item {
203203 LauncherPanel {
204204 id: panel
205205 objectName: "launcherPanel"
206− enabled: root.available && root.state == "visible"
206+ enabled: root.available && root.state == "visible" || root.state == "visibleTemporary"
207207 width: root.panelWidth
208208 anchors {
209209 top: parent.top
tests/qmltests/Launcher/tst_Launcher.qml+51−6
@@ -17,7 +17,7 @@
1717import QtQuick 2.0
1818import QtQuick.Layouts 1.1
1919import QtTest 1.0
20−import Unity.Test 0.1 as UT
20+import Unity.Test 0.1
2121import Ubuntu.Components 1.1
2222import ".."
2323import "../../../qml/Launcher"
@@ -78,7 +78,9 @@ Item {
7878 ColumnLayout {
7979 anchors { bottom: parent.bottom; right: parent.right; margins: units.gu(1) }
8080 spacing: units.gu(1)
81− width: units.gu(20)
81+ width: childrenRect.width
82+
83+ MouseTouchEmulationCheckbox {}
8284
8385 Button {
8486 text: "emit hinting signal"
@@ -98,7 +100,7 @@ Item {
98100 target: LauncherModel
99101 }
100102
101− UT.UnityTestCase {
103+ UnityTestCase {
102104 id: testCase
103105 name: "Launcher"
104106 when: windowShown
@@ -116,6 +118,9 @@ Item {
116118 launcherLoader.active = true;
117119 }
118120 function init() {
121+ // Make sure we don't start the test with the mouse hovering the launcher
122+ mouseMove(root, root.width, root.height / 2);
123+
119124 var listView = findChild(launcher, "launcherListView");
120125 // wait for it to settle before doing the flick. Otherwise the flick
121126 // might fail.
@@ -148,6 +153,17 @@ Item {
148153 tryCompare(launcher, "state", "visible");
149154 }
150155
156+ function revealByHover() {
157+ mouseMove(root, 1, root.height / 2);
158+
159+ var panel = findChild(launcher, "launcherPanel");
160+ verify(panel != undefined);
161+
162+ // wait until it gets fully extended
163+ tryCompare(panel, "x", 0);
164+ tryCompare(launcher, "state", "visibleTemporary");
165+ }
166+
151167 function waitUntilLauncherDisappears() {
152168 var panel = findChild(launcher, "launcherPanel");
153169 tryCompare(panel, "x", -panel.width, 1000);
@@ -189,8 +205,19 @@ Item {
189205 Launcher::launcherApplicationSelected signal should be emitted with the
190206 corresponding desktop file. E.g. clicking on phone icon should yield
191207 launcherApplicationSelected("[...]dialer-app.desktop") */
192− function test_clickingOnAppIconCausesSignalEmission() {
193− dragLauncherIntoView();
208+ function test_clickingOnAppIconCausesSignalEmission_data() {
209+ return [
210+ {tag: "by mouse", mouse: true},
211+ {tag: "by touch", mouse: false}
212+ ]
213+ }
214+
215+ function test_clickingOnAppIconCausesSignalEmission(data) {
216+ if (data.mouse) {
217+ revealByHover();
218+ } else {
219+ dragLauncherIntoView();
220+ }
194221 launcher.lastSelectedApplication = "";
195222 launcher.inverted = false;
196223
@@ -200,7 +227,11 @@ Item {
200227
201228 verify(appIcon != undefined);
202229
203− mouseClick(appIcon);
230+ if (data.mouse) {
231+ mouseClick(appIcon);
232+ } else {
233+ tap(appIcon);
234+ }
204235
205236 tryCompare(launcher, "lastSelectedApplication",
206237 appIcon.appId);
@@ -559,5 +590,19 @@ Item {
559590
560591 tryCompare(quickList, "state", "");
561592 }
593+
594+ function test_revealByHover() {
595+ var panel = findChild(launcher, "launcherPanel");
596+ verify(panel != undefined);
597+
598+ revealByHover();
599+ tryCompare(launcher, "state", "visibleTemporary");
600+
601+ // Now move the mouse away and make sure it hides in less than a second
602+ mouseMove(root, root.width, root.height / 2)
603+
604+ tryCompare(launcher, "state", "", 1000, "Launcher didn't hide after moving mouse away from it");
605+ waitUntilLauncherDisappears();
606+ }
562607 }
563608}