on xenial help sign in
Add DashShell to test Dash+Shell stuff
commit64d0b88a7ee26e2b0bed454ebefa4a67496f2dbb authorAlbert Astals Cid <albert.astals@canonical.com> dateMon 20 Jul 2015, 16:49 (11 years ago) parenta8c7b24
3 files changed+127−28
tests/qmltests/CMakeLists.txt+1 tests/qmltests/Dash/tst_Dash.qml−28 tests/qmltests/Dash/tst_DashShell.qml+126
tests/qmltests/CMakeLists.txt+1
@@ -18,6 +18,7 @@ add_unity8_qmltest(Components Showable)
1818add_unity8_qmltest(Components ZoomableImage)
1919add_unity8_qmltest(Dash Dash)
2020add_unity8_qmltest(Dash DashContent)
21+add_unity8_qmltest(Dash DashShell)
2122add_unity8_qmltest(Dash Card)
2223add_unity8_qmlbenchmark(Dash CardBenchmark 1000)
2324add_unity8_qmltest(Dash CardTool)
tests/qmltests/Dash/tst_Dash.qml−28
@@ -34,23 +34,11 @@ Item {
3434 property var panel: null
3535 // BEGIN To reduce warnings
3636
37−
3837 Dash {
3938 id: dash
4039 anchors.fill: parent
4140 }
4241
43− Window {
44− id: window
45− width: units.gu(40)
46− height: units.gu(80)
47− Shell {
48− id: shell
49− anchors.fill: parent
50− }
51− Component.onCompleted: window.show();
52− }
53−
5442 SignalSpy {
5543 id: spy
5644 }
@@ -278,22 +266,6 @@ Item {
278266 tryCompare(dashContentList, "currentIndex", 1)
279267 }
280268
281− function test_setShellHome() {
282− var dashContentList = findChild(dash, "dashContentList");
283− var startX = dash.width - units.gu(1);
284− var startY = dash.height / 2;
285− var stopX = units.gu(1)
286− var stopY = startY;
287− waitForRendering(dashContentList);
288− mouseFlick(dash, startX, startY, stopX, stopY);
289− mouseFlick(dash, startX, startY, stopX, stopY);
290− compare(dashContentList.currentIndex, 2, "Could not flick to scope id 2");
291−
292− var launcher = findChild(shell, "launcher");
293− launcher.showDashHome();
294− tryCompare(dashContentList, "currentIndex", 0);
295− }
296−
297269 function test_setCurrentScopeClosesPreview() {
298270 var dashContent = findChild(dash, "dashContent");
299271 waitForRendering(dash)
tests/qmltests/Dash/tst_DashShell.qmlnew file+126
@@ -0,0 +1,126 @@
1+/*
2+ * Copyright 2013 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.0
18+import QtQuick.Window 2.0
19+import QtTest 1.0
20+import "../../../qml/Dash"
21+import "../../../qml/"
22+import Ubuntu.Components 0.1
23+import Unity.Test 0.1 as UT
24+
25+Item {
26+ id: root
27+ width: units.gu(80)
28+ height: units.gu(80)
29+
30+ // BEGIN To reduce warnings
31+ // TODO I think it we should pass down these variables
32+ // as needed instead of hoping they will be globally around
33+ property var greeter: null
34+ property var panel: null
35+ // BEGIN To reduce warnings
36+
37+
38+ Shell {
39+ id: shell
40+ height: root.height
41+ width: root.width / 2
42+ }
43+
44+ Dash {
45+ id: dash
46+ height: root.height
47+ width: root.width / 2
48+ x: root.width / 2
49+ clip: true
50+ }
51+
52+ SignalSpy {
53+ id: spy
54+ }
55+
56+ UT.UnityTestCase {
57+ name: "DashShell"
58+ when: windowShown
59+
60+ readonly property Item dashContent: findChild(dash, "dashContent");
61+ readonly property var scopes: dashContent.scopes
62+
63+ function init() {
64+ // clear and reload the scopes.
65+ scopes.clear();
66+ var dashContentList = findChild(dash, "dashContentList");
67+ verify(dashContentList != undefined);
68+ tryCompare(dashContentList, "count", 0);
69+ scopes.load();
70+ tryCompare(dashContentList, "currentIndex", 0);
71+ tryCompare(dashContentList, "count", 6);
72+ tryCompare(scopes, "loaded", true);
73+ tryCompareFunction(function() {
74+ var mockScope1Loader = findChild(dash, "scopeLoader0");
75+ return mockScope1Loader && mockScope1Loader.item != null; },
76+ true, 15000);
77+ tryCompareFunction(function() {
78+ var mockScope1Loader = findChild(dash, "scopeLoader0");
79+ return mockScope1Loader && mockScope1Loader.status === Loader.Ready; },
80+ true, 15000);
81+ waitForRendering(findChild(dash, "scopeLoader0").item);
82+ }
83+
84+ function test_setShellHome() {
85+ var dashContentList = findChild(dash, "dashContentList");
86+ var startX = dash.width - units.gu(1);
87+ var startY = dash.height / 2;
88+ var stopX = units.gu(1)
89+ var stopY = startY;
90+ waitForRendering(dashContentList);
91+ mouseFlick(dash, startX, startY, stopX, stopY);
92+ mouseFlick(dash, startX, startY, stopX, stopY);
93+ compare(dashContentList.currentIndex, 2, "Could not flick to scope id 2");
94+
95+ var launcher = findChild(shell, "launcher");
96+ launcher.switchToNextState("visible")
97+ var buttonShowDashHome = findChild(launcher, "buttonShowDashHome");
98+ tryCompare(buttonShowDashHome, "enabled", true);
99+ mouseClick(buttonShowDashHome);
100+ tryCompare(dashContentList, "currentIndex", 0);
101+ }
102+
103+ function test_setLongSwipeOnDashNoChangeScope() {
104+ var dashContentList = findChild(dash, "dashContentList");
105+ var startX = dash.width - units.gu(1);
106+ var startY = dash.height / 2;
107+ var stopX = units.gu(1)
108+ var stopY = startY;
109+ waitForRendering(dashContentList);
110+ mouseFlick(dash, startX, startY, stopX, stopY);
111+ mouseFlick(dash, startX, startY, stopX, stopY);
112+ compare(dashContentList.currentIndex, 2, "Could not flick to scope id 2");
113+
114+ var startX = shell.width - units.gu(1);
115+ var startY = shell.height / 2;
116+ var stopX = units.gu(1)
117+ var stopY = startY;
118+ touchFlick(shell, startX, startY, stopX, stopY);
119+
120+ // Now do a long launcher movement
121+
122+ touchFlick(shell, stopX, startY, startX, stopY);
123+ compare(dashContentList.currentIndex, 2, "Opening the launcher changed the current scope");
124+ }
125+ }
126+}