on xenial help sign in
merge two launcher test cases
commitf582661a73361532b307250b4c683b55acbdb711 authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 12 Mar 2015, 15:31 (12 years ago) parent5ad2f3c
2 files changed+48−82
tests/qmltests/Launcher/LauncherTestCase.qml−26 tests/qmltests/Launcher/tst_Launcher.qml+48−56
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 {
7474 }
7575 }
7676 }
77− property Item launcher: launcherLoader.status === Loader.Ready ? launcherLoader.item : null
7877
7978 ColumnLayout {
8079 anchors { bottom: parent.bottom; right: parent.right; margins: units.gu(1) }
@@ -103,11 +102,12 @@ Item {
103102 target: LauncherModel
104103 }
105104
106− LauncherTestCase {
107− id: testCaseTouch
108− name: "LauncherTouch"
109− launcher: root.launcher
105+ UnityTestCase {
106+ id: testCase
107+ name: "Launcher"
108+ when: windowShown
110109
110+ property Item launcher: launcherLoader.status === Loader.Ready ? launcherLoader.item : null
111111 function cleanup() {
112112 launcherLoader.active = false;
113113 // Loader.status might be Loader.Null and Loader.item might be null but the Loader
@@ -120,7 +120,8 @@ Item {
120120 launcherLoader.active = true;
121121 }
122122 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);
124125
125126 var listView = findChild(launcher, "launcherListView");
126127 // wait for it to settle before doing the flick. Otherwise the flick
@@ -154,6 +155,34 @@ Item {
154155 tryCompare(launcher, "state", "visible");
155156 }
156157
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+
157186 // Drag from the left edge of the screen rightwards and check that the launcher
158187 // appears (as if being dragged by the finger/pointer)
159188 function test_dragLeftEdgeToRevealLauncherAndTapCenterToDismiss() {
@@ -178,8 +207,19 @@ Item {
178207 Launcher::launcherApplicationSelected signal should be emitted with the
179208 corresponding desktop file. E.g. clicking on phone icon should yield
180209 launcherApplicationSelected("[...]dialer-app.desktop") */
181− function test_clickingOnAppIconCausesSignalEmission() {
182− dragLauncherIntoView();
210+ function test_clickingOnAppIconCausesSignalEmission_data() {
211+ return [
212+ {tag: "by mouse", mouse: true},
213+ {tag: "by touch", mouse: false}
214+ ]
215+ }
216+
217+ function test_clickingOnAppIconCausesSignalEmission(data) {
218+ if (data.mouse) {
219+ revealByHover();
220+ } else {
221+ dragLauncherIntoView();
222+ }
183223 launcher.lastSelectedApplication = "";
184224 launcher.inverted = false;
185225
@@ -548,32 +588,6 @@ Item {
548588
549589 tryCompare(quickList, "state", "");
550590 }
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− }
577591
578592 function test_revealByHover() {
579593 var panel = findChild(launcher, "launcherPanel");
@@ -588,27 +602,5 @@ Item {
588602 tryCompare(launcher, "state", "", 1000, "Launcher didn't hide after moving mouse away from it");
589603 waitUntilLauncherDisappears();
590604 }
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− }
613605 }
614606}