This commit is contained in:
NissimHadar 2018-03-02 09:13:07 -08:00
parent 5bb4023fb5
commit 07267f9fe6
4 changed files with 84 additions and 2 deletions

View file

@ -0,0 +1,32 @@
//
// Downloader.cpp
//
// Created by Nissim Hadar on 1 Mar 2018.
// Copyright 2013 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "Downloader.h"
Downloader::Downloader(QUrl imageUrl, QObject *parent) : QObject(parent) {
connect(
&_networkAccessManager, SIGNAL (finished(QNetworkReply*)),
this, SLOT (fileDownloaded(QNetworkReply*))
);
QNetworkRequest request(imageUrl);
_networkAccessManager.get(request);
}
void Downloader::fileDownloaded(QNetworkReply* reply) {
_downloadedData = reply->readAll();
//emit a signal
reply->deleteLater();
emit downloaded();
}
QByteArray Downloader::downloadedData() const {
return _downloadedData;
}

View file

@ -0,0 +1,48 @@
//
// Downloader.h
//
// Created by Nissim Hadar on 1 Mar 2018.
// Copyright 2013 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_downloader_h
#define hifi_downloader_h
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QUrl>
#include <QDateTime>
#include <QFile>
#include <QFileInfo>
#include <QDebug>
#include <QObject>
#include <QByteArray>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
class Downloader : public QObject {
Q_OBJECT
public:
explicit Downloader(QUrl imageUrl, QObject *parent = 0);
QByteArray downloadedData() const;
signals:
void downloaded();
private slots:
void fileDownloaded(QNetworkReply* pReply);
private:
QNetworkAccessManager _networkAccessManager;
QByteArray _downloadedData;
};
#endif // hifi_downloader_h

View file

@ -214,7 +214,9 @@ void Test::evaluateTests(bool interactiveMode, QProgressBar* progressBar) {
}
}
autoTester->downloadImage(QUrl("http://ribafreixo.com/wp-content/uploads/2017/03/Order-Now-Button-300x113.png"));
////autoTester->downloadImage(QUrl("http://ribafreixo.com/wp-content/uploads/2017/03/Order-Now-Button-300x113.png"));
////autoTester->downloadImage(QUrl("https://github.com/NissimHadar/hifi_tests/blob/addRecursionToAutotester/tests/content/entity/zone/ambientLightInheritance/ExpectedImage_00000.jpg?raw=true"));
autoTester->downloadImage(QUrl("https://hifi-content.s3.amazonaws.com/nissim/autoTester/resources/ColourBox.jpg"));
////bool success = compareImageLists(expectedImages, resultImages, pathToImageDirectory, interactiveMode, progressBar);
////if (success) {

View file

@ -60,5 +60,5 @@ void AutoTester::saveImage() {
image.loadFromData(downloader->downloadedData());
int er = image.width();
int df = image.height();
image.save("D:/Dicom/lll.png");
image.save("D:/Dicom/lll.jpg");
}