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
commit36eaf968c36d128d136b61bd5e927d71d5623b62 authorAlbert Astals Cid <albert.astals@canonical.com> dateMon 20 Jul 2015, 12:42 (11 years ago) parentf753fd3
4 files changed+57−5
tests/mocks/Unity/DashCommunicator/dashcommunicator.cpp+7−2 tests/mocks/Unity/DashCommunicator/dashcommunicatorservice.cpp+14−1 tests/mocks/Unity/DashCommunicator/dashcommunicatorservice.h+6−1 tests/qmltests/Dash/tst_Dash.qml+30−1
tests/mocks/Unity/DashCommunicator/dashcommunicator.cpp+7−2
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014, 2015 Canonical, Ltd.
33 *
44 * This program is free software: you can redistribute it and/or modify it under
55 * the terms of the GNU Lesser General Public License version 3, as published by
@@ -16,6 +16,8 @@
1616
1717#include "dashcommunicator.h"
1818
19+#include "dashcommunicatorservice.h"
20+
1921#include <QObject>
2022#include <QDBusConnection>
2123#include <QDBusInterface>
@@ -30,8 +32,11 @@ DashCommunicator::~DashCommunicator()
3032{
3133}
3234
33−
3435void DashCommunicator::setCurrentScope(int index, bool animate, bool reset)
3536{
3637 Q_EMIT setCurrentScopeCalled(index, animate, reset);
38+
39+ if (DashCommunicatorService::theCommunicatorService()) {
40+ DashCommunicatorService::theCommunicatorService()->mockSetCurrentScope(index, animate, reset);
41+ }
3742}
tests/mocks/Unity/DashCommunicator/dashcommunicatorservice.cpp+14−1
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014, 2015 Canonical, Ltd.
33 *
44 * This program is free software: you can redistribute it and/or modify it under
55 * the terms of the GNU Lesser General Public License version 3, as published by
@@ -16,9 +16,17 @@
1616
1717#include "dashcommunicatorservice.h"
1818
19+#include <QDebug>
20+
21+DashCommunicatorService *DashCommunicatorService::m_theCommunicatorService = nullptr;
22+
1923DashCommunicatorService::DashCommunicatorService(QObject *parent):
2024 QObject(parent)
2125{
26+ if (m_theCommunicatorService) {
27+ qFatal("There's already a communicator service, this should not happen!");
28+ }
29+ m_theCommunicatorService = this;
2230}
2331
2432
@@ -27,6 +35,11 @@ DashCommunicatorService::~DashCommunicatorService()
2735
2836}
2937
38+DashCommunicatorService *DashCommunicatorService::theCommunicatorService()
39+{
40+ return m_theCommunicatorService;
41+}
42+
3043void DashCommunicatorService::mockSetCurrentScope(int index, bool animate, bool isSwipe)
3144{
3245 Q_EMIT setCurrentScopeRequested(index, animate, isSwipe);
tests/mocks/Unity/DashCommunicator/dashcommunicatorservice.h+6−1
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014, 2015 Canonical, Ltd.
33 *
44 * This program is free software: you can redistribute it and/or modify it under
55 * the terms of the GNU Lesser General Public License version 3, as published by
@@ -26,11 +26,16 @@ public:
2626 DashCommunicatorService(QObject *parent = 0);
2727 ~DashCommunicatorService();
2828
29+ static DashCommunicatorService *theCommunicatorService();
30+
2931Q_SIGNALS:
3032 void setCurrentScopeRequested(int index, bool animate, bool isSwipe);
3133
3234public Q_SLOTS:
3335 void mockSetCurrentScope(int index, bool animate, bool isSwipe);
36+
37+private:
38+ static DashCommunicatorService *m_theCommunicatorService;
3439};
3540
3641#endif // DBUSUNITYSESSIONSERVICE_H
tests/qmltests/Dash/tst_Dash.qml+30−1
@@ -15,13 +15,15 @@
1515 */
1616
1717import QtQuick 2.0
18+import QtQuick.Window 2.0
1819import QtTest 1.0
1920import "../../../qml/Dash"
21+import "../../../qml/"
2022import Ubuntu.Components 0.1
2123import Unity.Test 0.1 as UT
2224
2325Item {
24− id: shell
26+ id: root
2527 width: units.gu(40)
2628 height: units.gu(80)
2729
@@ -38,6 +40,17 @@ Item {
3840 anchors.fill: parent
3941 }
4042
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+
4154 SignalSpy {
4255 id: spy
4356 }
@@ -265,6 +278,22 @@ Item {
265278 tryCompare(dashContentList, "currentIndex", 1)
266279 }
267280
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+
268297 function test_setCurrentScopeClosesPreview() {
269298 var dashContent = findChild(dash, "dashContent");
270299 waitForRendering(dash)