on xenial help sign in
Add test that checks that the launcher dash home signal brings us back to the first scope in the dash
36eaf96Albert Astals Cid
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/Dash/tst_Dash.qml+30−1
@@ -15,13 +15,15 @@
15 */
15 */
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18+import QtQuick.Window 2.0
18import QtTest 1.0
19import QtTest 1.0
19import "../../../qml/Dash"
20import "../../../qml/Dash"
21+import "../../../qml/"
20import Ubuntu.Components 0.1
22import Ubuntu.Components 0.1
21import Unity.Test 0.1 as UT
23import Unity.Test 0.1 as UT
22
24
23Item {
25Item {
24− id: shell
26+ id: root
25 width: units.gu(40)
27 width: units.gu(40)
26 height: units.gu(80)
28 height: units.gu(80)
27
29
@@ -38,6 +40,17 @@ Item {
38 anchors.fill: parent
40 anchors.fill: parent
39 }
41 }
40
42
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+
41 SignalSpy {
54 SignalSpy {
42 id: spy
55 id: spy
43 }
56 }
@@ -265,6 +278,22 @@ Item {
265 tryCompare(dashContentList, "currentIndex", 1)
278 tryCompare(dashContentList, "currentIndex", 1)
266 }
279 }
267
280
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+
268 function test_setCurrentScopeClosesPreview() {
297 function test_setCurrentScopeClosesPreview() {
269 var dashContent = findChild(dash, "dashContent");
298 var dashContent = findChild(dash, "dashContent");
270 waitForRendering(dash)
299 waitForRendering(dash)