Merge lp:~mandel/ubuntu-download-manager/app-conn-pointers into lp:ubuntu-download-manager
- app-conn-pointers
- Merge into trunk
Proposed by
Manuel de la Peña
Status: | Merged |
---|---|
Approved by: | Manuel de la Peña |
Approved revision: | 211 |
Merged at revision: | 205 |
Proposed branch: | lp:~mandel/ubuntu-download-manager/app-conn-pointers |
Merge into: | lp:ubuntu-download-manager |
Prerequisite: | lp:~mandel/ubuntu-download-manager/apparmor-pointer |
Diff against target: |
684 lines (+192/-156) 10 files modified
libubuntudownloadmanager/downloads/daemon.cpp (+12/-6) libubuntudownloadmanager/downloads/daemon.h (+2/-1) libubuntudownloadmanager/downloads/manager.cpp (+6/-7) libubuntudownloadmanager/downloads/manager.h (+7/-8) ubuntu-download-manager-tests/downloads/test_daemon.cpp (+150/-104) ubuntu-download-manager-tests/downloads/test_daemon.h (+0/-10) ubuntu-download-manager-tests/downloads/test_download_manager.cpp (+9/-12) ubuntu-download-manager-tests/downloads/test_download_manager.h (+1/-2) ubuntu-download-manager-tests/fakes/fake_download_manager.cpp (+3/-4) ubuntu-download-manager-tests/fakes/fake_download_manager.h (+2/-2) |
To merge this branch: | bzr merge lp:~mandel/ubuntu-download-manager/app-conn-pointers |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Michał Karnicki (community) | Approve | ||
Review via email: mp+199279@code.launchpad.net |
Commit message
Use pointers instead of shared pointers to later deal with the mem management better.
Description of the change
Use pointers instead of shared pointers to later deal with the mem management better.
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
Michał Karnicki (karni) wrote : | # |
With the QCOMPARE argument order in mind for the future, +1.
review:
Approve
- 211. By Manuel de la Peña
-
Remove duplicated line.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:211
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 | === modified file 'libubuntudownloadmanager/downloads/daemon.cpp' |
2 | --- libubuntudownloadmanager/downloads/daemon.cpp 2013-11-12 11:27:26 +0000 |
3 | +++ libubuntudownloadmanager/downloads/daemon.cpp 2013-12-17 13:49:30 +0000 |
4 | @@ -44,13 +44,13 @@ |
5 | public: |
6 | explicit DaemonPrivate(Daemon* parent) |
7 | : q_ptr(parent) { |
8 | - _app = QSharedPointer<Application>(new Application()); |
9 | - _conn = QSharedPointer<DBusConnection>(new DBusConnection()); |
10 | + _app = new Application(); |
11 | + _conn = new DBusConnection(); |
12 | _shutDownTimer = new Timer(); |
13 | init(); |
14 | } |
15 | |
16 | - DaemonPrivate(QSharedPointer<Application> app, |
17 | + DaemonPrivate(Application* app, |
18 | DBusConnection* conn, |
19 | Timer* timer, |
20 | Manager* man, |
21 | @@ -65,6 +65,8 @@ |
22 | |
23 | ~DaemonPrivate() { |
24 | // no need to delete the adaptor because the interface is its parent |
25 | + delete _app; |
26 | + delete _conn; |
27 | delete _downInterface; |
28 | delete _shutDownTimer; |
29 | |
30 | @@ -195,9 +197,9 @@ |
31 | bool _isTimeoutEnabled = true; |
32 | bool _stoppable = false; |
33 | QList<QSslCertificate> _certs; |
34 | - QSharedPointer<Application> _app; |
35 | + Application* _app; |
36 | Timer* _shutDownTimer; |
37 | - QSharedPointer<DBusConnection> _conn; |
38 | + DBusConnection* _conn; |
39 | Manager* _downInterface; |
40 | DownloadManagerAdaptor* _downAdaptor; |
41 | Daemon* q_ptr; |
42 | @@ -212,7 +214,7 @@ |
43 | d_ptr(new DaemonPrivate(this)) { |
44 | } |
45 | |
46 | -Daemon::Daemon(QSharedPointer<Application> app, |
47 | +Daemon::Daemon(Application* app, |
48 | DBusConnection* conn, |
49 | Timer* timer, |
50 | Manager* man, |
51 | @@ -221,6 +223,10 @@ |
52 | d_ptr(new DaemonPrivate(app, conn, timer, man, this)) { |
53 | } |
54 | |
55 | +Daemon::~Daemon() { |
56 | + delete d_ptr; |
57 | +} |
58 | + |
59 | bool |
60 | Daemon::isTimeoutEnabled() { |
61 | Q_D(Daemon); |
62 | |
63 | === modified file 'libubuntudownloadmanager/downloads/daemon.h' |
64 | --- libubuntudownloadmanager/downloads/daemon.h 2013-11-08 17:46:32 +0000 |
65 | +++ libubuntudownloadmanager/downloads/daemon.h 2013-12-17 13:49:30 +0000 |
66 | @@ -39,11 +39,12 @@ |
67 | |
68 | public: |
69 | explicit Daemon(QObject *parent = 0); |
70 | - Daemon(QSharedPointer<Application> app, |
71 | + Daemon(Application* app, |
72 | DBusConnection* conn, |
73 | Timer* timer, |
74 | Manager* man, |
75 | QObject *parent = 0); |
76 | + virtual ~Daemon(); |
77 | |
78 | bool isTimeoutEnabled(); |
79 | void enableTimeout(bool enabled); |
80 | |
81 | === modified file 'libubuntudownloadmanager/downloads/manager.cpp' |
82 | --- libubuntudownloadmanager/downloads/manager.cpp 2013-12-17 13:49:30 +0000 |
83 | +++ libubuntudownloadmanager/downloads/manager.cpp 2013-12-17 13:49:30 +0000 |
84 | @@ -28,8 +28,8 @@ |
85 | |
86 | namespace DownloadManager { |
87 | |
88 | -Manager::Manager(QSharedPointer<Application> app, |
89 | - QSharedPointer<DBusConnection> connection, |
90 | +Manager::Manager(Application* app, |
91 | + DBusConnection* connection, |
92 | bool stoppable, |
93 | QObject* parent) |
94 | : QObject(parent), |
95 | @@ -42,15 +42,14 @@ |
96 | _networkInfo = new SystemNetworkInfo(); |
97 | RequestFactory* nam = new RequestFactory(_stoppable); |
98 | _processFactory = new ProcessFactory(); |
99 | - _downloadFactory = QSharedPointer<Factory>( |
100 | - new Factory(_apparmor, _networkInfo, nam, |
101 | - _processFactory)); |
102 | + _downloadFactory = new Factory(_apparmor, _networkInfo, nam, |
103 | + _processFactory); |
104 | _downloadsQueue = new Queue(_networkInfo); |
105 | init(); |
106 | } |
107 | |
108 | -Manager::Manager(QSharedPointer<Application> app, |
109 | - QSharedPointer<DBusConnection> connection, |
110 | +Manager::Manager(Application* app, |
111 | + DBusConnection* connection, |
112 | SystemNetworkInfo* networkInfo, |
113 | Factory* downloadFactory, |
114 | Queue* queue, |
115 | |
116 | === modified file 'libubuntudownloadmanager/downloads/manager.h' |
117 | --- libubuntudownloadmanager/downloads/manager.h 2013-12-17 13:49:30 +0000 |
118 | +++ libubuntudownloadmanager/downloads/manager.h 2013-12-17 13:49:30 +0000 |
119 | @@ -23,7 +23,6 @@ |
120 | #include <QByteArray> |
121 | #include <QtDBus/QDBusObjectPath> |
122 | #include <QtDBus/QDBusContext> |
123 | -#include <QSharedPointer> |
124 | #include <QSslCertificate> |
125 | #include "metatypes.h" |
126 | #include "downloads/download.h" |
127 | @@ -41,12 +40,12 @@ |
128 | Q_OBJECT |
129 | |
130 | public: |
131 | - Manager(QSharedPointer<Application> app, |
132 | - QSharedPointer<DBusConnection> connection, |
133 | + Manager(Application* app, |
134 | + DBusConnection* connection, |
135 | bool stoppable = false, |
136 | QObject *parent = 0); |
137 | - Manager(QSharedPointer<Application> app, |
138 | - QSharedPointer<DBusConnection> connection, |
139 | + Manager(Application* app, |
140 | + DBusConnection* connection, |
141 | SystemNetworkInfo* networkInfo, |
142 | Factory* downloadFactory, |
143 | Queue* queue, |
144 | @@ -98,14 +97,14 @@ |
145 | void onDownloadsChanged(QString); |
146 | |
147 | private: |
148 | - QSharedPointer<Application> _app; |
149 | + Application* _app; |
150 | qulonglong _throttle; |
151 | AppArmor* _apparmor; |
152 | SystemNetworkInfo* _networkInfo; |
153 | ProcessFactory* _processFactory; |
154 | - QSharedPointer<Factory> _downloadFactory; |
155 | + Factory* _downloadFactory; |
156 | Queue* _downloadsQueue; |
157 | - QSharedPointer<DBusConnection> _conn; |
158 | + DBusConnection* _conn; |
159 | bool _stoppable; |
160 | }; |
161 | |
162 | |
163 | === modified file 'ubuntu-download-manager-tests/downloads/test_daemon.cpp' |
164 | --- ubuntu-download-manager-tests/downloads/test_daemon.cpp 2013-11-18 10:13:02 +0000 |
165 | +++ ubuntu-download-manager-tests/downloads/test_daemon.cpp 2013-12-17 13:49:30 +0000 |
166 | @@ -24,37 +24,20 @@ |
167 | } |
168 | |
169 | void |
170 | -TestDaemon::init() { |
171 | - BaseTestCase::init(); |
172 | - _timer = new FakeTimer(); |
173 | - _app = new FakeApplication(); |
174 | - _appPointer = QSharedPointer<Application>(_app); |
175 | - _conn = QSharedPointer<FakeDBusConnection>(new FakeDBusConnection()); |
176 | - _man = new FakeDownloadManager(_appPointer, _conn); |
177 | - _daemon = new Daemon(_appPointer, |
178 | - _conn.data(), _timer, _man, this); |
179 | -} |
180 | - |
181 | -void |
182 | -TestDaemon::cleanup() { |
183 | - BaseTestCase::cleanup(); |
184 | - |
185 | - delete _app; |
186 | - delete _daemon; |
187 | - delete _timer; |
188 | - delete _man; |
189 | -} |
190 | - |
191 | -void |
192 | TestDaemon::testStart() { |
193 | - _conn->setRegisterServiceResult(true); |
194 | - _conn->setRegisterObjectResult(true); |
195 | - _conn->record(); |
196 | - _app->record(); |
197 | - |
198 | - _daemon->start(); |
199 | - |
200 | - QList<MethodData> calledMethods = _conn->calledMethods(); |
201 | + FakeTimer* timer = new FakeTimer(); |
202 | + FakeDBusConnection* conn = new FakeDBusConnection(); |
203 | + conn->setRegisterServiceResult(true); |
204 | + conn->setRegisterObjectResult(true); |
205 | + conn->record(); |
206 | + FakeApplication* app = new FakeApplication(); |
207 | + app->record(); |
208 | + FakeDownloadManager* man = new FakeDownloadManager(app, conn); |
209 | + |
210 | + QScopedPointer<Daemon> daemon(new Daemon(app, conn, timer, man, this)); |
211 | + daemon->start(); |
212 | + |
213 | + QList<MethodData> calledMethods = conn->calledMethods(); |
214 | |
215 | QCOMPARE(2, calledMethods.count()); |
216 | QCOMPARE(QString("registerService"), calledMethods[0].methodName()); |
217 | @@ -67,21 +50,27 @@ |
218 | QCOMPARE(QString("registerObject"), calledMethods[1].methodName()); |
219 | |
220 | // assert exit was NOT called |
221 | - calledMethods = _app->calledMethods(); |
222 | - QCOMPARE(0, calledMethods.count()); |
223 | + calledMethods = app->calledMethods(); |
224 | + QCOMPARE(1, calledMethods.count()); |
225 | + QVERIFY("exit" != calledMethods[0].methodName()); |
226 | } |
227 | |
228 | void |
229 | TestDaemon::testStartPath() { |
230 | QString myPath = "com.canonical.tests"; |
231 | - _conn->setRegisterServiceResult(true); |
232 | - _conn->setRegisterObjectResult(true); |
233 | - _conn->record(); |
234 | - _app->record(); |
235 | - |
236 | - _daemon->start(myPath); |
237 | - |
238 | - QList<MethodData> calledMethods = _conn->calledMethods(); |
239 | + FakeTimer* timer = new FakeTimer(); |
240 | + FakeDBusConnection* conn = new FakeDBusConnection(); |
241 | + conn->setRegisterServiceResult(true); |
242 | + conn->setRegisterObjectResult(true); |
243 | + conn->record(); |
244 | + FakeApplication* app = new FakeApplication(); |
245 | + app->record(); |
246 | + FakeDownloadManager* man = new FakeDownloadManager(app, conn); |
247 | + |
248 | + QScopedPointer<Daemon> daemon(new Daemon(app, conn, timer, man, this)); |
249 | + daemon->start(myPath); |
250 | + |
251 | + QList<MethodData> calledMethods = conn->calledMethods(); |
252 | |
253 | QCOMPARE(2, calledMethods.count()); |
254 | QCOMPARE(QString("registerService"), calledMethods[0].methodName()); |
255 | @@ -93,125 +82,167 @@ |
256 | QCOMPARE(QString("registerObject"), calledMethods[1].methodName()); |
257 | |
258 | // assert exit was NOT called |
259 | - calledMethods = _app->calledMethods(); |
260 | - QCOMPARE(0, calledMethods.count()); |
261 | + calledMethods = app->calledMethods(); |
262 | + QCOMPARE(1, calledMethods.count()); |
263 | + QVERIFY("exit" != calledMethods[0].methodName()); |
264 | } |
265 | |
266 | void |
267 | TestDaemon::testStartFailServiceRegister() { |
268 | - _conn->setRegisterServiceResult(false); |
269 | - _conn->setRegisterObjectResult(true); |
270 | - _conn->record(); |
271 | - _app->record(); |
272 | - |
273 | - _daemon->start(); |
274 | - |
275 | - QList<MethodData> calledMethods = _conn->calledMethods(); |
276 | + FakeTimer* timer = new FakeTimer(); |
277 | + FakeDBusConnection* conn = new FakeDBusConnection(); |
278 | + conn->setRegisterServiceResult(false); |
279 | + conn->setRegisterObjectResult(true); |
280 | + conn->record(); |
281 | + FakeApplication* app = new FakeApplication(); |
282 | + app->record(); |
283 | + FakeDownloadManager* man = new FakeDownloadManager(app, conn); |
284 | + |
285 | + QScopedPointer<Daemon> daemon(new Daemon(app, conn, timer, man, this)); |
286 | + daemon->start(); |
287 | + |
288 | + QList<MethodData> calledMethods = conn->calledMethods(); |
289 | |
290 | QCOMPARE(1, calledMethods.count()); |
291 | QCOMPARE(QString("registerService"), calledMethods[0].methodName()); |
292 | |
293 | // assert exit was called |
294 | - calledMethods = _app->calledMethods(); |
295 | - QCOMPARE(1, calledMethods.count()); |
296 | - QCOMPARE(QString("exit"), calledMethods[0].methodName()); |
297 | + calledMethods = app->calledMethods(); |
298 | + QCOMPARE(2, calledMethods.count()); |
299 | + QCOMPARE(QString("exit"), calledMethods[1].methodName()); |
300 | } |
301 | |
302 | void |
303 | TestDaemon::testStartFailObjectRegister() { |
304 | - _conn->setRegisterServiceResult(true); |
305 | - _conn->setRegisterObjectResult(false); |
306 | - _conn->record(); |
307 | - _app->record(); |
308 | - |
309 | - _daemon->start(); |
310 | - |
311 | - QList<MethodData> calledMethods = _conn->calledMethods(); |
312 | + FakeTimer* timer = new FakeTimer(); |
313 | + FakeDBusConnection* conn = new FakeDBusConnection(); |
314 | + conn->setRegisterServiceResult(true); |
315 | + conn->setRegisterObjectResult(false); |
316 | + conn->record(); |
317 | + FakeApplication* app = new FakeApplication(); |
318 | + app->record(); |
319 | + FakeDownloadManager* man = new FakeDownloadManager(app, conn); |
320 | + |
321 | + QScopedPointer<Daemon> daemon(new Daemon(app, conn, timer, man, this)); |
322 | + daemon->start(); |
323 | + |
324 | + QList<MethodData> calledMethods = conn->calledMethods(); |
325 | |
326 | QCOMPARE(2, calledMethods.count()); |
327 | QCOMPARE(QString("registerService"), calledMethods[0].methodName()); |
328 | QCOMPARE(QString("registerObject"), calledMethods[1].methodName()); |
329 | |
330 | // assert exit was called |
331 | - calledMethods = _app->calledMethods(); |
332 | - QCOMPARE(1, calledMethods.count()); |
333 | - QCOMPARE(QString("exit"), calledMethods[0].methodName()); |
334 | + calledMethods = app->calledMethods(); |
335 | + QCOMPARE(2, calledMethods.count()); |
336 | + QCOMPARE(QString("exit"), calledMethods[1].methodName()); |
337 | } |
338 | |
339 | void |
340 | TestDaemon::testTimerStop() { |
341 | - _timer->setIsActive(true); |
342 | - _timer->record(); |
343 | - _man->emitSizeChaged(1); |
344 | - |
345 | - QList<MethodData> calledMethods = _timer->calledMethods(); |
346 | - QCOMPARE(2, calledMethods.count()); |
347 | - QCOMPARE(QString("isActive"), calledMethods[0].methodName()); |
348 | - QCOMPARE(QString("stop"), calledMethods[1].methodName()); |
349 | + FakeTimer* timer = new FakeTimer(); |
350 | + timer->setIsActive(true); |
351 | + timer->record(); |
352 | + FakeDBusConnection* conn = new FakeDBusConnection(); |
353 | + FakeApplication* app = new FakeApplication(); |
354 | + FakeDownloadManager* man = new FakeDownloadManager(app, conn); |
355 | + QScopedPointer<Daemon> daemon(new Daemon(app, conn, timer, man, this)); |
356 | + |
357 | + man->emitSizeChaged(1); |
358 | + |
359 | + QList<MethodData> calledMethods = timer->calledMethods(); |
360 | + QCOMPARE(3, calledMethods.count()); |
361 | + QCOMPARE(QString("isActive"), calledMethods[1].methodName()); |
362 | + QCOMPARE(QString("stop"), calledMethods[2].methodName()); |
363 | } |
364 | |
365 | void |
366 | TestDaemon::testTimerStart() { |
367 | - _timer->setIsActive(false); |
368 | - _timer->record(); |
369 | - _man->emitSizeChaged(0); |
370 | - |
371 | - QList<MethodData> calledMethods = _timer->calledMethods(); |
372 | - QCOMPARE(2, calledMethods.count()); |
373 | - QCOMPARE(QString("isActive"), calledMethods[0].methodName()); |
374 | - QCOMPARE(QString("start"), calledMethods[1].methodName()); |
375 | + FakeTimer* timer = new FakeTimer(); |
376 | + timer->setIsActive(false); |
377 | + timer->record(); |
378 | + FakeDBusConnection* conn = new FakeDBusConnection(); |
379 | + FakeApplication* app = new FakeApplication(); |
380 | + FakeDownloadManager* man = new FakeDownloadManager(app, conn); |
381 | + QScopedPointer<Daemon> daemon(new Daemon(app, conn, timer, man, this)); |
382 | + |
383 | + man->emitSizeChaged(0); |
384 | + |
385 | + QList<MethodData> calledMethods = timer->calledMethods(); |
386 | + QCOMPARE(3, calledMethods.count()); |
387 | + QCOMPARE(QString("isActive"), calledMethods[1].methodName()); |
388 | + QCOMPARE(QString("start"), calledMethods[2].methodName()); |
389 | } |
390 | |
391 | void |
392 | TestDaemon::testTimeoutExit() { |
393 | - _app->record(); |
394 | + FakeTimer* timer = new FakeTimer(); |
395 | + FakeDBusConnection* conn = new FakeDBusConnection(); |
396 | + FakeApplication* app = new FakeApplication(); |
397 | + FakeDownloadManager* man = new FakeDownloadManager(app, conn); |
398 | + QScopedPointer<Daemon> daemon(new Daemon(app, conn, timer, man, this)); |
399 | + app->record(); |
400 | + |
401 | // emit the timeout signal and assert that exit was called |
402 | - _timer->emitTimeout(); |
403 | + timer->emitTimeout(); |
404 | |
405 | - QList<MethodData> calledMethods = _app->calledMethods(); |
406 | + QList<MethodData> calledMethods = app->calledMethods(); |
407 | QCOMPARE(1, calledMethods.count()); |
408 | QCOMPARE(QString("exit"), calledMethods[0].methodName()); |
409 | } |
410 | |
411 | void |
412 | TestDaemon::testDisableTimeout() { |
413 | - _timer->record(); |
414 | + FakeTimer* timer = new FakeTimer(); |
415 | + timer->record(); |
416 | + FakeDBusConnection* conn = new FakeDBusConnection(); |
417 | + FakeApplication* app = new FakeApplication(); |
418 | + FakeDownloadManager* man = new FakeDownloadManager(app, conn); |
419 | |
420 | // set the args so that we disable the timeout |
421 | QStringList args; |
422 | args << "-disable-timeout"; |
423 | - _app->setArguments(args); |
424 | + app->setArguments(args); |
425 | |
426 | // assert that start is never called |
427 | - _daemon = new Daemon(_appPointer, _conn.data(), _timer, _man, this); |
428 | - QList<MethodData> calledMethods = _timer->calledMethods(); |
429 | + QScopedPointer<Daemon> daemon(new Daemon(app, conn, timer, man, this)); |
430 | + QList<MethodData> calledMethods = timer->calledMethods(); |
431 | QCOMPARE(0, calledMethods.count()); |
432 | } |
433 | |
434 | void |
435 | TestDaemon::testSelfSignedCerts() { |
436 | - _man->record(); |
437 | + FakeTimer* timer = new FakeTimer(); |
438 | + FakeDBusConnection* conn = new FakeDBusConnection(); |
439 | + FakeApplication* app = new FakeApplication(); |
440 | + FakeDownloadManager* man = new FakeDownloadManager(app, conn); |
441 | + man->record(); |
442 | + |
443 | QStringList args; |
444 | args << "-self-signed-certs" << "*.pem"; |
445 | - _app->setArguments(args); |
446 | + app->setArguments(args); |
447 | |
448 | // assert that we set the certs |
449 | - _daemon = new Daemon(_appPointer, _conn.data(), _timer, _man, this); |
450 | - QList<MethodData> calledMethods = _man->calledMethods(); |
451 | + QScopedPointer<Daemon> daemon(new Daemon(app, conn, timer, man, this)); |
452 | + QList<MethodData> calledMethods = man->calledMethods(); |
453 | QCOMPARE(1, calledMethods.count()); |
454 | QCOMPARE(QString("setAcceptedCertificates"), calledMethods[0].methodName()); |
455 | } |
456 | |
457 | void |
458 | TestDaemon::testSelfSignedCertsMissingPath() { |
459 | - _man->record(); |
460 | + FakeTimer* timer = new FakeTimer(); |
461 | + FakeDBusConnection* conn = new FakeDBusConnection(); |
462 | + FakeApplication* app = new FakeApplication(); |
463 | + FakeDownloadManager* man = new FakeDownloadManager(app, conn); |
464 | + man->record(); |
465 | QStringList args; |
466 | args << "-self-signed-certs"; |
467 | - _app->setArguments(args); |
468 | + app->setArguments(args); |
469 | |
470 | // assert that we do not crash |
471 | - _daemon = new Daemon(_appPointer, _conn.data(), _timer, _man, this); |
472 | - QList<MethodData> calledMethods = _man->calledMethods(); |
473 | + QScopedPointer<Daemon> daemon(new Daemon(app, conn, timer, man, this)); |
474 | + QList<MethodData> calledMethods = man->calledMethods(); |
475 | QCOMPARE(1, calledMethods.count()); |
476 | } |
477 | |
478 | @@ -225,10 +256,15 @@ |
479 | |
480 | void |
481 | TestDaemon::testStoppable() { |
482 | + FakeTimer* timer = new FakeTimer(); |
483 | + FakeDBusConnection* conn = new FakeDBusConnection(); |
484 | + FakeApplication* app = new FakeApplication(); |
485 | + FakeDownloadManager* man = new FakeDownloadManager(app, conn); |
486 | + |
487 | QFETCH(bool, enabled); |
488 | - _daemon = new Daemon(_appPointer, _conn.data(), _timer, _man, this); |
489 | - _daemon->setStoppable(enabled); |
490 | - QCOMPARE(_daemon->isStoppable(), enabled); |
491 | + QScopedPointer<Daemon> daemon(new Daemon(app, conn, timer, man, this)); |
492 | + daemon->setStoppable(enabled); |
493 | + QCOMPARE(daemon->isStoppable(), enabled); |
494 | } |
495 | |
496 | void |
497 | @@ -241,19 +277,29 @@ |
498 | |
499 | void |
500 | TestDaemon::testSetTimeout() { |
501 | + FakeTimer* timer = new FakeTimer(); |
502 | + FakeDBusConnection* conn = new FakeDBusConnection(); |
503 | + FakeApplication* app = new FakeApplication(); |
504 | + FakeDownloadManager* man = new FakeDownloadManager(app, conn); |
505 | + |
506 | QFETCH(bool, enabled); |
507 | - _daemon = new Daemon(_appPointer, _conn.data(), _timer, _man, this); |
508 | - _daemon->enableTimeout(enabled); |
509 | - QCOMPARE(enabled, _daemon->isTimeoutEnabled()); |
510 | + QScopedPointer<Daemon> daemon(new Daemon(app, conn, timer, man, this)); |
511 | + daemon->enableTimeout(enabled); |
512 | + QCOMPARE(enabled, daemon->isTimeoutEnabled()); |
513 | } |
514 | |
515 | void |
516 | TestDaemon::testSetSelfSignedSslCerts() { |
517 | + FakeTimer* timer = new FakeTimer(); |
518 | + FakeDBusConnection* conn = new FakeDBusConnection(); |
519 | + FakeApplication* app = new FakeApplication(); |
520 | + FakeDownloadManager* man = new FakeDownloadManager(app, conn); |
521 | + |
522 | QList<QSslCertificate> certs = QSslCertificate::fromPath( |
523 | dataDirectory() + "/*.pem"); |
524 | - _daemon = new Daemon(_appPointer, _conn.data(), _timer, _man, this); |
525 | - _daemon->setSelfSignedCerts(certs); |
526 | - QList<QSslCertificate> daemonCerts = _daemon->selfSignedCerts(); |
527 | + QScopedPointer<Daemon> daemon(new Daemon(app, conn, timer, man, this)); |
528 | + daemon->setSelfSignedCerts(certs); |
529 | + QList<QSslCertificate> daemonCerts = daemon->selfSignedCerts(); |
530 | QCOMPARE(certs.count(), daemonCerts.count()); |
531 | foreach(QSslCertificate cert, certs) { |
532 | QVERIFY(daemonCerts.contains(cert)); |
533 | |
534 | === modified file 'ubuntu-download-manager-tests/downloads/test_daemon.h' |
535 | --- ubuntu-download-manager-tests/downloads/test_daemon.h 2013-11-16 18:46:06 +0000 |
536 | +++ ubuntu-download-manager-tests/downloads/test_daemon.h 2013-12-17 13:49:30 +0000 |
537 | @@ -36,8 +36,6 @@ |
538 | |
539 | private slots: // NOLINT(whitespace/indent) |
540 | |
541 | - void init() override; |
542 | - void cleanup() override; |
543 | void testStart(); |
544 | void testStartPath(); |
545 | void testStartFailServiceRegister(); |
546 | @@ -53,14 +51,6 @@ |
547 | void testSetTimeout_data(); |
548 | void testSetTimeout(); |
549 | void testSetSelfSignedSslCerts(); |
550 | - |
551 | - private: |
552 | - FakeTimer* _timer; |
553 | - FakeApplication* _app; |
554 | - QSharedPointer<Application> _appPointer; |
555 | - FakeDownloadManager* _man; |
556 | - QSharedPointer<FakeDBusConnection> _conn; |
557 | - Daemon* _daemon; |
558 | }; |
559 | |
560 | DECLARE_TEST(TestDaemon) |
561 | |
562 | === modified file 'ubuntu-download-manager-tests/downloads/test_download_manager.cpp' |
563 | --- ubuntu-download-manager-tests/downloads/test_download_manager.cpp 2013-12-17 13:49:30 +0000 |
564 | +++ ubuntu-download-manager-tests/downloads/test_download_manager.cpp 2013-12-17 13:49:30 +0000 |
565 | @@ -32,8 +32,7 @@ |
566 | TestDownloadManager::init() { |
567 | BaseTestCase::init(); |
568 | _app = new FakeApplication(); |
569 | - _appPointer = QSharedPointer<Application>(_app); |
570 | - _conn = QSharedPointer<FakeDBusConnection>(new FakeDBusConnection()); |
571 | + _conn = new FakeDBusConnection(); |
572 | _networkInfo = new FakeSystemNetworkInfo(); |
573 | _q = new FakeDownloadQueue(_networkInfo); |
574 | _uuidFactory = QSharedPointer<FakeUuidFactory>(new FakeUuidFactory()); |
575 | @@ -41,7 +40,7 @@ |
576 | _requestFactory = new FakeRequestFactory(); |
577 | _downloadFactory = new FakeDownloadFactory(_apparmor, _networkInfo, |
578 | _requestFactory, new FakeProcessFactory()); |
579 | - _man = new Manager(_appPointer, _conn, _networkInfo, _downloadFactory, _q); |
580 | + _man = new Manager(_app, _conn, _networkInfo, _downloadFactory, _q); |
581 | } |
582 | |
583 | void |
584 | @@ -255,7 +254,7 @@ |
585 | _downloadFactory = new FakeDownloadFactory(_apparmor, |
586 | new FakeSystemNetworkInfo(), new FakeRequestFactory(), |
587 | new FakeProcessFactory()); |
588 | - _man = new Manager(_appPointer, _conn, _networkInfo, |
589 | + _man = new Manager(_app, _conn, _networkInfo, |
590 | _downloadFactory, _q); |
591 | |
592 | QSignalSpy spy(_man, SIGNAL(downloadCreated(QDBusObjectPath))); |
593 | @@ -302,7 +301,7 @@ |
594 | _downloadFactory = new FakeDownloadFactory(_apparmor, |
595 | new FakeSystemNetworkInfo(), new FakeRequestFactory(), |
596 | new FakeProcessFactory()); |
597 | - _man = new Manager(_appPointer, _conn, _networkInfo, |
598 | + _man = new Manager(_app, _conn, _networkInfo, |
599 | _downloadFactory, _q); |
600 | |
601 | QSignalSpy spy(_man, SIGNAL(downloadCreated(QDBusObjectPath))); |
602 | @@ -380,7 +379,7 @@ |
603 | _downloadFactory = new FakeDownloadFactory(_apparmor, |
604 | new FakeSystemNetworkInfo(), new FakeRequestFactory(), |
605 | new FakeProcessFactory()); |
606 | - _man = new Manager(_appPointer, _conn, _networkInfo, |
607 | + _man = new Manager(_app, _conn, _networkInfo, |
608 | _downloadFactory, _q); |
609 | |
610 | QString firstUrl("http://www.ubuntu.com"), |
611 | @@ -472,9 +471,8 @@ |
612 | void |
613 | TestDownloadManager::testStoppable() { |
614 | _app->record(); |
615 | - _man = new Manager( |
616 | - _appPointer, qSharedPointerCast<DBusConnection>(_conn), |
617 | - _networkInfo, _downloadFactory, _q, true); |
618 | + _man = new Manager(_app, _conn, _networkInfo, |
619 | + _downloadFactory, _q, true); |
620 | _man->exit(); |
621 | QList<MethodData> calledMethods = _app->calledMethods(); |
622 | QCOMPARE(1, calledMethods.count()); |
623 | @@ -483,9 +481,8 @@ |
624 | void |
625 | TestDownloadManager::testNotStoppable() { |
626 | _app->record(); |
627 | - _man = new Manager( |
628 | - _appPointer, qSharedPointerCast<DBusConnection>(_conn), |
629 | - _networkInfo, _downloadFactory, _q, false); |
630 | + _man = new Manager(_app, _conn, _networkInfo, |
631 | + _downloadFactory, _q, false); |
632 | _man->exit(); |
633 | QList<MethodData> calledMethods = _app->calledMethods(); |
634 | QCOMPARE(0, calledMethods.count()); |
635 | |
636 | === modified file 'ubuntu-download-manager-tests/downloads/test_download_manager.h' |
637 | --- ubuntu-download-manager-tests/downloads/test_download_manager.h 2013-11-25 14:46:52 +0000 |
638 | +++ ubuntu-download-manager-tests/downloads/test_download_manager.h 2013-12-17 13:49:30 +0000 |
639 | @@ -71,11 +71,10 @@ |
640 | |
641 | private: |
642 | FakeApplication* _app; |
643 | - QSharedPointer<Application> _appPointer; |
644 | FakeSystemNetworkInfo* _networkInfo; |
645 | FakeRequestFactory* _requestFactory; |
646 | FakeDownloadFactory* _downloadFactory; |
647 | - QSharedPointer<FakeDBusConnection> _conn; |
648 | + FakeDBusConnection* _conn; |
649 | FakeDownloadQueue* _q; |
650 | QSharedPointer<FakeUuidFactory> _uuidFactory; |
651 | FakeAppArmor* _apparmor; |
652 | |
653 | === modified file 'ubuntu-download-manager-tests/fakes/fake_download_manager.cpp' |
654 | --- ubuntu-download-manager-tests/fakes/fake_download_manager.cpp 2013-10-30 11:04:37 +0000 |
655 | +++ ubuntu-download-manager-tests/fakes/fake_download_manager.cpp 2013-12-17 13:49:30 +0000 |
656 | @@ -18,10 +18,9 @@ |
657 | |
658 | #include "./fake_download_manager.h" |
659 | |
660 | -FakeDownloadManager::FakeDownloadManager( |
661 | - QSharedPointer<Application> app, |
662 | - QSharedPointer<DBusConnection> connection, |
663 | - QObject *parent) |
664 | +FakeDownloadManager::FakeDownloadManager(Application* app, |
665 | + DBusConnection* connection, |
666 | + QObject *parent) |
667 | : Manager(app, connection, parent), |
668 | Fake() { |
669 | } |
670 | |
671 | === modified file 'ubuntu-download-manager-tests/fakes/fake_download_manager.h' |
672 | --- ubuntu-download-manager-tests/fakes/fake_download_manager.h 2013-10-30 11:04:37 +0000 |
673 | +++ ubuntu-download-manager-tests/fakes/fake_download_manager.h 2013-12-17 13:49:30 +0000 |
674 | @@ -29,8 +29,8 @@ |
675 | Q_OBJECT |
676 | |
677 | public: |
678 | - explicit FakeDownloadManager(QSharedPointer<Application> app, |
679 | - QSharedPointer<DBusConnection> connection, |
680 | + explicit FakeDownloadManager(Application* app, |
681 | + DBusConnection* connection, |
682 | QObject *parent = 0); |
683 | |
684 | void emitSizeChaged(int size); |
PASSED: Continuous integration, rev:210 jenkins. qa.ubuntu. com/job/ ubuntu- download- manager- ci/261/ jenkins. qa.ubuntu. com/job/ ubuntu- download- manager- trusty- amd64-ci/ 150 jenkins. qa.ubuntu. com/job/ ubuntu- download- manager- trusty- armhf-ci/ 150
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/ubuntu- download- manager- ci/261/ rebuild
http://