Merge lp:~mandel/ubuntu-download-manager/testable-dbus-paths into lp:ubuntu-download-manager

Proposed by Manuel de la Peña
Status: Merged
Approved by: Manuel de la Peña
Approved revision: 166
Merged at revision: 167
Proposed branch: lp:~mandel/ubuntu-download-manager/testable-dbus-paths
Merge into: lp:ubuntu-download-manager
Diff against target: 105 lines (+39/-6)
4 files modified
libubuntudownloadmanager/downloads/daemon.cpp (+4/-5)
libubuntudownloadmanager/downloads/daemon.h (+1/-1)
ubuntu-download-manager-tests/downloads/test_daemon.cpp (+33/-0)
ubuntu-download-manager-tests/downloads/test_daemon.h (+1/-0)
To merge this branch: bzr merge lp:~mandel/ubuntu-download-manager/testable-dbus-paths
Reviewer Review Type Date Requested Status
Diego Sarmentero (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+194261@code.launchpad.net

Commit message

Allow to pass the path of the service to be started so that it is easier to test.

Description of the change

Allow to pass the path of the service to be started so that it is easier to test.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

+1

review: Approve
Revision history for this message
Manuel de la Peña (mandel) wrote :

Approving with a single review because it is a quite simple branch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libubuntudownloadmanager/downloads/daemon.cpp'
2--- libubuntudownloadmanager/downloads/daemon.cpp 2013-10-25 11:44:53 +0000
3+++ libubuntudownloadmanager/downloads/daemon.cpp 2013-11-07 00:06:20 +0000
4@@ -74,11 +74,10 @@
5 Logger::stopLogging();
6 }
7
8- void start() {
9+ void start(QString path) {
10 TRACE;
11 _downAdaptor = new DownloadManagerAdaptor(_downInterface);
12- bool ret = _conn->registerService(
13- "com.canonical.applications.Downloader");
14+ bool ret = _conn->registerService(path);
15 if (ret) {
16 qDebug() << "Service registered to"
17 << "com.canonical.applications.Downloader";
18@@ -201,9 +200,9 @@
19 }
20
21 void
22-Daemon::start() {
23+Daemon::start(QString path) {
24 Q_D(Daemon);
25- d->start();
26+ d->start(path);
27 }
28
29 } // DownloadManager
30
31=== modified file 'libubuntudownloadmanager/downloads/daemon.h'
32--- libubuntudownloadmanager/downloads/daemon.h 2013-10-25 11:44:53 +0000
33+++ libubuntudownloadmanager/downloads/daemon.h 2013-11-07 00:06:20 +0000
34@@ -45,7 +45,7 @@
35 QObject *parent = 0);
36
37 public slots: // NOLINT (whitespace/indent)
38- void start();
39+ void start(QString path="com.canonical.applications.Downloader");
40
41 private:
42 Q_PRIVATE_SLOT(d_func(), void onTimeout())
43
44=== modified file 'ubuntu-download-manager-tests/downloads/test_daemon.cpp'
45--- ubuntu-download-manager-tests/downloads/test_daemon.cpp 2013-10-30 11:04:37 +0000
46+++ ubuntu-download-manager-tests/downloads/test_daemon.cpp 2013-11-07 00:06:20 +0000
47@@ -16,6 +16,7 @@
48 * Boston, MA 02110-1301, USA.
49 */
50
51+#include <QDebug>
52 #include "test_daemon.h"
53
54 TestDaemon::TestDaemon(QObject *parent)
55@@ -64,6 +65,38 @@
56
57 QCOMPARE(2, calledMethods.count());
58 QCOMPARE(QString("registerService"), calledMethods[0].methodName());
59+
60+ StringWrapper* wrapper = reinterpret_cast<StringWrapper*>(
61+ calledMethods[0].params().inParams()[0]);
62+ QCOMPARE(QString("com.canonical.applications.Downloader"),
63+ wrapper->value());
64+
65+ QCOMPARE(QString("registerObject"), calledMethods[1].methodName());
66+
67+ // assert exit was NOT called
68+ calledMethods = _app->calledMethods();
69+ QCOMPARE(0, calledMethods.count());
70+}
71+
72+void
73+TestDaemon::testStartPath() {
74+ QString myPath = "com.canonical.tests";
75+ _conn->setRegisterServiceResult(true);
76+ _conn->setRegisterObjectResult(true);
77+ _conn->record();
78+ _app->record();
79+
80+ _daemon->start(myPath);
81+
82+ QList<MethodData> calledMethods = _conn->calledMethods();
83+
84+ QCOMPARE(2, calledMethods.count());
85+ QCOMPARE(QString("registerService"), calledMethods[0].methodName());
86+
87+ StringWrapper* wrapper = reinterpret_cast<StringWrapper*>(
88+ calledMethods[0].params().inParams()[0]);
89+ QCOMPARE(myPath, wrapper->value());
90+
91 QCOMPARE(QString("registerObject"), calledMethods[1].methodName());
92
93 // assert exit was NOT called
94
95=== modified file 'ubuntu-download-manager-tests/downloads/test_daemon.h'
96--- ubuntu-download-manager-tests/downloads/test_daemon.h 2013-10-30 11:04:37 +0000
97+++ ubuntu-download-manager-tests/downloads/test_daemon.h 2013-11-07 00:06:20 +0000
98@@ -39,6 +39,7 @@
99 void init() override;
100 void cleanup() override;
101 void testStart();
102+ void testStartPath();
103 void testStartFailServiceRegister();
104 void testStartFailObjectRegister();
105 void testTimerStop();

Subscribers

People subscribed via source and target branches