on xenial help sign in
fix launcher not reacting to first click when revealed by mouse hover, add tests
9a6aaebMichael Zanetti
qml/Launcher/Launcher.qml+1−1
@@ -203,7 +203,7 @@ Item {
203 LauncherPanel {
203 LauncherPanel {
204 id: panel
204 id: panel
205 objectName: "launcherPanel"
205 objectName: "launcherPanel"
206− enabled: root.available && root.state == "visible"
206+ enabled: root.available && root.state == "visible" || root.state == "visibleTemporary"
207 width: root.panelWidth
207 width: root.panelWidth
208 anchors {
208 anchors {
209 top: parent.top
209 top: parent.top
tests/qmltests/Launcher/tst_Launcher.qml+51−6
@@ -17,7 +17,7 @@
17import QtQuick 2.0
17import QtQuick 2.0
18import QtQuick.Layouts 1.1
18import QtQuick.Layouts 1.1
19import QtTest 1.0
19import QtTest 1.0
20−import Unity.Test 0.1 as UT
20+import Unity.Test 0.1
21import Ubuntu.Components 1.1
21import Ubuntu.Components 1.1
22import ".."
22import ".."
23import "../../../qml/Launcher"
23import "../../../qml/Launcher"
@@ -78,7 +78,9 @@ Item {
78 ColumnLayout {
78 ColumnLayout {
79 anchors { bottom: parent.bottom; right: parent.right; margins: units.gu(1) }
79 anchors { bottom: parent.bottom; right: parent.right; margins: units.gu(1) }
80 spacing: units.gu(1)
80 spacing: units.gu(1)
81− width: units.gu(20)
81+ width: childrenRect.width
82+
83+ MouseTouchEmulationCheckbox {}
82
84
83 Button {
85 Button {
84 text: "emit hinting signal"
86 text: "emit hinting signal"
@@ -98,7 +100,7 @@ Item {
98 target: LauncherModel
100 target: LauncherModel
99 }
101 }
100
102
101− UT.UnityTestCase {
103+ UnityTestCase {
102 id: testCase
104 id: testCase
103 name: "Launcher"
105 name: "Launcher"
104 when: windowShown
106 when: windowShown
@@ -116,6 +118,9 @@ Item {
116 launcherLoader.active = true;
118 launcherLoader.active = true;
117 }
119 }
118 function init() {
120 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+
119 var listView = findChild(launcher, "launcherListView");
124 var listView = findChild(launcher, "launcherListView");
120 // wait for it to settle before doing the flick. Otherwise the flick
125 // wait for it to settle before doing the flick. Otherwise the flick
121 // might fail.
126 // might fail.
@@ -148,6 +153,17 @@ Item {
148 tryCompare(launcher, "state", "visible");
153 tryCompare(launcher, "state", "visible");
149 }
154 }
150
155
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+
151 function waitUntilLauncherDisappears() {
167 function waitUntilLauncherDisappears() {
152 var panel = findChild(launcher, "launcherPanel");
168 var panel = findChild(launcher, "launcherPanel");
153 tryCompare(panel, "x", -panel.width, 1000);
169 tryCompare(panel, "x", -panel.width, 1000);
@@ -189,8 +205,19 @@ Item {
189 Launcher::launcherApplicationSelected signal should be emitted with the
205 Launcher::launcherApplicationSelected signal should be emitted with the
190 corresponding desktop file. E.g. clicking on phone icon should yield
206 corresponding desktop file. E.g. clicking on phone icon should yield
191 launcherApplicationSelected("[...]dialer-app.desktop") */
207 launcherApplicationSelected("[...]dialer-app.desktop") */
208+ function test_clickingOnAppIconCausesSignalEmission_data() {
209+ return [
210+ {tag: "by mouse", mouse: true},
211+ {tag: "by touch", mouse: false}
212+ ]
213+ }
214+
192− function test_clickingOnAppIconCausesSignalEmission() {
215+ function test_clickingOnAppIconCausesSignalEmission(data) {
216+ if (data.mouse) {
217+ revealByHover();
218+ } else {
193− dragLauncherIntoView();
219+ dragLauncherIntoView();
220+ }
194 launcher.lastSelectedApplication = "";
221 launcher.lastSelectedApplication = "";
195 launcher.inverted = false;
222 launcher.inverted = false;
196
223
@@ -200,7 +227,11 @@ Item {
200
227
201 verify(appIcon != undefined);
228 verify(appIcon != undefined);
202
229
230+ if (data.mouse) {
203− mouseClick(appIcon);
231+ mouseClick(appIcon);
232+ } else {
233+ tap(appIcon);
234+ }
204
235
205 tryCompare(launcher, "lastSelectedApplication",
236 tryCompare(launcher, "lastSelectedApplication",
206 appIcon.appId);
237 appIcon.appId);
@@ -559,5 +590,19 @@ Item {
559
590
560 tryCompare(quickList, "state", "");
591 tryCompare(quickList, "state", "");
561 }
592 }
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+ }
562 }
607 }
563}
608}