on xenial help sign in
fix launcher not reacting to first click in mouse mode, add tests
5ad2f3cMichael 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/LauncherTestCase.qmlnew file+26
@@ -0,0 +1,26 @@
1+import QtQuick 2.2
2+import Unity.Test 0.1
3+
4+UnityTestCase {
5+ id: root
6+ when: windowShown
7+
8+ property Item launcher: null
9+
10+ function waitUntilLauncherDisappears() {
11+ var panel = findChild(launcher, "launcherPanel");
12+ tryCompare(panel, "x", -panel.width, 1000);
13+ }
14+
15+ function positionLauncherListAtBeginning() {
16+ var listView = testCaseTouch.findChild(launcherLoader.item, "launcherListView");
17+ listView.contentY = -listView.topMargin;
18+ }
19+ function positionLauncherListAtEnd() {
20+ var listView = testCaseTouch.findChild(launcherLoader.item, "launcherListView");
21+ if ((listView.contentHeight + listView.topMargin + listView.bottomMargin) > listView.height) {
22+ listView.contentY = listView.topMargin + listView.contentHeight
23+ - listView.height;
24+ }
25+ }
26+}
tests/qmltests/Launcher/tst_Launcher.qml+74−23
@@ -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"
@@ -74,12 +74,17 @@ Item {
74 }
74 }
75 }
75 }
76 }
76 }
77+ property Item launcher: launcherLoader.status === Loader.Ready ? launcherLoader.item : null
77
78
78 ColumnLayout {
79 ColumnLayout {
79 anchors { bottom: parent.bottom; right: parent.right; margins: units.gu(1) }
80 anchors { bottom: parent.bottom; right: parent.right; margins: units.gu(1) }
80 spacing: units.gu(1)
81 spacing: units.gu(1)
81 width: units.gu(20)
82 width: units.gu(20)
82
83
84+ MouseTouchEmulationCheckbox {
85+ id: touchEmulationCheckBox
86+ }
87+
83 Button {
88 Button {
84 text: "emit hinting signal"
89 text: "emit hinting signal"
85 onClicked: LauncherModel.emitHint()
90 onClicked: LauncherModel.emitHint()
@@ -98,12 +103,11 @@ Item {
98 target: LauncherModel
103 target: LauncherModel
99 }
104 }
100
105
101− UT.UnityTestCase {
106+ LauncherTestCase {
102− id: testCase
107+ id: testCaseTouch
103− name: "Launcher"
108+ name: "LauncherTouch"
104− when: windowShown
109+ launcher: root.launcher
105
110
106− property Item launcher: launcherLoader.status === Loader.Ready ? launcherLoader.item : null
107 function cleanup() {
111 function cleanup() {
108 launcherLoader.active = false;
112 launcherLoader.active = false;
109 // Loader.status might be Loader.Null and Loader.item might be null but the Loader
113 // Loader.status might be Loader.Null and Loader.item might be null but the Loader
@@ -116,6 +120,8 @@ Item {
116 launcherLoader.active = true;
120 launcherLoader.active = true;
117 }
121 }
118 function init() {
122 function init() {
123+ touchEmulationCheckBox.checked = true;
124+
119 var listView = findChild(launcher, "launcherListView");
125 var listView = findChild(launcher, "launcherListView");
120 // wait for it to settle before doing the flick. Otherwise the flick
126 // wait for it to settle before doing the flick. Otherwise the flick
121 // might fail.
127 // might fail.
@@ -148,23 +154,6 @@ Item {
148 tryCompare(launcher, "state", "visible");
154 tryCompare(launcher, "state", "visible");
149 }
155 }
150
156
151− function waitUntilLauncherDisappears() {
152− var panel = findChild(launcher, "launcherPanel");
153− tryCompare(panel, "x", -panel.width, 1000);
154− }
155−
156− function positionLauncherListAtBeginning() {
157− var listView = testCase.findChild(launcherLoader.item, "launcherListView");
158− listView.contentY = -listView.topMargin;
159− }
160− function positionLauncherListAtEnd() {
161− var listView = testCase.findChild(launcherLoader.item, "launcherListView");
162− if ((listView.contentHeight + listView.topMargin + listView.bottomMargin) > listView.height) {
163− listView.contentY = listView.topMargin + listView.contentHeight
164− - listView.height;
165− }
166− }
167−
168 // Drag from the left edge of the screen rightwards and check that the launcher
157 // Drag from the left edge of the screen rightwards and check that the launcher
169 // appears (as if being dragged by the finger/pointer)
158 // appears (as if being dragged by the finger/pointer)
170 function test_dragLeftEdgeToRevealLauncherAndTapCenterToDismiss() {
159 function test_dragLeftEdgeToRevealLauncherAndTapCenterToDismiss() {
@@ -560,4 +549,66 @@ Item {
560 tryCompare(quickList, "state", "");
549 tryCompare(quickList, "state", "");
561 }
550 }
562 }
551 }
552+
553+ LauncherTestCase {
554+ id: testCaseMouse
555+ name: "LauncherMouse"
556+ launcher: root.launcher
557+
558+ function init() {
559+ touchEmulationCheckBox.checked = false;
560+ }
561+ function cleanup() {
562+ // Make sure we don't stop the test with the mouse hovering the launcher
563+ mouseMove(root, root.width, root.height / 2);
564+ waitUntilLauncherDisappears();
565+ }
566+
567+ function revealByHover() {
568+ mouseMove(root, 1, root.height / 2);
569+
570+ var panel = findChild(launcher, "launcherPanel");
571+ verify(panel != undefined);
572+
573+ // wait until it gets fully extended
574+ tryCompare(panel, "x", 0);
575+ tryCompare(launcher, "state", "visibleTemporary");
576+ }
577+
578+ function test_revealByHover() {
579+ var panel = findChild(launcher, "launcherPanel");
580+ verify(panel != undefined);
581+
582+ revealByHover();
583+ tryCompare(launcher, "state", "visibleTemporary");
584+
585+ // Now move the mouse away and make sure it hides in less than a second
586+ mouseMove(root, root.width, root.height / 2)
587+
588+ tryCompare(launcher, "state", "", 1000, "Launcher didn't hide after moving mouse away from it");
589+ waitUntilLauncherDisappears();
590+ }
591+
592+ function test_launchAppByMouseClick() {
593+ revealByHover();
594+
595+ launcher.lastSelectedApplication = "";
596+ launcher.inverted = false;
597+
598+ positionLauncherListAtBeginning();
599+
600+ var appIcon = findChild(launcher, "launcherDelegate0");
601+
602+ verify(appIcon != undefined);
603+
604+ mouseClick(appIcon);
605+
606+ tryCompare(launcher, "lastSelectedApplication",
607+ appIcon.appId);
608+
609+ // Clicking an icon should make it disappear
610+ tryCompare(launcher, "state", "", 1000, "Launcher didn't hide after moving mouse away from it");
611+ waitUntilLauncherDisappears();
612+ }
613+ }
563}
614}
tests/utils/modules/Unity/Test/MouseTouchEmulationCheckbox.qml+1
@@ -22,6 +22,7 @@ import Unity.Test 0.1
22RowLayout {
22RowLayout {
23 id: root
23 id: root
24 property alias color: label.color
24 property alias color: label.color
25+ property alias checked: checkbox.checked
25
26
26 Binding {
27 Binding {
27 target: MouseTouchAdaptor
28 target: MouseTouchAdaptor