~mandel/ubuntu-download-manager/use-apparmor

« back to all changes in this revision

Viewing changes to ubuntu-download-manager-tests/test_group_download.cpp

  • Committer: Manuel de la Pena
  • Date: 2013-09-09 16:05:49 UTC
  • Revision ID: manuel@canonical.com-20130909160549-6h8v9iza3dfeuxmq
Changed download factory to use apparmor to build the dbus paths.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
    _nam = new FakeRequestFactory();
36
36
    _processFactory = new FakeProcessFactory();
37
37
    _uuidFactory = new UuidFactory();
38
 
    _downloadFactory = new FakeDownloadFactory(_uuidFactory, _networkInfo,
39
 
        _nam, _processFactory);
 
38
    _downloadFactory = new FakeDownloadFactory(
 
39
        QSharedPointer<UuidFactory>(_uuidFactory),
 
40
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
41
        QSharedPointer<RequestFactory>(_nam),
 
42
        QSharedPointer<ProcessFactory>(_processFactory));
40
43
    _fileManager = new FakeFileManager();
41
44
}
42
45
 
50
53
        delete _processFactory;
51
54
    if (_downloadFactory != NULL)
52
55
        delete _downloadFactory;
 
56
    if (_fileManager != NULL)
 
57
        delete _fileManager;
53
58
}
54
59
 
55
60
void
57
62
    QList<GroupDownloadStruct> downloads;
58
63
 
59
64
    GroupDownload* group = new GroupDownload(_id, _path, downloads, _algo,
60
 
        _isGSMDownloadAllowed, _metadata, _headers, _networkInfo, _nam,
61
 
        _processFactory, _fileManager);
 
65
        _isGSMDownloadAllowed, _metadata, _headers,
 
66
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
67
        QSharedPointer<DownloadFactory>(_downloadFactory),
 
68
        QSharedPointer<FileManager>(_fileManager));
62
69
    group->cancelDownload();
63
70
}
64
71
 
71
78
        "other_local_file", ""));
72
79
 
73
80
    GroupDownload* group = new GroupDownload(_id, _path, downloads, _algo,
74
 
        _isGSMDownloadAllowed, _metadata, _headers, _networkInfo,
75
 
        _downloadFactory, _fileManager);
 
81
        _isGSMDownloadAllowed, _metadata, _headers,
 
82
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
83
        QSharedPointer<DownloadFactory>(_downloadFactory),
 
84
        QSharedPointer<FileManager>(_fileManager));
76
85
    group->cancelDownload();
77
86
    foreach(Download* download, _downloadFactory->downloads()) {
78
87
        QCOMPARE(Download::CANCEL, download->state());
92
101
        "other_reddit_local_file", ""));
93
102
 
94
103
    GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo,
95
 
        _isGSMDownloadAllowed, _metadata, _headers, _networkInfo,
96
 
        _downloadFactory, _fileManager);
 
104
        _isGSMDownloadAllowed, _metadata, _headers,
 
105
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
106
        QSharedPointer<DownloadFactory>(_downloadFactory),
 
107
        QSharedPointer<FileManager>(_fileManager));
97
108
 
98
109
    QList<Download*> downloads = _downloadFactory->downloads();
99
110
    reinterpret_cast<FakeDownload*>(downloads[0])->emitFinished(deleteFile);
124
135
        "other_reddit_local_file", ""));
125
136
 
126
137
    GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo,
127
 
        _isGSMDownloadAllowed, _metadata, _headers, _networkInfo,
128
 
        _downloadFactory, _fileManager);
 
138
        _isGSMDownloadAllowed, _metadata, _headers,
 
139
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
140
        QSharedPointer<DownloadFactory>(_downloadFactory),
 
141
        QSharedPointer<FileManager>(_fileManager));
129
142
 
130
143
    QList<Download*> downloads = _downloadFactory->downloads();
131
144
    reinterpret_cast<FakeDownload*>(downloads[0])->cancel();
143
156
    QList<GroupDownloadStruct> downloads;
144
157
 
145
158
    GroupDownload* group = new GroupDownload(_id, _path, downloads, _algo,
146
 
        _isGSMDownloadAllowed, _metadata, _headers, _networkInfo, _nam,
147
 
        _processFactory, _fileManager);
 
159
        _isGSMDownloadAllowed, _metadata, _headers,
 
160
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
161
        QSharedPointer<DownloadFactory>(_downloadFactory),
 
162
        QSharedPointer<FileManager>(_fileManager));
148
163
    group->pauseDownload();
149
164
}
150
165
 
157
172
        "other_local_file", ""));
158
173
 
159
174
    GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo,
160
 
        _isGSMDownloadAllowed, _metadata, _headers, _networkInfo,
161
 
        _downloadFactory, _fileManager);
 
175
        _isGSMDownloadAllowed, _metadata, _headers,
 
176
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
177
        QSharedPointer<DownloadFactory>(_downloadFactory),
 
178
        QSharedPointer<FileManager>(_fileManager));
162
179
    // start all downlaods
163
180
    QList<Download*> downloads = _downloadFactory->downloads();
164
181
    foreach(Download* download, downloads) {
183
200
        "other_reddit_local_file", ""));
184
201
 
185
202
    GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo,
186
 
        _isGSMDownloadAllowed, _metadata, _headers, _networkInfo,
187
 
        _downloadFactory, _fileManager);
 
203
        _isGSMDownloadAllowed, _metadata, _headers,
 
204
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
205
        QSharedPointer<DownloadFactory>(_downloadFactory),
 
206
        QSharedPointer<FileManager>(_fileManager));
188
207
 
189
208
    QList<Download*> downloads = _downloadFactory->downloads();
190
209
    reinterpret_cast<FakeDownload*>(downloads[0])->emitFinished(deleteFile);
215
234
        "other_reddit_local_file", ""));
216
235
 
217
236
    GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo,
218
 
        _isGSMDownloadAllowed, _metadata, _headers, _networkInfo,
219
 
        _downloadFactory, _fileManager);
 
237
        _isGSMDownloadAllowed, _metadata, _headers,
 
238
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
239
        QSharedPointer<DownloadFactory>(_downloadFactory),
 
240
        QSharedPointer<FileManager>(_fileManager));
220
241
 
221
242
    QList<Download*> downloads = _downloadFactory->downloads();
222
243
    reinterpret_cast<FakeDownload*>(downloads[0])->cancel();
236
257
    QList<GroupDownloadStruct> downloads;
237
258
 
238
259
    GroupDownload* group = new GroupDownload(_id, _path, downloads, _algo,
239
 
        _isGSMDownloadAllowed, _metadata, _headers, _networkInfo, _nam,
240
 
        _processFactory, _fileManager);
 
260
        _isGSMDownloadAllowed, _metadata, _headers,
 
261
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
262
        QSharedPointer<DownloadFactory>(_downloadFactory),
 
263
        QSharedPointer<FileManager>(_fileManager));
241
264
    group->cancelDownload();
242
265
}
243
266
 
254
277
        "other_reddit_local_file", ""));
255
278
 
256
279
    GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo,
257
 
        _isGSMDownloadAllowed, _metadata, _headers, _networkInfo,
258
 
        _downloadFactory, _fileManager);
 
280
        _isGSMDownloadAllowed, _metadata, _headers,
 
281
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
282
        QSharedPointer<DownloadFactory>(_downloadFactory),
 
283
        QSharedPointer<FileManager>(_fileManager));
259
284
 
260
285
    QList<Download*> downloads = _downloadFactory->downloads();
261
286
    foreach(Download* download, downloads) {
284
309
        "other_reddit_local_file", ""));
285
310
 
286
311
    GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo,
287
 
        _isGSMDownloadAllowed, _metadata, _headers, _networkInfo,
288
 
        _downloadFactory, _fileManager);
 
312
        _isGSMDownloadAllowed, _metadata, _headers,
 
313
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
314
        QSharedPointer<DownloadFactory>(_downloadFactory),
 
315
        QSharedPointer<FileManager>(_fileManager));
289
316
 
290
317
    QList<Download*> downloads = _downloadFactory->downloads();
291
318
    reinterpret_cast<FakeDownload*>(downloads[0])->emitFinished(deleteFile);
317
344
        "other_reddit_local_file", ""));
318
345
 
319
346
    GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo,
320
 
        _isGSMDownloadAllowed, _metadata, _headers, _networkInfo,
321
 
        _downloadFactory, _fileManager);
 
347
        _isGSMDownloadAllowed, _metadata, _headers,
 
348
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
349
        QSharedPointer<DownloadFactory>(_downloadFactory),
 
350
        QSharedPointer<FileManager>(_fileManager));
322
351
 
323
352
    QList<Download*> downloads = _downloadFactory->downloads();
324
353
    (downloads[0])->cancel();
350
379
        "other_reddit_local_file", ""));
351
380
 
352
381
    GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo,
353
 
        _isGSMDownloadAllowed, _metadata, _headers, _networkInfo,
354
 
        _downloadFactory, _fileManager);
 
382
        _isGSMDownloadAllowed, _metadata, _headers,
 
383
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
384
        QSharedPointer<DownloadFactory>(_downloadFactory),
 
385
        QSharedPointer<FileManager>(_fileManager));
355
386
 
356
387
    QList<Download*> downloads = _downloadFactory->downloads();
357
388
    group->resumeDownload();
368
399
    QList<GroupDownloadStruct> downloads;
369
400
 
370
401
    GroupDownload* group = new GroupDownload(_id, _path, downloads, _algo,
371
 
        _isGSMDownloadAllowed, _metadata, _headers, _networkInfo, _nam,
372
 
        _processFactory, _fileManager);
 
402
        _isGSMDownloadAllowed, _metadata, _headers,
 
403
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
404
        QSharedPointer<DownloadFactory>(_downloadFactory),
 
405
        QSharedPointer<FileManager>(_fileManager));
373
406
    group->startDownload();
374
407
}
375
408
 
386
419
        "other_reddit_local_file", ""));
387
420
 
388
421
    GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo,
389
 
        _isGSMDownloadAllowed, _metadata, _headers, _networkInfo,
390
 
        _downloadFactory, _fileManager);
 
422
        _isGSMDownloadAllowed, _metadata, _headers,
 
423
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
424
        QSharedPointer<DownloadFactory>(_downloadFactory),
 
425
        QSharedPointer<FileManager>(_fileManager));
391
426
 
392
427
    QList<Download*> downloads = _downloadFactory->downloads();
393
428
    group->startDownload();
412
447
        "other_reddit_local_file", ""));
413
448
 
414
449
    GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo,
415
 
        _isGSMDownloadAllowed, _metadata, _headers, _networkInfo,
416
 
        _downloadFactory, _fileManager);
 
450
        _isGSMDownloadAllowed, _metadata, _headers,
 
451
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
452
        QSharedPointer<DownloadFactory>(_downloadFactory),
 
453
        QSharedPointer<FileManager>(_fileManager));
417
454
 
418
455
    QList<Download*> downloads = _downloadFactory->downloads();
419
456
    group->startDownload();
442
479
        "other_reddit_local_file", ""));
443
480
 
444
481
    GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo,
445
 
        _isGSMDownloadAllowed, _metadata, _headers, _networkInfo,
446
 
        _downloadFactory, _fileManager);
 
482
        _isGSMDownloadAllowed, _metadata, _headers,
 
483
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
484
        QSharedPointer<DownloadFactory>(_downloadFactory),
 
485
        QSharedPointer<FileManager>(_fileManager));
447
486
 
448
487
    QList<Download*> downloads = _downloadFactory->downloads();
449
488
    group->startDownload();
474
513
        "other_reddit_local_file", ""));
475
514
 
476
515
    GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo,
477
 
        _isGSMDownloadAllowed, _metadata, _headers, _networkInfo,
478
 
        _downloadFactory, _fileManager);
 
516
        _isGSMDownloadAllowed, _metadata, _headers,
 
517
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
518
        QSharedPointer<DownloadFactory>(_downloadFactory),
 
519
        QSharedPointer<FileManager>(_fileManager));
479
520
 
480
521
    QList<Download*> downloads = _downloadFactory->downloads();
481
522
    reinterpret_cast<FakeDownload*>(downloads[0])->emitFinished(deleteFile);
503
544
        "other_reddit_local_file", ""));
504
545
 
505
546
    GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo,
506
 
        _isGSMDownloadAllowed, _metadata, _headers, _networkInfo,
507
 
        _downloadFactory, _fileManager);
 
547
        _isGSMDownloadAllowed, _metadata, _headers,
 
548
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
549
        QSharedPointer<DownloadFactory>(_downloadFactory),
 
550
        QSharedPointer<FileManager>(_fileManager));
508
551
 
509
552
    QList<Download*> downloads = _downloadFactory->downloads();
510
553
    downloads[0]->cancel();
533
576
        "other_reddit_local_file", ""));
534
577
 
535
578
    GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo,
536
 
        _isGSMDownloadAllowed, _metadata, _headers, _networkInfo,
537
 
        _downloadFactory, _fileManager);
 
579
        _isGSMDownloadAllowed, _metadata, _headers,
 
580
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
581
        QSharedPointer<DownloadFactory>(_downloadFactory),
 
582
        QSharedPointer<FileManager>(_fileManager));
538
583
    QSignalSpy spy(group, SIGNAL(finished(QStringList)));
539
584
 
540
585
    QList<Download*> downloads = _downloadFactory->downloads();
560
605
        "other_reddit_local_file", ""));
561
606
 
562
607
    GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo,
563
 
        _isGSMDownloadAllowed, _metadata, _headers, _networkInfo,
564
 
        _downloadFactory, _fileManager);
 
608
        _isGSMDownloadAllowed, _metadata, _headers,
 
609
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
610
        QSharedPointer<DownloadFactory>(_downloadFactory),
 
611
        QSharedPointer<FileManager>(_fileManager));
565
612
    QSignalSpy spy(group, SIGNAL(finished(QStringList)));
566
613
 
567
614
    QList<Download*> downloads = _downloadFactory->downloads();
588
635
        "other_reddit_local_file", ""));
589
636
 
590
637
    GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo,
591
 
        _isGSMDownloadAllowed, _metadata, _headers, _networkInfo,
592
 
        _downloadFactory, _fileManager);
 
638
        _isGSMDownloadAllowed, _metadata, _headers,
 
639
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
640
        QSharedPointer<DownloadFactory>(_downloadFactory),
 
641
        QSharedPointer<FileManager>(_fileManager));
593
642
    QSignalSpy spy(group, SIGNAL(error(QString)));
594
643
 
595
644
    QList<Download*> downloads = _downloadFactory->downloads();
615
664
        "other_reddit_local_file", ""));
616
665
 
617
666
    GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo,
618
 
        _isGSMDownloadAllowed, _metadata, _headers, _networkInfo,
619
 
        _downloadFactory, _fileManager);
 
667
        _isGSMDownloadAllowed, _metadata, _headers,
 
668
        QSharedPointer<SystemNetworkInfo>(_networkInfo),
 
669
        QSharedPointer<DownloadFactory>(_downloadFactory),
 
670
        QSharedPointer<FileManager>(_fileManager));
620
671
    QSignalSpy spy(group, SIGNAL(error(QString)));
621
672
 
622
673
    QList<Download*> downloads = _downloadFactory->downloads();