@@ -0,0 +1,135 @@
1+/*
2+ * Copyright 2015 Canonical Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.4
18+import QtTest 1.0
19+import "../../../qml/Dash"
20+import "../../../qml/"
21+import Ubuntu.Components 1.3
22+import Unity.Test 0.1 as UT
23+
24+Item {
25+ id: root
26+ width: units.gu(80)
27+ height: units.gu(80)
28+
29+ Shell {
30+ id: shell
31+ width: parent.width / 2
32+ height: parent.height
33+ }
34+
35+ Dash {
36+ id: dash
37+ width: parent.width / 2
38+ height: parent.height
39+ x: width
40+ clip: true
41+ }
42+
43+ UT.UnityTestCase {
44+ name: "DashShell"
45+ when: windowShown
46+
47+ readonly property Item dashContent: findChild(dash, "dashContent");
48+ readonly property var scopes: dashContent.scopes
49+
50+ function init() {
51+ dash.windowActive = true;
52+
53+ var greeter = findChild(shell, "greeter");
54+ greeter.forceShow();
55+
56+ // clear and reload the scopes.
57+ scopes.clear();
58+ var dashContentList = findChild(dash, "dashContentList");
59+ verify(dashContentList != undefined);
60+ tryCompare(dashContentList, "count", 0);
61+ scopes.load();
62+ tryCompare(dashContentList, "currentIndex", 0);
63+ tryCompare(dashContentList, "count", 6);
64+ tryCompare(scopes, "loaded", true);
65+ tryCompareFunction(function() {
66+ var mockScope1Loader = findChild(dash, "scopeLoader0");
67+ return mockScope1Loader && mockScope1Loader.item != null; },
68+ true, 15000);
69+ tryCompareFunction(function() {
70+ var mockScope1Loader = findChild(dash, "scopeLoader0");
71+ return mockScope1Loader && mockScope1Loader.status === Loader.Ready; },
72+ true, 15000);
73+ waitForRendering(findChild(dash, "scopeLoader0").item);
74+ }
75+
76+ function test_setShellHome() {
77+ var dashContentList = findChild(dash, "dashContentList");
78+ var startX = dash.width - units.gu(1);
79+ var startY = dash.height / 2;
80+ var stopX = units.gu(1)
81+ var stopY = startY;
82+ waitForRendering(dashContentList);
83+ touchFlick(dash, startX, startY, stopX, stopY);
84+ touchFlick(dash, startX, startY, stopX, stopY);
85+ compare(dashContentList.currentIndex, 2, "Could not flick to scope id 2");
86+
87+ // Flick the greeter away
88+ var startX = shell.width - units.gu(1);
89+ var startY = shell.height / 2;
90+ var stopX = units.gu(1)
91+ var stopY = startY;
92+ touchFlick(shell, startX, startY, stopX, stopY);
93+
94+ // Now do a long launcher movement
95+ touchFlick(shell, stopX, startY, startX, stopY);
96+
97+ var launcher = findChild(shell, "launcher");
98+ var buttonShowDashHome = findChild(launcher, "buttonShowDashHome");
99+ tryCompare(buttonShowDashHome, "enabled", true);
100+ tryCompare(launcher, "visibleWidth", launcher.panelWidth);
101+
102+ // Make sure that opening the launcher doesn't change the scope
103+ compare(dashContentList.currentIndex, 2, "Opening the launcher changed the current scope");
104+
105+ mouseClick(buttonShowDashHome);
106+ tryCompare(dashContentList, "currentIndex", 0);
107+ }
108+
109+ function test_setShortLauncherMoveResetNonActiveDash() {
110+ var dashContentList = findChild(dash, "dashContentList");
111+ var startX = dash.width - units.gu(1);
112+ var startY = dash.height / 2;
113+ var stopX = units.gu(1)
114+ var stopY = startY;
115+ waitForRendering(dashContentList);
116+ touchFlick(dash, startX, startY, stopX, stopY);
117+ touchFlick(dash, startX, startY, stopX, stopY);
118+ compare(dashContentList.currentIndex, 2, "Could not flick to scope id 2");
119+
120+ // Pretend the dash is not active
121+ dash.windowActive = false;
122+
123+ // Flick the greeter away
124+ var startX = shell.width - units.gu(1);
125+ var startY = shell.height / 2;
126+ var stopX = units.gu(1)
127+ var stopY = startY;
128+ touchFlick(shell, startX, startY, stopX, stopY);
129+
130+ // Now do a small launcher movement
131+ touchFlick(shell, stopX, startY, startX, stopY);
132+ compare(dashContentList.currentIndex, 0, "Small launcher move did not reset dash on non active window");
133+ }
134+ }
135+}