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
=== modified file 'libubuntudownloadmanager/downloads/daemon.cpp'
--- libubuntudownloadmanager/downloads/daemon.cpp 2013-10-25 11:44:53 +0000
+++ libubuntudownloadmanager/downloads/daemon.cpp 2013-11-07 00:06:20 +0000
@@ -74,11 +74,10 @@
74 Logger::stopLogging();74 Logger::stopLogging();
75 }75 }
7676
77 void start() {77 void start(QString path) {
78 TRACE;78 TRACE;
79 _downAdaptor = new DownloadManagerAdaptor(_downInterface);79 _downAdaptor = new DownloadManagerAdaptor(_downInterface);
80 bool ret = _conn->registerService(80 bool ret = _conn->registerService(path);
81 "com.canonical.applications.Downloader");
82 if (ret) {81 if (ret) {
83 qDebug() << "Service registered to"82 qDebug() << "Service registered to"
84 << "com.canonical.applications.Downloader";83 << "com.canonical.applications.Downloader";
@@ -201,9 +200,9 @@
201}200}
202201
203void202void
204Daemon::start() {203Daemon::start(QString path) {
205 Q_D(Daemon);204 Q_D(Daemon);
206 d->start();205 d->start(path);
207}206}
208207
209} // DownloadManager208} // DownloadManager
210209
=== modified file 'libubuntudownloadmanager/downloads/daemon.h'
--- libubuntudownloadmanager/downloads/daemon.h 2013-10-25 11:44:53 +0000
+++ libubuntudownloadmanager/downloads/daemon.h 2013-11-07 00:06:20 +0000
@@ -45,7 +45,7 @@
45 QObject *parent = 0);45 QObject *parent = 0);
4646
47 public slots: // NOLINT (whitespace/indent)47 public slots: // NOLINT (whitespace/indent)
48 void start();48 void start(QString path="com.canonical.applications.Downloader");
4949
50 private:50 private:
51 Q_PRIVATE_SLOT(d_func(), void onTimeout())51 Q_PRIVATE_SLOT(d_func(), void onTimeout())
5252
=== modified file 'ubuntu-download-manager-tests/downloads/test_daemon.cpp'
--- ubuntu-download-manager-tests/downloads/test_daemon.cpp 2013-10-30 11:04:37 +0000
+++ ubuntu-download-manager-tests/downloads/test_daemon.cpp 2013-11-07 00:06:20 +0000
@@ -16,6 +16,7 @@
16 * Boston, MA 02110-1301, USA.16 * Boston, MA 02110-1301, USA.
17 */17 */
1818
19#include <QDebug>
19#include "test_daemon.h"20#include "test_daemon.h"
2021
21TestDaemon::TestDaemon(QObject *parent)22TestDaemon::TestDaemon(QObject *parent)
@@ -64,6 +65,38 @@
6465
65 QCOMPARE(2, calledMethods.count());66 QCOMPARE(2, calledMethods.count());
66 QCOMPARE(QString("registerService"), calledMethods[0].methodName());67 QCOMPARE(QString("registerService"), calledMethods[0].methodName());
68
69 StringWrapper* wrapper = reinterpret_cast<StringWrapper*>(
70 calledMethods[0].params().inParams()[0]);
71 QCOMPARE(QString("com.canonical.applications.Downloader"),
72 wrapper->value());
73
74 QCOMPARE(QString("registerObject"), calledMethods[1].methodName());
75
76 // assert exit was NOT called
77 calledMethods = _app->calledMethods();
78 QCOMPARE(0, calledMethods.count());
79}
80
81void
82TestDaemon::testStartPath() {
83 QString myPath = "com.canonical.tests";
84 _conn->setRegisterServiceResult(true);
85 _conn->setRegisterObjectResult(true);
86 _conn->record();
87 _app->record();
88
89 _daemon->start(myPath);
90
91 QList<MethodData> calledMethods = _conn->calledMethods();
92
93 QCOMPARE(2, calledMethods.count());
94 QCOMPARE(QString("registerService"), calledMethods[0].methodName());
95
96 StringWrapper* wrapper = reinterpret_cast<StringWrapper*>(
97 calledMethods[0].params().inParams()[0]);
98 QCOMPARE(myPath, wrapper->value());
99
67 QCOMPARE(QString("registerObject"), calledMethods[1].methodName());100 QCOMPARE(QString("registerObject"), calledMethods[1].methodName());
68101
69 // assert exit was NOT called102 // assert exit was NOT called
70103
=== modified file 'ubuntu-download-manager-tests/downloads/test_daemon.h'
--- ubuntu-download-manager-tests/downloads/test_daemon.h 2013-10-30 11:04:37 +0000
+++ ubuntu-download-manager-tests/downloads/test_daemon.h 2013-11-07 00:06:20 +0000
@@ -39,6 +39,7 @@
39 void init() override;39 void init() override;
40 void cleanup() override;40 void cleanup() override;
41 void testStart();41 void testStart();
42 void testStartPath();
42 void testStartFailServiceRegister();43 void testStartFailServiceRegister();
43 void testStartFailObjectRegister();44 void testStartFailObjectRegister();
44 void testTimerStop();45 void testTimerStop();

Subscribers

People subscribed via source and target branches