Merge lp:~mandel/ubuntu-download-manager/single-daemon into lp:ubuntu-download-manager
- single-daemon
- Merge into trunk
Proposed by
Manuel de la Peña
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Alejandro J. Cura | ||||
Approved revision: | 100 | ||||
Merged at revision: | 96 | ||||
Proposed branch: | lp:~mandel/ubuntu-download-manager/single-daemon | ||||
Merge into: | lp:ubuntu-download-manager | ||||
Diff against target: |
558 lines (+278/-24) 13 files modified
libubuntudownloadmanager/application.cpp (+65/-0) libubuntudownloadmanager/application.h (+39/-0) libubuntudownloadmanager/download_daemon.cpp (+26/-12) libubuntudownloadmanager/download_daemon.h (+6/-2) libubuntudownloadmanager/libubuntudownloadmanager.pro (+4/-2) ubuntu-download-manager-tests/fake.cpp (+20/-0) ubuntu-download-manager-tests/fake.h (+13/-0) ubuntu-download-manager-tests/fake_application.cpp (+37/-0) ubuntu-download-manager-tests/fake_application.h (+35/-0) ubuntu-download-manager-tests/test_download_daemon.cpp (+24/-4) ubuntu-download-manager-tests/test_download_daemon.h (+2/-0) ubuntu-download-manager-tests/ubuntu-download-manager-tests.pro (+4/-2) ubuntu-download-manager/main.cpp (+3/-2) |
||||
To merge this branch: | bzr merge lp:~mandel/ubuntu-download-manager/single-daemon | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alejandro J. Cura (community) | Approve | ||
Diego Sarmentero (community) | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+181280@code.launchpad.net |
Commit message
Ensure that a single instance of the daemon can be ran.
Description of the change
Ensure that a single instance of the daemon can be ran.
To post a comment you must log in.
- 100. By Manuel de la Peña
-
Fixed broken tests.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
review:
Needs Fixing
(continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:100
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
review:
Approve
(continuous-integration)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file 'libubuntudownloadmanager/application.cpp' | |||
2 | --- libubuntudownloadmanager/application.cpp 1970-01-01 00:00:00 +0000 | |||
3 | +++ libubuntudownloadmanager/application.cpp 2013-08-21 12:22:01 +0000 | |||
4 | @@ -0,0 +1,65 @@ | |||
5 | 1 | /* | ||
6 | 2 | * Copyright 2013 2013 Canonical Ltd. | ||
7 | 3 | * | ||
8 | 4 | * This library is free software; you can redistribute it and/or | ||
9 | 5 | * modify it under the terms of version 3 of the GNU Lesser General Public | ||
10 | 6 | * License as published by the Free Software Foundation. | ||
11 | 7 | * | ||
12 | 8 | * This program is distributed in the hope that it will be useful, | ||
13 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | 11 | * General Public License for more details. | ||
16 | 12 | * | ||
17 | 13 | * You should have received a copy of the GNU Lesser General Public | ||
18 | 14 | * License along with this library; if not, write to the | ||
19 | 15 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
20 | 16 | * Boston, MA 02110-1301, USA. | ||
21 | 17 | */ | ||
22 | 18 | |||
23 | 19 | #include <QDebug> | ||
24 | 20 | #include <QCoreApplication> | ||
25 | 21 | #include "./application.h" | ||
26 | 22 | |||
27 | 23 | /* | ||
28 | 24 | * PRIVATE IMPLEMENTATION | ||
29 | 25 | */ | ||
30 | 26 | |||
31 | 27 | class ApplicationPrivate { | ||
32 | 28 | Q_DECLARE_PUBLIC(Application) | ||
33 | 29 | |||
34 | 30 | public: | ||
35 | 31 | explicit ApplicationPrivate(Application* parent); | ||
36 | 32 | |||
37 | 33 | virtual void exit(int returnCode); | ||
38 | 34 | |||
39 | 35 | private: | ||
40 | 36 | Application* q_ptr; | ||
41 | 37 | }; | ||
42 | 38 | |||
43 | 39 | ApplicationPrivate::ApplicationPrivate(Application* parent) | ||
44 | 40 | : q_ptr(parent) { | ||
45 | 41 | } | ||
46 | 42 | |||
47 | 43 | void | ||
48 | 44 | ApplicationPrivate::exit(int returnCode) { | ||
49 | 45 | // get the application instance and exit | ||
50 | 46 | QCoreApplication* app = QCoreApplication::instance(); | ||
51 | 47 | app->exit(returnCode); | ||
52 | 48 | } | ||
53 | 49 | |||
54 | 50 | /* | ||
55 | 51 | * PUBLIC IMPLEMENTATION | ||
56 | 52 | */ | ||
57 | 53 | |||
58 | 54 | |||
59 | 55 | Application::Application(QObject *parent) | ||
60 | 56 | : QObject(parent), | ||
61 | 57 | d_ptr(new ApplicationPrivate(this)) { | ||
62 | 58 | } | ||
63 | 59 | |||
64 | 60 | void | ||
65 | 61 | Application::exit(int returnCode) { | ||
66 | 62 | Q_D(Application); | ||
67 | 63 | qDebug() << "Exit app" << returnCode; | ||
68 | 64 | d->exit(returnCode); | ||
69 | 65 | } | ||
70 | 0 | 66 | ||
71 | === added file 'libubuntudownloadmanager/application.h' | |||
72 | --- libubuntudownloadmanager/application.h 1970-01-01 00:00:00 +0000 | |||
73 | +++ libubuntudownloadmanager/application.h 2013-08-21 12:22:01 +0000 | |||
74 | @@ -0,0 +1,39 @@ | |||
75 | 1 | /* | ||
76 | 2 | * Copyright 2013 2013 Canonical Ltd. | ||
77 | 3 | * | ||
78 | 4 | * This library is free software; you can redistribute it and/or | ||
79 | 5 | * modify it under the terms of version 3 of the GNU Lesser General Public | ||
80 | 6 | * License as published by the Free Software Foundation. | ||
81 | 7 | * | ||
82 | 8 | * This program is distributed in the hope that it will be useful, | ||
83 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
84 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
85 | 11 | * General Public License for more details. | ||
86 | 12 | * | ||
87 | 13 | * You should have received a copy of the GNU Lesser General Public | ||
88 | 14 | * License along with this library; if not, write to the | ||
89 | 15 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
90 | 16 | * Boston, MA 02110-1301, USA. | ||
91 | 17 | */ | ||
92 | 18 | |||
93 | 19 | #ifndef DOWNLOADER_LIB_APPLICATION_H | ||
94 | 20 | #define DOWNLOADER_LIB_APPLICATION_H | ||
95 | 21 | |||
96 | 22 | #include <QObject> | ||
97 | 23 | |||
98 | 24 | class ApplicationPrivate; | ||
99 | 25 | class Application : public QObject { | ||
100 | 26 | Q_OBJECT | ||
101 | 27 | Q_DECLARE_PRIVATE(Application) | ||
102 | 28 | |||
103 | 29 | public: | ||
104 | 30 | explicit Application(QObject *parent = 0); | ||
105 | 31 | |||
106 | 32 | virtual void exit(int returnCode = 0); | ||
107 | 33 | |||
108 | 34 | private: | ||
109 | 35 | // use pimpl so that we can mantains ABI compatibility | ||
110 | 36 | ApplicationPrivate* d_ptr; | ||
111 | 37 | }; | ||
112 | 38 | |||
113 | 39 | #endif // DOWNLOADER_LIB_APPLICATION_H | ||
114 | 0 | 40 | ||
115 | === modified file 'libubuntudownloadmanager/download_daemon.cpp' | |||
116 | --- libubuntudownloadmanager/download_daemon.cpp 2013-08-12 14:11:21 +0000 | |||
117 | +++ libubuntudownloadmanager/download_daemon.cpp 2013-08-21 12:22:01 +0000 | |||
118 | @@ -19,6 +19,7 @@ | |||
119 | 19 | #include <QtDBus/QDBusConnection> | 19 | #include <QtDBus/QDBusConnection> |
120 | 20 | #include <QDebug> | 20 | #include <QDebug> |
121 | 21 | #include <QSharedPointer> | 21 | #include <QSharedPointer> |
122 | 22 | #include "./application.h" | ||
123 | 22 | #include "./logger.h" | 23 | #include "./logger.h" |
124 | 23 | #include "./download_manager.h" | 24 | #include "./download_manager.h" |
125 | 24 | #include "./download_manager_adaptor.h" | 25 | #include "./download_manager_adaptor.h" |
126 | @@ -33,16 +34,18 @@ | |||
127 | 33 | 34 | ||
128 | 34 | public: | 35 | public: |
129 | 35 | explicit DownloadDaemonPrivate(DownloadDaemon* parent); | 36 | explicit DownloadDaemonPrivate(DownloadDaemon* parent); |
131 | 36 | explicit DownloadDaemonPrivate(DBusConnection* conn, | 37 | explicit DownloadDaemonPrivate(Application* app, |
132 | 38 | DBusConnection* conn, | ||
133 | 37 | DownloadDaemon* parent); | 39 | DownloadDaemon* parent); |
134 | 38 | ~DownloadDaemonPrivate(); | 40 | ~DownloadDaemonPrivate(); |
135 | 39 | 41 | ||
137 | 40 | bool start(); | 42 | void start(); |
138 | 41 | 43 | ||
139 | 42 | private: | 44 | private: |
140 | 43 | void init(); | 45 | void init(); |
141 | 44 | 46 | ||
142 | 45 | private: | 47 | private: |
143 | 48 | Application* _app; | ||
144 | 46 | QSharedPointer<DBusConnection> _conn; | 49 | QSharedPointer<DBusConnection> _conn; |
145 | 47 | DownloadManager* _downInterface; | 50 | DownloadManager* _downInterface; |
146 | 48 | DownloadManagerAdaptor* _downAdaptor; | 51 | DownloadManagerAdaptor* _downAdaptor; |
147 | @@ -51,14 +54,17 @@ | |||
148 | 51 | 54 | ||
149 | 52 | DownloadDaemonPrivate::DownloadDaemonPrivate(DownloadDaemon* parent) | 55 | DownloadDaemonPrivate::DownloadDaemonPrivate(DownloadDaemon* parent) |
150 | 53 | : q_ptr(parent) { | 56 | : q_ptr(parent) { |
151 | 57 | _app = new Application(); | ||
152 | 54 | _conn = QSharedPointer<DBusConnection>(new DBusConnection()); | 58 | _conn = QSharedPointer<DBusConnection>(new DBusConnection()); |
153 | 55 | _downInterface = new DownloadManager(_conn, q_ptr); | 59 | _downInterface = new DownloadManager(_conn, q_ptr); |
154 | 56 | init(); | 60 | init(); |
155 | 57 | } | 61 | } |
156 | 58 | 62 | ||
158 | 59 | DownloadDaemonPrivate::DownloadDaemonPrivate(DBusConnection* conn, | 63 | DownloadDaemonPrivate::DownloadDaemonPrivate(Application* app, |
159 | 64 | DBusConnection* conn, | ||
160 | 60 | DownloadDaemon* parent) | 65 | DownloadDaemon* parent) |
162 | 61 | : _conn(conn), | 66 | : _app(app), |
163 | 67 | _conn(conn), | ||
164 | 62 | q_ptr(parent) { | 68 | q_ptr(parent) { |
165 | 63 | _downInterface = new DownloadManager(_conn); | 69 | _downInterface = new DownloadManager(_conn); |
166 | 64 | init(); | 70 | init(); |
167 | @@ -79,12 +85,14 @@ | |||
168 | 79 | // no need to delete the adaptor because the interface is its parent | 85 | // no need to delete the adaptor because the interface is its parent |
169 | 80 | if (_downInterface) | 86 | if (_downInterface) |
170 | 81 | delete _downInterface; | 87 | delete _downInterface; |
171 | 88 | if (_app) | ||
172 | 89 | delete _app; | ||
173 | 82 | 90 | ||
174 | 83 | // stop logging | 91 | // stop logging |
175 | 84 | Logger::setupLogging(); | 92 | Logger::setupLogging(); |
176 | 85 | } | 93 | } |
177 | 86 | 94 | ||
179 | 87 | bool | 95 | void |
180 | 88 | DownloadDaemonPrivate::start() { | 96 | DownloadDaemonPrivate::start() { |
181 | 89 | qDebug() << "Starting daemon"; | 97 | qDebug() << "Starting daemon"; |
182 | 90 | _downAdaptor = new DownloadManagerAdaptor(_downInterface); | 98 | _downAdaptor = new DownloadManagerAdaptor(_downInterface); |
183 | @@ -94,10 +102,14 @@ | |||
184 | 94 | << "com.canonical.applications.Downloader"; | 102 | << "com.canonical.applications.Downloader"; |
185 | 95 | ret = _conn->registerObject("/", _downInterface); | 103 | ret = _conn->registerObject("/", _downInterface); |
186 | 96 | qDebug() << ret; | 104 | qDebug() << ret; |
188 | 97 | return ret; | 105 | if (!ret) { |
189 | 106 | qDebug() << "Could not register interface"; | ||
190 | 107 | _app->exit(-1); | ||
191 | 108 | } | ||
192 | 109 | return; | ||
193 | 98 | } | 110 | } |
196 | 99 | qDebug() << "Could not register"; | 111 | qDebug() << "Could not register service"; |
197 | 100 | return false; | 112 | _app->exit(-1); |
198 | 101 | } | 113 | } |
199 | 102 | 114 | ||
200 | 103 | /** | 115 | /** |
201 | @@ -109,13 +121,15 @@ | |||
202 | 109 | d_ptr(new DownloadDaemonPrivate(this)) { | 121 | d_ptr(new DownloadDaemonPrivate(this)) { |
203 | 110 | } | 122 | } |
204 | 111 | 123 | ||
206 | 112 | DownloadDaemon::DownloadDaemon(DBusConnection* conn, QObject *parent) | 124 | DownloadDaemon::DownloadDaemon(Application* app, |
207 | 125 | DBusConnection* conn, | ||
208 | 126 | QObject *parent) | ||
209 | 113 | : QObject(parent), | 127 | : QObject(parent), |
211 | 114 | d_ptr(new DownloadDaemonPrivate(conn, this)) { | 128 | d_ptr(new DownloadDaemonPrivate(app, conn, this)) { |
212 | 115 | } | 129 | } |
213 | 116 | 130 | ||
215 | 117 | bool | 131 | void |
216 | 118 | DownloadDaemon::start() { | 132 | DownloadDaemon::start() { |
217 | 119 | Q_D(DownloadDaemon); | 133 | Q_D(DownloadDaemon); |
219 | 120 | return d->start(); | 134 | d->start(); |
220 | 121 | } | 135 | } |
221 | 122 | 136 | ||
222 | === modified file 'libubuntudownloadmanager/download_daemon.h' | |||
223 | --- libubuntudownloadmanager/download_daemon.h 2013-07-23 14:39:41 +0000 | |||
224 | +++ libubuntudownloadmanager/download_daemon.h 2013-08-21 12:22:01 +0000 | |||
225 | @@ -21,6 +21,7 @@ | |||
226 | 21 | 21 | ||
227 | 22 | #include <QObject> | 22 | #include <QObject> |
228 | 23 | #include "./app-downloader-lib_global.h" | 23 | #include "./app-downloader-lib_global.h" |
229 | 24 | #include "./application.h" | ||
230 | 24 | #include "./dbus_connection.h" | 25 | #include "./dbus_connection.h" |
231 | 25 | 26 | ||
232 | 26 | class DownloadDaemonPrivate; | 27 | class DownloadDaemonPrivate; |
233 | @@ -30,9 +31,12 @@ | |||
234 | 30 | 31 | ||
235 | 31 | public: | 32 | public: |
236 | 32 | explicit DownloadDaemon(QObject *parent = 0); | 33 | explicit DownloadDaemon(QObject *parent = 0); |
238 | 33 | explicit DownloadDaemon(DBusConnection* conn, QObject *parent = 0); | 34 | explicit DownloadDaemon(Application* app, |
239 | 35 | DBusConnection* conn, | ||
240 | 36 | QObject *parent = 0); | ||
241 | 34 | 37 | ||
243 | 35 | bool start(); | 38 | public slots: |
244 | 39 | void start(); | ||
245 | 36 | 40 | ||
246 | 37 | private: | 41 | private: |
247 | 38 | // use pimpl so that we can mantains ABI compatibility | 42 | // use pimpl so that we can mantains ABI compatibility |
248 | 39 | 43 | ||
249 | === modified file 'libubuntudownloadmanager/libubuntudownloadmanager.pro' | |||
250 | --- libubuntudownloadmanager/libubuntudownloadmanager.pro 2013-07-26 15:50:37 +0000 | |||
251 | +++ libubuntudownloadmanager/libubuntudownloadmanager.pro 2013-08-21 12:22:01 +0000 | |||
252 | @@ -23,7 +23,8 @@ | |||
253 | 23 | xdg_basedir.cpp \ | 23 | xdg_basedir.cpp \ |
254 | 24 | process.cpp \ | 24 | process.cpp \ |
255 | 25 | process_factory.cpp \ | 25 | process_factory.cpp \ |
257 | 26 | logger.cpp | 26 | logger.cpp \ |
258 | 27 | application.cpp | ||
259 | 27 | 28 | ||
260 | 28 | HEADERS +=\ | 29 | HEADERS +=\ |
261 | 29 | app-downloader-lib_global.h \ | 30 | app-downloader-lib_global.h \ |
262 | @@ -42,7 +43,8 @@ | |||
263 | 42 | process.h \ | 43 | process.h \ |
264 | 43 | process_factory.h \ | 44 | process_factory.h \ |
265 | 44 | metatypes.h \ | 45 | metatypes.h \ |
267 | 45 | logger.h | 46 | logger.h \ |
268 | 47 | application.h | ||
269 | 46 | 48 | ||
270 | 47 | OTHER_FILES += \ | 49 | OTHER_FILES += \ |
271 | 48 | generate_adaptors.sh \ | 50 | generate_adaptors.sh \ |
272 | 49 | 51 | ||
273 | === modified file 'ubuntu-download-manager-tests/fake.cpp' | |||
274 | --- ubuntu-download-manager-tests/fake.cpp 2013-07-23 16:29:36 +0000 | |||
275 | +++ ubuntu-download-manager-tests/fake.cpp 2013-08-21 12:22:01 +0000 | |||
276 | @@ -79,6 +79,26 @@ | |||
277 | 79 | } | 79 | } |
278 | 80 | 80 | ||
279 | 81 | /* | 81 | /* |
280 | 82 | * INT WRAPPER | ||
281 | 83 | */ | ||
282 | 84 | |||
283 | 85 | IntWrapper::IntWrapper(int value, QObject* parent) | ||
284 | 86 | : QObject(parent), | ||
285 | 87 | _value(value) { | ||
286 | 88 | } | ||
287 | 89 | |||
288 | 90 | |||
289 | 91 | int | ||
290 | 92 | IntWrapper::value() { | ||
291 | 93 | return _value; | ||
292 | 94 | } | ||
293 | 95 | |||
294 | 96 | void | ||
295 | 97 | IntWrapper::setValue(int value) { | ||
296 | 98 | _value = value; | ||
297 | 99 | } | ||
298 | 100 | |||
299 | 101 | /* | ||
300 | 82 | * UINT WRAPPER | 102 | * UINT WRAPPER |
301 | 83 | */ | 103 | */ |
302 | 84 | 104 | ||
303 | 85 | 105 | ||
304 | === modified file 'ubuntu-download-manager-tests/fake.h' | |||
305 | --- ubuntu-download-manager-tests/fake.h 2013-07-23 17:45:38 +0000 | |||
306 | +++ ubuntu-download-manager-tests/fake.h 2013-08-21 12:22:01 +0000 | |||
307 | @@ -66,6 +66,19 @@ | |||
308 | 66 | QStringList _value; | 66 | QStringList _value; |
309 | 67 | }; | 67 | }; |
310 | 68 | 68 | ||
311 | 69 | class IntWrapper : public QObject { | ||
312 | 70 | Q_OBJECT | ||
313 | 71 | |||
314 | 72 | public: | ||
315 | 73 | IntWrapper(int value, QObject* parent = 0); | ||
316 | 74 | |||
317 | 75 | int value(); | ||
318 | 76 | void setValue(int value); | ||
319 | 77 | |||
320 | 78 | private: | ||
321 | 79 | int _value; | ||
322 | 80 | }; | ||
323 | 81 | |||
324 | 69 | class UintWrapper : public QObject { | 82 | class UintWrapper : public QObject { |
325 | 70 | Q_OBJECT | 83 | Q_OBJECT |
326 | 71 | 84 | ||
327 | 72 | 85 | ||
328 | === added file 'ubuntu-download-manager-tests/fake_application.cpp' | |||
329 | --- ubuntu-download-manager-tests/fake_application.cpp 1970-01-01 00:00:00 +0000 | |||
330 | +++ ubuntu-download-manager-tests/fake_application.cpp 2013-08-21 12:22:01 +0000 | |||
331 | @@ -0,0 +1,37 @@ | |||
332 | 1 | /* | ||
333 | 2 | * Copyright 2013 2013 Canonical Ltd. | ||
334 | 3 | * | ||
335 | 4 | * This library is free software; you can redistribute it and/or | ||
336 | 5 | * modify it under the terms of version 3 of the GNU Lesser General Public | ||
337 | 6 | * License as published by the Free Software Foundation. | ||
338 | 7 | * | ||
339 | 8 | * This program is distributed in the hope that it will be useful, | ||
340 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
341 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
342 | 11 | * General Public License for more details. | ||
343 | 12 | * | ||
344 | 13 | * You should have received a copy of the GNU Lesser General Public | ||
345 | 14 | * License along with this library; if not, write to the | ||
346 | 15 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
347 | 16 | * Boston, MA 02110-1301, USA. | ||
348 | 17 | */ | ||
349 | 18 | |||
350 | 19 | #include "fake_application.h" | ||
351 | 20 | |||
352 | 21 | FakeApplication::FakeApplication(QObject *parent) | ||
353 | 22 | : Application(parent), | ||
354 | 23 | Fake() { | ||
355 | 24 | } | ||
356 | 25 | |||
357 | 26 | void | ||
358 | 27 | FakeApplication::exit(int returnCode) { | ||
359 | 28 | if (_recording) { | ||
360 | 29 | QList<QObject*> inParams; | ||
361 | 30 | inParams.append(new IntWrapper(returnCode)); | ||
362 | 31 | |||
363 | 32 | QList<QObject*> outParams; | ||
364 | 33 | MethodParams params(inParams, outParams); | ||
365 | 34 | MethodData methodData("exit", params); | ||
366 | 35 | _called.append(methodData); | ||
367 | 36 | } | ||
368 | 37 | } | ||
369 | 0 | 38 | ||
370 | === added file 'ubuntu-download-manager-tests/fake_application.h' | |||
371 | --- ubuntu-download-manager-tests/fake_application.h 1970-01-01 00:00:00 +0000 | |||
372 | +++ ubuntu-download-manager-tests/fake_application.h 2013-08-21 12:22:01 +0000 | |||
373 | @@ -0,0 +1,35 @@ | |||
374 | 1 | /* | ||
375 | 2 | * Copyright 2013 2013 Canonical Ltd. | ||
376 | 3 | * | ||
377 | 4 | * This library is free software; you can redistribute it and/or | ||
378 | 5 | * modify it under the terms of version 3 of the GNU Lesser General Public | ||
379 | 6 | * License as published by the Free Software Foundation. | ||
380 | 7 | * | ||
381 | 8 | * This program is distributed in the hope that it will be useful, | ||
382 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
383 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
384 | 11 | * General Public License for more details. | ||
385 | 12 | * | ||
386 | 13 | * You should have received a copy of the GNU Lesser General Public | ||
387 | 14 | * License along with this library; if not, write to the | ||
388 | 15 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
389 | 16 | * Boston, MA 02110-1301, USA. | ||
390 | 17 | */ | ||
391 | 18 | |||
392 | 19 | #ifndef FAKE_APPLICATION_H | ||
393 | 20 | #define FAKE_APPLICATION_H | ||
394 | 21 | |||
395 | 22 | #include <QObject> | ||
396 | 23 | #include <application.h> | ||
397 | 24 | #include "./fake.h" | ||
398 | 25 | |||
399 | 26 | class FakeApplication : public Application, public Fake { | ||
400 | 27 | Q_OBJECT | ||
401 | 28 | |||
402 | 29 | public: | ||
403 | 30 | explicit FakeApplication(QObject *parent = 0); | ||
404 | 31 | |||
405 | 32 | void exit(int returnCode = 0) override; | ||
406 | 33 | }; | ||
407 | 34 | |||
408 | 35 | #endif // FAKE_APPLICATION_H | ||
409 | 0 | 36 | ||
410 | === modified file 'ubuntu-download-manager-tests/test_download_daemon.cpp' | |||
411 | --- ubuntu-download-manager-tests/test_download_daemon.cpp 2013-07-24 13:56:44 +0000 | |||
412 | +++ ubuntu-download-manager-tests/test_download_daemon.cpp 2013-08-21 12:22:01 +0000 | |||
413 | @@ -24,12 +24,15 @@ | |||
414 | 24 | 24 | ||
415 | 25 | void | 25 | void |
416 | 26 | TestDownloadDaemon::init() { | 26 | TestDownloadDaemon::init() { |
417 | 27 | _app = new FakeApplication(); | ||
418 | 27 | _conn = new FakeDBusConnection(); | 28 | _conn = new FakeDBusConnection(); |
420 | 28 | _daemon = new DownloadDaemon(_conn); | 29 | _daemon = new DownloadDaemon(_app, _conn, this); |
421 | 29 | } | 30 | } |
422 | 30 | 31 | ||
423 | 31 | void | 32 | void |
424 | 32 | TestDownloadDaemon::cleanup() { | 33 | TestDownloadDaemon::cleanup() { |
425 | 34 | if (_app != NULL) | ||
426 | 35 | delete _app; | ||
427 | 33 | if (_conn != NULL) | 36 | if (_conn != NULL) |
428 | 34 | delete _conn; | 37 | delete _conn; |
429 | 35 | if (_daemon != NULL) | 38 | if (_daemon != NULL) |
430 | @@ -41,14 +44,19 @@ | |||
431 | 41 | _conn->setRegisterServiceResult(true); | 44 | _conn->setRegisterServiceResult(true); |
432 | 42 | _conn->setRegisterObjectResult(true); | 45 | _conn->setRegisterObjectResult(true); |
433 | 43 | _conn->record(); | 46 | _conn->record(); |
434 | 47 | _app->record(); | ||
435 | 44 | 48 | ||
437 | 45 | QVERIFY(_daemon->start()); | 49 | _daemon->start(); |
438 | 46 | 50 | ||
439 | 47 | QList<MethodData> calledMethods = _conn->calledMethods(); | 51 | QList<MethodData> calledMethods = _conn->calledMethods(); |
440 | 48 | 52 | ||
441 | 49 | QCOMPARE(2, calledMethods.count()); | 53 | QCOMPARE(2, calledMethods.count()); |
442 | 50 | QCOMPARE(QString("registerService"), calledMethods[0].methodName()); | 54 | QCOMPARE(QString("registerService"), calledMethods[0].methodName()); |
443 | 51 | QCOMPARE(QString("registerObject"), calledMethods[1].methodName()); | 55 | QCOMPARE(QString("registerObject"), calledMethods[1].methodName()); |
444 | 56 | |||
445 | 57 | // assert exit was NOT called | ||
446 | 58 | calledMethods = _app->calledMethods(); | ||
447 | 59 | QCOMPARE(0, calledMethods.count()); | ||
448 | 52 | } | 60 | } |
449 | 53 | 61 | ||
450 | 54 | void | 62 | void |
451 | @@ -56,13 +64,19 @@ | |||
452 | 56 | _conn->setRegisterServiceResult(false); | 64 | _conn->setRegisterServiceResult(false); |
453 | 57 | _conn->setRegisterObjectResult(true); | 65 | _conn->setRegisterObjectResult(true); |
454 | 58 | _conn->record(); | 66 | _conn->record(); |
455 | 67 | _app->record(); | ||
456 | 59 | 68 | ||
458 | 60 | QVERIFY(!_daemon->start()); | 69 | _daemon->start(); |
459 | 61 | 70 | ||
460 | 62 | QList<MethodData> calledMethods = _conn->calledMethods(); | 71 | QList<MethodData> calledMethods = _conn->calledMethods(); |
461 | 63 | 72 | ||
462 | 64 | QCOMPARE(1, calledMethods.count()); | 73 | QCOMPARE(1, calledMethods.count()); |
463 | 65 | QCOMPARE(QString("registerService"), calledMethods[0].methodName()); | 74 | QCOMPARE(QString("registerService"), calledMethods[0].methodName()); |
464 | 75 | |||
465 | 76 | // assert exit was called | ||
466 | 77 | calledMethods = _app->calledMethods(); | ||
467 | 78 | QCOMPARE(1, calledMethods.count()); | ||
468 | 79 | QCOMPARE(QString("exit"), calledMethods[0].methodName()); | ||
469 | 66 | } | 80 | } |
470 | 67 | 81 | ||
471 | 68 | void | 82 | void |
472 | @@ -70,12 +84,18 @@ | |||
473 | 70 | _conn->setRegisterServiceResult(true); | 84 | _conn->setRegisterServiceResult(true); |
474 | 71 | _conn->setRegisterObjectResult(false); | 85 | _conn->setRegisterObjectResult(false); |
475 | 72 | _conn->record(); | 86 | _conn->record(); |
476 | 87 | _app->record(); | ||
477 | 73 | 88 | ||
479 | 74 | QVERIFY(!_daemon->start()); | 89 | _daemon->start(); |
480 | 75 | 90 | ||
481 | 76 | QList<MethodData> calledMethods = _conn->calledMethods(); | 91 | QList<MethodData> calledMethods = _conn->calledMethods(); |
482 | 77 | 92 | ||
483 | 78 | QCOMPARE(2, calledMethods.count()); | 93 | QCOMPARE(2, calledMethods.count()); |
484 | 79 | QCOMPARE(QString("registerService"), calledMethods[0].methodName()); | 94 | QCOMPARE(QString("registerService"), calledMethods[0].methodName()); |
485 | 80 | QCOMPARE(QString("registerObject"), calledMethods[1].methodName()); | 95 | QCOMPARE(QString("registerObject"), calledMethods[1].methodName()); |
486 | 96 | |||
487 | 97 | // assert exit was called | ||
488 | 98 | calledMethods = _app->calledMethods(); | ||
489 | 99 | QCOMPARE(1, calledMethods.count()); | ||
490 | 100 | QCOMPARE(QString("exit"), calledMethods[0].methodName()); | ||
491 | 81 | } | 101 | } |
492 | 82 | 102 | ||
493 | === modified file 'ubuntu-download-manager-tests/test_download_daemon.h' | |||
494 | --- ubuntu-download-manager-tests/test_download_daemon.h 2013-07-24 13:58:02 +0000 | |||
495 | +++ ubuntu-download-manager-tests/test_download_daemon.h 2013-08-21 12:22:01 +0000 | |||
496 | @@ -21,6 +21,7 @@ | |||
497 | 21 | 21 | ||
498 | 22 | #include <QObject> | 22 | #include <QObject> |
499 | 23 | #include <download_daemon.h> | 23 | #include <download_daemon.h> |
500 | 24 | #include "./fake_application.h" | ||
501 | 24 | #include "./fake_dbus_connection.h" | 25 | #include "./fake_dbus_connection.h" |
502 | 25 | #include "./test_runner.h" | 26 | #include "./test_runner.h" |
503 | 26 | 27 | ||
504 | @@ -39,6 +40,7 @@ | |||
505 | 39 | void testStartFailObjectRegister(); | 40 | void testStartFailObjectRegister(); |
506 | 40 | 41 | ||
507 | 41 | private: | 42 | private: |
508 | 43 | FakeApplication* _app; | ||
509 | 42 | FakeDBusConnection* _conn; | 44 | FakeDBusConnection* _conn; |
510 | 43 | DownloadDaemon* _daemon; | 45 | DownloadDaemon* _daemon; |
511 | 44 | }; | 46 | }; |
512 | 45 | 47 | ||
513 | === modified file 'ubuntu-download-manager-tests/ubuntu-download-manager-tests.pro' | |||
514 | --- ubuntu-download-manager-tests/ubuntu-download-manager-tests.pro 2013-07-21 14:30:42 +0000 | |||
515 | +++ ubuntu-download-manager-tests/ubuntu-download-manager-tests.pro 2013-08-21 12:22:01 +0000 | |||
516 | @@ -31,7 +31,8 @@ | |||
517 | 31 | fake_uuid_factory.cpp \ | 31 | fake_uuid_factory.cpp \ |
518 | 32 | fake_system_network_info.cpp \ | 32 | fake_system_network_info.cpp \ |
519 | 33 | fake_process.cpp \ | 33 | fake_process.cpp \ |
521 | 34 | fake_process_factory.cpp | 34 | fake_process_factory.cpp \ |
522 | 35 | fake_application.cpp | ||
523 | 35 | 36 | ||
524 | 36 | HEADERS += \ | 37 | HEADERS += \ |
525 | 37 | fake.h \ | 38 | fake.h \ |
526 | @@ -51,7 +52,8 @@ | |||
527 | 51 | fake_uuid_factory.h \ | 52 | fake_uuid_factory.h \ |
528 | 52 | fake_system_network_info.h \ | 53 | fake_system_network_info.h \ |
529 | 53 | fake_process.h \ | 54 | fake_process.h \ |
531 | 54 | fake_process_factory.h | 55 | fake_process_factory.h \ |
532 | 56 | fake_application.h | ||
533 | 55 | 57 | ||
534 | 56 | LIBS += -L$$OUT_PWD/../libubuntudownloadmanager/ -lubuntudownloadmanager | 58 | LIBS += -L$$OUT_PWD/../libubuntudownloadmanager/ -lubuntudownloadmanager |
535 | 57 | 59 | ||
536 | 58 | 60 | ||
537 | === modified file 'ubuntu-download-manager/main.cpp' | |||
538 | --- ubuntu-download-manager/main.cpp 2013-07-23 16:23:40 +0000 | |||
539 | +++ ubuntu-download-manager/main.cpp 2013-08-21 12:22:01 +0000 | |||
540 | @@ -16,15 +16,16 @@ | |||
541 | 16 | * Boston, MA 02110-1301, USA. | 16 | * Boston, MA 02110-1301, USA. |
542 | 17 | */ | 17 | */ |
543 | 18 | 18 | ||
544 | 19 | #include <QTimer> | ||
545 | 19 | #include <QCoreApplication> | 20 | #include <QCoreApplication> |
546 | 20 | #include <download_daemon.h> | 21 | #include <download_daemon.h> |
547 | 21 | 22 | ||
548 | 22 | int main(int argc, char *argv[]) { | 23 | int main(int argc, char *argv[]) { |
549 | 23 | QCoreApplication a(argc, argv); | 24 | QCoreApplication a(argc, argv); |
550 | 24 | 25 | ||
551 | 25 | // TODO(mandel): deal with the fact that we might be already running | ||
552 | 26 | DownloadDaemon* daemon = new DownloadDaemon(); | 26 | DownloadDaemon* daemon = new DownloadDaemon(); |
554 | 27 | daemon->start(); | 27 | // use a singleShot timer so that we start after exec so that exit works |
555 | 28 | QTimer::singleShot(0, daemon, SLOT(start())); | ||
556 | 28 | 29 | ||
557 | 29 | return a.exec(); | 30 | return a.exec(); |
558 | 30 | } | 31 | } |
FAILED: Continuous integration, rev:99 jenkins. qa.ubuntu. com/job/ ubuntu- download- manager- ci/18/ jenkins. qa.ubuntu. com/job/ ubuntu- download- manager- saucy-amd64- ci/18/console jenkins. qa.ubuntu. com/job/ ubuntu- download- manager- saucy-armhf- ci/9/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ ubuntu- download- manager- ci/18/rebuild
http://