on xenial help sign in
merge two launcher test cases
f582661Michael Zanetti
tests/qmltests/Launcher/LauncherTestCase.qmldeleted−26
@@ -1,26 +0,0 @@
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+48−56
@@ -74,7 +74,6 @@ Item {
74 }
74 }
75 }
75 }
76 }
76 }
77− property Item launcher: launcherLoader.status === Loader.Ready ? launcherLoader.item : null
78
77
79 ColumnLayout {
78 ColumnLayout {
80 anchors { bottom: parent.bottom; right: parent.right; margins: units.gu(1) }
79 anchors { bottom: parent.bottom; right: parent.right; margins: units.gu(1) }
@@ -103,11 +102,12 @@ Item {
103 target: LauncherModel
102 target: LauncherModel
104 }
103 }
105
104
106− LauncherTestCase {
105+ UnityTestCase {
107− id: testCaseTouch
106+ id: testCase
108− name: "LauncherTouch"
107+ name: "Launcher"
109− launcher: root.launcher
108+ when: windowShown
110
109
110+ property Item launcher: launcherLoader.status === Loader.Ready ? launcherLoader.item : null
111 function cleanup() {
111 function cleanup() {
112 launcherLoader.active = false;
112 launcherLoader.active = false;
113 // 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
@@ -120,7 +120,8 @@ Item {
120 launcherLoader.active = true;
120 launcherLoader.active = true;
121 }
121 }
122 function init() {
122 function init() {
123− touchEmulationCheckBox.checked = true;
123+ // Make sure we don't start the test with the mouse hovering the launcher
124+ mouseMove(root, root.width, root.height / 2);
124
125
125 var listView = findChild(launcher, "launcherListView");
126 var listView = findChild(launcher, "launcherListView");
126 // wait for it to settle before doing the flick. Otherwise the flick
127 // wait for it to settle before doing the flick. Otherwise the flick
@@ -154,6 +155,34 @@ Item {
154 tryCompare(launcher, "state", "visible");
155 tryCompare(launcher, "state", "visible");
155 }
156 }
156
157
158+ function revealByHover() {
159+ mouseMove(root, 1, root.height / 2);
160+
161+ var panel = findChild(launcher, "launcherPanel");
162+ verify(panel != undefined);
163+
164+ // wait until it gets fully extended
165+ tryCompare(panel, "x", 0);
166+ tryCompare(launcher, "state", "visibleTemporary");
167+ }
168+
169+ function waitUntilLauncherDisappears() {
170+ var panel = findChild(launcher, "launcherPanel");
171+ tryCompare(panel, "x", -panel.width, 1000);
172+ }
173+
174+ function positionLauncherListAtBeginning() {
175+ var listView = testCase.findChild(launcherLoader.item, "launcherListView");
176+ listView.contentY = -listView.topMargin;
177+ }
178+ function positionLauncherListAtEnd() {
179+ var listView = testCase.findChild(launcherLoader.item, "launcherListView");
180+ if ((listView.contentHeight + listView.topMargin + listView.bottomMargin) > listView.height) {
181+ listView.contentY = listView.topMargin + listView.contentHeight
182+ - listView.height;
183+ }
184+ }
185+
157 // Drag from the left edge of the screen rightwards and check that the launcher
186 // Drag from the left edge of the screen rightwards and check that the launcher
158 // appears (as if being dragged by the finger/pointer)
187 // appears (as if being dragged by the finger/pointer)
159 function test_dragLeftEdgeToRevealLauncherAndTapCenterToDismiss() {
188 function test_dragLeftEdgeToRevealLauncherAndTapCenterToDismiss() {
@@ -178,8 +207,19 @@ Item {
178 Launcher::launcherApplicationSelected signal should be emitted with the
207 Launcher::launcherApplicationSelected signal should be emitted with the
179 corresponding desktop file. E.g. clicking on phone icon should yield
208 corresponding desktop file. E.g. clicking on phone icon should yield
180 launcherApplicationSelected("[...]dialer-app.desktop") */
209 launcherApplicationSelected("[...]dialer-app.desktop") */
210+ function test_clickingOnAppIconCausesSignalEmission_data() {
211+ return [
212+ {tag: "by mouse", mouse: true},
213+ {tag: "by touch", mouse: false}
214+ ]
215+ }
216+
181− function test_clickingOnAppIconCausesSignalEmission() {
217+ function test_clickingOnAppIconCausesSignalEmission(data) {
218+ if (data.mouse) {
219+ revealByHover();
220+ } else {
182− dragLauncherIntoView();
221+ dragLauncherIntoView();
222+ }
183 launcher.lastSelectedApplication = "";
223 launcher.lastSelectedApplication = "";
184 launcher.inverted = false;
224 launcher.inverted = false;
185
225
@@ -548,32 +588,6 @@ Item {
548
588
549 tryCompare(quickList, "state", "");
589 tryCompare(quickList, "state", "");
550 }
590 }
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
591
578 function test_revealByHover() {
592 function test_revealByHover() {
579 var panel = findChild(launcher, "launcherPanel");
593 var panel = findChild(launcher, "launcherPanel");
@@ -588,27 +602,5 @@ Item {
588 tryCompare(launcher, "state", "", 1000, "Launcher didn't hide after moving mouse away from it");
602 tryCompare(launcher, "state", "", 1000, "Launcher didn't hide after moving mouse away from it");
589 waitUntilLauncherDisappears();
603 waitUntilLauncherDisappears();
590 }
604 }
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 }
605 }
614}
606}