summaryrefslogtreecommitdiffstats
path: root/tests/downloadspeed/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/downloadspeed/main.cpp')
-rw-r--r--tests/downloadspeed/main.cpp26
1 files changed, 5 insertions, 21 deletions
diff --git a/tests/downloadspeed/main.cpp b/tests/downloadspeed/main.cpp
index 6611ec17a..4edc0d8b6 100644
--- a/tests/downloadspeed/main.cpp
+++ b/tests/downloadspeed/main.cpp
@@ -42,6 +42,8 @@
#include <kdupdaterfiledownloader.h>
#include <kdupdaterfiledownloaderfactory.h>
+#include <fileutils.h>
+
#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
#include <QtCore/QObject>
@@ -49,26 +51,6 @@
#include <QtNetwork/QNetworkProxy>
-static QString humanReadableSize(quint64 intSize)
-{
- QString unit;
- double size;
-
- if (intSize < 1024 * 1024) {
- size = 1. + intSize / 1024.;
- unit = QObject::tr("kB");
- } else if (intSize < 1024 * 1024 * 1024) {
- size = 1. + intSize / 1024. / 1024.;
- unit = QObject::tr("MB");
- } else {
- size = 1. + intSize / 1024. / 1024. / 1024.;
- unit = QObject::tr("GB");
- }
-
- size = qRound(size * 10) / 10.0;
- return QString::fromLatin1("%L1 %2").arg(size, 0, 'g', 4).arg(unit);
-}
-
// -- Receiver
class Receiver : public QObject
@@ -100,7 +82,8 @@ public slots:
void downloadSpeed(qint64 speed)
{
- qDebug() << "Download speed:" << humanReadableSize(speed) + QLatin1String("/sec");
+ qDebug() << "Download speed:" <<
+ QInstaller::humanReadableSize(speed) + QLatin1String("/sec");
}
void downloadProgress(double progress)
@@ -181,6 +164,7 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
const QUrl url(a.arguments().value(1));
+ KDUpdater::FileDownloaderFactory::setFollowRedirects(true);
qDebug() << url.toString();
KDUpdater::FileDownloader *loader = KDUpdater::FileDownloaderFactory::instance().create(url.scheme(), 0);
if (loader) {