Merge lp:~mandel/ubuntu-download-manager/stop-when-empty into lp:ubuntu-download-manager
- stop-when-empty
- Merge into trunk
Proposed by
Manuel de la Peña
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Manuel de la Peña | ||||||||
Approved revision: | 99 | ||||||||
Merged at revision: | 100 | ||||||||
Proposed branch: | lp:~mandel/ubuntu-download-manager/stop-when-empty | ||||||||
Merge into: | lp:ubuntu-download-manager | ||||||||
Diff against target: |
1125 lines (+649/-39) 23 files modified
libubuntudownloadmanager/download.cpp (+3/-2) libubuntudownloadmanager/download_daemon.cpp (+52/-2) libubuntudownloadmanager/download_daemon.h (+9/-1) libubuntudownloadmanager/download_manager.cpp (+9/-4) libubuntudownloadmanager/download_manager.h (+2/-1) libubuntudownloadmanager/download_queue.cpp (+20/-22) libubuntudownloadmanager/download_queue.h (+1/-1) libubuntudownloadmanager/libubuntudownloadmanager.pro (+4/-2) libubuntudownloadmanager/timer.cpp (+99/-0) libubuntudownloadmanager/timer.h (+45/-0) ubuntu-download-manager-tests/fake_download_manager.cpp (+32/-0) ubuntu-download-manager-tests/fake_download_manager.h (+37/-0) ubuntu-download-manager-tests/fake_download_queue.cpp (+20/-0) ubuntu-download-manager-tests/fake_download_queue.h (+8/-0) ubuntu-download-manager-tests/fake_timer.cpp (+75/-0) ubuntu-download-manager-tests/fake_timer.h (+44/-0) ubuntu-download-manager-tests/irl_tests.py (+84/-0) ubuntu-download-manager-tests/test_download_daemon.cpp (+43/-1) ubuntu-download-manager-tests/test_download_daemon.h (+7/-0) ubuntu-download-manager-tests/test_download_manager.cpp (+44/-0) ubuntu-download-manager-tests/test_download_manager.h (+4/-0) ubuntu-download-manager-tests/ubuntu-download-manager-tests.pro (+6/-2) ubuntu-download-manager/ubuntu-download-manager.pro (+1/-1) |
||||||||
To merge this branch: | bzr merge lp:~mandel/ubuntu-download-manager/stop-when-empty | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Roberto Alsina (community) | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+181656@code.launchpad.net |
Commit message
Ensures that the daemon is stopped when there is nothing to download.
Description of the change
Ensures that the daemon is stopped when there is nothing to download. To make thing simpler to test irl I have added a python script in the tests directory that uses the downloader to get an image. That way you can test that the downloader works and once the download is done the daemon is closed.
To post a comment you must log in.
- 98. By Manuel de la Peña
-
Merged with trunk and resolved errors.
- 99. By Manuel de la Peña
-
Link bug.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
review:
Approve
(continuous-integration)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'libubuntudownloadmanager/download.cpp' |
2 | --- libubuntudownloadmanager/download.cpp 2013-08-21 14:10:28 +0000 |
3 | +++ libubuntudownloadmanager/download.cpp 2013-08-22 21:00:52 +0000 |
4 | @@ -352,7 +352,7 @@ |
5 | |
6 | QNetworkRequest |
7 | DownloadPrivate::buildRequest() { |
8 | - qDebug() << "Building request for " << _url; |
9 | + qDebug() << __FUNCTION__ << _url; |
10 | QNetworkRequest request = QNetworkRequest(_url); |
11 | foreach(const QString& header, _headers.keys()) { |
12 | QString data = _headers[header]; |
13 | @@ -366,7 +366,7 @@ |
14 | |
15 | void |
16 | DownloadPrivate::emitError(const QString& error) { |
17 | - qDebug() << "EMIT ERROR:" << error; |
18 | + qDebug() << __FUNCTION__ << error; |
19 | Q_Q(Download); |
20 | disconnectFromReplySignals(); |
21 | _reply->deleteLater(); |
22 | @@ -428,6 +428,7 @@ |
23 | |
24 | bool |
25 | DownloadPrivate::canDownload() { |
26 | + qDebug() << __FUNCTION__; |
27 | QNetworkInfo::NetworkMode mode = _networkInfo->currentNetworkMode(); |
28 | switch (mode) { |
29 | case QNetworkInfo::UnknownMode: |
30 | |
31 | === modified file 'libubuntudownloadmanager/download_daemon.cpp' |
32 | --- libubuntudownloadmanager/download_daemon.cpp 2013-08-21 12:21:49 +0000 |
33 | +++ libubuntudownloadmanager/download_daemon.cpp 2013-08-22 21:00:52 +0000 |
34 | @@ -36,16 +36,23 @@ |
35 | explicit DownloadDaemonPrivate(DownloadDaemon* parent); |
36 | explicit DownloadDaemonPrivate(Application* app, |
37 | DBusConnection* conn, |
38 | + Timer* timer, |
39 | + DownloadManager* man, |
40 | DownloadDaemon* parent); |
41 | ~DownloadDaemonPrivate(); |
42 | |
43 | void start(); |
44 | + void onTimeout(); |
45 | + void onDownloadManagerSizeChanged(int size); |
46 | + |
47 | + static const int timeout = 30000; |
48 | |
49 | private: |
50 | void init(); |
51 | |
52 | private: |
53 | Application* _app; |
54 | + Timer* _shutDownTimer; |
55 | QSharedPointer<DBusConnection> _conn; |
56 | DownloadManager* _downInterface; |
57 | DownloadManagerAdaptor* _downAdaptor; |
58 | @@ -56,21 +63,36 @@ |
59 | : q_ptr(parent) { |
60 | _app = new Application(); |
61 | _conn = QSharedPointer<DBusConnection>(new DBusConnection()); |
62 | + _shutDownTimer = new Timer(); |
63 | _downInterface = new DownloadManager(_conn, q_ptr); |
64 | init(); |
65 | } |
66 | |
67 | DownloadDaemonPrivate::DownloadDaemonPrivate(Application* app, |
68 | DBusConnection* conn, |
69 | + Timer* timer, |
70 | + DownloadManager* man, |
71 | DownloadDaemon* parent) |
72 | : _app(app), |
73 | + _shutDownTimer(timer), |
74 | _conn(conn), |
75 | + _downInterface(man), |
76 | q_ptr(parent) { |
77 | - _downInterface = new DownloadManager(_conn); |
78 | init(); |
79 | } |
80 | |
81 | void DownloadDaemonPrivate::init() { |
82 | + Q_Q(DownloadDaemon); |
83 | + |
84 | + q->connect(_shutDownTimer, SIGNAL(timeout()), |
85 | + q, SLOT(onTimeout())); |
86 | + _shutDownTimer->start(timeout); |
87 | + |
88 | + // connect to the download manager changes |
89 | + q->connect(_downInterface, |
90 | + SIGNAL(sizeChanged(int)), // NOLINT (readability/function) |
91 | + q, SLOT(onDownloadManagerSizeChanged(int))); // NOLINT (readability/function) |
92 | + |
93 | // set logging |
94 | Logger::setupLogging(); |
95 | #ifdef DEBUG |
96 | @@ -87,6 +109,8 @@ |
97 | delete _downInterface; |
98 | if (_app) |
99 | delete _app; |
100 | + if (_shutDownTimer) |
101 | + delete _shutDownTimer; |
102 | |
103 | // stop logging |
104 | Logger::setupLogging(); |
105 | @@ -112,6 +136,28 @@ |
106 | _app->exit(-1); |
107 | } |
108 | |
109 | +void |
110 | +DownloadDaemonPrivate::onTimeout() { |
111 | + qDebug() << "Timeout reached, shutdown service."; |
112 | + _app->exit(0); |
113 | +} |
114 | + |
115 | +void |
116 | +DownloadDaemonPrivate::onDownloadManagerSizeChanged(int size) { |
117 | + bool isActive = _shutDownTimer->isActive(); |
118 | + qDebug() << "Timer is active:" << isActive << "size is:" << size; |
119 | + |
120 | + if (isActive && size > 0) { |
121 | + qDebug() << "Timer must be stopped because we have" << size |
122 | + << "downloads."; |
123 | + _shutDownTimer->stop(); |
124 | + } |
125 | + if (!isActive && size == 0) { |
126 | + qDebug() << "Timer must be started because we have 0 downloads."; |
127 | + _shutDownTimer->start(timeout); |
128 | + } |
129 | +} |
130 | + |
131 | /** |
132 | * PUBLIC IMPLEMENTATION |
133 | */ |
134 | @@ -123,9 +169,11 @@ |
135 | |
136 | DownloadDaemon::DownloadDaemon(Application* app, |
137 | DBusConnection* conn, |
138 | + Timer* timer, |
139 | + DownloadManager* man, |
140 | QObject *parent) |
141 | : QObject(parent), |
142 | - d_ptr(new DownloadDaemonPrivate(app, conn, this)) { |
143 | + d_ptr(new DownloadDaemonPrivate(app, conn, timer, man, this)) { |
144 | } |
145 | |
146 | void |
147 | @@ -133,3 +181,5 @@ |
148 | Q_D(DownloadDaemon); |
149 | d->start(); |
150 | } |
151 | + |
152 | +#include "moc_download_daemon.cpp" |
153 | |
154 | === modified file 'libubuntudownloadmanager/download_daemon.h' |
155 | --- libubuntudownloadmanager/download_daemon.h 2013-08-21 12:08:43 +0000 |
156 | +++ libubuntudownloadmanager/download_daemon.h 2013-08-22 21:00:52 +0000 |
157 | @@ -23,6 +23,8 @@ |
158 | #include "./app-downloader-lib_global.h" |
159 | #include "./application.h" |
160 | #include "./dbus_connection.h" |
161 | +#include "./download_manager.h" |
162 | +#include "./timer.h" |
163 | |
164 | class DownloadDaemonPrivate; |
165 | class APPDOWNLOADERLIBSHARED_EXPORT DownloadDaemon : public QObject { |
166 | @@ -33,12 +35,18 @@ |
167 | explicit DownloadDaemon(QObject *parent = 0); |
168 | explicit DownloadDaemon(Application* app, |
169 | DBusConnection* conn, |
170 | + Timer* timer, |
171 | + DownloadManager* man, |
172 | QObject *parent = 0); |
173 | |
174 | - public slots: |
175 | + public slots: // NOLINT (whitespace/indent) |
176 | void start(); |
177 | |
178 | private: |
179 | + Q_PRIVATE_SLOT(d_func(), void onTimeout()) |
180 | + Q_PRIVATE_SLOT(d_func(), void onDownloadManagerSizeChanged(int)) // NOLINT (readability/function) |
181 | + |
182 | + private: |
183 | // use pimpl so that we can mantains ABI compatibility |
184 | DownloadDaemonPrivate* d_ptr; |
185 | }; |
186 | |
187 | === modified file 'libubuntudownloadmanager/download_manager.cpp' |
188 | --- libubuntudownloadmanager/download_manager.cpp 2013-07-26 14:05:22 +0000 |
189 | +++ libubuntudownloadmanager/download_manager.cpp 2013-08-22 21:00:52 +0000 |
190 | @@ -44,7 +44,7 @@ |
191 | void init(); |
192 | void addDownload(Download* download); |
193 | void loadPreviewsDownloads(QString path); |
194 | - void onDownloadRemoved(QString path); |
195 | + void onDownloadsChanged(QString path); |
196 | |
197 | QDBusObjectPath createDownload(const QString& url, |
198 | const QVariantMap& metadata, |
199 | @@ -111,7 +111,9 @@ |
200 | qDBusRegisterMetaType<StringMap>(); |
201 | |
202 | q->connect(_downloadsQueue, SIGNAL(downloadRemoved(QString)), |
203 | - q, SLOT(onDownloadRemoved(QString))); |
204 | + q, SLOT(onDownloadsChanged(QString))); |
205 | + q->connect(_downloadsQueue, SIGNAL(downloadAdded(QString)), |
206 | + q, SLOT(onDownloadsChanged(QString))); |
207 | |
208 | _reqFactory = new RequestFactory(); |
209 | _processFactory = new ProcessFactory(); |
210 | @@ -131,14 +133,17 @@ |
211 | } |
212 | |
213 | void |
214 | -DownloadManagerPrivate::onDownloadRemoved(QString path) { |
215 | - _conn->unregisterObject(path); |
216 | +DownloadManagerPrivate::onDownloadsChanged(QString path) { |
217 | + qDebug() << __FUNCTION__ << path; |
218 | + Q_Q(DownloadManager); |
219 | + emit q->sizeChanged(_downloadsQueue->size()); |
220 | } |
221 | |
222 | QDBusObjectPath |
223 | DownloadManagerPrivate::createDownload(const QString& url, |
224 | const QVariantMap& metadata, |
225 | StringMap headers) { |
226 | + qDebug() << __FUNCTION__ << url << metadata << headers; |
227 | return createDownloadWithHash(url, "", QCryptographicHash::Md5, |
228 | metadata, headers); |
229 | } |
230 | |
231 | === modified file 'libubuntudownloadmanager/download_manager.h' |
232 | --- libubuntudownloadmanager/download_manager.h 2013-07-26 14:05:22 +0000 |
233 | +++ libubuntudownloadmanager/download_manager.h 2013-08-22 21:00:52 +0000 |
234 | @@ -62,9 +62,10 @@ |
235 | |
236 | signals: |
237 | void downloadCreated(const QDBusObjectPath& path); |
238 | + void sizeChanged(int count); |
239 | |
240 | private: |
241 | - Q_PRIVATE_SLOT(d_func(), void onDownloadRemoved(QString)) |
242 | + Q_PRIVATE_SLOT(d_func(), void onDownloadsChanged(QString)) |
243 | |
244 | private: |
245 | // use pimpl so that we can mantains ABI compatibility |
246 | |
247 | === modified file 'libubuntudownloadmanager/download_queue.cpp' |
248 | --- libubuntudownloadmanager/download_queue.cpp 2013-08-21 14:10:28 +0000 |
249 | +++ libubuntudownloadmanager/download_queue.cpp 2013-08-22 21:00:52 +0000 |
250 | @@ -40,16 +40,15 @@ |
251 | QString currentDownload(); |
252 | QStringList paths(); |
253 | QHash<QString, Download*> downloads(); |
254 | + int size(); |
255 | |
256 | void onDownloadStateChanged(); |
257 | - void onDestroyed(const QString& path); |
258 | void onCurrentNetworkModeChanged(QNetworkInfo::NetworkMode mode); |
259 | |
260 | private: |
261 | void updateCurrentDownload(); |
262 | |
263 | private: |
264 | - QSignalMapper* _mapper; |
265 | QString _current; |
266 | DownloadList _downloads; // quick for access |
267 | QStringList _sortedPaths; // keep the order |
268 | @@ -63,19 +62,13 @@ |
269 | _networkInfo(networkInfo), |
270 | q_ptr(parent) { |
271 | Q_Q(DownloadQueue); |
272 | - _mapper = new QSignalMapper(); |
273 | |
274 | q->connect(_networkInfo, |
275 | SIGNAL(currentNetworkModeChanged(QNetworkInfo::NetworkMode)), q, |
276 | SLOT(onCurrentNetworkModeChanged(QNetworkInfo::NetworkMode))); |
277 | - |
278 | - q->connect(_mapper, SIGNAL(mapped(const QString&)), |
279 | - q, SLOT(onDestroyed(const QString&))); |
280 | } |
281 | |
282 | DownloadQueuePrivate::~DownloadQueuePrivate() { |
283 | - if (_mapper != NULL) |
284 | - delete _mapper; |
285 | } |
286 | |
287 | void |
288 | @@ -89,6 +82,8 @@ |
289 | Q_Q(DownloadQueue); |
290 | // connect to the signals and append to the list |
291 | QString path = value.first->path(); |
292 | + qDebug() << __FUNCTION__ << path; |
293 | + |
294 | _sortedPaths.append(path); |
295 | _downloads[path] = value; |
296 | |
297 | @@ -107,15 +102,10 @@ |
298 | _sortedPaths.removeOne(path); |
299 | _downloads.remove(path); |
300 | |
301 | - // connect to the adaptor destroyed event to ensure that we have |
302 | - // emitted all signals, else we might have a race condition where |
303 | - // the object path is removed from dbus to early |
304 | - q->connect(pair.second, SIGNAL(destroyed(QObject* obj)), |
305 | - _mapper, SLOT(map(QObject* obj))); |
306 | - _mapper->setMapping(pair.first, path); |
307 | - |
308 | pair.second->deleteLater(); |
309 | pair.first->deleteLater(); |
310 | + |
311 | + emit q->downloadRemoved(path); |
312 | } |
313 | |
314 | QString |
315 | @@ -137,8 +127,14 @@ |
316 | return downloads; |
317 | } |
318 | |
319 | +int |
320 | +DownloadQueuePrivate::size() { |
321 | + return _downloads.size(); |
322 | +} |
323 | + |
324 | void |
325 | DownloadQueuePrivate::onDownloadStateChanged() { |
326 | + qDebug() << __FUNCTION__; |
327 | Q_Q(DownloadQueue); |
328 | // get the appdownload that emited the signal and decide what to do with it |
329 | Download* sender = qobject_cast<Download*>(q->sender()); |
330 | @@ -180,13 +176,6 @@ |
331 | } |
332 | |
333 | void |
334 | -DownloadQueuePrivate::onDestroyed(const QString &path) { |
335 | - qDebug() << __FUNCTION__; |
336 | - Q_Q(DownloadQueue); |
337 | - emit q->downloadRemoved(path); |
338 | -} |
339 | - |
340 | -void |
341 | DownloadQueuePrivate::onCurrentNetworkModeChanged( |
342 | QNetworkInfo::NetworkMode mode) { |
343 | Q_UNUSED(mode); |
344 | @@ -195,6 +184,7 @@ |
345 | |
346 | void |
347 | DownloadQueuePrivate::updateCurrentDownload() { |
348 | + qDebug() << __FUNCTION__; |
349 | Q_Q(DownloadQueue); |
350 | |
351 | if (!_current.isEmpty()) { |
352 | @@ -203,10 +193,12 @@ |
353 | Download::State state = currentDownload->state(); |
354 | if (state == Download::CANCEL || state == Download::FINISH |
355 | || state == Download::ERROR) { |
356 | + qDebug() << "States is CANCEL || FINISH"; |
357 | remove(_current); |
358 | _current = ""; |
359 | } else if (!currentDownload->canDownload() |
360 | || state == Download::PAUSE) { |
361 | + qDebug() << "States is Cannot Download || PAUSE"; |
362 | _current = ""; |
363 | } else { |
364 | return; |
365 | @@ -272,4 +264,10 @@ |
366 | return d->downloads(); |
367 | } |
368 | |
369 | +int |
370 | +DownloadQueue::size() { |
371 | + Q_D(DownloadQueue); |
372 | + return d->size(); |
373 | +} |
374 | + |
375 | #include "moc_download_queue.cpp" |
376 | |
377 | === modified file 'libubuntudownloadmanager/download_queue.h' |
378 | --- libubuntudownloadmanager/download_queue.h 2013-07-23 15:51:01 +0000 |
379 | +++ libubuntudownloadmanager/download_queue.h 2013-08-22 21:00:52 +0000 |
380 | @@ -40,6 +40,7 @@ |
381 | QString currentDownload(); |
382 | QStringList paths(); |
383 | QHash<QString, Download*> downloads(); |
384 | + virtual int size(); |
385 | |
386 | signals: |
387 | // signals raised when things happens within the q |
388 | @@ -49,7 +50,6 @@ |
389 | |
390 | private: |
391 | Q_PRIVATE_SLOT(d_func(), void onDownloadStateChanged()) |
392 | - Q_PRIVATE_SLOT(d_func(), void onDestroyed(const QString& path)) |
393 | Q_PRIVATE_SLOT(d_func(), |
394 | void onCurrentNetworkModeChanged(QNetworkInfo::NetworkMode mode)) |
395 | |
396 | |
397 | === modified file 'libubuntudownloadmanager/libubuntudownloadmanager.pro' |
398 | --- libubuntudownloadmanager/libubuntudownloadmanager.pro 2013-08-21 11:08:29 +0000 |
399 | +++ libubuntudownloadmanager/libubuntudownloadmanager.pro 2013-08-22 21:00:52 +0000 |
400 | @@ -24,7 +24,8 @@ |
401 | process.cpp \ |
402 | process_factory.cpp \ |
403 | logger.cpp \ |
404 | - application.cpp |
405 | + application.cpp \ |
406 | + timer.cpp |
407 | |
408 | HEADERS +=\ |
409 | app-downloader-lib_global.h \ |
410 | @@ -44,7 +45,8 @@ |
411 | process_factory.h \ |
412 | metatypes.h \ |
413 | logger.h \ |
414 | - application.h |
415 | + application.h \ |
416 | + timer.h |
417 | |
418 | OTHER_FILES += \ |
419 | generate_adaptors.sh \ |
420 | |
421 | === added file 'libubuntudownloadmanager/timer.cpp' |
422 | --- libubuntudownloadmanager/timer.cpp 1970-01-01 00:00:00 +0000 |
423 | +++ libubuntudownloadmanager/timer.cpp 2013-08-22 21:00:52 +0000 |
424 | @@ -0,0 +1,99 @@ |
425 | +/* |
426 | + * Copyright 2013 2013 Canonical Ltd. |
427 | + * |
428 | + * This library is free software; you can redistribute it and/or |
429 | + * modify it under the terms of version 3 of the GNU Lesser General Public |
430 | + * License as published by the Free Software Foundation. |
431 | + * |
432 | + * This program is distributed in the hope that it will be useful, |
433 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
434 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
435 | + * General Public License for more details. |
436 | + * |
437 | + * You should have received a copy of the GNU Lesser General Public |
438 | + * License along with this library; if not, write to the |
439 | + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
440 | + * Boston, MA 02110-1301, USA. |
441 | + */ |
442 | + |
443 | +#include <QTimer> |
444 | +#include "./timer.h" |
445 | + |
446 | +/* |
447 | + * PRIVATE IMPLEMENTATION |
448 | + */ |
449 | + |
450 | +class TimerPrivate { |
451 | + Q_DECLARE_PUBLIC(Timer) |
452 | + |
453 | + public: |
454 | + explicit TimerPrivate(Timer* parent); |
455 | + ~TimerPrivate(); |
456 | + |
457 | + bool isActive(); |
458 | + void start(int msec); |
459 | + void stop(); |
460 | + |
461 | + private: |
462 | + QTimer* _timer; |
463 | + Timer* q_ptr; |
464 | +}; |
465 | + |
466 | +TimerPrivate::TimerPrivate(Timer* parent) |
467 | + : q_ptr(parent) { |
468 | + Q_Q(Timer); |
469 | + _timer = new QTimer(); |
470 | + _timer->setSingleShot(true); |
471 | + |
472 | + q->connect(_timer, SIGNAL(timeout()), |
473 | + q, SIGNAL(timeout())); |
474 | +} |
475 | + |
476 | +TimerPrivate::~TimerPrivate() { |
477 | + if (_timer) |
478 | + delete _timer; |
479 | +} |
480 | + |
481 | + |
482 | +bool |
483 | +TimerPrivate::isActive() { |
484 | + return _timer->isActive(); |
485 | +} |
486 | + |
487 | +void |
488 | +TimerPrivate::start(int msec) { |
489 | + _timer->start(msec); |
490 | +} |
491 | + |
492 | +void |
493 | +TimerPrivate::stop() { |
494 | + _timer->stop(); |
495 | +} |
496 | + |
497 | + |
498 | +/* |
499 | + * PUBLIC IMPLEMENTATION |
500 | + */ |
501 | + |
502 | +Timer::Timer(QObject *parent) |
503 | + : QObject(parent), |
504 | + d_ptr(new TimerPrivate(this)) { |
505 | +} |
506 | + |
507 | +bool |
508 | +Timer::isActive() { |
509 | + Q_D(Timer); |
510 | + return d->isActive(); |
511 | +} |
512 | + |
513 | +void |
514 | +Timer::start(int msec) { |
515 | + Q_D(Timer); |
516 | + d->start(msec); |
517 | +} |
518 | + |
519 | +void |
520 | +Timer::stop() { |
521 | + Q_D(Timer); |
522 | + d->stop(); |
523 | +} |
524 | |
525 | === added file 'libubuntudownloadmanager/timer.h' |
526 | --- libubuntudownloadmanager/timer.h 1970-01-01 00:00:00 +0000 |
527 | +++ libubuntudownloadmanager/timer.h 2013-08-22 21:00:52 +0000 |
528 | @@ -0,0 +1,45 @@ |
529 | +/* |
530 | + * Copyright 2013 2013 Canonical Ltd. |
531 | + * |
532 | + * This library is free software; you can redistribute it and/or |
533 | + * modify it under the terms of version 3 of the GNU Lesser General Public |
534 | + * License as published by the Free Software Foundation. |
535 | + * |
536 | + * This program is distributed in the hope that it will be useful, |
537 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
538 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
539 | + * General Public License for more details. |
540 | + * |
541 | + * You should have received a copy of the GNU Lesser General Public |
542 | + * License along with this library; if not, write to the |
543 | + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
544 | + * Boston, MA 02110-1301, USA. |
545 | + */ |
546 | + |
547 | +#ifndef DOWNLOADER_LIB_TIMER_H |
548 | +#define DOWNLOADER_LIB_TIMER_H |
549 | + |
550 | +#include <QObject> |
551 | + |
552 | + |
553 | +class TimerPrivate; |
554 | +class Timer : public QObject { |
555 | + Q_OBJECT |
556 | + Q_DECLARE_PRIVATE(Timer) |
557 | + |
558 | + public: |
559 | + explicit Timer(QObject *parent = 0); |
560 | + |
561 | + virtual bool isActive(); |
562 | + virtual void start(int msec); |
563 | + virtual void stop(); |
564 | + |
565 | + signals: |
566 | + void timeout(); |
567 | + |
568 | + private: |
569 | + // use pimpl so that we can mantains ABI compatibility |
570 | + TimerPrivate* d_ptr; |
571 | +}; |
572 | + |
573 | +#endif // DOWNLOADER_LIB_TIMER_H |
574 | |
575 | === added file 'ubuntu-download-manager-tests/fake_download_manager.cpp' |
576 | --- ubuntu-download-manager-tests/fake_download_manager.cpp 1970-01-01 00:00:00 +0000 |
577 | +++ ubuntu-download-manager-tests/fake_download_manager.cpp 2013-08-22 21:00:52 +0000 |
578 | @@ -0,0 +1,32 @@ |
579 | +/* |
580 | + * Copyright 2013 Canonical Ltd. |
581 | + * |
582 | + * This library is free software; you can redistribute it and/or |
583 | + * modify it under the terms of version 3 of the GNU Lesser General Public |
584 | + * License as published by the Free Software Foundation. |
585 | + * |
586 | + * This program is distributed in the hope that it will be useful, |
587 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
588 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
589 | + * General Public License for more details. |
590 | + * |
591 | + * You should have received a copy of the GNU Lesser General Public |
592 | + * License along with this library; if not, write to the |
593 | + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
594 | + * Boston, MA 02110-1301, USA. |
595 | + */ |
596 | + |
597 | +#include "./fake_download_manager.h" |
598 | + |
599 | +FakeDownloadManager::FakeDownloadManager( |
600 | + QSharedPointer<DBusConnection> connection, |
601 | + QObject *parent) |
602 | + : DownloadManager(connection, parent), |
603 | + Fake() { |
604 | +} |
605 | + |
606 | +void |
607 | +FakeDownloadManager::emitSizeChaged(int size) { |
608 | + emit sizeChanged(size); |
609 | +} |
610 | + |
611 | |
612 | === added file 'ubuntu-download-manager-tests/fake_download_manager.h' |
613 | --- ubuntu-download-manager-tests/fake_download_manager.h 1970-01-01 00:00:00 +0000 |
614 | +++ ubuntu-download-manager-tests/fake_download_manager.h 2013-08-22 21:00:52 +0000 |
615 | @@ -0,0 +1,37 @@ |
616 | +/* |
617 | + * Copyright 2013 Canonical Ltd. |
618 | + * |
619 | + * This library is free software; you can redistribute it and/or |
620 | + * modify it under the terms of version 3 of the GNU Lesser General Public |
621 | + * License as published by the Free Software Foundation. |
622 | + * |
623 | + * This program is distributed in the hope that it will be useful, |
624 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
625 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
626 | + * General Public License for more details. |
627 | + * |
628 | + * You should have received a copy of the GNU Lesser General Public |
629 | + * License along with this library; if not, write to the |
630 | + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
631 | + * Boston, MA 02110-1301, USA. |
632 | + */ |
633 | + |
634 | +#ifndef FAKE_DOWNLOAD_MANAGER_H |
635 | +#define FAKE_DOWNLOAD_MANAGER_H |
636 | + |
637 | +#include <QObject> |
638 | +#include <download_manager.h> |
639 | +#include "./fake.h" |
640 | + |
641 | + |
642 | +class FakeDownloadManager : public DownloadManager, public Fake { |
643 | + Q_OBJECT |
644 | + |
645 | + public: |
646 | + explicit FakeDownloadManager(QSharedPointer<DBusConnection> connection, |
647 | + QObject *parent = 0); |
648 | + |
649 | + void emitSizeChaged(int size); |
650 | +}; |
651 | + |
652 | +#endif // FAKE_DOWNLOAD_MANAGER_H |
653 | |
654 | === modified file 'ubuntu-download-manager-tests/fake_download_queue.cpp' |
655 | --- ubuntu-download-manager-tests/fake_download_queue.cpp 2013-07-23 17:42:03 +0000 |
656 | +++ ubuntu-download-manager-tests/fake_download_queue.cpp 2013-08-22 21:00:52 +0000 |
657 | @@ -57,3 +57,23 @@ |
658 | } |
659 | DownloadQueue::add(value); |
660 | } |
661 | + |
662 | +int |
663 | +FakeDownloadQueue::size() { |
664 | + return _size; |
665 | +} |
666 | + |
667 | +void |
668 | +FakeDownloadQueue::setSize(int size) { |
669 | + _size = size; |
670 | +} |
671 | + |
672 | +void |
673 | +FakeDownloadQueue::emitDownloadAdded(const QString& path) { |
674 | + emit downloadAdded(path); |
675 | +} |
676 | + |
677 | +void |
678 | +FakeDownloadQueue::emitDownloadRemoved(const QString& path) { |
679 | + emit downloadRemoved(path); |
680 | +} |
681 | |
682 | === modified file 'ubuntu-download-manager-tests/fake_download_queue.h' |
683 | --- ubuntu-download-manager-tests/fake_download_queue.h 2013-07-23 17:42:56 +0000 |
684 | +++ ubuntu-download-manager-tests/fake_download_queue.h 2013-08-22 21:00:52 +0000 |
685 | @@ -31,6 +31,14 @@ |
686 | |
687 | void add(Download* download, DownloadAdaptor* adaptor) override; |
688 | void add(const QPair<Download*, DownloadAdaptor*>& value) override; |
689 | + int size() override; |
690 | + void setSize(int size); |
691 | + |
692 | + void emitDownloadAdded(const QString& path); |
693 | + void emitDownloadRemoved(const QString& path); |
694 | + |
695 | + private: |
696 | + int _size; |
697 | }; |
698 | |
699 | #endif // FAKE_DOWNLOAD_QUEUE_H |
700 | |
701 | === added file 'ubuntu-download-manager-tests/fake_timer.cpp' |
702 | --- ubuntu-download-manager-tests/fake_timer.cpp 1970-01-01 00:00:00 +0000 |
703 | +++ ubuntu-download-manager-tests/fake_timer.cpp 2013-08-22 21:00:52 +0000 |
704 | @@ -0,0 +1,75 @@ |
705 | +/* |
706 | + * Copyright 2013 2013 Canonical Ltd. |
707 | + * |
708 | + * This library is free software; you can redistribute it and/or |
709 | + * modify it under the terms of version 3 of the GNU Lesser General Public |
710 | + * License as published by the Free Software Foundation. |
711 | + * |
712 | + * This program is distributed in the hope that it will be useful, |
713 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
714 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
715 | + * General Public License for more details. |
716 | + * |
717 | + * You should have received a copy of the GNU Lesser General Public |
718 | + * License along with this library; if not, write to the |
719 | + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
720 | + * Boston, MA 02110-1301, USA. |
721 | + */ |
722 | + |
723 | +#include "./fake_timer.h" |
724 | + |
725 | +FakeTimer::FakeTimer(QObject *parent) |
726 | + : Timer(parent), |
727 | + Fake() { |
728 | +} |
729 | + |
730 | +bool |
731 | +FakeTimer::isActive() { |
732 | + if (_recording) { |
733 | + QList<QObject*> inParams; |
734 | + |
735 | + QList<QObject*> outParams; |
736 | + outParams.append(new BoolWrapper(_isActive)); |
737 | + |
738 | + MethodParams params(inParams, outParams); |
739 | + MethodData methodData("isActive", params); |
740 | + _called.append(methodData); |
741 | + } |
742 | + return _isActive; |
743 | +} |
744 | + |
745 | +void |
746 | +FakeTimer::setIsActive(bool active) { |
747 | + _isActive = active; |
748 | +} |
749 | + |
750 | +void |
751 | +FakeTimer::start(int msec) { |
752 | + if (_recording) { |
753 | + QList<QObject*> inParams; |
754 | + inParams.append(new IntWrapper(msec)); |
755 | + |
756 | + QList<QObject*> outParams; |
757 | + |
758 | + MethodParams params(inParams, outParams); |
759 | + MethodData methodData("start", params); |
760 | + _called.append(methodData); |
761 | + } |
762 | +} |
763 | + |
764 | +void |
765 | +FakeTimer::stop() { |
766 | + if (_recording) { |
767 | + QList<QObject*> inParams; |
768 | + QList<QObject*> outParams; |
769 | + |
770 | + MethodParams params(inParams, outParams); |
771 | + MethodData methodData("stop", params); |
772 | + _called.append(methodData); |
773 | + } |
774 | +} |
775 | + |
776 | +void |
777 | +FakeTimer::emitTimeout() { |
778 | + emit timeout(); |
779 | +} |
780 | |
781 | === added file 'ubuntu-download-manager-tests/fake_timer.h' |
782 | --- ubuntu-download-manager-tests/fake_timer.h 1970-01-01 00:00:00 +0000 |
783 | +++ ubuntu-download-manager-tests/fake_timer.h 2013-08-22 21:00:52 +0000 |
784 | @@ -0,0 +1,44 @@ |
785 | +/* |
786 | + * Copyright 2013 2013 Canonical Ltd. |
787 | + * |
788 | + * This library is free software; you can redistribute it and/or |
789 | + * modify it under the terms of version 3 of the GNU Lesser General Public |
790 | + * License as published by the Free Software Foundation. |
791 | + * |
792 | + * This program is distributed in the hope that it will be useful, |
793 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
794 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
795 | + * General Public License for more details. |
796 | + * |
797 | + * You should have received a copy of the GNU Lesser General Public |
798 | + * License along with this library; if not, write to the |
799 | + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
800 | + * Boston, MA 02110-1301, USA. |
801 | + */ |
802 | + |
803 | +#ifndef FAKE_TIMER_H |
804 | +#define FAKE_TIMER_H |
805 | + |
806 | +#include <QObject> |
807 | +#include <timer.h> |
808 | +#include "./fake.h" |
809 | + |
810 | + |
811 | +class FakeTimer : public Timer, public Fake { |
812 | + Q_OBJECT |
813 | + |
814 | + public: |
815 | + explicit FakeTimer(QObject *parent = 0); |
816 | + |
817 | + bool isActive() override; |
818 | + void setIsActive(bool active); |
819 | + void start(int msec) override; |
820 | + void stop() override; |
821 | + |
822 | + void emitTimeout(); |
823 | + |
824 | + private: |
825 | + bool _isActive; |
826 | +}; |
827 | + |
828 | +#endif // FAKE_TIMER_H |
829 | |
830 | === added file 'ubuntu-download-manager-tests/irl_tests.py' |
831 | --- ubuntu-download-manager-tests/irl_tests.py 1970-01-01 00:00:00 +0000 |
832 | +++ ubuntu-download-manager-tests/irl_tests.py 2013-08-22 21:00:52 +0000 |
833 | @@ -0,0 +1,84 @@ |
834 | +#!/usr/bin/python |
835 | +# -*- encoding: utf-8 -*- |
836 | +# |
837 | +# Copyright 2013 Canonical Ltd. |
838 | +# |
839 | +# This program is free software: you can redistribute it and/or modify it |
840 | +# under the terms of the GNU General Public License version 3, as published |
841 | +# by the Free Software Foundation. |
842 | +# |
843 | +# This program is distributed in the hope that it will be useful, but |
844 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
845 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
846 | +# PURPOSE. See the GNU General Public License for more details. |
847 | +# |
848 | +# You should have received a copy of the GNU General Public License along |
849 | +# with this program. If not, see <http://www.gnu.org/licenses/>. |
850 | +# |
851 | +# In addition, as a special exception, the copyright holders give |
852 | +# permission to link the code of portions of this program with the |
853 | +# OpenSSL library under certain conditions as described in each |
854 | +# individual source file, and distribute linked combinations |
855 | +# including the two. |
856 | +# You must obey the GNU General Public License in all respects |
857 | +# for all of the code used other than OpenSSL. If you modify |
858 | +# file(s) with this exception, you may extend this exception to your |
859 | +# version of the file(s), but you are not obligated to do so. If you |
860 | +# do not wish to do so, delete this exception statement from your |
861 | +# version. If you delete this exception statement from all source |
862 | +# files in the program, then also delete it here. |
863 | +"""Test the ubuntu downloader.""" |
864 | + |
865 | +import gobject |
866 | +import dbus |
867 | +from dbus.mainloop.glib import DBusGMainLoop |
868 | + |
869 | +DBusGMainLoop(set_as_default=True) |
870 | + |
871 | +MANAGER_PATH = '/' |
872 | +MANAGER_IFACE = 'com.canonical.applications.DownloaderManager' |
873 | +DOWNLOAD_IFACE = 'com.canonical.applications.Download' |
874 | +IMAGE_FILE = 'http://i.imgur.com/y51njgu.jpg' |
875 | + |
876 | + |
877 | +def download_created(path): |
878 | + """Deal with the download created signal.""" |
879 | + print 'Download created in %s' % path |
880 | + |
881 | + |
882 | +def finished_callback(path, loop): |
883 | + """Deal with the finis signal.""" |
884 | + print 'Download performed in "%s"' % path |
885 | + loop.quit() |
886 | + |
887 | + |
888 | +def progress_callback(total, progress): |
889 | + """Deal with the progress signals.""" |
890 | + print 'Progress is %s/%s' % (progress, total) |
891 | + |
892 | +if __name__ == '__main__': |
893 | + |
894 | + bus = dbus.SessionBus() |
895 | + loop = gobject.MainLoop() |
896 | + manager = bus.get_object('com.canonical.applications.Downloader', |
897 | + MANAGER_PATH) |
898 | + manager_dev_iface = dbus.Interface(manager, dbus_interface=MANAGER_IFACE) |
899 | + |
900 | + # ensure that download created works |
901 | + manager_dev_iface.connect_to_signal('downloadCreated', download_created) |
902 | + |
903 | + down_path = manager_dev_iface.createDownload(IMAGE_FILE, {}, {}) |
904 | + |
905 | + download = bus.get_object('com.canonical.applications.Downloader', |
906 | + down_path) |
907 | + |
908 | + download_dev_iface = dbus.Interface(download, dbus_interface=DOWNLOAD_IFACE) |
909 | + |
910 | + # connect to signals |
911 | + download_dev_iface.connect_to_signal('progress', progress_callback) |
912 | + download_dev_iface.connect_to_signal('finished', |
913 | + lambda path: finished_callback(path, loop)) |
914 | + |
915 | + download_dev_iface.start() |
916 | + |
917 | + loop.run() |
918 | |
919 | === modified file 'ubuntu-download-manager-tests/test_download_daemon.cpp' |
920 | --- ubuntu-download-manager-tests/test_download_daemon.cpp 2013-08-21 12:21:49 +0000 |
921 | +++ ubuntu-download-manager-tests/test_download_daemon.cpp 2013-08-22 21:00:52 +0000 |
922 | @@ -24,9 +24,11 @@ |
923 | |
924 | void |
925 | TestDownloadDaemon::init() { |
926 | + _timer = new FakeTimer(); |
927 | _app = new FakeApplication(); |
928 | _conn = new FakeDBusConnection(); |
929 | - _daemon = new DownloadDaemon(_app, _conn, this); |
930 | + _man = new FakeDownloadManager(QSharedPointer<DBusConnection>(_conn)); |
931 | + _daemon = new DownloadDaemon(_app, _conn, _timer, _man, this); |
932 | } |
933 | |
934 | void |
935 | @@ -37,6 +39,10 @@ |
936 | delete _conn; |
937 | if (_daemon != NULL) |
938 | delete _daemon; |
939 | + if (_timer != NULL) |
940 | + delete _timer; |
941 | + if (_man != NULL) |
942 | + delete _man; |
943 | } |
944 | |
945 | void |
946 | @@ -99,3 +105,39 @@ |
947 | QCOMPARE(1, calledMethods.count()); |
948 | QCOMPARE(QString("exit"), calledMethods[0].methodName()); |
949 | } |
950 | + |
951 | +void |
952 | +TestDownloadDaemon::testTimerStop() { |
953 | + _timer->setIsActive(true); |
954 | + _timer->record(); |
955 | + _man->emitSizeChaged(1); |
956 | + |
957 | + QList<MethodData> calledMethods = _timer->calledMethods(); |
958 | + QCOMPARE(2, calledMethods.count()); |
959 | + QCOMPARE(QString("isActive"), calledMethods[0].methodName()); |
960 | + QCOMPARE(QString("stop"), calledMethods[1].methodName()); |
961 | +} |
962 | + |
963 | +void |
964 | +TestDownloadDaemon::testTimerStart() { |
965 | + _timer->setIsActive(false); |
966 | + _timer->record(); |
967 | + _man->emitSizeChaged(0); |
968 | + |
969 | + QList<MethodData> calledMethods = _timer->calledMethods(); |
970 | + QCOMPARE(2, calledMethods.count()); |
971 | + QCOMPARE(QString("isActive"), calledMethods[0].methodName()); |
972 | + QCOMPARE(QString("start"), calledMethods[1].methodName()); |
973 | +} |
974 | + |
975 | +void |
976 | +TestDownloadDaemon::testTimeoutExit() { |
977 | + _app->record(); |
978 | + // emit the timeout signal and assert that exit was called |
979 | + _timer->emitTimeout(); |
980 | + |
981 | + QList<MethodData> calledMethods = _app->calledMethods(); |
982 | + QCOMPARE(1, calledMethods.count()); |
983 | + QCOMPARE(QString("exit"), calledMethods[0].methodName()); |
984 | +} |
985 | + |
986 | |
987 | === modified file 'ubuntu-download-manager-tests/test_download_daemon.h' |
988 | --- ubuntu-download-manager-tests/test_download_daemon.h 2013-08-21 11:40:25 +0000 |
989 | +++ ubuntu-download-manager-tests/test_download_daemon.h 2013-08-22 21:00:52 +0000 |
990 | @@ -23,6 +23,8 @@ |
991 | #include <download_daemon.h> |
992 | #include "./fake_application.h" |
993 | #include "./fake_dbus_connection.h" |
994 | +#include "./fake_download_manager.h" |
995 | +#include "./fake_timer.h" |
996 | #include "./test_runner.h" |
997 | |
998 | class TestDownloadDaemon : public QObject { |
999 | @@ -38,9 +40,14 @@ |
1000 | void testStart(); |
1001 | void testStartFailServiceRegister(); |
1002 | void testStartFailObjectRegister(); |
1003 | + void testTimerStop(); |
1004 | + void testTimerStart(); |
1005 | + void testTimeoutExit(); |
1006 | |
1007 | private: |
1008 | + FakeTimer* _timer; |
1009 | FakeApplication* _app; |
1010 | + FakeDownloadManager* _man; |
1011 | FakeDBusConnection* _conn; |
1012 | DownloadDaemon* _daemon; |
1013 | }; |
1014 | |
1015 | === modified file 'ubuntu-download-manager-tests/test_download_manager.cpp' |
1016 | --- ubuntu-download-manager-tests/test_download_manager.cpp 2013-07-26 14:05:22 +0000 |
1017 | +++ ubuntu-download-manager-tests/test_download_manager.cpp 2013-08-22 21:00:52 +0000 |
1018 | @@ -387,3 +387,47 @@ |
1019 | QCOMPARE(download->throttle(), speed); |
1020 | } |
1021 | } |
1022 | + |
1023 | +void |
1024 | +TestDownloadManager::testSizeChangedEmittedOnAddition_data() { |
1025 | + QTest::addColumn<int>("size"); |
1026 | + |
1027 | + QTest::newRow("First row") << 4; |
1028 | + QTest::newRow("Second row") << 5; |
1029 | + QTest::newRow("Third row") << 0; |
1030 | + QTest::newRow("Last row") << 34; |
1031 | +} |
1032 | + |
1033 | +void |
1034 | +TestDownloadManager::testSizeChangedEmittedOnAddition() { |
1035 | + QFETCH(int, size); |
1036 | + QSignalSpy spy(_man, SIGNAL(sizeChanged(int))); |
1037 | + _q->setSize(size); |
1038 | + _q->emitDownloadAdded(""); |
1039 | + |
1040 | + QCOMPARE(spy.count(), 1); |
1041 | + QList<QVariant> arguments = spy.takeFirst(); |
1042 | + QCOMPARE(arguments.at(0).toInt(), size); |
1043 | +} |
1044 | + |
1045 | +void |
1046 | +TestDownloadManager::testSizeChangedEmittedOnRemoval_data() { |
1047 | + QTest::addColumn<int>("size"); |
1048 | + |
1049 | + QTest::newRow("First row") << 4; |
1050 | + QTest::newRow("Second row") << 5; |
1051 | + QTest::newRow("Third row") << 0; |
1052 | + QTest::newRow("Last row") << 34; |
1053 | +} |
1054 | + |
1055 | +void |
1056 | +TestDownloadManager::testSizeChangedEmittedOnRemoval() { |
1057 | + QFETCH(int, size); |
1058 | + QSignalSpy spy(_man, SIGNAL(sizeChanged(int))); |
1059 | + _q->setSize(size); |
1060 | + _q->emitDownloadRemoved(""); |
1061 | + |
1062 | + QCOMPARE(spy.count(), 1); |
1063 | + QList<QVariant> arguments = spy.takeFirst(); |
1064 | + QCOMPARE(arguments.at(0).toInt(), size); |
1065 | +} |
1066 | |
1067 | === modified file 'ubuntu-download-manager-tests/test_download_manager.h' |
1068 | --- ubuntu-download-manager-tests/test_download_manager.h 2013-07-26 14:05:22 +0000 |
1069 | +++ ubuntu-download-manager-tests/test_download_manager.h 2013-08-22 21:00:52 +0000 |
1070 | @@ -44,6 +44,8 @@ |
1071 | void testCreateDownloadWithHash_data(); |
1072 | void testSetThrottleNotDownloads_data(); |
1073 | void testSetThrottleWithDownloads_data(); |
1074 | + void testSizeChangedEmittedOnAddition_data(); |
1075 | + void testSizeChangedEmittedOnRemoval_data(); |
1076 | |
1077 | // tests |
1078 | void testCreateDownload(); |
1079 | @@ -52,6 +54,8 @@ |
1080 | void testAllDownloadsWithMetadata(); |
1081 | void testSetThrottleNotDownloads(); |
1082 | void testSetThrottleWithDownloads(); |
1083 | + void testSizeChangedEmittedOnAddition(); |
1084 | + void testSizeChangedEmittedOnRemoval(); |
1085 | |
1086 | private: |
1087 | QCryptographicHash::Algorithm algoFromString(const QString& data); |
1088 | |
1089 | === modified file 'ubuntu-download-manager-tests/ubuntu-download-manager-tests.pro' |
1090 | --- ubuntu-download-manager-tests/ubuntu-download-manager-tests.pro 2013-08-21 11:40:25 +0000 |
1091 | +++ ubuntu-download-manager-tests/ubuntu-download-manager-tests.pro 2013-08-22 21:00:52 +0000 |
1092 | @@ -32,7 +32,9 @@ |
1093 | fake_system_network_info.cpp \ |
1094 | fake_process.cpp \ |
1095 | fake_process_factory.cpp \ |
1096 | - fake_application.cpp |
1097 | + fake_application.cpp \ |
1098 | + fake_timer.cpp \ |
1099 | + fake_download_manager.cpp |
1100 | |
1101 | HEADERS += \ |
1102 | fake.h \ |
1103 | @@ -53,7 +55,9 @@ |
1104 | fake_system_network_info.h \ |
1105 | fake_process.h \ |
1106 | fake_process_factory.h \ |
1107 | - fake_application.h |
1108 | + fake_application.h \ |
1109 | + fake_timer.h \ |
1110 | + fake_download_manager.h |
1111 | |
1112 | LIBS += -L$$OUT_PWD/../libubuntudownloadmanager/ -lubuntudownloadmanager |
1113 | |
1114 | |
1115 | === modified file 'ubuntu-download-manager/ubuntu-download-manager.pro' |
1116 | --- ubuntu-download-manager/ubuntu-download-manager.pro 2013-07-21 20:16:06 +0000 |
1117 | +++ ubuntu-download-manager/ubuntu-download-manager.pro 2013-08-22 21:00:52 +0000 |
1118 | @@ -4,7 +4,7 @@ |
1119 | # |
1120 | #------------------------------------------------- |
1121 | |
1122 | -QT += core |
1123 | +QT += core systeminfo |
1124 | |
1125 | QT -= gui |
1126 |
PASSED: Continuous integration, rev:99 jenkins. qa.ubuntu. com/job/ ubuntu- download- manager- ci/21/ jenkins. qa.ubuntu. com/job/ ubuntu- download- manager- saucy-amd64- ci/21 jenkins. qa.ubuntu. com/job/ ubuntu- download- manager- saucy-armhf- ci/12
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ ubuntu- download- manager- ci/21/rebuild
http://