on xenial help sign in
Add tests for Shell+Dash interaction
a566a03Albert Astals Cid
qml/Dash/Dash.qml+3−1
@@ -36,10 +36,12 @@ Showable {
36 }
36 }
37 }
37 }
38
38
39+ property bool windowActive: window.active
40+
39 DashCommunicatorService {
41 DashCommunicatorService {
40 objectName: "dashCommunicatorService"
42 objectName: "dashCommunicatorService"
41 onSetCurrentScopeRequested: {
43 onSetCurrentScopeRequested: {
42− if (!isSwipe || !window.active || bottomEdgeController.progress != 0 || scopeItem.scope || dashContent.subPageShown) {
44+ if (!isSwipe || !windowActive || bottomEdgeController.progress != 0 || scopeItem.scope || dashContent.subPageShown) {
43 if (bottomEdgeController.progress != 0 && window.active) animate = false;
45 if (bottomEdgeController.progress != 0 && window.active) animate = false;
44 dashContent.setCurrentScopeAtIndex(index, animate, true)
46 dashContent.setCurrentScopeAtIndex(index, animate, true)
45 backToDashContent()
47 backToDashContent()
tests/mocks/Unity/DashCommunicator/dashcommunicator.cpp+7−2
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014, 2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software: you can redistribute it and/or modify it under
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
5 * the terms of the GNU Lesser General Public License version 3, as published by
@@ -16,6 +16,8 @@
16
16
17#include "dashcommunicator.h"
17#include "dashcommunicator.h"
18
18
19+#include "dashcommunicatorservice.h"
20+
19#include <QObject>
21#include <QObject>
20#include <QDBusConnection>
22#include <QDBusConnection>
21#include <QDBusInterface>
23#include <QDBusInterface>
@@ -30,8 +32,11 @@ DashCommunicator::~DashCommunicator()
30{
32{
31}
33}
32
34
33−
34void DashCommunicator::setCurrentScope(int index, bool animate, bool reset)
35void DashCommunicator::setCurrentScope(int index, bool animate, bool reset)
35{
36{
36 Q_EMIT setCurrentScopeCalled(index, animate, reset);
37 Q_EMIT setCurrentScopeCalled(index, animate, reset);
38+
39+ if (DashCommunicatorService::theCommunicatorService()) {
40+ DashCommunicatorService::theCommunicatorService()->mockSetCurrentScope(index, animate, reset);
41+ }
37}
42}
tests/mocks/Unity/DashCommunicator/dashcommunicatorservice.cpp+14−1
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014, 2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software: you can redistribute it and/or modify it under
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
5 * the terms of the GNU Lesser General Public License version 3, as published by
@@ -16,9 +16,17 @@
16
16
17#include "dashcommunicatorservice.h"
17#include "dashcommunicatorservice.h"
18
18
19+#include <QDebug>
20+
21+DashCommunicatorService *DashCommunicatorService::m_theCommunicatorService = nullptr;
22+
19DashCommunicatorService::DashCommunicatorService(QObject *parent):
23DashCommunicatorService::DashCommunicatorService(QObject *parent):
20 QObject(parent)
24 QObject(parent)
21{
25{
26+ if (m_theCommunicatorService) {
27+ qFatal("There's already a communicator service, this should not happen!");
28+ }
29+ m_theCommunicatorService = this;
22}
30}
23
31
24
32
@@ -27,6 +35,11 @@ DashCommunicatorService::~DashCommunicatorService()
27
35
28}
36}
29
37
38+DashCommunicatorService *DashCommunicatorService::theCommunicatorService()
39+{
40+ return m_theCommunicatorService;
41+}
42+
30void DashCommunicatorService::mockSetCurrentScope(int index, bool animate, bool isSwipe)
43void DashCommunicatorService::mockSetCurrentScope(int index, bool animate, bool isSwipe)
31{
44{
32 Q_EMIT setCurrentScopeRequested(index, animate, isSwipe);
45 Q_EMIT setCurrentScopeRequested(index, animate, isSwipe);
tests/mocks/Unity/DashCommunicator/dashcommunicatorservice.h+6−1
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014, 2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software: you can redistribute it and/or modify it under
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
5 * the terms of the GNU Lesser General Public License version 3, as published by
@@ -26,11 +26,16 @@ public:
26 DashCommunicatorService(QObject *parent = 0);
26 DashCommunicatorService(QObject *parent = 0);
27 ~DashCommunicatorService();
27 ~DashCommunicatorService();
28
28
29+ static DashCommunicatorService *theCommunicatorService();
30+
29Q_SIGNALS:
31Q_SIGNALS:
30 void setCurrentScopeRequested(int index, bool animate, bool isSwipe);
32 void setCurrentScopeRequested(int index, bool animate, bool isSwipe);
31
33
32public Q_SLOTS:
34public Q_SLOTS:
33 void mockSetCurrentScope(int index, bool animate, bool isSwipe);
35 void mockSetCurrentScope(int index, bool animate, bool isSwipe);
36+
37+private:
38+ static DashCommunicatorService *m_theCommunicatorService;
34};
39};
35
40
36#endif // DBUSUNITYSESSIONSERVICE_H
41#endif // DBUSUNITYSESSIONSERVICE_H
tests/qmltests/CMakeLists.txt+1
@@ -18,6 +18,7 @@ add_unity8_qmltest(Components Showable)
18add_unity8_qmltest(Components ZoomableImage)
18add_unity8_qmltest(Components ZoomableImage)
19add_unity8_qmltest(Dash Dash)
19add_unity8_qmltest(Dash Dash)
20add_unity8_qmltest(Dash DashContent)
20add_unity8_qmltest(Dash DashContent)
21+add_unity8_qmltest(Dash DashShell)
21add_unity8_qmltest(Dash Card)
22add_unity8_qmltest(Dash Card)
22add_unity8_qmlbenchmark(Dash CardBenchmark 1000)
23add_unity8_qmlbenchmark(Dash CardBenchmark 1000)
23add_unity8_qmltest(Dash CardTool)
24add_unity8_qmltest(Dash CardTool)
tests/qmltests/Dash/tst_DashShell.qmlnew file+135
@@ -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+}