@@ -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}