Merge lp:~mandel/ubuntu-download-manager/solve-leaks into lp:ubuntu-download-manager

Proposed by Manuel de la Peña
Status: Merged
Approved by: Manuel de la Peña
Approved revision: 229
Merged at revision: 207
Proposed branch: lp:~mandel/ubuntu-download-manager/solve-leaks
Merge into: lp:ubuntu-download-manager
Diff against target: 2097 lines (+416/-361)
28 files modified
libubuntudownloadmanager/downloads/factory.cpp (+9/-0)
libubuntudownloadmanager/downloads/factory.h (+2/-0)
libubuntudownloadmanager/downloads/file_download.cpp (+0/-2)
libubuntudownloadmanager/downloads/group_download.cpp (+0/-2)
libubuntudownloadmanager/downloads/manager.cpp (+2/-2)
libubuntudownloadmanager/downloads/manager.h (+0/-1)
libubuntudownloadmanager/system/system_network_info.cpp (+4/-1)
ubuntu-download-manager-tests/downloads/test_daemon.cpp (+12/-0)
ubuntu-download-manager-tests/downloads/test_daemon.h (+2/-0)
ubuntu-download-manager-tests/downloads/test_download.cpp (+156/-157)
ubuntu-download-manager-tests/downloads/test_download_factory.cpp (+34/-27)
ubuntu-download-manager-tests/downloads/test_download_manager.cpp (+61/-40)
ubuntu-download-manager-tests/downloads/test_download_queue.cpp (+6/-3)
ubuntu-download-manager-tests/downloads/test_download_queue.h (+0/-1)
ubuntu-download-manager-tests/downloads/test_downloads_db.cpp (+13/-15)
ubuntu-download-manager-tests/downloads/test_group_download.cpp (+85/-79)
ubuntu-download-manager-tests/downloads/test_group_download.h (+0/-1)
ubuntu-download-manager-tests/fakes/fake_apparmor.cpp (+7/-7)
ubuntu-download-manager-tests/fakes/fake_application.cpp (+1/-1)
ubuntu-download-manager-tests/fakes/fake_download.cpp (+1/-1)
ubuntu-download-manager-tests/fakes/fake_download_factory.cpp (+5/-5)
ubuntu-download-manager-tests/fakes/fake_file_manager.cpp (+1/-1)
ubuntu-download-manager-tests/fakes/fake_network_reply.cpp (+4/-4)
ubuntu-download-manager-tests/fakes/fake_process.cpp (+3/-3)
ubuntu-download-manager-tests/fakes/fake_process_factory.cpp (+1/-1)
ubuntu-download-manager-tests/fakes/fake_request_factory.cpp (+2/-2)
ubuntu-download-manager-tests/fakes/fake_sm_file_download.cpp (+3/-3)
ubuntu-download-manager-tests/fakes/fake_timer.cpp (+2/-2)
To merge this branch: bzr merge lp:~mandel/ubuntu-download-manager/solve-leaks
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+199426@code.launchpad.net

Commit message

Solve all known mem leaks from the project.

Description of the change

This branch solves all the known memory leaks in the project. in order to run the tests with valgrind do the following:

cd solve-leaks
mkdir build
cd build
qmake ../download-manager.pro
make
LD_LIBRARY_PATH=ubuntu-download-manager-common/:libubuntudownloadmanager/ valgrind --leak-check=full ubuntu-download-manager-tests/ubuntu-download-manager-tests

The above will run the tests and will check for mem leaks, in the result should be that the tests pass and that you have a result similar to the following:

==16989==
==16989== HEAP SUMMARY:
==16989== in use at exit: 34,884 bytes in 646 blocks
==16989== total heap usage: 520,198 allocs, 519,552 frees, 84,422,831 bytes allocated
==16989==
==16989== LEAK SUMMARY:
==16989== definitely lost: 0 bytes in 0 blocks
==16989== indirectly lost: 0 bytes in 0 blocks
==16989== possibly lost: 0 bytes in 0 blocks
==16989== still reachable: 34,884 bytes in 646 blocks
==16989== suppressed: 0 bytes in 0 blocks
==16989== Reachable blocks (those to which a pointer was found) are not shown.
==16989== To see them, rerun with: --leak-check=full --show-reachable=yes
==16989==
==16989== For counts of detected and suppressed errors, rerun with: -v
==16989== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)

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
Roberto Alsina (ralsina) wrote :

+1 it shows a few harmless leaks in T we can ignore.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libubuntudownloadmanager/downloads/factory.cpp'
2--- libubuntudownloadmanager/downloads/factory.cpp 2013-11-28 13:18:20 +0000
3+++ libubuntudownloadmanager/downloads/factory.cpp 2013-12-18 10:06:42 +0000
4@@ -35,12 +35,21 @@
5 */
6
7
8+Factory::Factory(QObject* parent)
9+ : QObject(parent) {
10+ _apparmor = new AppArmor(this);
11+}
12+
13 Factory::Factory(AppArmor* apparmor,
14 QObject* parent)
15 : QObject(parent),
16 _apparmor(apparmor) {
17 }
18
19+Factory::~Factory() {
20+ delete _apparmor;
21+}
22+
23 void
24 Factory::getDownloadPath(const QString& dbusOwner,
25 const QVariantMap& metadata,
26
27=== modified file 'libubuntudownloadmanager/downloads/factory.h'
28--- libubuntudownloadmanager/downloads/factory.h 2013-11-28 13:18:20 +0000
29+++ libubuntudownloadmanager/downloads/factory.h 2013-12-18 10:06:42 +0000
30@@ -34,8 +34,10 @@
31 Q_OBJECT
32
33 public:
34+ explicit Factory(QObject* parent = 0);
35 Factory(AppArmor* apparmor,
36 QObject *parent = 0);
37+ virtual ~Factory();
38
39 // create downloads comming from a dbus call
40
41
42=== modified file 'libubuntudownloadmanager/downloads/file_download.cpp'
43--- libubuntudownloadmanager/downloads/file_download.cpp 2013-12-12 10:57:27 +0000
44+++ libubuntudownloadmanager/downloads/file_download.cpp 2013-12-18 10:06:42 +0000
45@@ -398,8 +398,6 @@
46 this, &FileDownload::onOnlineStateChanged);
47
48 _filePath = getSaveFileName();
49- _reply = NULL;
50- _currentData = NULL;
51
52 // ensure that the download is valid
53 if (!_url.isValid()) {
54
55=== modified file 'libubuntudownloadmanager/downloads/group_download.cpp'
56--- libubuntudownloadmanager/downloads/group_download.cpp 2013-11-28 11:46:34 +0000
57+++ libubuntudownloadmanager/downloads/group_download.cpp 2013-12-18 10:06:42 +0000
58@@ -299,5 +299,3 @@
59 } // DownloadManager
60
61 } // Ubuntu
62-
63-#include "moc_group_download.cpp"
64
65=== modified file 'libubuntudownloadmanager/downloads/manager.cpp'
66--- libubuntudownloadmanager/downloads/manager.cpp 2013-11-29 11:42:01 +0000
67+++ libubuntudownloadmanager/downloads/manager.cpp 2013-12-18 10:06:42 +0000
68@@ -37,9 +37,8 @@
69 _throttle(0),
70 _stoppable(stoppable) {
71 _conn = connection;
72- _apparmor = new AppArmor(connection);
73 RequestFactory::setStoppable(_stoppable);
74- _downloadFactory = new Factory(_apparmor);
75+ _downloadFactory = new Factory(this);
76 _downloadsQueue = new Queue(this);
77 init();
78 }
79@@ -63,6 +62,7 @@
80
81 Manager::~Manager() {
82 delete _downloadsQueue;
83+ delete _downloadFactory;
84 }
85
86 void
87
88=== modified file 'libubuntudownloadmanager/downloads/manager.h'
89--- libubuntudownloadmanager/downloads/manager.h 2013-11-29 11:32:39 +0000
90+++ libubuntudownloadmanager/downloads/manager.h 2013-12-18 10:06:42 +0000
91@@ -97,7 +97,6 @@
92 private:
93 Application* _app;
94 qulonglong _throttle;
95- AppArmor* _apparmor;
96 Factory* _downloadFactory;
97 Queue* _downloadsQueue;
98 DBusConnection* _conn;
99
100=== modified file 'libubuntudownloadmanager/system/system_network_info.cpp'
101--- libubuntudownloadmanager/system/system_network_info.cpp 2013-11-27 16:00:50 +0000
102+++ libubuntudownloadmanager/system/system_network_info.cpp 2013-12-18 10:06:42 +0000
103@@ -105,9 +105,12 @@
104 SystemNetworkInfo*
105 SystemNetworkInfo::instance() {
106 if(_instance == NULL) {
107+ qDebug() << "Instance is null";
108 _mutex.lock();
109- if(_instance == NULL)
110+ if(_instance == NULL){
111+ qDebug() << "Create new instance";
112 _instance = new SystemNetworkInfo();
113+ }
114 _mutex.unlock();
115 }
116 return _instance;
117
118=== modified file 'ubuntu-download-manager-tests/downloads/test_daemon.cpp'
119--- ubuntu-download-manager-tests/downloads/test_daemon.cpp 2013-12-17 13:42:50 +0000
120+++ ubuntu-download-manager-tests/downloads/test_daemon.cpp 2013-12-18 10:06:42 +0000
121@@ -24,6 +24,18 @@
122 }
123
124 void
125+TestDaemon::init() {
126+ BaseTestCase::init();
127+}
128+
129+void
130+TestDaemon::cleanup() {
131+ BaseTestCase::cleanup();
132+ SystemNetworkInfo::deleteInstance();
133+ RequestFactory::deleteInstance();
134+}
135+
136+void
137 TestDaemon::testStart() {
138 FakeTimer* timer = new FakeTimer();
139 FakeDBusConnection* conn = new FakeDBusConnection();
140
141=== modified file 'ubuntu-download-manager-tests/downloads/test_daemon.h'
142--- ubuntu-download-manager-tests/downloads/test_daemon.h 2013-11-29 15:47:01 +0000
143+++ ubuntu-download-manager-tests/downloads/test_daemon.h 2013-12-18 10:06:42 +0000
144@@ -36,6 +36,8 @@
145
146 private slots: // NOLINT(whitespace/indent)
147
148+ void init() override;
149+ void cleanup() override;
150 void testStart();
151 void testStartPath();
152 void testStartFailServiceRegister();
153
154=== modified file 'ubuntu-download-manager-tests/downloads/test_download.cpp'
155--- ubuntu-download-manager-tests/downloads/test_download.cpp 2013-11-27 13:29:03 +0000
156+++ ubuntu-download-manager-tests/downloads/test_download.cpp 2013-12-18 10:06:42 +0000
157@@ -55,9 +55,9 @@
158 TestDownload::cleanup() {
159 BaseTestCase::cleanup();
160
161- delete _networkInfo;
162- delete _reqFactory;
163- delete _processFactory;
164+ SystemNetworkInfo::deleteInstance();
165+ RequestFactory::deleteInstance();
166+ ProcessFactory::deleteInstance();
167 }
168
169 void
170@@ -82,8 +82,8 @@
171 QFETCH(QString, path);
172 QFETCH(QUrl, url);
173
174- FileDownload* download = new FileDownload(id, path, _isConfined,
175- _rootPath, url, _metadata, _headers);
176+ QScopedPointer<FileDownload> download(new FileDownload(id, path, _isConfined,
177+ _rootPath, url, _metadata, _headers));
178
179 // assert that we did set the intial state correctly
180 // gets for internal state
181@@ -126,8 +126,8 @@
182 QFETCH(QString, hash);
183 QFETCH(QString, algo);
184
185- FileDownload* download = new FileDownload(id, path, _isConfined,
186- _rootPath, url, hash, algo, _metadata, _headers);
187+ QScopedPointer<FileDownload> download(new FileDownload(id, path, _isConfined,
188+ _rootPath, url, hash, algo, _metadata, _headers));
189
190 QCOMPARE(download->downloadId(), id);
191 QCOMPARE(download->path(), path);
192@@ -154,8 +154,8 @@
193 TestDownload::testPath() {
194 // create an app download and assert that the returned data is correct
195 QFETCH(QString, path);
196- FileDownload* download = new FileDownload(_id, path, _isConfined,
197- _rootPath, _url, _metadata, _headers);
198+ QScopedPointer<FileDownload> download(new FileDownload(_id, path, _isConfined,
199+ _rootPath, _url, _metadata, _headers));
200 QCOMPARE(download->path(), path);
201 }
202
203@@ -174,8 +174,8 @@
204 TestDownload::testUrl() {
205 // create an app download and assert that the returned data is correct
206 QFETCH(QUrl, url);
207- FileDownload* download = new FileDownload(_id, _path, _isConfined,
208- _rootPath, url, _metadata, _headers);
209+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
210+ _rootPath, url, _metadata, _headers));
211 QCOMPARE(download->url(), url);
212 }
213
214@@ -198,9 +198,9 @@
215 QFETCH(qulonglong, total);
216
217 _reqFactory->record();
218- FileDownload* download = new FileDownload(_id, _path, _isConfined,
219- _rootPath, _url, _metadata, _headers);
220- QSignalSpy spy(download , SIGNAL(progress(qulonglong, qulonglong)));
221+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
222+ _rootPath, _url, _metadata, _headers));
223+ QSignalSpy spy(download.data(), SIGNAL(progress(qulonglong, qulonglong)));
224
225 // start the download so that we do have access to the reply
226 download->start(); // change state
227@@ -241,9 +241,9 @@
228 QFETCH(int, total);
229
230 _reqFactory->record();
231- FileDownload* download = new FileDownload(_id, _path, _isConfined,
232- _rootPath, _url, _metadata, _headers);
233- QSignalSpy spy(download , SIGNAL(progress(qulonglong, qulonglong)));
234+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
235+ _rootPath, _url, _metadata, _headers));
236+ QSignalSpy spy(download.data(), SIGNAL(progress(qulonglong, qulonglong)));
237
238 // start the download so that we do have access to the reply
239 download->start(); // change state
240@@ -272,9 +272,9 @@
241 // assert that the total size is just set once
242 // by emitting two signals with diff sizes
243 _reqFactory->record();
244- FileDownload* download = new FileDownload(_id, _path, _isConfined,
245- _rootPath, _url, _metadata, _headers);
246- QSignalSpy spy(download , SIGNAL(progress(qulonglong, qulonglong)));
247+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
248+ _rootPath, _url, _metadata, _headers));
249+ QSignalSpy spy(download.data(), SIGNAL(progress(qulonglong, qulonglong)));
250
251 // start the download so that we do have access to the reply
252 download->start(); // change state
253@@ -293,8 +293,8 @@
254
255 void
256 TestDownload::testTotalSizeNoProgress() {
257- FileDownload* download = new FileDownload(_id, _path, _isConfined,
258- _rootPath, _url, _metadata, _headers);
259+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
260+ _rootPath, _url, _metadata, _headers));
261 QCOMPARE(0ULL, download->totalSize());
262 }
263
264@@ -311,8 +311,8 @@
265 void
266 TestDownload::testSetThrottleNoReply() {
267 QFETCH(qulonglong, speed);
268- FileDownload* download = new FileDownload(_id, _path, _isConfined,
269- _rootPath, _url, _metadata, _headers);
270+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
271+ _rootPath, _url, _metadata, _headers));
272 download->setThrottle(speed);
273 QCOMPARE(speed, download->throttle());
274 }
275@@ -332,8 +332,8 @@
276 QFETCH(uint, speed);
277
278 _reqFactory->record();
279- FileDownload* download = new FileDownload(_id, _path, _isConfined,
280- _rootPath, _url, _metadata, _headers);
281+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
282+ _rootPath, _url, _metadata, _headers));
283 download->setThrottle(speed);
284
285 download->start(); // change state
286@@ -363,10 +363,10 @@
287 TestDownload::testSetGSMDownloadSame() {
288 QFETCH(bool, value);
289
290- FileDownload* download = new FileDownload(_id, _path, _isConfined,
291- _rootPath, _url, _metadata, _headers);
292+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
293+ _rootPath, _url, _metadata, _headers));
294 download->allowGSMDownload(value);
295- QSignalSpy spy(download , SIGNAL(stateChanged()));
296+ QSignalSpy spy(download.data(), SIGNAL(stateChanged()));
297
298 download->allowGSMDownload(value);
299 QCOMPARE(spy.count(), 0);
300@@ -386,10 +386,10 @@
301 QFETCH(bool, oldValue);
302 QFETCH(bool, newValue);
303
304- FileDownload* download = new FileDownload(_id, _path, _isConfined,
305- _rootPath, _url, _metadata, _headers);
306+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
307+ _rootPath, _url, _metadata, _headers));
308 download->allowGSMDownload(oldValue);
309- QSignalSpy spy(download , SIGNAL(stateChanged()));
310+ QSignalSpy spy(download.data(), SIGNAL(stateChanged()));
311
312 download->allowGSMDownload(newValue);
313 QCOMPARE(spy.count(), 1);
314@@ -429,8 +429,8 @@
315 _networkInfo->setMode(mode.value<QNetworkInfo::NetworkMode>());
316 _networkInfo->record();
317
318- FileDownload* download = new FileDownload(_id, _path, _isConfined,
319- _rootPath, _url, _metadata, _headers);
320+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
321+ _rootPath, _url, _metadata, _headers));
322 download->allowGSMDownload(true);
323 QVERIFY(download->canDownload());
324 QList<MethodData> calledMethods = _networkInfo->calledMethods();
325@@ -475,8 +475,8 @@
326 _networkInfo->setMode(mode.value<QNetworkInfo::NetworkMode>());
327 _networkInfo->record();
328
329- FileDownload* download = new FileDownload(_id, _path, _isConfined,
330- _rootPath, _url, _metadata, _headers);
331+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
332+ _rootPath, _url, _metadata, _headers));
333 download->allowGSMDownload(false);
334
335 QCOMPARE(result, download->canDownload());
336@@ -486,9 +486,9 @@
337
338 void
339 TestDownload::testCancel() {
340- FileDownload* download = new FileDownload(_id, _path, _isConfined,
341- _rootPath, _url, _metadata, _headers);
342- QSignalSpy spy(download , SIGNAL(stateChanged()));
343+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
344+ _rootPath, _url, _metadata, _headers));
345+ QSignalSpy spy(download.data(), SIGNAL(stateChanged()));
346 download->cancel();
347
348 QCOMPARE(spy.count(), 1);
349@@ -497,9 +497,9 @@
350
351 void
352 TestDownload::testPause() {
353- FileDownload* download = new FileDownload(_id, _path, _isConfined,
354- _rootPath, _url, _metadata, _headers);
355- QSignalSpy spy(download , SIGNAL(stateChanged()));
356+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
357+ _rootPath, _url, _metadata, _headers));
358+ QSignalSpy spy(download.data(), SIGNAL(stateChanged()));
359 download->pause();
360
361 QCOMPARE(spy.count(), 1);
362@@ -508,9 +508,9 @@
363
364 void
365 TestDownload::testResume() {
366- FileDownload* download = new FileDownload(_id, _path, _isConfined,
367- _rootPath, _url, _metadata, _headers);
368- QSignalSpy spy(download , SIGNAL(stateChanged()));
369+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
370+ _rootPath, _url, _metadata, _headers));
371+ QSignalSpy spy(download.data(), SIGNAL(stateChanged()));
372 download->resume();
373
374 QCOMPARE(spy.count(), 1);
375@@ -519,9 +519,9 @@
376
377 void
378 TestDownload::testStart() {
379- FileDownload* download = new FileDownload(_id, _path, _isConfined,
380- _rootPath, _url, _metadata, _headers);
381- QSignalSpy spy(download , SIGNAL(stateChanged()));
382+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
383+ _rootPath, _url, _metadata, _headers));
384+ QSignalSpy spy(download.data(), SIGNAL(stateChanged()));
385 download->start();
386
387 QCOMPARE(spy.count(), 1);
388@@ -533,9 +533,9 @@
389 // tell the fake nam to record so that we can access the reply
390
391 _reqFactory->record();
392- FileDownload* download = new FileDownload(_id, _path, _isConfined,
393- _rootPath, _url, _metadata, _headers);
394- QSignalSpy spy(download,
395+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
396+ _rootPath, _url, _metadata, _headers));
397+ QSignalSpy spy(download.data(),
398 SIGNAL(canceled(bool))); // NOLINT(readability/function)
399
400 download->start(); // change state
401@@ -564,9 +564,9 @@
402 void
403 TestDownload::testCancelDownloadNotStarted() {
404 _reqFactory->record();
405- FileDownload* download = new FileDownload(_id, _path, _isConfined,
406- _rootPath, _url, _metadata, _headers);
407- QSignalSpy spy(download,
408+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
409+ _rootPath, _url, _metadata, _headers));
410+ QSignalSpy spy(download.data(),
411 SIGNAL(canceled(bool))); // NOLINT(readability/function)
412
413 download->cancel(); // change state
414@@ -584,9 +584,9 @@
415 void
416 TestDownload::testPauseDownload() {
417 _reqFactory->record();
418- FileDownload* download = new FileDownload(_id, _path, _isConfined,
419- _rootPath, _url, _metadata, _headers);
420- QSignalSpy spy(download,
421+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
422+ _rootPath, _url, _metadata, _headers));
423+ QSignalSpy spy(download.data(),
424 SIGNAL(paused(bool))); // NOLINT(readability/function)
425
426 download->start(); // change state
427@@ -619,9 +619,9 @@
428
429 void
430 TestDownload::testPauseDownloadNotStarted() {
431- FileDownload* download = new FileDownload(_id, _path, _isConfined,
432- _rootPath, _url, _metadata, _headers);
433- QSignalSpy spy(download,
434+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
435+ _rootPath, _url, _metadata, _headers));
436+ QSignalSpy spy(download.data(),
437 SIGNAL(paused(bool))); // NOLINT(readability/function)
438
439 download->pause();
440@@ -635,9 +635,9 @@
441
442 void
443 TestDownload::testResumeRunning() {
444- FileDownload* download = new FileDownload(_id, _path, _isConfined,
445- _rootPath, _url, _metadata, _headers);
446- QSignalSpy spy(download,
447+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
448+ _rootPath, _url, _metadata, _headers));
449+ QSignalSpy spy(download.data(),
450 SIGNAL(resumed(bool))); // NOLINT(readability/function)
451
452 download->start();
453@@ -654,9 +654,9 @@
454 void
455 TestDownload::testResumeDownload() {
456 _reqFactory->record();
457- FileDownload* download = new FileDownload(_id, _path, _isConfined,
458- _rootPath, _url, _metadata, _headers);
459- QSignalSpy spy(download , SIGNAL(paused(bool result)));
460+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
461+ _rootPath, _url, _metadata, _headers));
462+ QSignalSpy spy(download.data(), SIGNAL(paused(bool result)));
463
464 download->start(); // change state
465 download->startDownload();
466@@ -692,9 +692,9 @@
467 void
468 TestDownload::testStartDownload() {
469 _reqFactory->record();
470- FileDownload* download = new FileDownload(_id, _path, _isConfined,
471- _rootPath, _url, _metadata, _headers);
472- QSignalSpy spy(download,
473+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
474+ _rootPath, _url, _metadata, _headers));
475+ QSignalSpy spy(download.data(),
476 SIGNAL(started(bool))); // NOLINT(readability/function)
477
478 download->start(); // change state
479@@ -713,9 +713,9 @@
480 void
481 TestDownload::testStartDownloadAlreadyStarted() {
482 _reqFactory->record();
483- FileDownload* download = new FileDownload(_id, _path, _isConfined,
484- _rootPath, _url, _metadata, _headers);
485- QSignalSpy spy(download,
486+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
487+ _rootPath, _url, _metadata, _headers));
488+ QSignalSpy spy(download.data(),
489 SIGNAL(started(bool))); // NOLINT(readability/function)
490
491 download->start(); // change state
492@@ -736,10 +736,10 @@
493 void
494 TestDownload::testOnSuccessNoHash() {
495 _reqFactory->record();
496- FileDownload* download = new FileDownload(_id, _path, _isConfined,
497- _rootPath, _url, _metadata, _headers);
498- QSignalSpy spy(download , SIGNAL(finished(QString)));
499- QSignalSpy processingSpy(download, SIGNAL(processing(QString)));
500+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
501+ _rootPath, _url, _metadata, _headers));
502+ QSignalSpy spy(download.data(), SIGNAL(finished(QString)));
503+ QSignalSpy processingSpy(download.data(), SIGNAL(processing(QString)));
504
505 download->start(); // change state
506 download->startDownload();
507@@ -759,11 +759,10 @@
508 void
509 TestDownload::testOnSuccessHashError() {
510 _reqFactory->record();
511- FileDownload* download = new FileDownload(_id, _path, _isConfined,
512- _rootPath, _url,
513- "imposible-hash-is-not-hex", _algo, _metadata, _headers);
514- QSignalSpy errorSpy(download , SIGNAL(error(QString)));
515- QSignalSpy processingSpy(download, SIGNAL(processing(QString)));
516+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
517+ _rootPath, _url, "imposible-hash-is-not-hex", _algo, _metadata, _headers));
518+ QSignalSpy errorSpy(download.data(), SIGNAL(error(QString)));
519+ QSignalSpy processingSpy(download.data(), SIGNAL(processing(QString)));
520
521 download->start(); // change state
522 download->startDownload();
523@@ -789,7 +788,7 @@
524
525 // create the spy here else we will register other not interesting
526 // signals
527- QSignalSpy stateSpy(download , SIGNAL(stateChanged()));
528+ QSignalSpy stateSpy(download.data(), SIGNAL(stateChanged()));
529 emit reply->finished();
530
531 // the has is a random string so we should get an error signal
532@@ -827,10 +826,10 @@
533 QFETCH(QString, hash);
534
535 _reqFactory->record();
536- FileDownload* download = new FileDownload(_id, _path, _isConfined,
537- _rootPath, _url, hash, _algo, _metadata, _headers);
538- QSignalSpy spy(download , SIGNAL(finished(QString)));
539- QSignalSpy processingSpy(download, SIGNAL(processing(QString)));
540+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
541+ _rootPath, _url, hash, _algo, _metadata, _headers));
542+ QSignalSpy spy(download.data(), SIGNAL(finished(QString)));
543+ QSignalSpy processingSpy(download.data(), SIGNAL(processing(QString)));
544
545 download->start(); // change state
546 download->startDownload();
547@@ -864,9 +863,9 @@
548 void
549 TestDownload::testOnHttpError() {
550 _reqFactory->record();
551- FileDownload* download = new FileDownload(_id, _path, _isConfined,
552- _rootPath, _url, _metadata, _headers);
553- QSignalSpy spy(download , SIGNAL(error(QString)));
554+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
555+ _rootPath, _url, _metadata, _headers));
556+ QSignalSpy spy(download.data(), SIGNAL(error(QString)));
557
558 download->start(); // change state
559 download->startDownload();
560@@ -911,8 +910,8 @@
561 TestDownload::testSetRawHeadersStart() {
562 QFETCH(StringMap, headers);
563 _reqFactory->record();
564- FileDownload* download = new FileDownload(_id, _path, _isConfined,
565- _rootPath, _url, _metadata, headers);
566+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
567+ _rootPath, _url, _metadata, headers));
568
569 download->start(); // change state
570 download->startDownload();
571@@ -964,8 +963,8 @@
572 // similar to the previous test but we want to ensure that range is not set
573 QFETCH(StringMap, headers);
574 _reqFactory->record();
575- FileDownload* download = new FileDownload(_id, _path, _isConfined,
576- _rootPath, _url, _metadata, headers);
577+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
578+ _rootPath, _url, _metadata, headers));
579
580 download->start(); // change state
581 download->startDownload();
582@@ -1012,9 +1011,9 @@
583 QFETCH(StringMap, headers);
584
585 _reqFactory->record();
586- FileDownload* download = new FileDownload(_id, _path, _isConfined,
587- _rootPath, _url, _metadata, headers);
588- QSignalSpy spy(download , SIGNAL(paused(bool result)));
589+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
590+ _rootPath, _url, _metadata, headers));
591+ QSignalSpy spy(download.data(), SIGNAL(paused(bool result)));
592
593 download->start(); // change state
594 download->startDownload();
595@@ -1089,9 +1088,9 @@
596 QFETCH(StringMap, headers);
597
598 _reqFactory->record();
599- FileDownload* download = new FileDownload(_id, _path, _isConfined,
600- _rootPath, _url, _metadata, headers);
601- QSignalSpy spy(download , SIGNAL(paused(bool result)));
602+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
603+ _rootPath, _url, _metadata, headers));
604+ QSignalSpy spy(download.data(), SIGNAL(paused(bool result)));
605
606 download->start(); // change state
607 download->startDownload();
608@@ -1155,9 +1154,9 @@
609
610 _processFactory->record();
611 _reqFactory->record();
612- FileDownload* download = new FileDownload(_id, _path, _isConfined,
613- _rootPath, _url, metadata, _headers);
614- QSignalSpy processingSpy(download, SIGNAL(processing(QString)));
615+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
616+ _rootPath, _url, metadata, _headers));
617+ QSignalSpy processingSpy(download.data(), SIGNAL(processing(QString)));
618
619 download->start(); // change state
620 download->startDownload();
621@@ -1218,9 +1217,9 @@
622
623 _processFactory->record();
624 _reqFactory->record();
625- FileDownload* download = new FileDownload(_id, _path, _isConfined,
626- _rootPath, _url, metadata, _headers);
627- QSignalSpy processingSpy(download, SIGNAL(processing(QString)));
628+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
629+ _rootPath, _url, metadata, _headers));
630+ QSignalSpy processingSpy(download.data(), SIGNAL(processing(QString)));
631
632 download->start(); // change state
633 download->startDownload();
634@@ -1281,9 +1280,9 @@
635
636 _processFactory->record();
637 _reqFactory->record();
638- FileDownload* download = new FileDownload(_id, _path, _isConfined,
639- _rootPath, _url, metadata, _headers);
640- QSignalSpy processingSpy(download, SIGNAL(processing(QString)));
641+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
642+ _rootPath, _url, metadata, _headers));
643+ QSignalSpy processingSpy(download.data(), SIGNAL(processing(QString)));
644
645 download->start(); // change state
646 download->startDownload();
647@@ -1323,10 +1322,10 @@
648
649 _processFactory->record();
650 _reqFactory->record();
651- FileDownload* download = new FileDownload(_id, _path, _isConfined,
652- _rootPath, _url, metadata, _headers);
653- QSignalSpy spy(download , SIGNAL(finished(QString)));
654- QSignalSpy processingSpy(download, SIGNAL(processing(QString)));
655+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
656+ _rootPath, _url, metadata, _headers));
657+ QSignalSpy spy(download.data(), SIGNAL(finished(QString)));
658+ QSignalSpy processingSpy(download.data(), SIGNAL(processing(QString)));
659
660 download->start(); // change state
661 download->startDownload();
662@@ -1360,10 +1359,10 @@
663
664 _processFactory->record();
665 _reqFactory->record();
666- FileDownload* download = new FileDownload(_id, _path, _isConfined,
667- _rootPath, _url, metadata, _headers);
668- QSignalSpy spy(download , SIGNAL(error(QString)));
669- QSignalSpy processingSpy(download, SIGNAL(processing(QString)));
670+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
671+ _rootPath, _url, metadata, _headers));
672+ QSignalSpy spy(download.data(), SIGNAL(error(QString)));
673+ QSignalSpy processingSpy(download.data(), SIGNAL(processing(QString)));
674
675 download->start(); // change state
676 download->startDownload();
677@@ -1397,10 +1396,10 @@
678
679 _processFactory->record();
680 _reqFactory->record();
681- FileDownload* download = new FileDownload(_id, _path, _isConfined,
682- _rootPath, _url, metadata, _headers);
683- QSignalSpy spy(download , SIGNAL(error(QString)));
684- QSignalSpy processingSpy(download, SIGNAL(processing(QString)));
685+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
686+ _rootPath, _url, metadata, _headers));
687+ QSignalSpy spy(download.data(), SIGNAL(error(QString)));
688+ QSignalSpy processingSpy(download.data(), SIGNAL(processing(QString)));
689
690 download->start(); // change state
691 download->startDownload();
692@@ -1435,12 +1434,12 @@
693
694 _processFactory->record();
695 _reqFactory->record();
696- FileDownload* download = new FileDownload(_id, _path, _isConfined,
697- _rootPath, _url, metadata, _headers);
698+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
699+ _rootPath, _url, metadata, _headers));
700
701 // write something in the expected file
702 QString fileName = download->filePath();
703- QFile* file = new QFile(fileName);
704+ QScopedPointer<QFile> file(new QFile(fileName));
705 file->open(QIODevice::ReadWrite | QFile::Append);
706 file->write("my data goes here");
707 file->close();
708@@ -1495,8 +1494,8 @@
709 TestDownload::testSetRawHeaderAcceptEncoding() {
710 QFETCH(StringMap, headers);
711 _reqFactory->record();
712- FileDownload* download = new FileDownload(_id, _path, _isConfined,
713- _rootPath, _url, _metadata, headers);
714+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
715+ _rootPath, _url, _metadata, headers));
716
717 download->start(); // change state
718 download->startDownload();
719@@ -1517,13 +1516,13 @@
720 errors.append(QSslError(QSslError::CertificateExpired));
721
722 _reqFactory->record();
723- FileDownload* download = new FileDownload(_id, _path, _isConfined,
724- _rootPath, _url, _metadata, _headers);
725+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
726+ _rootPath, _url, _metadata, _headers));
727
728 download->start(); // change state
729 download->startDownload();
730
731- QSignalSpy stateSpy(download , SIGNAL(stateChanged()));
732+ QSignalSpy stateSpy(download.data(), SIGNAL(stateChanged()));
733
734 // we need to set the data before we pause!!!
735 QList<MethodData> calledMethods = _reqFactory->calledMethods();
736@@ -1546,13 +1545,13 @@
737 errors.append(QSslError(QSslError::CertificateExpired));
738
739 _reqFactory->record();
740- FileDownload* download = new FileDownload(_id, _path, _isConfined,
741- _rootPath, _url, _metadata, _headers);
742+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
743+ _rootPath, _url, _metadata, _headers));
744
745 download->start(); // change state
746 download->startDownload();
747
748- QSignalSpy stateSpy(download , SIGNAL(stateChanged()));
749+ QSignalSpy stateSpy(download.data(), SIGNAL(stateChanged()));
750
751 // we need to set the data before we pause!!!
752 QList<MethodData> calledMethods = _reqFactory->calledMethods();
753@@ -1577,8 +1576,8 @@
754 QString localPath = "/home/my/local/path";
755 metadata["local-path"] = localPath;
756
757- FileDownload* download = new FileDownload(_id, _path, true,
758- _rootPath, _url, metadata, _headers);
759+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, true,
760+ _rootPath, _url, metadata, _headers));
761
762 qDebug() << download->filePath();
763 QVERIFY(download->filePath() != localPath);
764@@ -1590,8 +1589,8 @@
765 QString localPath = "/home/my/local/path";
766 metadata["local-path"] = localPath;
767
768- FileDownload* download = new FileDownload(_id, _path, false,
769- _rootPath, _url, metadata, _headers);
770+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, false,
771+ _rootPath, _url, metadata, _headers));
772
773 qDebug() << download->filePath();
774 QCOMPARE(download->filePath(), localPath);
775@@ -1599,24 +1598,24 @@
776
777 void
778 TestDownload::testInvalidUrl() {
779- FileDownload* download = new FileDownload(_id, _path, _isConfined,
780- _rootPath, QUrl(), _metadata, _headers);
781+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
782+ _rootPath, QUrl(), _metadata, _headers));
783
784 QVERIFY(!download->isValid());
785 }
786
787 void
788 TestDownload::testValidUrl() {
789- FileDownload* download = new FileDownload(_id, _path, _isConfined,
790- _rootPath, _url, _metadata, _headers);
791+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
792+ _rootPath, _url, _metadata, _headers));
793
794 QVERIFY(download->isValid());
795 }
796
797 void
798 TestDownload::testInvalidHashAlgorithm() {
799- FileDownload* download = new FileDownload(_id, _path, _isConfined,
800- _rootPath, _url, "hash", "not-valid-algo", _metadata, _headers);
801+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
802+ _rootPath, _url, "hash", "not-valid-algo", _metadata, _headers));
803 QVERIFY(!download->isValid());
804 }
805
806@@ -1636,8 +1635,8 @@
807 void
808 TestDownload::testValidHashAlgorithm() {
809 QFETCH(QString, algo);
810- FileDownload* download = new FileDownload(_id, _path, _isConfined,
811- _rootPath, _url, "hash", algo, _metadata, _headers);
812+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
813+ _rootPath, _url, "hash", algo, _metadata, _headers));
814 QVERIFY(download->isValid());
815 }
816
817@@ -1645,7 +1644,7 @@
818 TestDownload::testInvalidFilePresent() {
819 // create a file so that we get an error
820 QString filePath = testDirectory() + QDir::separator() + "test_file.jpg";
821- QFile* file = new QFile(filePath);
822+ QScopedPointer<QFile> file(new QFile(filePath));
823 file->open(QIODevice::ReadWrite | QFile::Append);
824 file->write("data data data!");
825 file->close();
826@@ -1653,8 +1652,8 @@
827 QVariantMap metadata;
828 metadata["local-path"] = filePath;
829
830- FileDownload* download = new FileDownload(_id, _path, false,
831- _rootPath, _url, metadata, _headers);
832+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, false,
833+ _rootPath, _url, metadata, _headers));
834 QVERIFY(!download->isValid());
835 }
836
837@@ -1665,8 +1664,8 @@
838 QVariantMap metadata;
839 metadata["local-path"] = filePath;
840
841- FileDownload* download = new FileDownload(_id, _path, false,
842- _rootPath, _url, metadata, _headers);
843+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, false,
844+ _rootPath, _url, metadata, _headers));
845 QVERIFY(download->isValid());
846 }
847
848@@ -1675,20 +1674,20 @@
849 // create a download and get the filename to use, then write it
850 // and create the same download and assert that the filename is diff
851
852- FileDownload* download = new FileDownload(_id, _path, true,
853- _rootPath, _url, _metadata, _headers);
854+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, true,
855+ _rootPath, _url, _metadata, _headers));
856
857 QString filePath = download->filePath();
858
859- QFile* file = new QFile(filePath);
860+ QScopedPointer<QFile> file(new QFile(filePath));
861 file->open(QIODevice::ReadWrite | QFile::Append);
862 file->write("data data data!");
863 file->close();
864
865- download = new FileDownload(_id, _path, true,
866- _rootPath, _url, _metadata, _headers);
867+ QScopedPointer<FileDownload> other(new FileDownload(_id, _path, true,
868+ _rootPath, _url, _metadata, _headers));
869
870- QVERIFY(filePath != download->filePath());
871+ QVERIFY(filePath != other->filePath());
872 }
873
874 void
875@@ -1702,10 +1701,10 @@
876 metadata["post-download-command"] = command;
877
878 _reqFactory->record();
879- FileDownload* download = new FileDownload(_id, _path, _isConfined,
880- _rootPath, _url, hash, _algo, metadata, _headers);
881+ QScopedPointer<FileDownload> download(new FileDownload(_id, _path, _isConfined,
882+ _rootPath, _url, hash, _algo, metadata, _headers));
883
884- QSignalSpy processingSpy(download, SIGNAL(processing(QString)));
885+ QSignalSpy processingSpy(download.data(), SIGNAL(processing(QString)));
886
887 download->start(); // change state
888 download->startDownload();
889
890=== modified file 'ubuntu-download-manager-tests/downloads/test_download_factory.cpp'
891--- ubuntu-download-manager-tests/downloads/test_download_factory.cpp 2013-11-28 13:18:20 +0000
892+++ ubuntu-download-manager-tests/downloads/test_download_factory.cpp 2013-12-18 10:06:42 +0000
893@@ -17,6 +17,7 @@
894 */
895
896 #include <downloads/file_download.h>
897+#include <system/file_manager.h>
898 #include <system/hash_algorithm.h>
899 #include <system/uuid_utils.h>
900 #include "test_download_factory.h"
901@@ -32,15 +33,17 @@
902 _apparmor = new FakeAppArmor(_uuidFactory);
903 _networkInfo = new FakeSystemNetworkInfo();
904 SystemNetworkInfo::setInstance(_networkInfo);
905- _processFactory = new FakeProcessFactory();
906- _downFactory = new Factory(_apparmor, _processFactory);
907+ _downFactory = new Factory(_apparmor);
908 }
909
910 void
911 TestDownloadFactory::cleanup() {
912 BaseTestCase::cleanup();
913
914+ SystemNetworkInfo::deleteInstance();
915 delete _downFactory;
916+ FileManager::deleteInstance();
917+ RequestFactory::deleteInstance();
918 }
919
920 void
921@@ -49,8 +52,8 @@
922
923 // create a download, assert that it was
924 // created and that the id and the path are correctly set
925- Download* download = _downFactory->createDownload("", QUrl(),
926- QVariantMap(), QMap<QString, QString>());
927+ QScopedPointer<Download> download(_downFactory->createDownload("", QUrl(),
928+ QVariantMap(), QMap<QString, QString>()));
929
930 QList<MethodData> calledMethods = _apparmor->calledMethods();
931 QCOMPARE(1, calledMethods.count());
932@@ -70,8 +73,8 @@
933 QString algo = "Md5";
934
935 // same as above but assert hash and hash algo
936- Download* download = _downFactory->createDownload("", QUrl(),
937- hash, algo, QVariantMap(), QMap<QString, QString>());
938+ QScopedPointer<Download> download(_downFactory->createDownload("", QUrl(),
939+ hash, algo, QVariantMap(), QMap<QString, QString>()));
940
941 QList<MethodData> calledMethods = _apparmor->calledMethods();
942 QCOMPARE(1, calledMethods.count());
943@@ -82,7 +85,9 @@
944 QCOMPARE(download->downloadId(), id->value());
945 QCOMPARE(download->path(), path->value());
946
947- FileDownload* single = reinterpret_cast<FileDownload*>(download);
948+ // no need to worry about the pointer because it will be
949+ // deleted by the QScopedPointer
950+ FileDownload* single = reinterpret_cast<FileDownload*>(download.data());
951 QCOMPARE(hash, single->hash());
952 QCOMPARE(HashAlgorithm::getHashAlgo(algo), single->hashAlgorithm());
953 }
954@@ -93,9 +98,9 @@
955
956 // create a download, assert that it was
957 // created and that the id and the path are correctly set
958- Download* download = _downFactory->createDownload("",
959+ QScopedPointer<Download> download(_downFactory->createDownload("",
960 QList<GroupDownloadStruct>(), "Md5",
961- true, QVariantMap(), QMap<QString, QString>());
962+ true, QVariantMap(), QMap<QString, QString>()));
963
964 QList<MethodData> calledMethods = _apparmor->calledMethods();
965 QCOMPARE(1, calledMethods.count());
966@@ -118,8 +123,8 @@
967 QVariantMap metadata;
968 metadata["objectpath"] = id;
969
970- Download* download = _downFactory->createDownload("", QUrl(),
971- metadata, QMap<QString, QString>());
972+ QScopedPointer<Download> download(_downFactory->createDownload("", QUrl(),
973+ metadata, QMap<QString, QString>()));
974
975 QList<MethodData> calledMethods = _apparmor->calledMethods();
976 QCOMPARE(1, calledMethods.count());
977@@ -138,8 +143,8 @@
978 QVariantMap metadata;
979 metadata["objectpath"] = "bad-id";
980
981- Download* download = _downFactory->createDownload("", QUrl(),
982- QVariantMap(), QMap<QString, QString>());
983+ QScopedPointer<Download> download(_downFactory->createDownload("", QUrl(),
984+ QVariantMap(), QMap<QString, QString>()));
985
986 QList<MethodData> calledMethods = _apparmor->calledMethods();
987 QCOMPARE(1, calledMethods.count());
988@@ -164,8 +169,8 @@
989 QString algo = "Md5";
990
991 // same as above but assert hash and hash algo
992- Download* download = _downFactory->createDownload("", QUrl(),
993- hash, algo, metadata, QMap<QString, QString>());
994+ QScopedPointer<Download> download(_downFactory->createDownload("", QUrl(),
995+ hash, algo, metadata, QMap<QString, QString>()));
996
997 QList<MethodData> calledMethods = _apparmor->calledMethods();
998 QCOMPARE(1, calledMethods.count());
999@@ -174,7 +179,8 @@
1000 QCOMPARE(download->downloadId(), id);
1001 QCOMPARE(download->path(), path->value());
1002
1003- FileDownload* single = reinterpret_cast<FileDownload*>(download);
1004+ // not to worry, QSCopedPointer will take care of the pointer
1005+ FileDownload* single = reinterpret_cast<FileDownload*>(download.data());
1006 QCOMPARE(hash, single->hash());
1007 QCOMPARE(HashAlgorithm::getHashAlgo(algo), single->hashAlgorithm());
1008 }
1009@@ -190,8 +196,8 @@
1010 QString algo = "Md5";
1011
1012 // same as above but assert hash and hash algo
1013- Download* download = _downFactory->createDownload("", QUrl(),
1014- hash, algo, metadata, QMap<QString, QString>());
1015+ QScopedPointer<Download> download(_downFactory->createDownload("", QUrl(),
1016+ hash, algo, metadata, QMap<QString, QString>()));
1017
1018 QList<MethodData> calledMethods = _apparmor->calledMethods();
1019 QCOMPARE(1, calledMethods.count());
1020@@ -202,7 +208,8 @@
1021 QCOMPARE(download->downloadId(), id->value());
1022 QCOMPARE(download->path(), path->value());
1023
1024- FileDownload* single = reinterpret_cast<FileDownload*>(download);
1025+ // not to worry the QScopedPointer will take care of the pointer
1026+ FileDownload* single = reinterpret_cast<FileDownload*>(download.data());
1027 QCOMPARE(hash, single->hash());
1028 QCOMPARE(HashAlgorithm::getHashAlgo(algo), single->hashAlgorithm());
1029 }
1030@@ -218,9 +225,9 @@
1031 QVariantMap metadata;
1032 metadata["objectpath"] = id;
1033
1034- Download* download = _downFactory->createDownload("",
1035+ QScopedPointer<Download> download(_downFactory->createDownload("",
1036 QList<GroupDownloadStruct>(), "Md5",
1037- true, metadata, QMap<QString, QString>());
1038+ true, metadata, QMap<QString, QString>()));
1039
1040 QList<MethodData> calledMethods = _apparmor->calledMethods();
1041 QCOMPARE(1, calledMethods.count());
1042@@ -239,9 +246,9 @@
1043 QVariantMap metadata;
1044 metadata["objectpath"] = "bad-id";
1045
1046- Download* download = _downFactory->createDownload("",
1047+ QScopedPointer<Download> download(_downFactory->createDownload("",
1048 QList<GroupDownloadStruct>(), "Md5",
1049- true, metadata, QMap<QString, QString>());
1050+ true, metadata, QMap<QString, QString>()));
1051
1052 QList<MethodData> calledMethods = _apparmor->calledMethods();
1053 QCOMPARE(1, calledMethods.count());
1054@@ -256,8 +263,8 @@
1055 void
1056 TestDownloadFactory::testCreateDownloadForGroup() {
1057 _apparmor->record();
1058- Download* download = _downFactory->createDownloadForGroup(true, "", QUrl(),
1059- QVariantMap(), QMap<QString, QString>());
1060+ QScopedPointer<Download> download(_downFactory->createDownloadForGroup(true, "", QUrl(),
1061+ QVariantMap(), QMap<QString, QString>()));
1062
1063 QList<MethodData> calledMethods = _apparmor->calledMethods();
1064 QCOMPARE(1, calledMethods.count());
1065@@ -273,8 +280,8 @@
1066 void
1067 TestDownloadFactory::testCreateDownloadForGroupWithHash() {
1068 _apparmor->record();
1069- Download* download = _downFactory->createDownloadForGroup(true, "", QUrl(),
1070- "", "Md5", QVariantMap(), QMap<QString, QString>());
1071+ QScopedPointer<Download> download(_downFactory->createDownloadForGroup(true, "", QUrl(),
1072+ "", "Md5", QVariantMap(), QMap<QString, QString>()));
1073
1074 QList<MethodData> calledMethods = _apparmor->calledMethods();
1075 QCOMPARE(1, calledMethods.count());
1076
1077=== modified file 'ubuntu-download-manager-tests/downloads/test_download_manager.cpp'
1078--- ubuntu-download-manager-tests/downloads/test_download_manager.cpp 2013-11-29 11:42:01 +0000
1079+++ ubuntu-download-manager-tests/downloads/test_download_manager.cpp 2013-12-18 10:06:42 +0000
1080@@ -41,7 +41,7 @@
1081 _requestFactory = new FakeRequestFactory();
1082 RequestFactory::setInstance(_requestFactory);
1083 _downloadFactory = new FakeDownloadFactory(
1084- _apparmor, new FakeProcessFactory());
1085+ _apparmor);
1086 _man = new Manager(_app, _conn, _downloadFactory, _q);
1087 }
1088
1089@@ -49,7 +49,12 @@
1090 TestDownloadManager::cleanup() {
1091 BaseTestCase::cleanup();
1092
1093+ SystemNetworkInfo::deleteInstance();
1094+ RequestFactory::deleteInstance();
1095+ ProcessFactory::deleteInstance();
1096 delete _man;
1097+ delete _conn;
1098+ delete _app;
1099 }
1100
1101 QCryptographicHash::Algorithm
1102@@ -246,18 +251,20 @@
1103
1104 void
1105 TestDownloadManager::testGetAllDownloads() {
1106+ FakeDownloadQueue* q = new FakeDownloadQueue();
1107+ FakeAppArmor* apparmor = new FakeAppArmor(QSharedPointer<UuidFactory>(
1108+ new UuidFactory()));
1109+ FakeDownloadFactory* downloadFactory = new FakeDownloadFactory(
1110+ apparmor);
1111+
1112 // add a number of downloads and assert that all the paths are returned
1113- _q->record();
1114+ q->record();
1115 _conn->record();
1116
1117 // do not use the fake uuid factory, else we only get one object path
1118- _apparmor = new FakeAppArmor(QSharedPointer<UuidFactory>(
1119- new UuidFactory()));
1120- _downloadFactory = new FakeDownloadFactory(
1121- _apparmor, new FakeProcessFactory());
1122- _man = new Manager(_app, _conn, _downloadFactory, _q);
1123+ QScopedPointer<Manager> man(new Manager(_app, _conn, downloadFactory, q));
1124
1125- QSignalSpy spy(_man, SIGNAL(downloadCreated(QDBusObjectPath)));
1126+ QSignalSpy spy(man.data(), SIGNAL(downloadCreated(QDBusObjectPath)));
1127
1128 QString firstUrl("http://www.ubuntu.com"),
1129 secondUrl("http://www.ubuntu.com/phone"),
1130@@ -265,18 +272,18 @@
1131 QVariantMap firstMetadata, secondMetadata, thirdMetadata;
1132 StringMap firstHeaders, secondHeaders, thirdHeaders;
1133
1134- _man->createDownload(
1135+ man->createDownload(
1136 DownloadStruct(firstUrl, firstMetadata, firstHeaders));
1137- _man->createDownload(
1138+ man->createDownload(
1139 DownloadStruct(secondUrl, secondMetadata, secondHeaders));
1140- _man->createDownload(
1141+ man->createDownload(
1142 DownloadStruct(thirdUrl, thirdMetadata, thirdHeaders));
1143
1144 QCOMPARE(spy.count(), 3);
1145
1146 // get the diff create downloads and theri paths so
1147 // that we can assert that they are returned
1148- QList<MethodData> calledMethods = _q->calledMethods();
1149+ QList<MethodData> calledMethods = q->calledMethods();
1150 QCOMPARE(3, calledMethods.count());
1151 QList<QString> paths;
1152 for (int index = 0; index < calledMethods.count(); index++) {
1153@@ -285,24 +292,26 @@
1154 paths << download->path();
1155 }
1156
1157- QList<QDBusObjectPath> allDownloads = _man->getAllDownloads();
1158+ QList<QDBusObjectPath> allDownloads = man->getAllDownloads();
1159 QCOMPARE(paths.count(), allDownloads.count());
1160 }
1161
1162 void
1163 TestDownloadManager::testAllDownloadsWithMetadata() {
1164+ FakeDownloadQueue* q = new FakeDownloadQueue();
1165+ FakeAppArmor* apparmor = new FakeAppArmor(QSharedPointer<UuidFactory>(
1166+ new UuidFactory()));
1167+ FakeDownloadFactory* downloadFactory = new FakeDownloadFactory(
1168+ apparmor);
1169+
1170 // add a number of downloads and assert that all the paths are returned
1171- _q->record();
1172+ q->record();
1173 _conn->record();
1174
1175 // do not use the fake uuid factory, else we only get one object path
1176- _apparmor = new FakeAppArmor(QSharedPointer<UuidFactory>(
1177- new UuidFactory()));
1178- _downloadFactory = new FakeDownloadFactory(
1179- _apparmor, new FakeProcessFactory());
1180- _man = new Manager(_app, _conn, _downloadFactory, _q);
1181+ QScopedPointer<Manager> man(new Manager(_app, _conn, downloadFactory, q));
1182
1183- QSignalSpy spy(_man, SIGNAL(downloadCreated(QDBusObjectPath)));
1184+ QSignalSpy spy(man.data(), SIGNAL(downloadCreated(QDBusObjectPath)));
1185
1186 QString firstUrl("http://www.ubuntu.com"),
1187 secondUrl("http://www.ubuntu.com/phone"),
1188@@ -314,18 +323,18 @@
1189 secondMetadata["type"] = "second";
1190 thirdMetadata["type"] = "first";
1191
1192- _man->createDownload(
1193+ man->createDownload(
1194 DownloadStruct(firstUrl, firstMetadata, firstHeaders));
1195- _man->createDownload(
1196+ man->createDownload(
1197 DownloadStruct(secondUrl, secondMetadata, secondHeaders));
1198- _man->createDownload(
1199+ man->createDownload(
1200 DownloadStruct(thirdUrl, thirdMetadata, thirdHeaders));
1201
1202 QCOMPARE(spy.count(), 3);
1203
1204 // get the diff create downloads and theri paths so that we
1205 // can assert that they are returned
1206- QList<MethodData> calledMethods = _q->calledMethods();
1207+ QList<MethodData> calledMethods = q->calledMethods();
1208 QCOMPARE(3, calledMethods.count());
1209 QList<QString> downloads;
1210 for (int index = 0; index < calledMethods.count(); index++) {
1211@@ -334,7 +343,7 @@
1212 downloads << download->path();
1213 }
1214
1215- QList<QDBusObjectPath> filtered = _man->getAllDownloadsWithMetadata(
1216+ QList<QDBusObjectPath> filtered = man->getAllDownloadsWithMetadata(
1217 "type", "first");
1218
1219 QCOMPARE(2, filtered.count());
1220@@ -372,11 +381,13 @@
1221 QFETCH(qulonglong, speed);
1222
1223 // do not use the fake uuid factory, else we only get one object path
1224- _apparmor = new FakeAppArmor(QSharedPointer<UuidFactory>(
1225+ FakeDownloadQueue* q = new FakeDownloadQueue();
1226+ FakeAppArmor* apparmor = new FakeAppArmor(QSharedPointer<UuidFactory>(
1227 new UuidFactory()));
1228- _downloadFactory = new FakeDownloadFactory(
1229- _apparmor, new FakeProcessFactory());
1230- _man = new Manager(_app, _conn, _downloadFactory, _q);
1231+ FakeDownloadFactory* downloadFactory = new FakeDownloadFactory(
1232+ apparmor);
1233+
1234+ QScopedPointer<Manager> man(new Manager(_app, _conn, downloadFactory, q));
1235
1236 QString firstUrl("http://www.ubuntu.com"),
1237 secondUrl("http://www.ubuntu.com/phone"),
1238@@ -388,16 +399,16 @@
1239 secondMetadata["type"] = "second";
1240 thirdMetadata["type"] = "first";
1241
1242- _man->createDownload(
1243+ man->createDownload(
1244 DownloadStruct(firstUrl, firstMetadata, firstHeaders));
1245- _man->createDownload(
1246+ man->createDownload(
1247 DownloadStruct(secondUrl, secondMetadata, secondHeaders));
1248- _man->createDownload(
1249+ man->createDownload(
1250 DownloadStruct(thirdUrl, thirdMetadata, thirdHeaders));
1251
1252- _man->setDefaultThrottle(speed);
1253+ man->setDefaultThrottle(speed);
1254
1255- QList<MethodData> calledMethods = _q->calledMethods();
1256+ QList<MethodData> calledMethods = q->calledMethods();
1257 for (int index = 0; index < calledMethods.count(); index++) {
1258 FileDownload* download = reinterpret_cast<FileDownload*>(
1259 calledMethods[index].params().inParams()[0]);
1260@@ -466,20 +477,30 @@
1261
1262 void
1263 TestDownloadManager::testStoppable() {
1264+ FakeDownloadQueue* q = new FakeDownloadQueue();
1265+ FakeAppArmor* apparmor = new FakeAppArmor(QSharedPointer<UuidFactory>(
1266+ new UuidFactory()));
1267+ FakeDownloadFactory* downloadFactory = new FakeDownloadFactory(
1268+ apparmor);
1269 _app->record();
1270- _man = new Manager(_app, _conn,
1271- _downloadFactory, _q, true);
1272- _man->exit();
1273+
1274+ QScopedPointer<Manager> man(new Manager(_app, _conn, downloadFactory, q, true));
1275+ man->exit();
1276 QList<MethodData> calledMethods = _app->calledMethods();
1277 QCOMPARE(1, calledMethods.count());
1278 }
1279
1280 void
1281 TestDownloadManager::testNotStoppable() {
1282+ FakeDownloadQueue* q = new FakeDownloadQueue();
1283+ FakeAppArmor* apparmor = new FakeAppArmor(QSharedPointer<UuidFactory>(
1284+ new UuidFactory()));
1285+ FakeDownloadFactory* downloadFactory = new FakeDownloadFactory(
1286+ apparmor);
1287 _app->record();
1288- _man = new Manager(_app, _conn,
1289- _downloadFactory, _q, false);
1290- _man->exit();
1291+
1292+ QScopedPointer<Manager> man(new Manager(_app, _conn, downloadFactory, q, false));
1293+ man->exit();
1294 QList<MethodData> calledMethods = _app->calledMethods();
1295 QCOMPARE(0, calledMethods.count());
1296 }
1297
1298=== modified file 'ubuntu-download-manager-tests/downloads/test_download_queue.cpp'
1299--- ubuntu-download-manager-tests/downloads/test_download_queue.cpp 2013-11-27 13:06:46 +0000
1300+++ ubuntu-download-manager-tests/downloads/test_download_queue.cpp 2013-12-18 10:06:42 +0000
1301@@ -31,13 +31,13 @@
1302 _isConfined = true;
1303 _rootPath = "/random/root/path";
1304 _networkInfo = new FakeSystemNetworkInfo();
1305- _processFactory = new FakeProcessFactory();
1306+ SystemNetworkInfo::setInstance(_networkInfo);
1307 _first = new FakeDownload(UuidUtils::getDBusString(QUuid::createUuid()),
1308 "first-path", _isConfined, _rootPath, QUrl(),
1309- QVariantMap(), QMap<QString, QString>(), _processFactory);
1310+ QVariantMap(), QMap<QString, QString>());
1311 _second = new FakeDownload(UuidUtils::getDBusString(QUuid::createUuid()),
1312 "second-path", _isConfined, _rootPath, QUrl(),
1313- QVariantMap(), QMap<QString, QString>(), _processFactory);
1314+ QVariantMap(), QMap<QString, QString>());
1315 _q = new Queue();
1316 }
1317
1318@@ -45,6 +45,9 @@
1319 TestDownloadQueue::cleanup() {
1320 BaseTestCase::cleanup();
1321
1322+ SystemNetworkInfo::deleteInstance();
1323+ delete _first;
1324+ delete _second;
1325 delete _q;
1326 }
1327
1328
1329=== modified file 'ubuntu-download-manager-tests/downloads/test_download_queue.h'
1330--- ubuntu-download-manager-tests/downloads/test_download_queue.h 2013-11-27 13:06:46 +0000
1331+++ ubuntu-download-manager-tests/downloads/test_download_queue.h 2013-12-18 10:06:42 +0000
1332@@ -61,7 +61,6 @@
1333 bool _isConfined;
1334 QString _rootPath;
1335 FakeSystemNetworkInfo* _networkInfo;
1336- FakeProcessFactory* _processFactory;
1337 FakeDownload* _first;
1338 FakeDownload* _second;
1339 Queue* _q;
1340
1341=== modified file 'ubuntu-download-manager-tests/downloads/test_downloads_db.cpp'
1342--- ubuntu-download-manager-tests/downloads/test_downloads_db.cpp 2013-11-27 13:06:46 +0000
1343+++ ubuntu-download-manager-tests/downloads/test_downloads_db.cpp 2013-12-18 10:06:42 +0000
1344@@ -56,6 +56,8 @@
1345 delete _db;
1346
1347 QFile::remove(dbFile);
1348+ SystemNetworkInfo::deleteInstance();
1349+ FileManager::deleteInstance();
1350 }
1351
1352 void
1353@@ -141,12 +143,10 @@
1354 QFETCH(QVariantMap, metadata);
1355 QFETCH(StringMap, headers);
1356
1357- ProcessFactory* processFactory = new FakeProcessFactory();
1358-
1359- FakeDownload* download = new FakeDownload(id, path, false, "", url, hash,
1360- hashAlgoString, metadata, headers, processFactory);
1361-
1362- _db->storeSingleDownload(download);
1363+ QScopedPointer<FakeDownload> download(new FakeDownload(id, path, false, "", url, hash,
1364+ hashAlgoString, metadata, headers));
1365+
1366+ _db->storeSingleDownload(download.data());
1367 // query that the download is there and that the data is correct
1368 QSqlDatabase db = _db->db();
1369 db.open();
1370@@ -233,19 +233,17 @@
1371 QFETCH(QVariantMap, metadata);
1372 QFETCH(StringMap, headers);
1373
1374- ProcessFactory* processFactory = new FakeProcessFactory();
1375-
1376- FakeDownload* download = new FakeDownload(id, path, true, "", url, hash,
1377- hashAlgoString, metadata, headers, processFactory);
1378-
1379- _db->storeSingleDownload(download);
1380+ QScopedPointer<FakeDownload> download(new FakeDownload(id, path, true, "", url, hash,
1381+ hashAlgoString, metadata, headers));
1382+
1383+ _db->storeSingleDownload(download.data());
1384
1385 // create a second download with same id but a diff path to test is update
1386 QString newPath = path + path;
1387- FakeDownload* secondDownload = new FakeDownload(id, newPath, true, "",
1388- url, hash, hashAlgoString, metadata, headers, processFactory);
1389+ QScopedPointer<FakeDownload> secondDownload(new FakeDownload(id, newPath, true, "",
1390+ url, hash, hashAlgoString, metadata, headers));
1391
1392- _db->storeSingleDownload(secondDownload);
1393+ _db->storeSingleDownload(secondDownload.data());
1394
1395 // query that the download is there and that the data is correct
1396 QSqlDatabase db = _db->db();
1397
1398=== modified file 'ubuntu-download-manager-tests/downloads/test_group_download.cpp'
1399--- ubuntu-download-manager-tests/downloads/test_group_download.cpp 2013-11-28 13:18:20 +0000
1400+++ ubuntu-download-manager-tests/downloads/test_group_download.cpp 2013-12-18 10:06:42 +0000
1401@@ -38,11 +38,9 @@
1402 _isGSMDownloadAllowed = true;
1403 _networkInfo = new FakeSystemNetworkInfo();
1404 SystemNetworkInfo::setInstance(_networkInfo);
1405- _processFactory = new FakeProcessFactory();
1406 _uuidFactory = new UuidFactory();
1407 _apparmor = new FakeAppArmor(QSharedPointer<UuidFactory>(_uuidFactory));
1408- _downloadFactory = new FakeDownloadFactory(
1409- _apparmor, _processFactory);
1410+ _downloadFactory = new FakeDownloadFactory(_apparmor);
1411 _fileManager = new FakeFileManager();
1412 FileManager::setInstance(_fileManager);
1413 }
1414@@ -51,6 +49,8 @@
1415 TestGroupDownload::cleanup() {
1416 BaseTestCase::cleanup();
1417
1418+ SystemNetworkInfo::deleteInstance();
1419+ FileManager::deleteInstance();
1420 delete _downloadFactory;
1421 }
1422
1423@@ -72,9 +72,9 @@
1424 downloads.append(GroupDownloadStruct("http://ubuntu.com",
1425 "other_local_file", ""));
1426
1427- GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath,
1428- downloads, _algo, _isGSMDownloadAllowed, _metadata, _headers,
1429- _downloadFactory, _fileManager);
1430+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path, _isConfined,
1431+ _rootPath, downloads, _algo, _isGSMDownloadAllowed, _metadata, _headers,
1432+ _downloadFactory, _fileManager));
1433 group->cancelDownload();
1434 foreach(Download* download, _downloadFactory->downloads()) {
1435 QCOMPARE(Download::CANCEL, download->state());
1436@@ -93,9 +93,10 @@
1437 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1438 "other_reddit_local_file", ""));
1439
1440- GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath,
1441- downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers,
1442- _downloadFactory, _fileManager);
1443+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path,
1444+ _isConfined, _rootPath, downloadsStruct, _algo,
1445+ _isGSMDownloadAllowed, _metadata, _headers,
1446+ _downloadFactory, _fileManager));
1447
1448 QList<Download*> downloads = _downloadFactory->downloads();
1449 reinterpret_cast<FakeDownload*>(downloads[0])->emitFinished(deleteFile);
1450@@ -125,9 +126,10 @@
1451 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1452 "other_reddit_local_file", ""));
1453
1454- GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath,
1455- downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers,
1456- _downloadFactory, _fileManager);
1457+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path,
1458+ _isConfined, _rootPath, downloadsStruct, _algo,
1459+ _isGSMDownloadAllowed, _metadata, _headers,
1460+ _downloadFactory, _fileManager));
1461
1462 QList<Download*> downloads = _downloadFactory->downloads();
1463 reinterpret_cast<FakeDownload*>(downloads[0])->cancel();
1464@@ -144,9 +146,9 @@
1465 TestGroupDownload::testPauseNoDownloads() {
1466 QList<GroupDownloadStruct> downloads;
1467
1468- GroupDownload* group = new GroupDownload(_id, _path, _isConfined,
1469+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path, _isConfined,
1470 _rootPath, downloads, _algo, _isGSMDownloadAllowed, _metadata,
1471- _headers, _downloadFactory, _fileManager);
1472+ _headers, _downloadFactory, _fileManager));
1473 group->pauseDownload();
1474 }
1475
1476@@ -158,9 +160,10 @@
1477 downloadsStruct.append(GroupDownloadStruct("http://ubuntu.com",
1478 "other_local_file", ""));
1479
1480- GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath,
1481- downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers,
1482- _downloadFactory, _fileManager);
1483+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path,
1484+ _isConfined, _rootPath, downloadsStruct, _algo,
1485+ _isGSMDownloadAllowed, _metadata, _headers,
1486+ _downloadFactory, _fileManager));
1487 // start all downlaods
1488 QList<Download*> downloads = _downloadFactory->downloads();
1489 foreach(Download* download, downloads) {
1490@@ -184,9 +187,10 @@
1491 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1492 "other_reddit_local_file", ""));
1493
1494- GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath,
1495- downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers,
1496- _downloadFactory, _fileManager);
1497+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path,
1498+ _isConfined, _rootPath, downloadsStruct, _algo,
1499+ _isGSMDownloadAllowed, _metadata, _headers,
1500+ _downloadFactory, _fileManager));
1501
1502 QList<Download*> downloads = _downloadFactory->downloads();
1503 reinterpret_cast<FakeDownload*>(downloads[0])->emitFinished(deleteFile);
1504@@ -216,9 +220,10 @@
1505 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1506 "other_reddit_local_file", ""));
1507
1508- GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath,
1509- downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers,
1510- _downloadFactory, _fileManager);
1511+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path,
1512+ _isConfined, _rootPath, downloadsStruct, _algo,
1513+ _isGSMDownloadAllowed, _metadata, _headers,
1514+ _downloadFactory, _fileManager));
1515
1516 QList<Download*> downloads = _downloadFactory->downloads();
1517 reinterpret_cast<FakeDownload*>(downloads[0])->cancel();
1518@@ -237,9 +242,9 @@
1519 TestGroupDownload::testResumeNoDownloads() {
1520 QList<GroupDownloadStruct> downloads;
1521
1522- GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath,
1523- downloads, _algo, _isGSMDownloadAllowed, _metadata, _headers,
1524- _downloadFactory, _fileManager);
1525+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path,
1526+ _isConfined, _rootPath, downloads, _algo, _isGSMDownloadAllowed,
1527+ _metadata, _headers, _downloadFactory, _fileManager));
1528 group->cancelDownload();
1529 }
1530
1531@@ -255,9 +260,9 @@
1532 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1533 "other_reddit_local_file", ""));
1534
1535- GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath,
1536- downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers,
1537- _downloadFactory, _fileManager);
1538+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path,
1539+ _isConfined, _rootPath, downloadsStruct, _algo, _isGSMDownloadAllowed,
1540+ _metadata, _headers, _downloadFactory, _fileManager));
1541
1542 QList<Download*> downloads = _downloadFactory->downloads();
1543 foreach(Download* download, downloads) {
1544@@ -285,9 +290,10 @@
1545 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1546 "other_reddit_local_file", ""));
1547
1548- GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath,
1549- downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers,
1550- _downloadFactory, _fileManager);
1551+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path,
1552+ _isConfined, _rootPath, downloadsStruct, _algo,
1553+ _isGSMDownloadAllowed, _metadata, _headers, _downloadFactory,
1554+ _fileManager));
1555
1556 QList<Download*> downloads = _downloadFactory->downloads();
1557 qDebug() << "Downloads" << downloads;
1558@@ -319,9 +325,9 @@
1559 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1560 "other_reddit_local_file", ""));
1561
1562- GroupDownload* group = new GroupDownload(_id, _path, _isConfined,
1563+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path, _isConfined,
1564 _rootPath, downloadsStruct, _algo, _isGSMDownloadAllowed,
1565- _metadata, _headers, _downloadFactory, _fileManager);
1566+ _metadata, _headers, _downloadFactory, _fileManager));
1567
1568 QList<Download*> downloads = _downloadFactory->downloads();
1569 (downloads[0])->cancel();
1570@@ -352,10 +358,10 @@
1571 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1572 "other_reddit_local_file", ""));
1573
1574- GroupDownload* group = new GroupDownload(_id, _path, _isConfined,
1575+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path, _isConfined,
1576 _rootPath, downloadsStruct, _algo, _isGSMDownloadAllowed,
1577 _metadata, _headers, _downloadFactory,
1578- _fileManager);
1579+ _fileManager));
1580
1581 QList<Download*> downloads = _downloadFactory->downloads();
1582 group->resumeDownload();
1583@@ -371,10 +377,10 @@
1584 TestGroupDownload::testStartNoDownloads() {
1585 QList<GroupDownloadStruct> downloads;
1586
1587- GroupDownload* group = new GroupDownload(_id, _path, _isConfined,
1588+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path, _isConfined,
1589 _rootPath, downloads, _algo,
1590 _isGSMDownloadAllowed, _metadata, _headers,
1591- _downloadFactory, _fileManager);
1592+ _downloadFactory, _fileManager));
1593 group->startDownload();
1594 }
1595
1596@@ -390,9 +396,9 @@
1597 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1598 "other_reddit_local_file", ""));
1599
1600- GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath,
1601+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path, _isConfined, _rootPath,
1602 downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers,
1603- _downloadFactory, _fileManager);
1604+ _downloadFactory, _fileManager));
1605
1606 QList<Download*> downloads = _downloadFactory->downloads();
1607 group->startDownload();
1608@@ -416,9 +422,9 @@
1609 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1610 "other_reddit_local_file", ""));
1611
1612- GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath,
1613+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path, _isConfined, _rootPath,
1614 downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers,
1615- _downloadFactory, _fileManager);
1616+ _downloadFactory, _fileManager));
1617
1618 QList<Download*> downloads = _downloadFactory->downloads();
1619 group->startDownload();
1620@@ -446,9 +452,9 @@
1621 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1622 "other_reddit_local_file", ""));
1623
1624- GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath,
1625+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path, _isConfined, _rootPath,
1626 downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers,
1627- _downloadFactory, _fileManager);
1628+ _downloadFactory, _fileManager));
1629
1630 QList<Download*> downloads = _downloadFactory->downloads();
1631 group->startDownload();
1632@@ -478,9 +484,9 @@
1633 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1634 "other_reddit_local_file", ""));
1635
1636- GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath,
1637+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path, _isConfined, _rootPath,
1638 downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers,
1639- _downloadFactory, _fileManager);
1640+ _downloadFactory, _fileManager));
1641
1642 QList<Download*> downloads = _downloadFactory->downloads();
1643 reinterpret_cast<FakeDownload*>(downloads[0])->emitFinished(deleteFile);
1644@@ -507,9 +513,9 @@
1645 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1646 "other_reddit_local_file", ""));
1647
1648- GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath,
1649+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path, _isConfined, _rootPath,
1650 downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers,
1651- _downloadFactory, _fileManager);
1652+ _downloadFactory, _fileManager));
1653
1654 QList<Download*> downloads = _downloadFactory->downloads();
1655 downloads[0]->cancel();
1656@@ -537,10 +543,10 @@
1657 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1658 "other_reddit_local_file", ""));
1659
1660- GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath,
1661+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path, _isConfined, _rootPath,
1662 downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers,
1663- _downloadFactory, _fileManager);
1664- QSignalSpy spy(group, SIGNAL(finished(QStringList)));
1665+ _downloadFactory, _fileManager));
1666+ QSignalSpy spy(group.data(), SIGNAL(finished(QStringList)));
1667
1668 QList<Download*> downloads = _downloadFactory->downloads();
1669 group->startDownload();
1670@@ -564,10 +570,10 @@
1671 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1672 "other_reddit_local_file", ""));
1673
1674- GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath,
1675+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path, _isConfined, _rootPath,
1676 downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers,
1677- _downloadFactory, _fileManager);
1678- QSignalSpy spy(group, SIGNAL(finished(QStringList)));
1679+ _downloadFactory, _fileManager));
1680+ QSignalSpy spy(group.data(), SIGNAL(finished(QStringList)));
1681
1682 QList<Download*> downloads = _downloadFactory->downloads();
1683 group->startDownload();
1684@@ -592,10 +598,10 @@
1685 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1686 "other_reddit_local_file", ""));
1687
1688- GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath,
1689+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path, _isConfined, _rootPath,
1690 downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers,
1691- _downloadFactory, _fileManager);
1692- QSignalSpy spy(group, SIGNAL(error(QString)));
1693+ _downloadFactory, _fileManager));
1694+ QSignalSpy spy(group.data(), SIGNAL(error(QString)));
1695
1696 QList<Download*> downloads = _downloadFactory->downloads();
1697 group->startDownload();
1698@@ -620,10 +626,10 @@
1699 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1700 "other_reddit_local_file", ""));
1701
1702- GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath,
1703+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path, _isConfined, _rootPath,
1704 downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers,
1705- _downloadFactory, _fileManager);
1706- QSignalSpy spy(group, SIGNAL(error(QString)));
1707+ _downloadFactory, _fileManager));
1708+ QSignalSpy spy(group.data(), SIGNAL(error(QString)));
1709
1710 QList<Download*> downloads = _downloadFactory->downloads();
1711 group->startDownload();
1712@@ -650,9 +656,9 @@
1713 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1714 "other_reddit_local_file", ""));
1715
1716- GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath,
1717+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path, _isConfined, _rootPath,
1718 downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers,
1719- _downloadFactory, _fileManager);
1720+ _downloadFactory, _fileManager));
1721
1722 Q_UNUSED(group);
1723
1724@@ -696,9 +702,9 @@
1725 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1726 "other_reddit_local_file", ""));
1727
1728- GroupDownload* group = new GroupDownload(_id, _path, confined, _rootPath,
1729+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path, confined, _rootPath,
1730 downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers,
1731- _downloadFactory, _fileManager);
1732+ _downloadFactory, _fileManager));
1733
1734 Q_UNUSED(group);
1735
1736@@ -717,9 +723,9 @@
1737 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1738 "other_reddit_local_file", ""));
1739
1740- GroupDownload* group = new GroupDownload(_id, _path, false, _rootPath,
1741+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path, false, _rootPath,
1742 downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers,
1743- _downloadFactory, _fileManager);
1744+ _downloadFactory, _fileManager));
1745
1746 QVERIFY(!group->isValid());
1747 }
1748@@ -734,9 +740,9 @@
1749 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1750 "other_reddit_local_file", ""));
1751
1752- GroupDownload* group = new GroupDownload(_id, _path, false, _rootPath,
1753+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path, false, _rootPath,
1754 downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers,
1755- _downloadFactory, _fileManager);
1756+ _downloadFactory, _fileManager));
1757
1758 QVERIFY(group->isValid());
1759 }
1760@@ -751,9 +757,9 @@
1761 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1762 "other_reddit_local_file", "sasaas"));
1763
1764- GroupDownload* group = new GroupDownload(_id, _path, false, _rootPath,
1765+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path, false, _rootPath,
1766 downloadsStruct, "wrong", _isGSMDownloadAllowed, _metadata, _headers,
1767- _downloadFactory, _fileManager);
1768+ _downloadFactory, _fileManager));
1769
1770 QVERIFY(!group->isValid());
1771 }
1772@@ -782,9 +788,9 @@
1773 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1774 "other_reddit_local_file", "sasa"));
1775
1776- GroupDownload* group = new GroupDownload(_id, _path, false, _rootPath,
1777+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path, false, _rootPath,
1778 downloadsStruct, algo, _isGSMDownloadAllowed, _metadata, _headers,
1779- _downloadFactory, _fileManager);
1780+ _downloadFactory, _fileManager));
1781
1782 QVERIFY(group->isValid());
1783 }
1784@@ -792,7 +798,7 @@
1785 void
1786 TestGroupDownload::testInvalidFilePresent() {
1787 QString filePath = testDirectory() + QDir::separator() + "test_file.jpg";
1788- QFile* file = new QFile(filePath);
1789+ QScopedPointer<QFile> file(new QFile(filePath));
1790 file->open(QIODevice::ReadWrite | QFile::Append);
1791 file->write("data data data!");
1792 file->close();
1793@@ -805,9 +811,9 @@
1794 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1795 "other_reddit_local_file", ""));
1796
1797- GroupDownload* group = new GroupDownload(_id, _path, false, _rootPath,
1798+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path, false, _rootPath,
1799 downloadsStruct, "md5", _isGSMDownloadAllowed, _metadata, _headers,
1800- _downloadFactory, _fileManager);
1801+ _downloadFactory, _fileManager));
1802
1803 QVERIFY(!group->isValid());
1804 }
1805@@ -824,9 +830,9 @@
1806 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1807 "other_reddit_local_file", ""));
1808
1809- GroupDownload* group = new GroupDownload(_id, _path, false, _rootPath,
1810+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path, false, _rootPath,
1811 downloadsStruct, "md5", _isGSMDownloadAllowed, _metadata, _headers,
1812- _downloadFactory, _fileManager);
1813+ _downloadFactory, _fileManager));
1814
1815 QVERIFY(group->isValid());
1816 }
1817@@ -858,9 +864,9 @@
1818 downloadsStruct.append(GroupDownloadStruct("http://reddit.com",
1819 "other_reddit_local_file", ""));
1820
1821- GroupDownload* group = new GroupDownload(_id, _path, false, _rootPath,
1822+ QScopedPointer<GroupDownload> group(new GroupDownload(_id, _path, false, _rootPath,
1823 downloadsStruct, "md5", _isGSMDownloadAllowed, _metadata, _headers,
1824- _downloadFactory, _fileManager);
1825+ _downloadFactory, _fileManager));
1826
1827 QVERIFY(!group->isValid());
1828 }
1829
1830=== modified file 'ubuntu-download-manager-tests/downloads/test_group_download.h'
1831--- ubuntu-download-manager-tests/downloads/test_group_download.h 2013-11-28 11:46:34 +0000
1832+++ ubuntu-download-manager-tests/downloads/test_group_download.h 2013-12-18 10:06:42 +0000
1833@@ -96,7 +96,6 @@
1834 UuidFactory* _uuidFactory;
1835 FakeAppArmor* _apparmor;
1836 FakeSystemNetworkInfo* _networkInfo;
1837- FakeProcessFactory* _processFactory;
1838 FakeDownloadFactory* _downloadFactory;
1839 FakeFileManager* _fileManager;
1840 };
1841
1842=== modified file 'ubuntu-download-manager-tests/fakes/fake_apparmor.cpp'
1843--- ubuntu-download-manager-tests/fakes/fake_apparmor.cpp 2013-10-30 11:04:37 +0000
1844+++ ubuntu-download-manager-tests/fakes/fake_apparmor.cpp 2013-12-18 10:06:42 +0000
1845@@ -34,8 +34,8 @@
1846 QList<QObject*> inParams;
1847
1848 QList<QObject*> outParams;
1849- outParams.append(new StringWrapper(id));
1850- outParams.append(new StringWrapper(dbusPath));
1851+ outParams.append(new StringWrapper(id, this));
1852+ outParams.append(new StringWrapper(dbusPath, this));
1853 MethodParams params(inParams, outParams);
1854 MethodData methodData("getDBusPath", params);
1855 _called.append(methodData);
1856@@ -63,13 +63,13 @@
1857 isConfined = _isConfined;
1858 if (_recording) {
1859 QList<QObject*> inParams;
1860- inParams.append(new StringWrapper(id));
1861- inParams.append(new StringWrapper(connName));
1862+ inParams.append(new StringWrapper(id, this));
1863+ inParams.append(new StringWrapper(connName, this));
1864
1865 QList<QObject*> outParams;
1866- outParams.append(new StringWrapper(id));
1867- outParams.append(new StringWrapper(dbusPath));
1868- outParams.append(new StringWrapper(localPath));
1869+ outParams.append(new StringWrapper(id, this));
1870+ outParams.append(new StringWrapper(dbusPath, this));
1871+ outParams.append(new StringWrapper(localPath, this));
1872 MethodParams params(inParams, outParams);
1873 MethodData methodData("getSecurePath", params);
1874 _called.append(methodData);
1875
1876=== modified file 'ubuntu-download-manager-tests/fakes/fake_application.cpp'
1877--- ubuntu-download-manager-tests/fakes/fake_application.cpp 2013-10-30 11:04:37 +0000
1878+++ ubuntu-download-manager-tests/fakes/fake_application.cpp 2013-12-18 10:06:42 +0000
1879@@ -27,7 +27,7 @@
1880 FakeApplication::exit(int returnCode) {
1881 if (_recording) {
1882 QList<QObject*> inParams;
1883- inParams.append(new IntWrapper(returnCode));
1884+ inParams.append(new IntWrapper(returnCode, this));
1885
1886 QList<QObject*> outParams;
1887 MethodParams params(inParams, outParams);
1888
1889=== modified file 'ubuntu-download-manager-tests/fakes/fake_download.cpp'
1890--- ubuntu-download-manager-tests/fakes/fake_download.cpp 2013-11-27 13:29:03 +0000
1891+++ ubuntu-download-manager-tests/fakes/fake_download.cpp 2013-12-18 10:06:42 +0000
1892@@ -66,7 +66,7 @@
1893 FakeDownload::setThrottle(qulonglong speed) {
1894 if (_recording) {
1895 QList<QObject*> inParams;
1896- inParams.append(new UintWrapper(speed));
1897+ inParams.append(new UintWrapper(speed, this));
1898
1899 QList<QObject*> outParams;
1900 MethodParams params(inParams, outParams);
1901
1902=== modified file 'ubuntu-download-manager-tests/fakes/fake_download_factory.cpp'
1903--- ubuntu-download-manager-tests/fakes/fake_download_factory.cpp 2013-11-28 13:18:20 +0000
1904+++ ubuntu-download-manager-tests/fakes/fake_download_factory.cpp 2013-12-18 10:06:42 +0000
1905@@ -44,7 +44,7 @@
1906 QString id = _apparmor->getSecurePath(downloadOwner, dbusPath, rootPath,
1907 isConfined);
1908 Download* down = new FakeDownload(id, dbusPath, isConfined, rootPath, url,
1909- metadata, headers);
1910+ metadata, headers, this);
1911 _downloads.append(down);
1912 qDebug() << "Downloads count" << _downloads.count();
1913 return down;
1914@@ -69,7 +69,7 @@
1915 QString id = _apparmor->getSecurePath(downloadOwner, dbusPath, rootPath,
1916 isConfined);
1917 Download* down = new FakeDownload(id, dbusPath, isConfined, rootPath, url,
1918- hash, algo, metadata, headers);
1919+ hash, algo, metadata, headers, this);
1920 _downloads.append(down);
1921 qDebug() << "Downloads count" << _downloads.count();
1922 return down;
1923@@ -97,7 +97,7 @@
1924 QString id = _apparmor->getSecurePath(downloadOwner, dbusPath, rootPath,
1925 isConfined);
1926 Download* down = new FakeDownload(id, dbusPath, isConfined, rootPath,
1927- QUrl(), "", algo, metadata, headers);
1928+ QUrl(), "", algo, metadata, headers, this);
1929 _downloads.append(down);
1930 qDebug() << "Downloads count" << _downloads.count();
1931 return down;
1932@@ -119,7 +119,7 @@
1933 QString dbusPath;
1934 _apparmor->getDBusPath(id, dbusPath);
1935 Download* down = new FakeDownload(id, dbusPath, isConfined, rootPath,
1936- url, metadata, headers);
1937+ url, metadata, headers, this);
1938 _downloads.append(down);
1939 qDebug() << "Downloads count" << _downloads.count();
1940 return down;
1941@@ -137,7 +137,7 @@
1942 QString dbusPath;
1943 _apparmor->getDBusPath(id, dbusPath);
1944 Download* down = new FileDownload(id, dbusPath, isConfined,
1945- rootPath, url, hash, algo, metadata, headers);
1946+ rootPath, url, hash, algo, metadata, headers, this);
1947 _downloads.append(down);
1948 qDebug() << "Downloads count" << _downloads.count();
1949 return down;
1950
1951=== modified file 'ubuntu-download-manager-tests/fakes/fake_file_manager.cpp'
1952--- ubuntu-download-manager-tests/fakes/fake_file_manager.cpp 2013-10-30 11:04:37 +0000
1953+++ ubuntu-download-manager-tests/fakes/fake_file_manager.cpp 2013-12-18 10:06:42 +0000
1954@@ -27,7 +27,7 @@
1955 FakeFileManager::remove(const QString& path) {
1956 if (_recording) {
1957 QList<QObject*> inParams;
1958- inParams.append(new StringWrapper(path));
1959+ inParams.append(new StringWrapper(path, this));
1960
1961 QList<QObject*> outParams;
1962 MethodParams params(inParams, outParams);
1963
1964=== modified file 'ubuntu-download-manager-tests/fakes/fake_network_reply.cpp'
1965--- ubuntu-download-manager-tests/fakes/fake_network_reply.cpp 2013-10-30 11:04:37 +0000
1966+++ ubuntu-download-manager-tests/fakes/fake_network_reply.cpp 2013-12-18 10:06:42 +0000
1967@@ -37,7 +37,7 @@
1968 }
1969
1970 FakeNetworkReply::FakeNetworkReply(QObject *parent)
1971- : NetworkReply(new FakeQNetworkReply(parent)),
1972+ : NetworkReply(new FakeQNetworkReply(), parent),
1973 Fake() {
1974 }
1975
1976@@ -74,7 +74,7 @@
1977 FakeNetworkReply::setReadBufferSize(uint size) {
1978 if (_recording) {
1979 QList<QObject*> inParams;
1980- inParams.append(new UintWrapper(size));
1981+ inParams.append(new UintWrapper(size, this));
1982
1983 QList<QObject*> outParams;
1984 MethodParams params(inParams, outParams);
1985@@ -104,10 +104,10 @@
1986 FakeNetworkReply::canIgnoreSslErrors(const QList<QSslError>& errors) {
1987 if (_recording) {
1988 QList<QObject*> inParams;
1989- inParams.append(new SslErrorsListWrapper(errors));
1990+ inParams.append(new SslErrorsListWrapper(errors, this));
1991
1992 QList<QObject*> outParams;
1993- outParams.append(new BoolWrapper(_canIgnoreSsl));
1994+ outParams.append(new BoolWrapper(_canIgnoreSsl, this));
1995 MethodParams params(inParams, outParams);
1996 MethodData methodData("canIgnoreSslErrors", params);
1997 _called.append(methodData);
1998
1999=== modified file 'ubuntu-download-manager-tests/fakes/fake_process.cpp'
2000--- ubuntu-download-manager-tests/fakes/fake_process.cpp 2013-10-30 11:04:37 +0000
2001+++ ubuntu-download-manager-tests/fakes/fake_process.cpp 2013-12-18 10:06:42 +0000
2002@@ -44,9 +44,9 @@
2003 QProcess::OpenMode mode) {
2004 if (_recording) {
2005 QList<QObject*> inParams;
2006- inParams.append(new StringWrapper(program));
2007- inParams.append(new StringListWrapper(arguments));
2008- inParams.append(new OpenModeWrapper(mode));
2009+ inParams.append(new StringWrapper(program, this));
2010+ inParams.append(new StringListWrapper(arguments, this));
2011+ inParams.append(new OpenModeWrapper(mode, this));
2012
2013 QList<QObject*> outParams;
2014 MethodParams params(inParams, outParams);
2015
2016=== modified file 'ubuntu-download-manager-tests/fakes/fake_process_factory.cpp'
2017--- ubuntu-download-manager-tests/fakes/fake_process_factory.cpp 2013-10-30 11:04:37 +0000
2018+++ ubuntu-download-manager-tests/fakes/fake_process_factory.cpp 2013-12-18 10:06:42 +0000
2019@@ -26,7 +26,7 @@
2020
2021 Process*
2022 FakeProcessFactory::createProcess() {
2023- FakeProcess* process = new FakeProcess();
2024+ FakeProcess* process = new FakeProcess(this);
2025
2026 if (_recording) {
2027 QList<QObject*> inParams;
2028
2029=== modified file 'ubuntu-download-manager-tests/fakes/fake_request_factory.cpp'
2030--- ubuntu-download-manager-tests/fakes/fake_request_factory.cpp 2013-10-30 11:04:37 +0000
2031+++ ubuntu-download-manager-tests/fakes/fake_request_factory.cpp 2013-12-18 10:06:42 +0000
2032@@ -38,11 +38,11 @@
2033 NetworkReply*
2034 FakeRequestFactory::get(const QNetworkRequest& request) {
2035 // return a FakeQNetworkReply
2036- FakeNetworkReply* reply = new FakeNetworkReply();
2037+ FakeNetworkReply* reply = new FakeNetworkReply(this);
2038
2039 if (_recording) {
2040 QList<QObject*> inParams;
2041- inParams.append(new RequestWrapper(request));
2042+ inParams.append(new RequestWrapper(request, this));
2043
2044 QList<QObject*> outParams;
2045 outParams.append(reply);
2046
2047=== modified file 'ubuntu-download-manager-tests/fakes/fake_sm_file_download.cpp'
2048--- ubuntu-download-manager-tests/fakes/fake_sm_file_download.cpp 2013-11-11 16:14:46 +0000
2049+++ ubuntu-download-manager-tests/fakes/fake_sm_file_download.cpp 2013-12-18 10:06:42 +0000
2050@@ -58,7 +58,7 @@
2051 FakeSMFileDownload::emitError(QString error) {
2052 if (_recording) {
2053 QList<QObject*> inParams;
2054- inParams.append(new StringWrapper(error));
2055+ inParams.append(new StringWrapper(error, this));
2056
2057 QList<QObject*> outParams;
2058 MethodParams params(inParams, outParams);
2059@@ -71,7 +71,7 @@
2060 FakeSMFileDownload::emitNetworkError(QNetworkReply::NetworkError code) {
2061 if (_recording) {
2062 QList<QObject*> inParams;
2063- inParams.append(new NetworkErrorWrapper(code));
2064+ inParams.append(new NetworkErrorWrapper(code, this));
2065
2066 QList<QObject*> outParams;
2067 MethodParams params(inParams, outParams);
2068@@ -84,7 +84,7 @@
2069 FakeSMFileDownload::emitSslError(const QList<QSslError>& errors) {
2070 if (_recording) {
2071 QList<QObject*> inParams;
2072- inParams.append(new SslErrorsWrapper(errors));
2073+ inParams.append(new SslErrorsWrapper(errors, this));
2074
2075 QList<QObject*> outParams;
2076 MethodParams params(inParams, outParams);
2077
2078=== modified file 'ubuntu-download-manager-tests/fakes/fake_timer.cpp'
2079--- ubuntu-download-manager-tests/fakes/fake_timer.cpp 2013-10-30 11:04:37 +0000
2080+++ ubuntu-download-manager-tests/fakes/fake_timer.cpp 2013-12-18 10:06:42 +0000
2081@@ -29,7 +29,7 @@
2082 QList<QObject*> inParams;
2083
2084 QList<QObject*> outParams;
2085- outParams.append(new BoolWrapper(_isActive));
2086+ outParams.append(new BoolWrapper(_isActive, this));
2087
2088 MethodParams params(inParams, outParams);
2089 MethodData methodData("isActive", params);
2090@@ -47,7 +47,7 @@
2091 FakeTimer::start(int msec) {
2092 if (_recording) {
2093 QList<QObject*> inParams;
2094- inParams.append(new IntWrapper(msec));
2095+ inParams.append(new IntWrapper(msec, this));
2096
2097 QList<QObject*> outParams;
2098

Subscribers

People subscribed via source and target branches