Merge lp:~mandel/ubuntu-download-manager/use-appid-local-path into lp:ubuntu-download-manager
- use-appid-local-path
- Merge into trunk
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Manuel de la Peña | ||||||||
Approved revision: | 128 | ||||||||
Merged at revision: | 124 | ||||||||
Proposed branch: | lp:~mandel/ubuntu-download-manager/use-appid-local-path | ||||||||
Merge into: | lp:ubuntu-download-manager | ||||||||
Diff against target: |
2205 lines (+809/-275) 25 files modified
libubuntudownloadmanager/apparmor.cpp (+82/-26) libubuntudownloadmanager/apparmor.h (+11/-2) libubuntudownloadmanager/download.cpp (+30/-2) libubuntudownloadmanager/download.h (+6/-0) libubuntudownloadmanager/download_factory.cpp (+97/-14) libubuntudownloadmanager/download_factory.h (+18/-0) libubuntudownloadmanager/group_download.cpp (+19/-6) libubuntudownloadmanager/group_download.h (+4/-0) libubuntudownloadmanager/single_download.cpp (+26/-40) libubuntudownloadmanager/single_download.h (+6/-0) ubuntu-download-manager-tests/fake_apparmor.cpp (+45/-21) ubuntu-download-manager-tests/fake_apparmor.h (+15/-2) ubuntu-download-manager-tests/fake_download.cpp (+8/-4) ubuntu-download-manager-tests/fake_download.h (+24/-20) ubuntu-download-manager-tests/fake_download_factory.cpp (+66/-6) ubuntu-download-manager-tests/fake_download_factory.h (+14/-0) ubuntu-download-manager-tests/test_download.cpp (+153/-78) ubuntu-download-manager-tests/test_download.h (+6/-0) ubuntu-download-manager-tests/test_download_factory.cpp (+34/-0) ubuntu-download-manager-tests/test_download_factory.h (+2/-0) ubuntu-download-manager-tests/test_download_queue.cpp (+6/-2) ubuntu-download-manager-tests/test_download_queue.h (+2/-0) ubuntu-download-manager-tests/test_downloads_db.cpp (+5/-5) ubuntu-download-manager-tests/test_group_download.cpp (+125/-47) ubuntu-download-manager-tests/test_group_download.h (+5/-0) |
||||||||
To merge this branch: | bzr merge lp:~mandel/ubuntu-download-manager/use-appid-local-path | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Mike McCracken (community) | Approve | ||
Diego Sarmentero (community) | Approve | ||
Review via email:
|
Commit message
Fixed the location where the file is stored. If the local-file metadata is provided and the app is not cofined that would be the used file else the XDG/APP_ID one will be used.
Description of the change
Fixed the location where the file is stored. If the local-file metadata is provided and the app is not cofined that would be the used file else the XDG/APP_ID one will be used.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Diego Sarmentero (diegosarmentero) wrote : | # |
+1 Look ok to me, just a little thing: Shouldn't we be using QStandardPaths instead of the implementation of xdg that we seem to be using here in part of the code? is xdg providing anything else that QStandardPaths+QDir is not doing?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Manuel de la Peña (mandel) wrote : | # |
> +1 Look ok to me, just a little thing: Shouldn't we be using QStandardPaths
> instead of the implementation of xdg that we seem to be using here in part of
> the code? is xdg providing anything else that QStandardPaths+QDir is not
> doing?
You are correct, I was working without the QStandardPaths because they used not to support XDG in qt4 (or ealier) I'll create a branch to use QStandardPaths over the class I created in a diff branch.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mike McCracken (mikemc) wrote : | # |
1.
the reason for the needsfixing:
Unless I'm up too late, it looks like in download_
'bool isConfined' on lines 83, 103, and 124. I can't tell what the
intended default for those functions is, but the value will be
undefined. (see
e.g. http://
which references the C++ standard and has a funny example program.)
- related, I saw a lot of tests for those functions but couldn't
really tell if this issue was covered by tests. It'd be nice to create
a test that checks this and see what happens.
I saw in test_download.cpp and test_group_
just set to a single value for the whole class. would it make sense to use the
QTest::addColumn trick to have it run all those tests with both values?
2.
In AppArmor.h/.cpp, the the public API has "isContained" as the last
parameter of both versions of getSecurePath(), but the internal
versions call it 'isConfined'. they should probably all say
'isConfined'. (Not a needsfixing but it'd be nice if you have time to
fix it here)
3.
Not a branch blocker, but I found the download-factory API a little
awkward. Why is every function an overloaded version of
createDownload()? One version creates a group download, for example,
and the versions that you add in this branch have a comment about
being used to create 'from a group download', so they're different too
- why not use different names?
(One argument for using different names is that it's easier to grep
through the source that way)
- 128. By Manuel de la Peña
-
Made changes according to review.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mike McCracken (mikemc) : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:128
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'libubuntudownloadmanager/apparmor.cpp' |
2 | --- libubuntudownloadmanager/apparmor.cpp 2013-09-10 15:27:32 +0000 |
3 | +++ libubuntudownloadmanager/apparmor.cpp 2013-09-18 10:19:27 +0000 |
4 | @@ -24,6 +24,7 @@ |
5 | #include <QRegExp> |
6 | #include "./dbus_proxy.h" |
7 | #include "./uuid_factory.h" |
8 | +#include "./xdg_basedir.h" |
9 | #include "./apparmor.h" |
10 | |
11 | /* |
12 | @@ -41,39 +42,77 @@ |
13 | _uuidFactory = new UuidFactory(); |
14 | } |
15 | |
16 | - QPair<QUuid, QString> getUuidString(QUuid id, QString path) { |
17 | + QString getUuidPath(QUuid id, QString path) { |
18 | qDebug() << __PRETTY_FUNCTION__ << path; |
19 | QString idString = path + "/" + id.toString().replace( |
20 | QRegExp("[-{}]"), ""); |
21 | qDebug() << "Download path is" << idString; |
22 | - return QPair<QUuid, QString>(id, idString); |
23 | - } |
24 | - |
25 | - QPair<QUuid, QString> getSecurePath(QString connectionName) { |
26 | + return idString; |
27 | + } |
28 | + |
29 | + void getDBusPath(QUuid& id, QString& dbusPath) { |
30 | + id = _uuidFactory->createUuid(); |
31 | + dbusPath = getUuidPath(id, ""); |
32 | + } |
33 | + |
34 | + QUuid getSecurePath(const QString& connName, |
35 | + QString& dbusPath, |
36 | + QString& localPath, |
37 | + bool& isConfined) { |
38 | QUuid id = _uuidFactory->createUuid(); |
39 | - return getSecurePath(id, connectionName); |
40 | - } |
41 | - |
42 | - QPair<QUuid, QString> getSecurePath(QUuid id, QString connectionName) { |
43 | - if (connectionName.isEmpty()) { |
44 | - return getUuidString(id, QString(BASE_ACCOUNT_URL)); |
45 | + getSecurePath(connName, id, dbusPath, localPath, isConfined); |
46 | + return id; |
47 | + } |
48 | + |
49 | + QString getLocalPath(const QString& appId) { |
50 | + QStringList pathComponents; |
51 | + if (!appId.isEmpty()) { |
52 | + QStringList appIdInfo = appId.split("_"); |
53 | + if (appIdInfo.count() > 0) |
54 | + pathComponents << appIdInfo[0]; |
55 | + } |
56 | + |
57 | + pathComponents << "Downloads"; |
58 | + QString localPath = XDGBasedir::saveDataPath(pathComponents); |
59 | + qDebug() << "Local path is" << localPath; |
60 | + return localPath; |
61 | + } |
62 | + |
63 | + void getSecurePath(const QString& connName, |
64 | + const QUuid& id, |
65 | + QString& dbusPath, |
66 | + QString& localPath, |
67 | + bool& isConfined) { |
68 | + if (connName.isEmpty()) { |
69 | + dbusPath = getUuidPath(id, QString(BASE_ACCOUNT_URL)); |
70 | + localPath = getLocalPath(""); |
71 | + isConfined = false; |
72 | + return; |
73 | } |
74 | |
75 | QDBusPendingReply<QString> reply = |
76 | - _dbus->GetConnectionAppArmorSecurityContext(connectionName); |
77 | + _dbus->GetConnectionAppArmorSecurityContext(connName); |
78 | // blocking but should be ok for now |
79 | reply.waitForFinished(); |
80 | if (reply.isError()) { |
81 | qCritical() << reply.error(); |
82 | - return getUuidString(id, QString(BASE_ACCOUNT_URL)); |
83 | + dbusPath = getUuidPath(id, QString(BASE_ACCOUNT_URL)); |
84 | + localPath = getLocalPath(""); |
85 | + isConfined = false; |
86 | + return; |
87 | } else { |
88 | // use the returned value |
89 | QString appId = reply.value(); |
90 | qDebug() << "AppId is " << appId; |
91 | |
92 | if (appId.isEmpty() || appId == UNCONFINED_ID) { |
93 | - return getUuidString(id, QString(BASE_ACCOUNT_URL)); |
94 | + qDebug() << "UNCONFINED APP"; |
95 | + dbusPath = getUuidPath(id, QString(BASE_ACCOUNT_URL)); |
96 | + localPath = getLocalPath(""); |
97 | + isConfined = false; |
98 | + return; |
99 | } else { |
100 | + isConfined = true; |
101 | QByteArray appIdBa = appId.toUtf8(); |
102 | |
103 | char * appIdPath; |
104 | @@ -83,14 +122,18 @@ |
105 | if (appIdPath == NULL) { |
106 | qCritical() << "Unable to allocate memory for " |
107 | << "nih_dbus_path()"; |
108 | - return getUuidString(id, QString(BASE_ACCOUNT_URL)); |
109 | + dbusPath = getUuidPath(id, QString(BASE_ACCOUNT_URL)); |
110 | + localPath = getLocalPath(appId); |
111 | + return; |
112 | } |
113 | QString path = QString(appIdPath); |
114 | qDebug() << "AppId path is " << appIdPath; |
115 | |
116 | // free nih data |
117 | nih_free(appIdPath); |
118 | - return getUuidString(id, path); |
119 | + dbusPath = getUuidPath(id, path); |
120 | + localPath = getLocalPath(appId); |
121 | + return; |
122 | } // not empty appid string |
123 | } // no dbus error |
124 | } |
125 | @@ -116,14 +159,27 @@ |
126 | d_ptr(new AppArmorPrivate(this)) { |
127 | } |
128 | |
129 | -QPair<QUuid, QString> |
130 | -AppArmor::getSecurePath(QString connectionName) { |
131 | - Q_D(AppArmor); |
132 | - return d->getSecurePath(connectionName); |
133 | -} |
134 | - |
135 | -QPair<QUuid, QString> |
136 | -AppArmor::getSecurePath(QUuid id, QString connectionName) { |
137 | - Q_D(AppArmor); |
138 | - return d->getSecurePath(id, connectionName); |
139 | +void |
140 | +AppArmor::getDBusPath(QUuid& id, QString& dbusPath) { |
141 | + Q_D(AppArmor); |
142 | + return d->getDBusPath(id, dbusPath); |
143 | +} |
144 | + |
145 | +QUuid |
146 | +AppArmor::getSecurePath(const QString& connName, |
147 | + QString& dbusPath, |
148 | + QString& localPath, |
149 | + bool& isConfined) { |
150 | + Q_D(AppArmor); |
151 | + return d->getSecurePath(connName, dbusPath, localPath, isConfined); |
152 | +} |
153 | + |
154 | +void |
155 | +AppArmor::getSecurePath(const QString& connName, |
156 | + const QUuid& id, |
157 | + QString& dbusPath, |
158 | + QString& localPath, |
159 | + bool& isConfined) { |
160 | + Q_D(AppArmor); |
161 | + d->getSecurePath(connName, id, dbusPath, localPath, isConfined); |
162 | } |
163 | |
164 | === modified file 'libubuntudownloadmanager/apparmor.h' |
165 | --- libubuntudownloadmanager/apparmor.h 2013-09-10 15:27:32 +0000 |
166 | +++ libubuntudownloadmanager/apparmor.h 2013-09-18 10:19:27 +0000 |
167 | @@ -32,8 +32,17 @@ |
168 | public: |
169 | explicit AppArmor(QObject *parent = 0); |
170 | |
171 | - virtual QPair<QUuid, QString> getSecurePath(QString connName); |
172 | - virtual QPair<QUuid, QString> getSecurePath(QUuid id, QString connName); |
173 | + virtual void getDBusPath(QUuid& id, QString& dbusPath); |
174 | + |
175 | + virtual QUuid getSecurePath(const QString& connName, |
176 | + QString& dbusPath, |
177 | + QString& localPath, |
178 | + bool& isConfined); |
179 | + virtual void getSecurePath(const QString& connName, |
180 | + const QUuid& id, |
181 | + QString& dbusPath, |
182 | + QString& localPath, |
183 | + bool& isConfined); |
184 | |
185 | private: |
186 | // use pimpl so that we can mantains ABI compatibility |
187 | |
188 | === modified file 'libubuntudownloadmanager/download.cpp' |
189 | --- libubuntudownloadmanager/download.cpp 2013-09-09 16:05:49 +0000 |
190 | +++ libubuntudownloadmanager/download.cpp 2013-09-18 10:19:27 +0000 |
191 | @@ -30,6 +30,8 @@ |
192 | public: |
193 | DownloadPrivate(const QUuid& id, |
194 | const QString& path, |
195 | + bool isConfined, |
196 | + const QString& rootPath, |
197 | const QVariantMap& metadata, |
198 | const QMap<QString, QString>& headers, |
199 | QSharedPointer<SystemNetworkInfo> networkInfo, |
200 | @@ -39,6 +41,8 @@ |
201 | _allowGSMDownload(true), |
202 | _state(Download::IDLE), |
203 | _dbusPath(path), |
204 | + _isConfined(isConfined), |
205 | + _rootPath(rootPath), |
206 | _metadata(metadata), |
207 | _headers(headers), |
208 | _networkInfo(networkInfo), |
209 | @@ -58,6 +62,14 @@ |
210 | return _dbusPath; |
211 | } |
212 | |
213 | + bool isConfined() const { |
214 | + return _isConfined; |
215 | + } |
216 | + |
217 | + QString rootPath() const { |
218 | + return _rootPath; |
219 | + } |
220 | + |
221 | Download::State state() { |
222 | return _state; |
223 | } |
224 | @@ -158,6 +170,8 @@ |
225 | bool _allowGSMDownload; |
226 | Download::State _state; |
227 | QString _dbusPath; |
228 | + bool _isConfined; |
229 | + QString _rootPath; |
230 | QVariantMap _metadata; |
231 | QMap<QString, QString> _headers; |
232 | QSharedPointer<SystemNetworkInfo> _networkInfo; |
233 | @@ -171,13 +185,15 @@ |
234 | |
235 | Download::Download(const QUuid& id, |
236 | const QString& path, |
237 | + bool isConfined, |
238 | + const QString& rootPath, |
239 | const QVariantMap& metadata, |
240 | const QMap<QString, QString>& headers, |
241 | QSharedPointer<SystemNetworkInfo> networkInfo, |
242 | QObject* parent) |
243 | : QObject(parent), |
244 | - d_ptr(new DownloadPrivate(id, path, metadata, headers, |
245 | - networkInfo, this)) { |
246 | + d_ptr(new DownloadPrivate(id, path, isConfined, rootPath, metadata, |
247 | + headers, networkInfo, this)) { |
248 | } |
249 | |
250 | QUuid |
251 | @@ -192,6 +208,18 @@ |
252 | return d->path(); |
253 | } |
254 | |
255 | +bool |
256 | +Download::isConfined() { |
257 | + Q_D(Download); |
258 | + return d->isConfined(); |
259 | +} |
260 | + |
261 | +QString |
262 | +Download::rootPath() { |
263 | + Q_D(Download); |
264 | + return d->rootPath(); |
265 | +} |
266 | + |
267 | Download::State |
268 | Download::state() { |
269 | Q_D(Download); |
270 | |
271 | === modified file 'libubuntudownloadmanager/download.h' |
272 | --- libubuntudownloadmanager/download.h 2013-09-09 16:05:49 +0000 |
273 | +++ libubuntudownloadmanager/download.h 2013-09-18 10:19:27 +0000 |
274 | @@ -46,6 +46,8 @@ |
275 | |
276 | Download(const QUuid& id, |
277 | const QString& path, |
278 | + bool isConfined, |
279 | + const QString& rootPath, |
280 | const QVariantMap& metadata, |
281 | const QMap<QString, QString>& headers, |
282 | QSharedPointer<SystemNetworkInfo> networkInfo, |
283 | @@ -55,6 +57,10 @@ |
284 | |
285 | QString path(); |
286 | |
287 | + bool isConfined(); |
288 | + |
289 | + QString rootPath(); |
290 | + |
291 | Download::State state(); |
292 | void setState(Download::State state); |
293 | |
294 | |
295 | === modified file 'libubuntudownloadmanager/download_factory.cpp' |
296 | --- libubuntudownloadmanager/download_factory.cpp 2013-09-10 15:27:32 +0000 |
297 | +++ libubuntudownloadmanager/download_factory.cpp 2013-09-18 10:19:27 +0000 |
298 | @@ -24,6 +24,7 @@ |
299 | #include "./download_factory.h" |
300 | |
301 | #define OBJECT_PATH_KEY "objectpath" |
302 | + |
303 | /* |
304 | * PRIVATE IMPLEMENTATION |
305 | */ |
306 | @@ -46,22 +47,29 @@ |
307 | q_ptr(parent) { |
308 | } |
309 | |
310 | - QPair<QUuid, QString> getDownloadPath(const QString& dbusOwner, |
311 | - const QVariantMap& metadata) { |
312 | + void getDownloadPath(const QString& dbusOwner, |
313 | + const QVariantMap& metadata, |
314 | + QUuid& id, |
315 | + QString& dbusPath, |
316 | + QString& rootPath, |
317 | + bool& isConfined) { |
318 | qDebug() << __PRETTY_FUNCTION__ << dbusOwner << metadata; |
319 | if (metadata.contains(OBJECT_PATH_KEY)) { |
320 | // create a uuid using the string value form the metadata |
321 | - QUuid id = QUuid(metadata[OBJECT_PATH_KEY].toString()); |
322 | + id = QUuid(metadata[OBJECT_PATH_KEY].toString()); |
323 | if (id.isNull()) { |
324 | qCritical() << "Uuid sent by client is NULL"; |
325 | - return _apparmor->getSecurePath(dbusOwner); |
326 | + id = _apparmor->getSecurePath(dbusOwner, dbusPath, rootPath, |
327 | + isConfined); |
328 | } else { |
329 | qDebug() << "Using the id from the client" << id; |
330 | - return _apparmor->getSecurePath(id, dbusOwner); |
331 | + _apparmor->getSecurePath(dbusOwner, id, dbusPath, rootPath, |
332 | + isConfined); |
333 | } |
334 | } else { |
335 | qDebug() << "DownloadFactory assigns the Download Uuid."; |
336 | - return _apparmor->getSecurePath(dbusOwner); |
337 | + id = _apparmor->getSecurePath(dbusOwner, dbusPath, rootPath, |
338 | + isConfined); |
339 | } |
340 | } |
341 | |
342 | @@ -69,9 +77,15 @@ |
343 | const QUrl& url, |
344 | const QVariantMap& metadata, |
345 | const QMap<QString, QString>& headers) { |
346 | - QPair<QUuid, QString> idData = getDownloadPath(dbusOwner, metadata); |
347 | - Download* down = new SingleDownload(idData.first, idData.second, url, |
348 | - metadata, headers, _networkInfo, _nam, _processFactory); |
349 | + QUuid id; |
350 | + QString dbusPath; |
351 | + QString rootPath; |
352 | + bool isConfined = false; |
353 | + getDownloadPath(dbusOwner, metadata, id, dbusPath, rootPath, |
354 | + isConfined); |
355 | + qDebug() << "Download secure data is " << id << dbusPath << rootPath; |
356 | + Download* down = new SingleDownload(id, dbusPath, isConfined, rootPath, |
357 | + url, metadata, headers, _networkInfo, _nam, _processFactory); |
358 | DownloadAdaptor* adaptor = new DownloadAdaptor(down); |
359 | down->setAdaptor(adaptor); |
360 | return down; |
361 | @@ -83,9 +97,15 @@ |
362 | QCryptographicHash::Algorithm algo, |
363 | const QVariantMap& metadata, |
364 | const QMap<QString, QString>& headers) { |
365 | - QPair<QUuid, QString> idData = getDownloadPath(dbusOwner, metadata); |
366 | - Download* down = new SingleDownload(idData.first, idData.second, url, |
367 | - hash, algo, metadata, headers, _networkInfo, _nam, |
368 | + QUuid id; |
369 | + QString dbusPath; |
370 | + QString rootPath; |
371 | + bool isConfined = false; |
372 | + getDownloadPath(dbusOwner, metadata, id, dbusPath, rootPath, |
373 | + isConfined); |
374 | + qDebug() << "Download secure data is " << id << dbusPath << rootPath; |
375 | + Download* down = new SingleDownload(id, dbusPath, isConfined, |
376 | + rootPath, url, hash, algo, metadata, headers, _networkInfo, _nam, |
377 | _processFactory); |
378 | DownloadAdaptor* adaptor = new DownloadAdaptor(down); |
379 | down->setAdaptor(adaptor); |
380 | @@ -98,8 +118,14 @@ |
381 | bool allowed3G, |
382 | const QVariantMap& metadata, |
383 | StringMap headers) { |
384 | - QPair<QUuid, QString> idData = getDownloadPath(dbusOwner, metadata); |
385 | - Download* down = new GroupDownload(idData.first, idData.second, |
386 | + QUuid id; |
387 | + QString dbusPath; |
388 | + QString rootPath; |
389 | + bool isConfined = false; |
390 | + getDownloadPath(dbusOwner, metadata, id, dbusPath, rootPath, |
391 | + isConfined); |
392 | + qDebug() << "Download secure data is " << id << dbusPath << rootPath; |
393 | + Download* down = new GroupDownload(id, dbusPath, isConfined, rootPath, |
394 | downloads, algo, allowed3G, metadata, headers, _networkInfo, |
395 | _self); |
396 | GroupDownloadAdaptor* adaptor = new GroupDownloadAdaptor(down); |
397 | @@ -107,6 +133,39 @@ |
398 | return down; |
399 | } |
400 | |
401 | + Download* createDownloadForGroup(bool isConfined, |
402 | + const QString& rootPath, |
403 | + const QUrl& url, |
404 | + const QVariantMap& metadata, |
405 | + const QMap<QString, QString>& headers) { |
406 | + QUuid id; |
407 | + QString dbusPath; |
408 | + _apparmor->getDBusPath(id, dbusPath); |
409 | + Download* down = new SingleDownload(id, dbusPath, isConfined, rootPath, |
410 | + url, metadata, headers, _networkInfo, _nam, _processFactory); |
411 | + DownloadAdaptor* adaptor = new DownloadAdaptor(down); |
412 | + down->setAdaptor(adaptor); |
413 | + return down; |
414 | + } |
415 | + |
416 | + Download* createDownloadForGroup(bool isConfined, |
417 | + const QString& rootPath, |
418 | + const QUrl& url, |
419 | + const QString& hash, |
420 | + QCryptographicHash::Algorithm algo, |
421 | + const QVariantMap& metadata, |
422 | + const QMap<QString, QString>& headers) { |
423 | + QUuid id; |
424 | + QString dbusPath; |
425 | + _apparmor->getDBusPath(id, dbusPath); |
426 | + Download* down = new SingleDownload(id, dbusPath, isConfined, |
427 | + rootPath, url, hash, algo, metadata, headers, _networkInfo, _nam, |
428 | + _processFactory); |
429 | + DownloadAdaptor* adaptor = new DownloadAdaptor(down); |
430 | + down->setAdaptor(adaptor); |
431 | + return down; |
432 | + } |
433 | + |
434 | private: |
435 | QSharedPointer<AppArmor> _apparmor; |
436 | QSharedPointer<SystemNetworkInfo> _networkInfo; |
437 | @@ -162,3 +221,27 @@ |
438 | return d->createDownload(dbusOwner, downloads, algo, allowed3G, metadata, |
439 | headers); |
440 | } |
441 | + |
442 | +Download* |
443 | +DownloadFactory::createDownloadForGroup(bool isConfined, |
444 | + const QString& rootPath, |
445 | + const QUrl& url, |
446 | + const QVariantMap& metadata, |
447 | + const QMap<QString, QString>& headers) { |
448 | + Q_D(DownloadFactory); |
449 | + return d->createDownloadForGroup(isConfined, rootPath, url, metadata, |
450 | + headers); |
451 | +} |
452 | + |
453 | +Download* |
454 | +DownloadFactory::createDownloadForGroup(bool isConfined, |
455 | + const QString& rootPath, |
456 | + const QUrl& url, |
457 | + const QString& hash, |
458 | + QCryptographicHash::Algorithm algo, |
459 | + const QVariantMap& metadata, |
460 | + const QMap<QString, QString>& headers) { |
461 | + Q_D(DownloadFactory); |
462 | + return d->createDownloadForGroup(isConfined, rootPath, url, hash, algo, |
463 | + metadata, headers); |
464 | +} |
465 | |
466 | === modified file 'libubuntudownloadmanager/download_factory.h' |
467 | --- libubuntudownloadmanager/download_factory.h 2013-09-10 12:18:34 +0000 |
468 | +++ libubuntudownloadmanager/download_factory.h 2013-09-18 10:19:27 +0000 |
469 | @@ -40,6 +40,8 @@ |
470 | QSharedPointer<ProcessFactory> processFactory, |
471 | QObject *parent = 0); |
472 | |
473 | + // create downloads comming from a dbus call |
474 | + |
475 | virtual Download* createDownload(const QString& dbusOwner, |
476 | const QUrl& url, |
477 | const QVariantMap& metadata, |
478 | @@ -59,6 +61,22 @@ |
479 | const QVariantMap& metadata, |
480 | StringMap headers); |
481 | |
482 | + // create downloads from a group download |
483 | + |
484 | + virtual Download* createDownloadForGroup(bool isConfined, |
485 | + const QString& rootPath, |
486 | + const QUrl& url, |
487 | + const QVariantMap& metadata, |
488 | + const QMap<QString, QString>& headers); |
489 | + |
490 | + virtual Download* createDownloadForGroup(bool isConfined, |
491 | + const QString& rootPath, |
492 | + const QUrl& url, |
493 | + const QString& hash, |
494 | + QCryptographicHash::Algorithm algo, |
495 | + const QVariantMap& metadata, |
496 | + const QMap<QString, QString>& headers); |
497 | + |
498 | private: |
499 | // use pimpl so that we can mantains ABI compatibility |
500 | DownloadFactoryPrivate* d_ptr; |
501 | |
502 | === modified file 'libubuntudownloadmanager/group_download.cpp' |
503 | --- libubuntudownloadmanager/group_download.cpp 2013-09-10 12:18:34 +0000 |
504 | +++ libubuntudownloadmanager/group_download.cpp 2013-09-18 10:19:27 +0000 |
505 | @@ -80,15 +80,22 @@ |
506 | QString hash = download.getHash(); |
507 | |
508 | SingleDownload* singleDownload; |
509 | + QVariantMap downloadMetadata = QVariantMap(metadata); |
510 | + downloadMetadata[LOCAL_PATH_KEY] = download.getLocalFile(); |
511 | + qDebug() << "Download metadata is" << downloadMetadata; |
512 | + qDebug() << "Group metadata is" << metadata; |
513 | + |
514 | if (hash.isEmpty()) { |
515 | qDebug() << "Creating SingleDownload with no hash."; |
516 | singleDownload = qobject_cast<SingleDownload*>( |
517 | - _downFactory->createDownload("", url, metadata, headers)); |
518 | + _downFactory->createDownloadForGroup(q->isConfined(), |
519 | + q->rootPath(), url, downloadMetadata, headers)); |
520 | } else { |
521 | qDebug() << "Creating SingleDownload with hash."; |
522 | singleDownload = qobject_cast<SingleDownload*>( |
523 | - _downFactory->createDownload("", url, hash, algo, metadata, |
524 | - headers)); |
525 | + _downFactory->createDownloadForGroup(q->isConfined(), |
526 | + q->rootPath(), url, hash, algo, downloadMetadata, |
527 | + headers)); |
528 | } |
529 | |
530 | singleDownload->allowGSMDownload(isGSMDownloadAllowed); |
531 | @@ -223,7 +230,7 @@ |
532 | Q_Q(GroupDownload); |
533 | SingleDownload* sender = qobject_cast<SingleDownload*>(q->sender()); |
534 | qDebug() << __PRETTY_FUNCTION__; |
535 | - // TODO (mandel): the result is not real, we need to be smarter make |
536 | + // TODO(mandel): the result is not real, we need to be smarter make |
537 | // a head request get size and name and the do all this, but atm is |
538 | // 'good enough' get the sender and check if we received |
539 | // progress from it, update its data and recanculate |
540 | @@ -292,6 +299,8 @@ |
541 | |
542 | GroupDownload::GroupDownload(const QUuid& id, |
543 | const QString& path, |
544 | + bool isConfined, |
545 | + const QString& rootPath, |
546 | QList<GroupDownloadStruct> downloads, |
547 | QCryptographicHash::Algorithm algo, |
548 | bool isGSMDownloadAllowed, |
549 | @@ -300,13 +309,16 @@ |
550 | QSharedPointer<SystemNetworkInfo> networkInfo, |
551 | QSharedPointer<DownloadFactory> downFactory, |
552 | QObject* parent) |
553 | - : Download(id, path, metadata, headers, networkInfo, parent), |
554 | + : Download(id, path, isConfined, rootPath, metadata, headers, |
555 | + networkInfo, parent), |
556 | d_ptr(new GroupDownloadPrivate(downloads, algo, isGSMDownloadAllowed, |
557 | networkInfo, downFactory, this)) { |
558 | } |
559 | |
560 | GroupDownload::GroupDownload(const QUuid& id, |
561 | const QString& path, |
562 | + bool isConfined, |
563 | + const QString& rootPath, |
564 | QList<GroupDownloadStruct> downloads, |
565 | QCryptographicHash::Algorithm algo, |
566 | bool isGSMDownloadAllowed, |
567 | @@ -316,7 +328,8 @@ |
568 | QSharedPointer<DownloadFactory> downFactory, |
569 | QSharedPointer<FileManager> fileManager, |
570 | QObject* parent) |
571 | - : Download(id, path, metadata, headers, networkInfo, parent), |
572 | + : Download(id, path, isConfined, rootPath, metadata, headers, |
573 | + networkInfo, parent), |
574 | d_ptr(new GroupDownloadPrivate(downloads, algo, isGSMDownloadAllowed, |
575 | networkInfo, downFactory, fileManager, this)) { |
576 | } |
577 | |
578 | === modified file 'libubuntudownloadmanager/group_download.h' |
579 | --- libubuntudownloadmanager/group_download.h 2013-09-10 12:18:34 +0000 |
580 | +++ libubuntudownloadmanager/group_download.h 2013-09-18 10:19:27 +0000 |
581 | @@ -36,6 +36,8 @@ |
582 | public: |
583 | GroupDownload(const QUuid& id, |
584 | const QString& path, |
585 | + bool isConfined, |
586 | + const QString& rootPath, |
587 | QList<GroupDownloadStruct> downloads, |
588 | QCryptographicHash::Algorithm algo, |
589 | bool isGSMDownloadAllowed, |
590 | @@ -47,6 +49,8 @@ |
591 | |
592 | GroupDownload(const QUuid& id, |
593 | const QString& path, |
594 | + bool isConfined, |
595 | + const QString& rootPath, |
596 | QList<GroupDownloadStruct> downloads, |
597 | QCryptographicHash::Algorithm algo, |
598 | bool isGSMDownloadAllowed, |
599 | |
600 | === modified file 'libubuntudownloadmanager/single_download.cpp' |
601 | --- libubuntudownloadmanager/single_download.cpp 2013-09-09 16:05:49 +0000 |
602 | +++ libubuntudownloadmanager/single_download.cpp 2013-09-18 10:19:27 +0000 |
603 | @@ -85,9 +85,7 @@ |
604 | } |
605 | |
606 | QString filePath() { |
607 | - if (_currentData) |
608 | - return _currentData->fileName(); |
609 | - return saveFileName(); |
610 | + return _filePath; |
611 | } |
612 | |
613 | QString hash() const { |
614 | @@ -188,7 +186,7 @@ |
615 | qDebug() << "Starting download."; |
616 | // create file that will be used to mantain the state of the |
617 | // download when resumed. |
618 | - _currentData = new QFile(saveFileName()); |
619 | + _currentData = new QFile(_filePath); |
620 | _currentData->open(QIODevice::ReadWrite | QFile::Append); |
621 | |
622 | // signals should take care or calling deleteLater on the |
623 | @@ -356,12 +354,8 @@ |
624 | |
625 | private: |
626 | void init() { |
627 | - Q_Q(SingleDownload); |
628 | - QStringList pathComponents; |
629 | - pathComponents << "download_manager" << q->downloadId().toString(); |
630 | - _localPath = XDGBasedir::saveDataPath(pathComponents); |
631 | - qDebug() << "File will be downloaded to" << _localPath; |
632 | - |
633 | + _filePath = saveFileName(); |
634 | + qDebug() << "Download path is" << _filePath; |
635 | _reply = NULL; |
636 | _currentData = NULL; |
637 | } |
638 | @@ -395,39 +389,25 @@ |
639 | } |
640 | |
641 | QString saveFileName() { |
642 | + Q_Q(SingleDownload); |
643 | + |
644 | QString path = _url.path(); |
645 | QString basename = QFileInfo(path).fileName(); |
646 | |
647 | if (basename.isEmpty()) |
648 | basename = DATA_FILE_NAME; |
649 | |
650 | - QString final_path = _localPath + QDir::separator() + basename; |
651 | - return final_path; |
652 | - } |
653 | - |
654 | - bool removeDir(const QString& dirName) { |
655 | - bool result = true; |
656 | - QDir dir(dirName); |
657 | - |
658 | - QFlags<QDir::Filter> filter = QDir::NoDotAndDotDot | QDir::System |
659 | - | QDir::Hidden | QDir::AllDirs | QDir::Files; |
660 | - if (dir.exists(dirName)) { |
661 | - foreach(QFileInfo info, |
662 | - dir.entryInfoList(filter, QDir::DirsFirst)) { |
663 | - if (info.isDir()) { |
664 | - result = removeDir(info.absoluteFilePath()); |
665 | - } else { |
666 | - result = QFile::remove(info.absoluteFilePath()); |
667 | - } |
668 | - |
669 | - if (!result) { |
670 | - return result; |
671 | - } |
672 | - } |
673 | - result = dir.rmdir(dirName); |
674 | + QVariantMap metadata = q->metadata(); |
675 | + QString finalPath; |
676 | + |
677 | + if (!q->isConfined() && metadata.contains(LOCAL_PATH_KEY)) { |
678 | + qDebug() << "App is not confined and provided a local path"; |
679 | + finalPath = metadata[LOCAL_PATH_KEY].toString(); |
680 | + } else { |
681 | + finalPath = q->rootPath() + QDir::separator() + basename; |
682 | } |
683 | |
684 | - return result; |
685 | + return finalPath; |
686 | } |
687 | |
688 | void cleanUpCurrentData() { |
689 | @@ -442,9 +422,9 @@ |
690 | if (!success) |
691 | qWarning() << "Error removing" << fileName; |
692 | } |
693 | - success = removeDir(_localPath); |
694 | + success = QFile::remove(_filePath); |
695 | if (!success) |
696 | - qWarning() << "Error removing" << _localPath; |
697 | + qWarning() << "Error removing" << _filePath; |
698 | } |
699 | |
700 | QNetworkRequest buildRequest() { |
701 | @@ -474,8 +454,8 @@ |
702 | |
703 | private: |
704 | qulonglong _totalSize; |
705 | - QString _localPath; |
706 | QUrl _url; |
707 | + QString _filePath; |
708 | QString _hash; |
709 | QCryptographicHash::Algorithm _algo; |
710 | NetworkReply* _reply; |
711 | @@ -491,6 +471,8 @@ |
712 | |
713 | SingleDownload::SingleDownload(const QUuid& id, |
714 | const QString& path, |
715 | + bool isConfined, |
716 | + const QString& rootPath, |
717 | const QUrl& url, |
718 | const QVariantMap& metadata, |
719 | const QMap<QString, QString>& headers, |
720 | @@ -498,12 +480,15 @@ |
721 | QSharedPointer<RequestFactory> nam, |
722 | QSharedPointer<ProcessFactory> processFactory, |
723 | QObject* parent) |
724 | - : Download(id, path, metadata, headers, networkInfo, parent), |
725 | + : Download(id, path, isConfined, rootPath, metadata, headers, networkInfo, |
726 | + parent), |
727 | d_ptr(new SingleDownloadPrivate(url, nam, processFactory, this)) { |
728 | } |
729 | |
730 | SingleDownload::SingleDownload(const QUuid& id, |
731 | const QString& path, |
732 | + bool isConfined, |
733 | + const QString& rootPath, |
734 | const QUrl& url, |
735 | const QString& hash, |
736 | QCryptographicHash::Algorithm algo, |
737 | @@ -513,7 +498,8 @@ |
738 | QSharedPointer<RequestFactory> nam, |
739 | QSharedPointer<ProcessFactory> processFactory, |
740 | QObject* parent) |
741 | - : Download(id, path, metadata, headers, networkInfo, parent), |
742 | + : Download(id, path, isConfined, rootPath, metadata, headers, networkInfo, |
743 | + parent), |
744 | d_ptr(new SingleDownloadPrivate(url, hash, algo, nam, |
745 | processFactory, this)) { |
746 | } |
747 | |
748 | === modified file 'libubuntudownloadmanager/single_download.h' |
749 | --- libubuntudownloadmanager/single_download.h 2013-09-09 16:05:49 +0000 |
750 | +++ libubuntudownloadmanager/single_download.h 2013-09-18 10:19:27 +0000 |
751 | @@ -28,6 +28,8 @@ |
752 | #include "./app-downloader-lib_global.h" |
753 | #include "./download.h" |
754 | |
755 | +#define LOCAL_PATH_KEY "local-path" |
756 | + |
757 | class SingleDownloadPrivate; |
758 | class APPDOWNLOADERLIBSHARED_EXPORT SingleDownload : public Download { |
759 | Q_OBJECT |
760 | @@ -36,6 +38,8 @@ |
761 | public: |
762 | SingleDownload(const QUuid& id, |
763 | const QString& path, |
764 | + bool isConfined, |
765 | + const QString& rootPath, |
766 | const QUrl& url, |
767 | const QVariantMap& metadata, |
768 | const QMap<QString, QString>& headers, |
769 | @@ -45,6 +49,8 @@ |
770 | QObject* parent = 0); |
771 | SingleDownload(const QUuid& id, |
772 | const QString& path, |
773 | + bool isConfined, |
774 | + const QString& rootPath, |
775 | const QUrl& url, |
776 | const QString& hash, |
777 | QCryptographicHash::Algorithm algo, |
778 | |
779 | === modified file 'ubuntu-download-manager-tests/fake_apparmor.cpp' |
780 | --- ubuntu-download-manager-tests/fake_apparmor.cpp 2013-09-10 15:27:32 +0000 |
781 | +++ ubuntu-download-manager-tests/fake_apparmor.cpp 2013-09-18 10:19:27 +0000 |
782 | @@ -21,31 +21,46 @@ |
783 | FakeAppArmor::FakeAppArmor(QSharedPointer<UuidFactory> uuidFactory, |
784 | QObject *parent) |
785 | : AppArmor(parent), |
786 | + _isConfined(true), |
787 | _uuidFactory(uuidFactory) { |
788 | } |
789 | |
790 | -QPair<QUuid, QString> |
791 | -FakeAppArmor::getSecurePath(QString connName) { |
792 | +void |
793 | +FakeAppArmor::getDBusPath(QUuid& id, QString& dbusPath) { |
794 | + id = _uuidFactory->createUuid(); |
795 | + dbusPath = id.toString().replace(QRegExp("[-{}]"), ""); |
796 | + if (_recording) { |
797 | + QList<QObject*> inParams; |
798 | + |
799 | + QList<QObject*> outParams; |
800 | + outParams.append(new UuidWrapper(id)); |
801 | + outParams.append(new StringWrapper(dbusPath)); |
802 | + MethodParams params(inParams, outParams); |
803 | + MethodData methodData("getDBusPath", params); |
804 | + _called.append(methodData); |
805 | + } |
806 | +} |
807 | + |
808 | +QUuid |
809 | +FakeAppArmor::getSecurePath(const QString& connName, |
810 | + QString& dbusPath, |
811 | + QString& localPath, |
812 | + bool& isConfined) { |
813 | QUuid id = _uuidFactory->createUuid(); |
814 | - QString uuidString = id.toString().replace(QRegExp("[-{}]"), ""); |
815 | - if (_recording) { |
816 | - QList<QObject*> inParams; |
817 | - inParams.append(new StringWrapper(connName)); |
818 | - |
819 | - QList<QObject*> outParams; |
820 | - outParams.append(new UuidWrapper(id)); |
821 | - outParams.append(new StringWrapper(uuidString)); |
822 | - MethodParams params(inParams, outParams); |
823 | - MethodData methodData("getSecurePath", params); |
824 | - _called.append(methodData); |
825 | - } |
826 | - |
827 | - return QPair<QUuid, QString>(id, uuidString); |
828 | + getSecurePath(connName, id, dbusPath, localPath, isConfined); |
829 | + return id; |
830 | } |
831 | |
832 | -QPair<QUuid, QString> |
833 | -FakeAppArmor::getSecurePath(QUuid id, QString connName) { |
834 | +void |
835 | +FakeAppArmor::getSecurePath(const QString& connName, |
836 | + const QUuid& id, |
837 | + QString& dbusPath, |
838 | + QString& localPath, |
839 | + bool& isConfined) { |
840 | QString uuidString = id.toString().replace(QRegExp("[-{}]"), ""); |
841 | + dbusPath = "dbus/" + uuidString; |
842 | + localPath = "local/"+ uuidString; |
843 | + isConfined = _isConfined; |
844 | if (_recording) { |
845 | QList<QObject*> inParams; |
846 | inParams.append(new UuidWrapper(id)); |
847 | @@ -53,11 +68,20 @@ |
848 | |
849 | QList<QObject*> outParams; |
850 | outParams.append(new UuidWrapper(id)); |
851 | - outParams.append(new StringWrapper(uuidString)); |
852 | + outParams.append(new StringWrapper(dbusPath)); |
853 | + outParams.append(new StringWrapper(localPath)); |
854 | MethodParams params(inParams, outParams); |
855 | MethodData methodData("getSecurePath", params); |
856 | _called.append(methodData); |
857 | } |
858 | - |
859 | - return QPair<QUuid, QString>(id, uuidString); |
860 | +} |
861 | + |
862 | +bool |
863 | +FakeAppArmor::isConfined() { |
864 | + return _isConfined; |
865 | +} |
866 | + |
867 | +void |
868 | +FakeAppArmor::setIsConfined() { |
869 | + _isConfined = true; |
870 | } |
871 | |
872 | === modified file 'ubuntu-download-manager-tests/fake_apparmor.h' |
873 | --- ubuntu-download-manager-tests/fake_apparmor.h 2013-09-10 15:27:32 +0000 |
874 | +++ ubuntu-download-manager-tests/fake_apparmor.h 2013-09-18 10:19:27 +0000 |
875 | @@ -31,10 +31,23 @@ |
876 | FakeAppArmor(QSharedPointer<UuidFactory> uuidFactory, |
877 | QObject *parent = 0); |
878 | |
879 | - QPair<QUuid, QString> getSecurePath(QString connName) override; |
880 | - QPair<QUuid, QString> getSecurePath(QUuid id, QString connName) override; |
881 | + void getDBusPath(QUuid& id, QString& dbusPath) override; |
882 | + |
883 | + QUuid getSecurePath(const QString& connName, |
884 | + QString& dbusPath, |
885 | + QString& localPath, |
886 | + bool& isConfined) override; |
887 | + void getSecurePath(const QString& connName, |
888 | + const QUuid& id, |
889 | + QString& dbusPath, |
890 | + QString& localPath, |
891 | + bool& isConfined) override; |
892 | + |
893 | + bool isConfined(); |
894 | + void setIsConfined(); |
895 | |
896 | private: |
897 | + bool _isConfined; |
898 | QSharedPointer<UuidFactory> _uuidFactory; |
899 | }; |
900 | |
901 | |
902 | === modified file 'ubuntu-download-manager-tests/fake_download.cpp' |
903 | --- ubuntu-download-manager-tests/fake_download.cpp 2013-09-09 16:05:49 +0000 |
904 | +++ ubuntu-download-manager-tests/fake_download.cpp 2013-09-18 10:19:27 +0000 |
905 | @@ -21,6 +21,8 @@ |
906 | |
907 | FakeDownload::FakeDownload(const QUuid& id, |
908 | const QString& path, |
909 | + bool isConfined, |
910 | + const QString& rootPath, |
911 | const QUrl& url, |
912 | const QVariantMap& metadata, |
913 | const QMap<QString, QString> &headers, |
914 | @@ -28,13 +30,15 @@ |
915 | QSharedPointer<RequestFactory> nam, |
916 | QSharedPointer<ProcessFactory> processFactory, |
917 | QObject* parent) |
918 | - : SingleDownload(id, path, url, metadata, headers, networkInfo, nam, |
919 | - processFactory, parent), |
920 | + : SingleDownload(id, path, isConfined, rootPath, url, metadata, |
921 | + headers, networkInfo, nam, processFactory, parent), |
922 | _canDownload(true) { |
923 | } |
924 | |
925 | FakeDownload::FakeDownload(const QUuid& id, |
926 | const QString& path, |
927 | + bool isConfined, |
928 | + const QString& rootPath, |
929 | const QUrl& url, |
930 | const QString& hash, |
931 | QCryptographicHash::Algorithm algo, |
932 | @@ -44,8 +48,8 @@ |
933 | QSharedPointer<RequestFactory> nam, |
934 | QSharedPointer<ProcessFactory> processFactory, |
935 | QObject* parent) |
936 | - : SingleDownload(id, path, url, hash, algo, metadata, headers, |
937 | - networkInfo, nam, processFactory, parent), |
938 | + : SingleDownload(id, path, isConfined, rootPath, url, hash, algo, |
939 | + metadata, headers, networkInfo, nam, processFactory, parent), |
940 | _canDownload(true) { |
941 | } |
942 | |
943 | |
944 | === modified file 'ubuntu-download-manager-tests/fake_download.h' |
945 | --- ubuntu-download-manager-tests/fake_download.h 2013-09-09 16:05:49 +0000 |
946 | +++ ubuntu-download-manager-tests/fake_download.h 2013-09-18 10:19:27 +0000 |
947 | @@ -28,26 +28,30 @@ |
948 | Q_OBJECT |
949 | |
950 | public: |
951 | - explicit FakeDownload(const QUuid& id, |
952 | - const QString& path, |
953 | - const QUrl& url, |
954 | - const QVariantMap& metadata, |
955 | - const QMap<QString, QString>& headers, |
956 | - QSharedPointer<SystemNetworkInfo> networkInfo, |
957 | - QSharedPointer<RequestFactory> nam, |
958 | - QSharedPointer<ProcessFactory> processFactory, |
959 | - QObject* parent = 0); |
960 | - explicit FakeDownload(const QUuid& id, |
961 | - const QString& path, |
962 | - const QUrl& url, |
963 | - const QString& hash, |
964 | - QCryptographicHash::Algorithm algo, |
965 | - const QVariantMap& metadata, |
966 | - const QMap<QString, QString> &headers, |
967 | - QSharedPointer<SystemNetworkInfo> networkInfo, |
968 | - QSharedPointer<RequestFactory> nam, |
969 | - QSharedPointer<ProcessFactory> processFactory, |
970 | - QObject* parent = 0); |
971 | + FakeDownload(const QUuid& id, |
972 | + const QString& path, |
973 | + bool isConfined, |
974 | + const QString& rootPath, |
975 | + const QUrl& url, |
976 | + const QVariantMap& metadata, |
977 | + const QMap<QString, QString>& headers, |
978 | + QSharedPointer<SystemNetworkInfo> networkInfo, |
979 | + QSharedPointer<RequestFactory> nam, |
980 | + QSharedPointer<ProcessFactory> processFactory, |
981 | + QObject* parent = 0); |
982 | + FakeDownload(const QUuid& id, |
983 | + const QString& path, |
984 | + bool isConfined, |
985 | + const QString& rootPath, |
986 | + const QUrl& url, |
987 | + const QString& hash, |
988 | + QCryptographicHash::Algorithm algo, |
989 | + const QVariantMap& metadata, |
990 | + const QMap<QString, QString> &headers, |
991 | + QSharedPointer<SystemNetworkInfo> networkInfo, |
992 | + QSharedPointer<RequestFactory> nam, |
993 | + QSharedPointer<ProcessFactory> processFactory, |
994 | + QObject* parent = 0); |
995 | |
996 | bool canDownload() override; |
997 | void setCanDownload(bool canDownload); |
998 | |
999 | === modified file 'ubuntu-download-manager-tests/fake_download_factory.cpp' |
1000 | --- ubuntu-download-manager-tests/fake_download_factory.cpp 2013-09-10 12:18:34 +0000 |
1001 | +++ ubuntu-download-manager-tests/fake_download_factory.cpp 2013-09-18 10:19:27 +0000 |
1002 | @@ -38,15 +38,21 @@ |
1003 | const QUrl& url, |
1004 | const QVariantMap& metadata, |
1005 | const QMap<QString, QString>& headers) { |
1006 | + qDebug() << __PRETTY_FUNCTION__; |
1007 | if (_recording) { |
1008 | MethodData methodData; |
1009 | methodData.setMethodName("createDownload"); |
1010 | _called.append(methodData); |
1011 | } |
1012 | - QPair<QUuid, QString> idData = _apparmor->getSecurePath(downloadOwner); |
1013 | - Download* down = new FakeDownload(idData.first, idData.second, url, |
1014 | + QString dbusPath; |
1015 | + QString rootPath; |
1016 | + bool isConfined; |
1017 | + QUuid id = _apparmor->getSecurePath(downloadOwner, dbusPath, rootPath, |
1018 | + isConfined); |
1019 | + Download* down = new FakeDownload(id, dbusPath, isConfined, rootPath, url, |
1020 | metadata, headers, _networkInfo, _nam, _processFactory); |
1021 | _downloads.append(down); |
1022 | + qDebug() << "Downloads count" << _downloads.count(); |
1023 | return down; |
1024 | } |
1025 | |
1026 | @@ -57,15 +63,21 @@ |
1027 | QCryptographicHash::Algorithm algo, |
1028 | const QVariantMap& metadata, |
1029 | const QMap<QString, QString>& headers) { |
1030 | + qDebug() << __PRETTY_FUNCTION__; |
1031 | if (_recording) { |
1032 | MethodData methodData; |
1033 | methodData.setMethodName("createDownload"); |
1034 | _called.append(methodData); |
1035 | } |
1036 | - QPair<QUuid, QString> idData = _apparmor->getSecurePath(downloadOwner); |
1037 | - Download* down = new FakeDownload(idData.first, idData.second, url, |
1038 | + QString dbusPath; |
1039 | + QString rootPath; |
1040 | + bool isConfined; |
1041 | + QUuid id = _apparmor->getSecurePath(downloadOwner, dbusPath, rootPath, |
1042 | + isConfined); |
1043 | + Download* down = new FakeDownload(id, dbusPath, isConfined, rootPath, url, |
1044 | hash, algo, metadata, headers, _networkInfo, _nam, _processFactory); |
1045 | _downloads.append(down); |
1046 | + qDebug() << "Downloads count" << _downloads.count(); |
1047 | return down; |
1048 | } |
1049 | |
1050 | @@ -76,6 +88,7 @@ |
1051 | bool allowed3G, |
1052 | const QVariantMap& metadata, |
1053 | StringMap headers) { |
1054 | + qDebug() << __PRETTY_FUNCTION__; |
1055 | Q_UNUSED(allowed3G); |
1056 | Q_UNUSED(downloads); |
1057 | if (_recording) { |
1058 | @@ -83,11 +96,58 @@ |
1059 | methodData.setMethodName("createDownload"); |
1060 | _called.append(methodData); |
1061 | } |
1062 | - QPair<QUuid, QString> idData = _apparmor->getSecurePath(downloadOwner); |
1063 | - Download* down = new FakeDownload(idData.first, idData.second, |
1064 | + |
1065 | + QString dbusPath; |
1066 | + QString rootPath; |
1067 | + bool isConfined; |
1068 | + QUuid id = _apparmor->getSecurePath(downloadOwner, dbusPath, rootPath, |
1069 | + isConfined); |
1070 | + Download* down = new FakeDownload(id, dbusPath, isConfined, rootPath, |
1071 | QUrl(), "", algo, metadata, headers, _networkInfo, _nam, |
1072 | _processFactory); |
1073 | _downloads.append(down); |
1074 | + qDebug() << "Downloads count" << _downloads.count(); |
1075 | + return down; |
1076 | +} |
1077 | + |
1078 | +Download* |
1079 | +FakeDownloadFactory::createDownloadForGroup(bool isConfined, |
1080 | + const QString& rootPath, |
1081 | + const QUrl& url, |
1082 | + const QVariantMap& metadata, |
1083 | + const QMap<QString, QString>& headers) { |
1084 | + qDebug() << __PRETTY_FUNCTION__; |
1085 | + if (_recording) { |
1086 | + MethodData methodData; |
1087 | + methodData.setMethodName("createDownload"); |
1088 | + _called.append(methodData); |
1089 | + } |
1090 | + QUuid id; |
1091 | + QString dbusPath; |
1092 | + _apparmor->getDBusPath(id, dbusPath); |
1093 | + Download* down = new FakeDownload(id, dbusPath, isConfined, rootPath, |
1094 | + url, metadata, headers, _networkInfo, _nam, _processFactory); |
1095 | + _downloads.append(down); |
1096 | + qDebug() << "Downloads count" << _downloads.count(); |
1097 | + return down; |
1098 | +} |
1099 | + |
1100 | +Download* |
1101 | +FakeDownloadFactory::createDownloadForGroup(bool isConfined, |
1102 | + const QString& rootPath, |
1103 | + const QUrl& url, |
1104 | + const QString& hash, |
1105 | + QCryptographicHash::Algorithm algo, |
1106 | + const QVariantMap& metadata, |
1107 | + const QMap<QString, QString>& headers) { |
1108 | + QUuid id; |
1109 | + QString dbusPath; |
1110 | + _apparmor->getDBusPath(id, dbusPath); |
1111 | + Download* down = new SingleDownload(id, dbusPath, isConfined, |
1112 | + rootPath, url, hash, algo, metadata, headers, _networkInfo, _nam, |
1113 | + _processFactory); |
1114 | + _downloads.append(down); |
1115 | + qDebug() << "Downloads count" << _downloads.count(); |
1116 | return down; |
1117 | } |
1118 | |
1119 | |
1120 | === modified file 'ubuntu-download-manager-tests/fake_download_factory.h' |
1121 | --- ubuntu-download-manager-tests/fake_download_factory.h 2013-09-10 12:18:34 +0000 |
1122 | +++ ubuntu-download-manager-tests/fake_download_factory.h 2013-09-18 10:19:27 +0000 |
1123 | @@ -53,6 +53,20 @@ |
1124 | const QVariantMap& metadata, |
1125 | StringMap headers) override; |
1126 | |
1127 | + Download* createDownloadForGroup(bool isConfined, |
1128 | + const QString& rootPath, |
1129 | + const QUrl& url, |
1130 | + const QVariantMap& metadata, |
1131 | + const QMap<QString, QString>& headers) override; |
1132 | + |
1133 | + Download* createDownloadForGroup(bool isConfined, |
1134 | + const QString& rootPath, |
1135 | + const QUrl& url, |
1136 | + const QString& hash, |
1137 | + QCryptographicHash::Algorithm algo, |
1138 | + const QVariantMap& metadata, |
1139 | + const QMap<QString, QString>& headers) override; |
1140 | + |
1141 | QList<Download*> downloads(); |
1142 | |
1143 | private: |
1144 | |
1145 | === modified file 'ubuntu-download-manager-tests/test_download.cpp' |
1146 | --- ubuntu-download-manager-tests/test_download.cpp 2013-09-09 16:05:49 +0000 |
1147 | +++ ubuntu-download-manager-tests/test_download.cpp 2013-09-18 10:19:27 +0000 |
1148 | @@ -67,6 +67,8 @@ |
1149 | setenv("XDG_DATA_HOME", |
1150 | _testDir.absolutePath().toStdString().c_str(), 1); |
1151 | _id = QUuid::createUuid(); |
1152 | + _isConfined = false; |
1153 | + _rootPath = _testDir.absolutePath(); |
1154 | _path = "random path to dbus"; |
1155 | _url = QUrl("http://ubuntu.com"); |
1156 | _algo = QCryptographicHash::Sha256; |
1157 | @@ -111,8 +113,9 @@ |
1158 | QFETCH(QString, path); |
1159 | QFETCH(QUrl, url); |
1160 | |
1161 | - SingleDownload* download = new SingleDownload(id, path, url, _metadata, |
1162 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1163 | + SingleDownload* download = new SingleDownload(id, path, _isConfined, |
1164 | + _rootPath, url, _metadata, _headers, |
1165 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1166 | QSharedPointer<RequestFactory>(_reqFactory), |
1167 | QSharedPointer<ProcessFactory>(_processFactory)); |
1168 | |
1169 | @@ -159,7 +162,8 @@ |
1170 | QFETCH(QString, hash); |
1171 | QFETCH(int, algo); |
1172 | |
1173 | - SingleDownload* download = new SingleDownload(id, path, url, hash, |
1174 | + SingleDownload* download = new SingleDownload(id, path, _isConfined, |
1175 | + _rootPath, url, hash, |
1176 | (QCryptographicHash::Algorithm)algo, _metadata, _headers, |
1177 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1178 | QSharedPointer<RequestFactory>(_reqFactory), |
1179 | @@ -192,7 +196,8 @@ |
1180 | TestDownload::testPath() { |
1181 | // create an app download and assert that the returned data is correct |
1182 | QFETCH(QString, path); |
1183 | - SingleDownload* download = new SingleDownload(_id, path, _url, _metadata, |
1184 | + SingleDownload* download = new SingleDownload(_id, path, _isConfined, |
1185 | + _rootPath, _url, _metadata, |
1186 | _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1187 | QSharedPointer<RequestFactory>(_reqFactory), |
1188 | QSharedPointer<ProcessFactory>(_processFactory)); |
1189 | @@ -214,8 +219,9 @@ |
1190 | TestDownload::testUrl() { |
1191 | // create an app download and assert that the returned data is correct |
1192 | QFETCH(QUrl, url); |
1193 | - SingleDownload* download = new SingleDownload(_id, _path, url, _metadata, |
1194 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1195 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1196 | + _rootPath, url, _metadata, _headers, |
1197 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1198 | QSharedPointer<RequestFactory>(_reqFactory), |
1199 | QSharedPointer<ProcessFactory>(_processFactory)); |
1200 | QCOMPARE(download->url(), url); |
1201 | @@ -241,8 +247,9 @@ |
1202 | QFETCH(qulonglong, total); |
1203 | |
1204 | _reqFactory->record(); |
1205 | - SingleDownload* download = new SingleDownload(_id, _path, _url, _metadata, |
1206 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1207 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1208 | + _rootPath, _url, _metadata, _headers, |
1209 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1210 | QSharedPointer<RequestFactory>(_reqFactory), |
1211 | QSharedPointer<ProcessFactory>(_processFactory)); |
1212 | QSignalSpy spy(download , SIGNAL(progress(qulonglong, qulonglong))); |
1213 | @@ -257,12 +264,12 @@ |
1214 | reply->setData(fileData); |
1215 | emit reply->downloadProgress(received, total); |
1216 | |
1217 | - // assert that the total is set and tha the signals is emited |
1218 | + // assert that the total is set and that the signals is emited |
1219 | QCOMPARE(download->totalSize(), total); |
1220 | QCOMPARE(spy.count(), 1); |
1221 | |
1222 | QList<QVariant> arguments = spy.takeFirst(); |
1223 | - // assert that the size isnot the received but the file size |
1224 | + // assert that the size is not the received but the file size |
1225 | QCOMPARE(arguments.at(0).toULongLong(), (qulonglong)fileData.size()); |
1226 | QCOMPARE(arguments.at(1).toULongLong(), total); |
1227 | delete download; |
1228 | @@ -287,8 +294,9 @@ |
1229 | QFETCH(int, total); |
1230 | |
1231 | _reqFactory->record(); |
1232 | - SingleDownload* download = new SingleDownload(_id, _path, _url, _metadata, |
1233 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1234 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1235 | + _rootPath, _url, _metadata, _headers, |
1236 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1237 | QSharedPointer<RequestFactory>(_reqFactory), |
1238 | QSharedPointer<ProcessFactory>(_processFactory)); |
1239 | QSignalSpy spy(download , SIGNAL(progress(qulonglong, qulonglong))); |
1240 | @@ -321,8 +329,9 @@ |
1241 | // assert that the total size is just set once |
1242 | // by emitting two signals with diff sizes |
1243 | _reqFactory->record(); |
1244 | - SingleDownload* download = new SingleDownload(_id, _path, _url, _metadata, |
1245 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1246 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1247 | + _rootPath, _url, _metadata, _headers, |
1248 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1249 | QSharedPointer<RequestFactory>(_reqFactory), |
1250 | QSharedPointer<ProcessFactory>(_processFactory)); |
1251 | QSignalSpy spy(download , SIGNAL(progress(qulonglong, qulonglong))); |
1252 | @@ -344,8 +353,9 @@ |
1253 | |
1254 | void |
1255 | TestDownload::testTotalSizeNoProgress() { |
1256 | - SingleDownload* download = new SingleDownload(_id, _path, _url, _metadata, |
1257 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1258 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1259 | + _rootPath, _url, _metadata, _headers, |
1260 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1261 | QSharedPointer<RequestFactory>(_reqFactory), |
1262 | QSharedPointer<ProcessFactory>(_processFactory)); |
1263 | QCOMPARE(0ULL, download->totalSize()); |
1264 | @@ -365,8 +375,9 @@ |
1265 | void |
1266 | TestDownload::testSetThrottleNoReply() { |
1267 | QFETCH(qulonglong, speed); |
1268 | - SingleDownload* download = new SingleDownload(_id, _path, _url, _metadata, |
1269 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1270 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1271 | + _rootPath, _url, _metadata, _headers, |
1272 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1273 | QSharedPointer<RequestFactory>(_reqFactory), |
1274 | QSharedPointer<ProcessFactory>(_processFactory)); |
1275 | download->setThrottle(speed); |
1276 | @@ -388,8 +399,9 @@ |
1277 | QFETCH(uint, speed); |
1278 | |
1279 | _reqFactory->record(); |
1280 | - SingleDownload* download = new SingleDownload(_id, _path, _url, _metadata, |
1281 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1282 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1283 | + _rootPath, _url, _metadata, _headers, |
1284 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1285 | QSharedPointer<RequestFactory>(_reqFactory), |
1286 | QSharedPointer<ProcessFactory>(_processFactory)); |
1287 | download->setThrottle(speed); |
1288 | @@ -421,8 +433,9 @@ |
1289 | TestDownload::testSetGSMDownloadSame() { |
1290 | QFETCH(bool, value); |
1291 | |
1292 | - SingleDownload* download = new SingleDownload(_id, _path, _url, _metadata, |
1293 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1294 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1295 | + _rootPath, _url, _metadata, _headers, |
1296 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1297 | QSharedPointer<RequestFactory>(_reqFactory), |
1298 | QSharedPointer<ProcessFactory>(_processFactory)); |
1299 | download->allowGSMDownload(value); |
1300 | @@ -446,8 +459,9 @@ |
1301 | QFETCH(bool, oldValue); |
1302 | QFETCH(bool, newValue); |
1303 | |
1304 | - SingleDownload* download = new SingleDownload(_id, _path, _url, _metadata, |
1305 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1306 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1307 | + _rootPath, _url, _metadata, _headers, |
1308 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1309 | QSharedPointer<RequestFactory>(_reqFactory), |
1310 | QSharedPointer<ProcessFactory>(_processFactory)); |
1311 | download->allowGSMDownload(oldValue); |
1312 | @@ -491,8 +505,9 @@ |
1313 | _networkInfo->setMode(mode.value<QNetworkInfo::NetworkMode>()); |
1314 | _networkInfo->record(); |
1315 | |
1316 | - SingleDownload* download = new SingleDownload(_id, _path, _url, _metadata, |
1317 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1318 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1319 | + _rootPath, _url, _metadata, _headers, |
1320 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1321 | QSharedPointer<RequestFactory>(_reqFactory), |
1322 | QSharedPointer<ProcessFactory>(_processFactory)); |
1323 | download->allowGSMDownload(true); |
1324 | @@ -539,8 +554,9 @@ |
1325 | _networkInfo->setMode(mode.value<QNetworkInfo::NetworkMode>()); |
1326 | _networkInfo->record(); |
1327 | |
1328 | - SingleDownload* download = new SingleDownload(_id, _path, _url, _metadata, |
1329 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1330 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1331 | + _rootPath, _url, _metadata, _headers, |
1332 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1333 | QSharedPointer<RequestFactory>(_reqFactory), |
1334 | QSharedPointer<ProcessFactory>(_processFactory)); |
1335 | download->allowGSMDownload(false); |
1336 | @@ -552,8 +568,9 @@ |
1337 | |
1338 | void |
1339 | TestDownload::testCancel() { |
1340 | - SingleDownload* download = new SingleDownload(_id, _path, _url, _metadata, |
1341 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1342 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1343 | + _rootPath, _url, _metadata, _headers, |
1344 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1345 | QSharedPointer<RequestFactory>(_reqFactory), |
1346 | QSharedPointer<ProcessFactory>(_processFactory)); |
1347 | QSignalSpy spy(download , SIGNAL(stateChanged())); |
1348 | @@ -566,8 +583,9 @@ |
1349 | |
1350 | void |
1351 | TestDownload::testPause() { |
1352 | - SingleDownload* download = new SingleDownload(_id, _path, _url, _metadata, |
1353 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1354 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1355 | + _rootPath, _url, _metadata, _headers, |
1356 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1357 | QSharedPointer<RequestFactory>(_reqFactory), |
1358 | QSharedPointer<ProcessFactory>(_processFactory)); |
1359 | QSignalSpy spy(download , SIGNAL(stateChanged())); |
1360 | @@ -580,8 +598,9 @@ |
1361 | |
1362 | void |
1363 | TestDownload::testResume() { |
1364 | - SingleDownload* download = new SingleDownload(_id, _path, _url, _metadata, |
1365 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1366 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1367 | + _rootPath, _url, _metadata, _headers, |
1368 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1369 | QSharedPointer<RequestFactory>(_reqFactory), |
1370 | QSharedPointer<ProcessFactory>(_processFactory)); |
1371 | QSignalSpy spy(download , SIGNAL(stateChanged())); |
1372 | @@ -594,8 +613,9 @@ |
1373 | |
1374 | void |
1375 | TestDownload::testStart() { |
1376 | - SingleDownload* download = new SingleDownload(_id, _path, _url, _metadata, |
1377 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1378 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1379 | + _rootPath, _url, _metadata, _headers, |
1380 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1381 | QSharedPointer<RequestFactory>(_reqFactory), |
1382 | QSharedPointer<ProcessFactory>(_processFactory)); |
1383 | QSignalSpy spy(download , SIGNAL(stateChanged())); |
1384 | @@ -611,8 +631,9 @@ |
1385 | // tell the fake nam to record so that we can access the reply |
1386 | |
1387 | _reqFactory->record(); |
1388 | - SingleDownload* download = new SingleDownload(_id, _path, _url, _metadata, |
1389 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1390 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1391 | + _rootPath, _url, _metadata, _headers, |
1392 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1393 | QSharedPointer<RequestFactory>(_reqFactory), |
1394 | QSharedPointer<ProcessFactory>(_processFactory)); |
1395 | QSignalSpy spy(download, |
1396 | @@ -645,8 +666,9 @@ |
1397 | void |
1398 | TestDownload::testCancelDownloadNotStarted() { |
1399 | _reqFactory->record(); |
1400 | - SingleDownload* download = new SingleDownload(_id, _path, _url, _metadata, |
1401 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1402 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1403 | + _rootPath, _url, _metadata, _headers, |
1404 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1405 | QSharedPointer<RequestFactory>(_reqFactory), |
1406 | QSharedPointer<ProcessFactory>(_processFactory)); |
1407 | QSignalSpy spy(download, |
1408 | @@ -668,8 +690,9 @@ |
1409 | void |
1410 | TestDownload::testPauseDownload() { |
1411 | _reqFactory->record(); |
1412 | - SingleDownload* download = new SingleDownload(_id, _path, _url, _metadata, |
1413 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1414 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1415 | + _rootPath, _url, _metadata, _headers, |
1416 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1417 | QSharedPointer<RequestFactory>(_reqFactory), |
1418 | QSharedPointer<ProcessFactory>(_processFactory)); |
1419 | QSignalSpy spy(download, |
1420 | @@ -707,8 +730,9 @@ |
1421 | |
1422 | void |
1423 | TestDownload::testPauseDownloadNotStarted() { |
1424 | - SingleDownload* download = new SingleDownload(_id, _path, _url, _metadata, |
1425 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1426 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1427 | + _rootPath, _url, _metadata, _headers, |
1428 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1429 | QSharedPointer<RequestFactory>(_reqFactory), |
1430 | QSharedPointer<ProcessFactory>(_processFactory)); |
1431 | QSignalSpy spy(download, |
1432 | @@ -726,8 +750,9 @@ |
1433 | |
1434 | void |
1435 | TestDownload::testResumeRunning() { |
1436 | - SingleDownload* download = new SingleDownload(_id, _path, _url, _metadata, |
1437 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1438 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1439 | + _rootPath, _url, _metadata, _headers, |
1440 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1441 | QSharedPointer<RequestFactory>(_reqFactory), |
1442 | QSharedPointer<ProcessFactory>(_processFactory)); |
1443 | QSignalSpy spy(download, |
1444 | @@ -748,8 +773,9 @@ |
1445 | void |
1446 | TestDownload::testResumeDownload() { |
1447 | _reqFactory->record(); |
1448 | - SingleDownload* download = new SingleDownload(_id, _path, _url, _metadata, |
1449 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1450 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1451 | + _rootPath, _url, _metadata, _headers, |
1452 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1453 | QSharedPointer<RequestFactory>(_reqFactory), |
1454 | QSharedPointer<ProcessFactory>(_processFactory)); |
1455 | QSignalSpy spy(download , SIGNAL(paused(bool result))); |
1456 | @@ -788,8 +814,9 @@ |
1457 | void |
1458 | TestDownload::testStartDownload() { |
1459 | _reqFactory->record(); |
1460 | - SingleDownload* download = new SingleDownload(_id, _path, _url, _metadata, |
1461 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1462 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1463 | + _rootPath, _url, _metadata, _headers, |
1464 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1465 | QSharedPointer<RequestFactory>(_reqFactory), |
1466 | QSharedPointer<ProcessFactory>(_processFactory)); |
1467 | QSignalSpy spy(download, |
1468 | @@ -812,8 +839,9 @@ |
1469 | void |
1470 | TestDownload::testStartDownloadAlreadyStarted() { |
1471 | _reqFactory->record(); |
1472 | - SingleDownload* download = new SingleDownload(_id, _path, _url, _metadata, |
1473 | - _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1474 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1475 | + _rootPath, _url, _metadata, _headers, |
1476 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1477 | QSharedPointer<RequestFactory>(_reqFactory), |
1478 | QSharedPointer<ProcessFactory>(_processFactory)); |
1479 | QSignalSpy spy(download, |
1480 | @@ -838,8 +866,9 @@ |
1481 | void |
1482 | TestDownload::testOnSuccessNoHash() { |
1483 | _reqFactory->record(); |
1484 | - SingleDownload* download = new SingleDownload(_id, _path, _url, |
1485 | - _metadata, _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1486 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1487 | + _rootPath, _url, _metadata, _headers, |
1488 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1489 | QSharedPointer<RequestFactory>(_reqFactory), |
1490 | QSharedPointer<ProcessFactory>(_processFactory)); |
1491 | QSignalSpy spy(download , SIGNAL(finished(QString))); |
1492 | @@ -861,7 +890,8 @@ |
1493 | void |
1494 | TestDownload::testOnSuccessHashError() { |
1495 | _reqFactory->record(); |
1496 | - SingleDownload* download = new SingleDownload(_id, _path, _url, |
1497 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1498 | + _rootPath, _url, |
1499 | "imposible-hash-is-not-hex", _algo, _metadata, _headers, |
1500 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1501 | QSharedPointer<RequestFactory>(_reqFactory), |
1502 | @@ -924,7 +954,8 @@ |
1503 | QFETCH(QString, hash); |
1504 | |
1505 | _reqFactory->record(); |
1506 | - SingleDownload* download = new SingleDownload(_id, _path, _url, hash, _algo, |
1507 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1508 | + _rootPath, _url, hash, _algo, |
1509 | _metadata, _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1510 | QSharedPointer<RequestFactory>(_reqFactory), |
1511 | QSharedPointer<ProcessFactory>(_processFactory)); |
1512 | @@ -963,8 +994,8 @@ |
1513 | void |
1514 | TestDownload::testOnHttpError() { |
1515 | _reqFactory->record(); |
1516 | - SingleDownload* download = new SingleDownload(_id, _path, _url, |
1517 | - _metadata, _headers, |
1518 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1519 | + _rootPath, _url, _metadata, _headers, |
1520 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1521 | QSharedPointer<RequestFactory>(_reqFactory), |
1522 | QSharedPointer<ProcessFactory>(_processFactory)); |
1523 | @@ -1016,8 +1047,9 @@ |
1524 | TestDownload::testSetRawHeadersStart() { |
1525 | QFETCH(StringMap, headers); |
1526 | _reqFactory->record(); |
1527 | - SingleDownload* download = new SingleDownload(_id, _path, _url, |
1528 | - _metadata, headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1529 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1530 | + _rootPath, _url, _metadata, headers, |
1531 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1532 | QSharedPointer<RequestFactory>(_reqFactory), |
1533 | QSharedPointer<ProcessFactory>(_processFactory)); |
1534 | |
1535 | @@ -1072,8 +1104,9 @@ |
1536 | // similar to the previous test but we want to ensure that range is not set |
1537 | QFETCH(StringMap, headers); |
1538 | _reqFactory->record(); |
1539 | - SingleDownload* download = new SingleDownload(_id, _path, _url, |
1540 | - _metadata, headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1541 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1542 | + _rootPath, _url, _metadata, headers, |
1543 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1544 | QSharedPointer<RequestFactory>(_reqFactory), |
1545 | QSharedPointer<ProcessFactory>(_processFactory)); |
1546 | |
1547 | @@ -1123,8 +1156,9 @@ |
1548 | QFETCH(StringMap, headers); |
1549 | |
1550 | _reqFactory->record(); |
1551 | - SingleDownload* download = new SingleDownload(_id, _path, _url, |
1552 | - _metadata, headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1553 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1554 | + _rootPath, _url, _metadata, headers, |
1555 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1556 | QSharedPointer<RequestFactory>(_reqFactory), |
1557 | QSharedPointer<ProcessFactory>(_processFactory)); |
1558 | QSignalSpy spy(download , SIGNAL(paused(bool result))); |
1559 | @@ -1203,8 +1237,9 @@ |
1560 | QFETCH(StringMap, headers); |
1561 | |
1562 | _reqFactory->record(); |
1563 | - SingleDownload* download = new SingleDownload(_id, _path, _url, _metadata, |
1564 | - headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1565 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1566 | + _rootPath, _url, _metadata, headers, |
1567 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1568 | QSharedPointer<RequestFactory>(_reqFactory), |
1569 | QSharedPointer<ProcessFactory>(_processFactory)); |
1570 | QSignalSpy spy(download , SIGNAL(paused(bool result))); |
1571 | @@ -1271,8 +1306,9 @@ |
1572 | |
1573 | _processFactory->record(); |
1574 | _reqFactory->record(); |
1575 | - SingleDownload* download = new SingleDownload(_id, _path, _url, |
1576 | - metadata, _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1577 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1578 | + _rootPath, _url, metadata, _headers, |
1579 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1580 | QSharedPointer<RequestFactory>(_reqFactory), |
1581 | QSharedPointer<ProcessFactory>(_processFactory)); |
1582 | |
1583 | @@ -1334,8 +1370,9 @@ |
1584 | |
1585 | _processFactory->record(); |
1586 | _reqFactory->record(); |
1587 | - SingleDownload* download = new SingleDownload(_id, _path, _url, |
1588 | - metadata, _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1589 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1590 | + _rootPath, _url, metadata, _headers, |
1591 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1592 | QSharedPointer<RequestFactory>(_reqFactory), |
1593 | QSharedPointer<ProcessFactory>(_processFactory)); |
1594 | |
1595 | @@ -1397,8 +1434,9 @@ |
1596 | |
1597 | _processFactory->record(); |
1598 | _reqFactory->record(); |
1599 | - SingleDownload* download = new SingleDownload(_id, _path, _url, |
1600 | - metadata, _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1601 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1602 | + _rootPath, _url, metadata, _headers, |
1603 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1604 | QSharedPointer<RequestFactory>(_reqFactory), |
1605 | QSharedPointer<ProcessFactory>(_processFactory)); |
1606 | |
1607 | @@ -1439,8 +1477,9 @@ |
1608 | |
1609 | _processFactory->record(); |
1610 | _reqFactory->record(); |
1611 | - SingleDownload* download = new SingleDownload(_id, _path, _url, |
1612 | - metadata, _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1613 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1614 | + _rootPath, _url, metadata, _headers, |
1615 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1616 | QSharedPointer<RequestFactory>(_reqFactory), |
1617 | QSharedPointer<ProcessFactory>(_processFactory)); |
1618 | QSignalSpy spy(download , SIGNAL(finished(QString))); |
1619 | @@ -1476,8 +1515,9 @@ |
1620 | |
1621 | _processFactory->record(); |
1622 | _reqFactory->record(); |
1623 | - SingleDownload* download = new SingleDownload(_id, _path, _url, |
1624 | - metadata, _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1625 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1626 | + _rootPath, _url, metadata, _headers, |
1627 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1628 | QSharedPointer<RequestFactory>(_reqFactory), |
1629 | QSharedPointer<ProcessFactory>(_processFactory)); |
1630 | QSignalSpy spy(download , SIGNAL(error(QString))); |
1631 | @@ -1513,8 +1553,9 @@ |
1632 | |
1633 | _processFactory->record(); |
1634 | _reqFactory->record(); |
1635 | - SingleDownload* download = new SingleDownload(_id, _path, _url, |
1636 | - metadata, _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1637 | + SingleDownload* download = new SingleDownload(_id, _path, _isConfined, |
1638 | + _rootPath, _url, metadata, _headers, |
1639 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1640 | QSharedPointer<RequestFactory>(_reqFactory), |
1641 | QSharedPointer<ProcessFactory>(_processFactory)); |
1642 | QSignalSpy spy(download , SIGNAL(error(QString))); |
1643 | @@ -1540,3 +1581,37 @@ |
1644 | process->emitFinished(1, QProcess::CrashExit); |
1645 | QCOMPARE(spy.count(), 1); |
1646 | } |
1647 | + |
1648 | + |
1649 | +void |
1650 | +TestDownload::testLocalPathConfined() { |
1651 | + // assert that the root path used is not the one in the metadata |
1652 | + QVariantMap metadata; |
1653 | + QString localPath = "/home/my/local/path"; |
1654 | + metadata["local-path"] = localPath; |
1655 | + |
1656 | + SingleDownload* download = new SingleDownload(_id, _path, true, |
1657 | + _rootPath, _url, metadata, _headers, |
1658 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1659 | + QSharedPointer<RequestFactory>(_reqFactory), |
1660 | + QSharedPointer<ProcessFactory>(_processFactory)); |
1661 | + |
1662 | + qDebug() << download->filePath(); |
1663 | + QVERIFY(download->filePath() != localPath); |
1664 | +} |
1665 | + |
1666 | +void |
1667 | +TestDownload::testLocalPathNotConfined() { |
1668 | + QVariantMap metadata; |
1669 | + QString localPath = "/home/my/local/path"; |
1670 | + metadata["local-path"] = localPath; |
1671 | + |
1672 | + SingleDownload* download = new SingleDownload(_id, _path, false, |
1673 | + _rootPath, _url, metadata, _headers, |
1674 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1675 | + QSharedPointer<RequestFactory>(_reqFactory), |
1676 | + QSharedPointer<ProcessFactory>(_processFactory)); |
1677 | + |
1678 | + qDebug() << download->filePath(); |
1679 | + QCOMPARE(download->filePath(), localPath); |
1680 | +} |
1681 | |
1682 | === modified file 'ubuntu-download-manager-tests/test_download.h' |
1683 | --- ubuntu-download-manager-tests/test_download.h 2013-08-24 09:52:47 +0000 |
1684 | +++ ubuntu-download-manager-tests/test_download.h 2013-09-18 10:19:27 +0000 |
1685 | @@ -111,12 +111,18 @@ |
1686 | void testProcessFinishedWithError(); |
1687 | void testProcessFinishedCrash(); |
1688 | |
1689 | + // local path generation tests |
1690 | + void testLocalPathConfined(); |
1691 | + void testLocalPathNotConfined(); |
1692 | + |
1693 | private: |
1694 | bool removeDir(const QString& dirName); |
1695 | |
1696 | private: |
1697 | QDir _testDir; |
1698 | QUuid _id; |
1699 | + bool _isConfined; |
1700 | + QString _rootPath; |
1701 | QVariantMap _metadata; |
1702 | QMap<QString, QString> _headers; |
1703 | QString _path; |
1704 | |
1705 | === modified file 'ubuntu-download-manager-tests/test_download_factory.cpp' |
1706 | --- ubuntu-download-manager-tests/test_download_factory.cpp 2013-09-10 15:27:32 +0000 |
1707 | +++ ubuntu-download-manager-tests/test_download_factory.cpp 2013-09-18 10:19:27 +0000 |
1708 | @@ -251,3 +251,37 @@ |
1709 | QCOMPARE(download->downloadId(), id->value()); |
1710 | QCOMPARE(download->path(), path->value()); |
1711 | } |
1712 | + |
1713 | +void |
1714 | +TestDownloadFactory::testCreateDownloadForGroup() { |
1715 | + _apparmor->record(); |
1716 | + Download* download = _downFactory->createDownloadForGroup(true, "", QUrl(), |
1717 | + QVariantMap(), QMap<QString, QString>()); |
1718 | + |
1719 | + QList<MethodData> calledMethods = _apparmor->calledMethods(); |
1720 | + QCOMPARE(1, calledMethods.count()); |
1721 | + UuidWrapper* id = reinterpret_cast<UuidWrapper*>( |
1722 | + calledMethods[0].params().outParams()[0]); |
1723 | + StringWrapper* path = reinterpret_cast<StringWrapper*>( |
1724 | + calledMethods[0].params().outParams()[1]); |
1725 | + |
1726 | + QCOMPARE(download->downloadId(), id->value()); |
1727 | + QCOMPARE(download->path(), path->value()); |
1728 | +} |
1729 | + |
1730 | +void |
1731 | +TestDownloadFactory::testCreateDownloadForGroupWithHash() { |
1732 | + _apparmor->record(); |
1733 | + Download* download = _downFactory->createDownloadForGroup(true, "", QUrl(), |
1734 | + "", QCryptographicHash::Md5, QVariantMap(), QMap<QString, QString>()); |
1735 | + |
1736 | + QList<MethodData> calledMethods = _apparmor->calledMethods(); |
1737 | + QCOMPARE(1, calledMethods.count()); |
1738 | + UuidWrapper* id = reinterpret_cast<UuidWrapper*>( |
1739 | + calledMethods[0].params().outParams()[0]); |
1740 | + StringWrapper* path = reinterpret_cast<StringWrapper*>( |
1741 | + calledMethods[0].params().outParams()[1]); |
1742 | + |
1743 | + QCOMPARE(download->downloadId(), id->value()); |
1744 | + QCOMPARE(download->path(), path->value()); |
1745 | +} |
1746 | |
1747 | === modified file 'ubuntu-download-manager-tests/test_download_factory.h' |
1748 | --- ubuntu-download-manager-tests/test_download_factory.h 2013-09-10 15:27:32 +0000 |
1749 | +++ ubuntu-download-manager-tests/test_download_factory.h 2013-09-18 10:19:27 +0000 |
1750 | @@ -48,6 +48,8 @@ |
1751 | void testCreateDownloadWithHashAndNullUuid(); |
1752 | void testCreateGroupDownloadWithValidUuid(); |
1753 | void testCreateGroupDownloadWithNullUuid(); |
1754 | + void testCreateDownloadForGroup(); |
1755 | + void testCreateDownloadForGroupWithHash(); |
1756 | |
1757 | private: |
1758 | FakeAppArmor* _apparmor; |
1759 | |
1760 | === modified file 'ubuntu-download-manager-tests/test_download_queue.cpp' |
1761 | --- ubuntu-download-manager-tests/test_download_queue.cpp 2013-09-09 16:05:49 +0000 |
1762 | +++ ubuntu-download-manager-tests/test_download_queue.cpp 2013-09-18 10:19:27 +0000 |
1763 | @@ -26,15 +26,19 @@ |
1764 | |
1765 | void |
1766 | TestDownloadQueue::init() { |
1767 | + _isConfined = true; |
1768 | + _rootPath = "/random/root/path"; |
1769 | _networkInfo = new FakeSystemNetworkInfo(); |
1770 | _reqFactory = new FakeRequestFactory(); |
1771 | _processFactory = new FakeProcessFactory(); |
1772 | - _first = new FakeDownload(QUuid::createUuid(), "first-path", QUrl(), |
1773 | + _first = new FakeDownload(QUuid::createUuid(), "first-path", |
1774 | + _isConfined, _rootPath, QUrl(), |
1775 | QVariantMap(), QMap<QString, QString>(), |
1776 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1777 | QSharedPointer<RequestFactory>(_reqFactory), |
1778 | QSharedPointer<ProcessFactory>(_processFactory)); |
1779 | - _second = new FakeDownload(QUuid::createUuid(), "second-path", QUrl(), |
1780 | + _second = new FakeDownload(QUuid::createUuid(), "second-path", |
1781 | + _isConfined, _rootPath, QUrl(), |
1782 | QVariantMap(), QMap<QString, QString>(), |
1783 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1784 | QSharedPointer<RequestFactory>(_reqFactory), |
1785 | |
1786 | === modified file 'ubuntu-download-manager-tests/test_download_queue.h' |
1787 | --- ubuntu-download-manager-tests/test_download_queue.h 2013-09-01 17:34:24 +0000 |
1788 | +++ ubuntu-download-manager-tests/test_download_queue.h 2013-09-18 10:19:27 +0000 |
1789 | @@ -57,6 +57,8 @@ |
1790 | void testDownloadErrorWithOtherReady(); |
1791 | |
1792 | private: |
1793 | + bool _isConfined; |
1794 | + QString _rootPath; |
1795 | FakeSystemNetworkInfo* _networkInfo; |
1796 | FakeRequestFactory* _reqFactory; |
1797 | FakeProcessFactory* _processFactory; |
1798 | |
1799 | === modified file 'ubuntu-download-manager-tests/test_downloads_db.cpp' |
1800 | --- ubuntu-download-manager-tests/test_downloads_db.cpp 2013-09-09 16:05:49 +0000 |
1801 | +++ ubuntu-download-manager-tests/test_downloads_db.cpp 2013-09-18 10:19:27 +0000 |
1802 | @@ -181,7 +181,7 @@ |
1803 | QSharedPointer<ProcessFactory> processFactory = |
1804 | QSharedPointer<ProcessFactory>(new FakeProcessFactory()); |
1805 | |
1806 | - FakeDownload* download = new FakeDownload(id, path, url, hash, |
1807 | + FakeDownload* download = new FakeDownload(id, path, false, "", url, hash, |
1808 | HashAlgorithm::getHashAlgo(hashAlgoString), metadata, headers, |
1809 | networkInfo, nam, processFactory); |
1810 | |
1811 | @@ -279,7 +279,7 @@ |
1812 | QSharedPointer<ProcessFactory> processFactory = |
1813 | QSharedPointer<ProcessFactory>(new FakeProcessFactory()); |
1814 | |
1815 | - FakeDownload* download = new FakeDownload(id, path, url, hash, |
1816 | + FakeDownload* download = new FakeDownload(id, path, true, "", url, hash, |
1817 | HashAlgorithm::getHashAlgo(hashAlgoString), metadata, headers, |
1818 | networkInfo, nam, processFactory); |
1819 | |
1820 | @@ -287,9 +287,9 @@ |
1821 | |
1822 | // create a second download with same id but a diff path to test is update |
1823 | QString newPath = path + path; |
1824 | - FakeDownload* secondDownload = new FakeDownload(id, newPath, url, hash, |
1825 | - HashAlgorithm::getHashAlgo(hashAlgoString), metadata, headers, |
1826 | - networkInfo, nam, processFactory); |
1827 | + FakeDownload* secondDownload = new FakeDownload(id, newPath, true, "", |
1828 | + url, hash, HashAlgorithm::getHashAlgo(hashAlgoString), metadata, |
1829 | + headers, networkInfo, nam, processFactory); |
1830 | |
1831 | _db->storeSingleDownload(secondDownload); |
1832 | |
1833 | |
1834 | === modified file 'ubuntu-download-manager-tests/test_group_download.cpp' |
1835 | --- ubuntu-download-manager-tests/test_group_download.cpp 2013-09-10 12:18:34 +0000 |
1836 | +++ ubuntu-download-manager-tests/test_group_download.cpp 2013-09-18 10:19:27 +0000 |
1837 | @@ -29,6 +29,8 @@ |
1838 | TestGroupDownload::init() { |
1839 | _id = QUuid::createUuid(); |
1840 | _path = "/group/dbus/path"; |
1841 | + _isConfined = true; |
1842 | + _rootPath = "/random/dbus/path"; |
1843 | _algo = QCryptographicHash::Md5; |
1844 | _isGSMDownloadAllowed = true; |
1845 | _networkInfo = new FakeSystemNetworkInfo(); |
1846 | @@ -62,9 +64,9 @@ |
1847 | TestGroupDownload::testCancelNoDownloads() { |
1848 | QList<GroupDownloadStruct> downloads; |
1849 | |
1850 | - GroupDownload* group = new GroupDownload(_id, _path, downloads, _algo, |
1851 | - _isGSMDownloadAllowed, _metadata, _headers, |
1852 | - QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1853 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, |
1854 | + _rootPath, downloads, _algo, _isGSMDownloadAllowed, _metadata, |
1855 | + _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1856 | QSharedPointer<DownloadFactory>(_downloadFactory), |
1857 | QSharedPointer<FileManager>(_fileManager)); |
1858 | group->cancelDownload(); |
1859 | @@ -78,8 +80,8 @@ |
1860 | downloads.append(GroupDownloadStruct("http://ubuntu.com", |
1861 | "other_local_file", "")); |
1862 | |
1863 | - GroupDownload* group = new GroupDownload(_id, _path, downloads, _algo, |
1864 | - _isGSMDownloadAllowed, _metadata, _headers, |
1865 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath, |
1866 | + downloads, _algo, _isGSMDownloadAllowed, _metadata, _headers, |
1867 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1868 | QSharedPointer<DownloadFactory>(_downloadFactory), |
1869 | QSharedPointer<FileManager>(_fileManager)); |
1870 | @@ -101,8 +103,8 @@ |
1871 | downloadsStruct.append(GroupDownloadStruct("http://reddit.com", |
1872 | "other_reddit_local_file", "")); |
1873 | |
1874 | - GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo, |
1875 | - _isGSMDownloadAllowed, _metadata, _headers, |
1876 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath, |
1877 | + downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers, |
1878 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1879 | QSharedPointer<DownloadFactory>(_downloadFactory), |
1880 | QSharedPointer<FileManager>(_fileManager)); |
1881 | @@ -135,8 +137,8 @@ |
1882 | downloadsStruct.append(GroupDownloadStruct("http://reddit.com", |
1883 | "other_reddit_local_file", "")); |
1884 | |
1885 | - GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo, |
1886 | - _isGSMDownloadAllowed, _metadata, _headers, |
1887 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath, |
1888 | + downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers, |
1889 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1890 | QSharedPointer<DownloadFactory>(_downloadFactory), |
1891 | QSharedPointer<FileManager>(_fileManager)); |
1892 | @@ -156,9 +158,9 @@ |
1893 | TestGroupDownload::testPauseNoDownloads() { |
1894 | QList<GroupDownloadStruct> downloads; |
1895 | |
1896 | - GroupDownload* group = new GroupDownload(_id, _path, downloads, _algo, |
1897 | - _isGSMDownloadAllowed, _metadata, _headers, |
1898 | - QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1899 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, |
1900 | + _rootPath, downloads, _algo, _isGSMDownloadAllowed, _metadata, |
1901 | + _headers, QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1902 | QSharedPointer<DownloadFactory>(_downloadFactory), |
1903 | QSharedPointer<FileManager>(_fileManager)); |
1904 | group->pauseDownload(); |
1905 | @@ -172,8 +174,8 @@ |
1906 | downloadsStruct.append(GroupDownloadStruct("http://ubuntu.com", |
1907 | "other_local_file", "")); |
1908 | |
1909 | - GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo, |
1910 | - _isGSMDownloadAllowed, _metadata, _headers, |
1911 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath, |
1912 | + downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers, |
1913 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1914 | QSharedPointer<DownloadFactory>(_downloadFactory), |
1915 | QSharedPointer<FileManager>(_fileManager)); |
1916 | @@ -200,8 +202,8 @@ |
1917 | downloadsStruct.append(GroupDownloadStruct("http://reddit.com", |
1918 | "other_reddit_local_file", "")); |
1919 | |
1920 | - GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo, |
1921 | - _isGSMDownloadAllowed, _metadata, _headers, |
1922 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath, |
1923 | + downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers, |
1924 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1925 | QSharedPointer<DownloadFactory>(_downloadFactory), |
1926 | QSharedPointer<FileManager>(_fileManager)); |
1927 | @@ -234,8 +236,8 @@ |
1928 | downloadsStruct.append(GroupDownloadStruct("http://reddit.com", |
1929 | "other_reddit_local_file", "")); |
1930 | |
1931 | - GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo, |
1932 | - _isGSMDownloadAllowed, _metadata, _headers, |
1933 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath, |
1934 | + downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers, |
1935 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1936 | QSharedPointer<DownloadFactory>(_downloadFactory), |
1937 | QSharedPointer<FileManager>(_fileManager)); |
1938 | @@ -257,8 +259,8 @@ |
1939 | TestGroupDownload::testResumeNoDownloads() { |
1940 | QList<GroupDownloadStruct> downloads; |
1941 | |
1942 | - GroupDownload* group = new GroupDownload(_id, _path, downloads, _algo, |
1943 | - _isGSMDownloadAllowed, _metadata, _headers, |
1944 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath, |
1945 | + downloads, _algo, _isGSMDownloadAllowed, _metadata, _headers, |
1946 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1947 | QSharedPointer<DownloadFactory>(_downloadFactory), |
1948 | QSharedPointer<FileManager>(_fileManager)); |
1949 | @@ -277,8 +279,8 @@ |
1950 | downloadsStruct.append(GroupDownloadStruct("http://reddit.com", |
1951 | "other_reddit_local_file", "")); |
1952 | |
1953 | - GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo, |
1954 | - _isGSMDownloadAllowed, _metadata, _headers, |
1955 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath, |
1956 | + downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers, |
1957 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1958 | QSharedPointer<DownloadFactory>(_downloadFactory), |
1959 | QSharedPointer<FileManager>(_fileManager)); |
1960 | @@ -309,13 +311,14 @@ |
1961 | downloadsStruct.append(GroupDownloadStruct("http://reddit.com", |
1962 | "other_reddit_local_file", "")); |
1963 | |
1964 | - GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo, |
1965 | - _isGSMDownloadAllowed, _metadata, _headers, |
1966 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath, |
1967 | + downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers, |
1968 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1969 | QSharedPointer<DownloadFactory>(_downloadFactory), |
1970 | QSharedPointer<FileManager>(_fileManager)); |
1971 | |
1972 | QList<Download*> downloads = _downloadFactory->downloads(); |
1973 | + qDebug() << "Downloads" << downloads; |
1974 | reinterpret_cast<FakeDownload*>(downloads[0])->emitFinished(deleteFile); |
1975 | for (int index = 1; index < downloads.count(); index++) { |
1976 | downloads[index]->start(); |
1977 | @@ -344,8 +347,9 @@ |
1978 | downloadsStruct.append(GroupDownloadStruct("http://reddit.com", |
1979 | "other_reddit_local_file", "")); |
1980 | |
1981 | - GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo, |
1982 | - _isGSMDownloadAllowed, _metadata, _headers, |
1983 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, |
1984 | + _rootPath, downloadsStruct, _algo, _isGSMDownloadAllowed, |
1985 | + _metadata, _headers, |
1986 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1987 | QSharedPointer<DownloadFactory>(_downloadFactory), |
1988 | QSharedPointer<FileManager>(_fileManager)); |
1989 | @@ -379,8 +383,9 @@ |
1990 | downloadsStruct.append(GroupDownloadStruct("http://reddit.com", |
1991 | "other_reddit_local_file", "")); |
1992 | |
1993 | - GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo, |
1994 | - _isGSMDownloadAllowed, _metadata, _headers, |
1995 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, |
1996 | + _rootPath, downloadsStruct, _algo, _isGSMDownloadAllowed, |
1997 | + _metadata, _headers, |
1998 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
1999 | QSharedPointer<DownloadFactory>(_downloadFactory), |
2000 | QSharedPointer<FileManager>(_fileManager)); |
2001 | @@ -399,7 +404,8 @@ |
2002 | TestGroupDownload::testStartNoDownloads() { |
2003 | QList<GroupDownloadStruct> downloads; |
2004 | |
2005 | - GroupDownload* group = new GroupDownload(_id, _path, downloads, _algo, |
2006 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, |
2007 | + _rootPath, downloads, _algo, |
2008 | _isGSMDownloadAllowed, _metadata, _headers, |
2009 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
2010 | QSharedPointer<DownloadFactory>(_downloadFactory), |
2011 | @@ -419,8 +425,8 @@ |
2012 | downloadsStruct.append(GroupDownloadStruct("http://reddit.com", |
2013 | "other_reddit_local_file", "")); |
2014 | |
2015 | - GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo, |
2016 | - _isGSMDownloadAllowed, _metadata, _headers, |
2017 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath, |
2018 | + downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers, |
2019 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
2020 | QSharedPointer<DownloadFactory>(_downloadFactory), |
2021 | QSharedPointer<FileManager>(_fileManager)); |
2022 | @@ -447,8 +453,8 @@ |
2023 | downloadsStruct.append(GroupDownloadStruct("http://reddit.com", |
2024 | "other_reddit_local_file", "")); |
2025 | |
2026 | - GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo, |
2027 | - _isGSMDownloadAllowed, _metadata, _headers, |
2028 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath, |
2029 | + downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers, |
2030 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
2031 | QSharedPointer<DownloadFactory>(_downloadFactory), |
2032 | QSharedPointer<FileManager>(_fileManager)); |
2033 | @@ -479,8 +485,8 @@ |
2034 | downloadsStruct.append(GroupDownloadStruct("http://reddit.com", |
2035 | "other_reddit_local_file", "")); |
2036 | |
2037 | - GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo, |
2038 | - _isGSMDownloadAllowed, _metadata, _headers, |
2039 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath, |
2040 | + downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers, |
2041 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
2042 | QSharedPointer<DownloadFactory>(_downloadFactory), |
2043 | QSharedPointer<FileManager>(_fileManager)); |
2044 | @@ -513,8 +519,8 @@ |
2045 | downloadsStruct.append(GroupDownloadStruct("http://reddit.com", |
2046 | "other_reddit_local_file", "")); |
2047 | |
2048 | - GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo, |
2049 | - _isGSMDownloadAllowed, _metadata, _headers, |
2050 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath, |
2051 | + downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers, |
2052 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
2053 | QSharedPointer<DownloadFactory>(_downloadFactory), |
2054 | QSharedPointer<FileManager>(_fileManager)); |
2055 | @@ -544,8 +550,8 @@ |
2056 | downloadsStruct.append(GroupDownloadStruct("http://reddit.com", |
2057 | "other_reddit_local_file", "")); |
2058 | |
2059 | - GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo, |
2060 | - _isGSMDownloadAllowed, _metadata, _headers, |
2061 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath, |
2062 | + downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers, |
2063 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
2064 | QSharedPointer<DownloadFactory>(_downloadFactory), |
2065 | QSharedPointer<FileManager>(_fileManager)); |
2066 | @@ -576,8 +582,8 @@ |
2067 | downloadsStruct.append(GroupDownloadStruct("http://reddit.com", |
2068 | "other_reddit_local_file", "")); |
2069 | |
2070 | - GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo, |
2071 | - _isGSMDownloadAllowed, _metadata, _headers, |
2072 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath, |
2073 | + downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers, |
2074 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
2075 | QSharedPointer<DownloadFactory>(_downloadFactory), |
2076 | QSharedPointer<FileManager>(_fileManager)); |
2077 | @@ -605,8 +611,8 @@ |
2078 | downloadsStruct.append(GroupDownloadStruct("http://reddit.com", |
2079 | "other_reddit_local_file", "")); |
2080 | |
2081 | - GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo, |
2082 | - _isGSMDownloadAllowed, _metadata, _headers, |
2083 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath, |
2084 | + downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers, |
2085 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
2086 | QSharedPointer<DownloadFactory>(_downloadFactory), |
2087 | QSharedPointer<FileManager>(_fileManager)); |
2088 | @@ -635,8 +641,8 @@ |
2089 | downloadsStruct.append(GroupDownloadStruct("http://reddit.com", |
2090 | "other_reddit_local_file", "")); |
2091 | |
2092 | - GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo, |
2093 | - _isGSMDownloadAllowed, _metadata, _headers, |
2094 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath, |
2095 | + downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers, |
2096 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
2097 | QSharedPointer<DownloadFactory>(_downloadFactory), |
2098 | QSharedPointer<FileManager>(_fileManager)); |
2099 | @@ -664,8 +670,8 @@ |
2100 | downloadsStruct.append(GroupDownloadStruct("http://reddit.com", |
2101 | "other_reddit_local_file", "")); |
2102 | |
2103 | - GroupDownload* group = new GroupDownload(_id, _path, downloadsStruct, _algo, |
2104 | - _isGSMDownloadAllowed, _metadata, _headers, |
2105 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath, |
2106 | + downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers, |
2107 | QSharedPointer<SystemNetworkInfo>(_networkInfo), |
2108 | QSharedPointer<DownloadFactory>(_downloadFactory), |
2109 | QSharedPointer<FileManager>(_fileManager)); |
2110 | @@ -683,3 +689,75 @@ |
2111 | QCOMPARE(2, calledMethods.count()); |
2112 | QCOMPARE(spy.count(), 1); |
2113 | } |
2114 | + |
2115 | +void |
2116 | +TestGroupDownload::testLocalPathSingleDownload() { |
2117 | + // assert that the local path of the download was set in the metadata |
2118 | + QList<GroupDownloadStruct> downloadsStruct; |
2119 | + downloadsStruct.append(GroupDownloadStruct("http://one.ubunt.com", |
2120 | + "local_file", "")); |
2121 | + downloadsStruct.append(GroupDownloadStruct("http://ubuntu.com", |
2122 | + "other_local_file", "")); |
2123 | + downloadsStruct.append(GroupDownloadStruct("http://reddit.com", |
2124 | + "other_reddit_local_file", "")); |
2125 | + |
2126 | + GroupDownload* group = new GroupDownload(_id, _path, _isConfined, _rootPath, |
2127 | + downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers, |
2128 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
2129 | + QSharedPointer<DownloadFactory>(_downloadFactory), |
2130 | + QSharedPointer<FileManager>(_fileManager)); |
2131 | + |
2132 | + Q_UNUSED(group); |
2133 | + |
2134 | + QList<Download*> downloads = _downloadFactory->downloads(); |
2135 | + |
2136 | + // assert that each metadata has the local file set |
2137 | + QVariantMap downMeta = downloads[0]->metadata(); |
2138 | + QVERIFY(downMeta.contains(LOCAL_PATH_KEY)); |
2139 | + QCOMPARE(downMeta[LOCAL_PATH_KEY].toString(), |
2140 | + downloadsStruct[0].getLocalFile()); |
2141 | + |
2142 | + downMeta = downloads[1]->metadata(); |
2143 | + QVERIFY(downMeta.contains(LOCAL_PATH_KEY)); |
2144 | + QCOMPARE(downMeta[LOCAL_PATH_KEY].toString(), |
2145 | + downloadsStruct[1].getLocalFile()); |
2146 | + |
2147 | + downMeta = downloads[2]->metadata(); |
2148 | + QVERIFY(downMeta.contains(LOCAL_PATH_KEY)); |
2149 | + QCOMPARE(downMeta[LOCAL_PATH_KEY].toString(), |
2150 | + downloadsStruct[2].getLocalFile()); |
2151 | +} |
2152 | + |
2153 | +void |
2154 | +TestGroupDownload::testConfinedSingleDownload_data() { |
2155 | + QTest::addColumn<bool>("confined"); |
2156 | + |
2157 | + QTest::newRow("Confined") << true; |
2158 | + QTest::newRow("Unconfined") << false; |
2159 | +} |
2160 | + |
2161 | +void |
2162 | +TestGroupDownload::testConfinedSingleDownload() { |
2163 | + // assert that the created downloads are confined |
2164 | + QFETCH(bool, confined); |
2165 | + |
2166 | + QList<GroupDownloadStruct> downloadsStruct; |
2167 | + downloadsStruct.append(GroupDownloadStruct("http://one.ubunt.com", |
2168 | + "local_file", "")); |
2169 | + downloadsStruct.append(GroupDownloadStruct("http://ubuntu.com", |
2170 | + "other_local_file", "")); |
2171 | + downloadsStruct.append(GroupDownloadStruct("http://reddit.com", |
2172 | + "other_reddit_local_file", "")); |
2173 | + |
2174 | + GroupDownload* group = new GroupDownload(_id, _path, confined, _rootPath, |
2175 | + downloadsStruct, _algo, _isGSMDownloadAllowed, _metadata, _headers, |
2176 | + QSharedPointer<SystemNetworkInfo>(_networkInfo), |
2177 | + QSharedPointer<DownloadFactory>(_downloadFactory), |
2178 | + QSharedPointer<FileManager>(_fileManager)); |
2179 | + |
2180 | + Q_UNUSED(group); |
2181 | + |
2182 | + foreach(Download* download, _downloadFactory->downloads()) { |
2183 | + QCOMPARE(confined, download->isConfined()); |
2184 | + } |
2185 | +} |
2186 | |
2187 | === modified file 'ubuntu-download-manager-tests/test_group_download.h' |
2188 | --- ubuntu-download-manager-tests/test_group_download.h 2013-09-10 12:18:34 +0000 |
2189 | +++ ubuntu-download-manager-tests/test_group_download.h 2013-09-18 10:19:27 +0000 |
2190 | @@ -64,10 +64,15 @@ |
2191 | void testAllDownloadsFinished(); |
2192 | void testSingleDownloadErrorNoFinished(); |
2193 | void testSingleDownloadErrorWithFinished(); |
2194 | + void testLocalPathSingleDownload(); |
2195 | + void testConfinedSingleDownload_data(); |
2196 | + void testConfinedSingleDownload(); |
2197 | |
2198 | private: |
2199 | QUuid _id; |
2200 | QString _path; |
2201 | + bool _isConfined; |
2202 | + QString _rootPath; |
2203 | QCryptographicHash::Algorithm _algo; |
2204 | bool _isGSMDownloadAllowed; |
2205 | QVariantMap _metadata; |
PASSED: Continuous integration, rev:127 jenkins. qa.ubuntu. com/job/ ubuntu- download- manager- ci/43/ jenkins. qa.ubuntu. com/job/ ubuntu- download- manager- saucy-amd64- ci/43 jenkins. qa.ubuntu. com/job/ ubuntu- download- manager- saucy-armhf- ci/34
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ ubuntu- download- manager- ci/43/rebuild
http://