on xenial help sign in
fix launcher not reacting to first click in mouse mode, add tests
commit5ad2f3c368b3499ca6c2998473e97097e5278317 authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 12 Mar 2015, 14:04 (12 years ago) parent9e6b4da
4 files changed+102−24
qml/Launcher/Launcher.qml+1−1 tests/qmltests/Launcher/LauncherTestCase.qml+26 tests/qmltests/Launcher/tst_Launcher.qml+74−23 tests/utils/modules/Unity/Test/MouseTouchEmulationCheckbox.qml+1
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/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 @@
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"
@@ -74,12 +74,17 @@ Item {
7474 }
7575 }
7676 }
77+ property Item launcher: launcherLoader.status === Loader.Ready ? launcherLoader.item : null
7778
7879 ColumnLayout {
7980 anchors { bottom: parent.bottom; right: parent.right; margins: units.gu(1) }
8081 spacing: units.gu(1)
8182 width: units.gu(20)
8283
84+ MouseTouchEmulationCheckbox {
85+ id: touchEmulationCheckBox
86+ }
87+
8388 Button {
8489 text: "emit hinting signal"
8590 onClicked: LauncherModel.emitHint()
@@ -98,12 +103,11 @@ Item {
98103 target: LauncherModel
99104 }
100105
101− UT.UnityTestCase {
102− id: testCase
103− name: "Launcher"
104− when: windowShown
106+ LauncherTestCase {
107+ id: testCaseTouch
108+ name: "LauncherTouch"
109+ launcher: root.launcher
105110
106− property Item launcher: launcherLoader.status === Loader.Ready ? launcherLoader.item : null
107111 function cleanup() {
108112 launcherLoader.active = false;
109113 // Loader.status might be Loader.Null and Loader.item might be null but the Loader
@@ -116,6 +120,8 @@ Item {
116120 launcherLoader.active = true;
117121 }
118122 function init() {
123+ touchEmulationCheckBox.checked = true;
124+
119125 var listView = findChild(launcher, "launcherListView");
120126 // wait for it to settle before doing the flick. Otherwise the flick
121127 // might fail.
@@ -148,23 +154,6 @@ Item {
148154 tryCompare(launcher, "state", "visible");
149155 }
150156
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−
168157 // Drag from the left edge of the screen rightwards and check that the launcher
169158 // appears (as if being dragged by the finger/pointer)
170159 function test_dragLeftEdgeToRevealLauncherAndTapCenterToDismiss() {
@@ -560,4 +549,66 @@ Item {
560549 tryCompare(quickList, "state", "");
561550 }
562551 }
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+ }
563614}
tests/utils/modules/Unity/Test/MouseTouchEmulationCheckbox.qml+1
@@ -22,6 +22,7 @@ import Unity.Test 0.1
2222RowLayout {
2323 id: root
2424 property alias color: label.color
25+ property alias checked: checkbox.checked
2526
2627 Binding {
2728 target: MouseTouchAdaptor