Stores downloaded images in correct folder and with correct filenames.

This commit is contained in:
NissimHadar 2018-03-02 16:49:09 -08:00
parent d29adcd000
commit 4b836a2ca9
3 changed files with 24 additions and 15 deletions
tools/auto-tester/src

View file

@ -198,7 +198,8 @@ void Test::evaluateTests(bool interactiveMode, QProgressBar* progressBar) {
// Images that are in the wrong format are ignored.
QStringList sortedTestResultsFilenames = createListOfAllJPEGimagesInDirectory(pathToTestResultsDirectory);
QStringList expectedImages;
QStringList expectedImagesURLs;
QStringList expectedImagesFilenames;
QStringList resultImages;
const QString URLPrefix("https://raw.githubusercontent.com");
@ -217,14 +218,16 @@ void Test::evaluateTests(bool interactiveMode, QProgressBar* progressBar) {
QString expectedImageFilenameTail = currentFilename.left(currentFilename.length() - 4).right(NUM_DIGITS);
QString expectedImageFilename = EXPECTED_IMAGE_PREFIX + expectedImageFilenameTail + EXPECTED_IMAGE_TYPE;
expectedImagesFilenames << expectedImageFilename;
QString imageURLString(URLPrefix + "/" + githubUser + "/" + testsRepo + "/" + branch + "/" + expectedImagePartialSourceDirectory + "/" + expectedImageFilename);
expectedImages << imageURLString;
expectedImagesURLs << imageURLString;
}
}
//autoTester->downloadImage(QUrl("https://raw.githubusercontent.com/NissimHadar/hifi_tests/addRecursionToAutotester/tests/content/entity/zone/ambientLightInheritance/ExpectedImage_00000.jpg"));
autoTester->downloadImages(expectedImagesURLs, pathToTestResultsDirectory, expectedImagesFilenames);
autoTester->downloadImages(expectedImages);
// Wait for do
////if (success) {
//// messageBox.information(0, "Success", "All images are as expected");

View file

@ -51,7 +51,7 @@ void AutoTester::on_closeButton_clicked() {
exit(0);
}
void AutoTester::downloadImage(QUrl url) {
void AutoTester::downloadImage(const QUrl& url) {
downloaders.emplace_back(new Downloader(url, this));
connect(downloaders[_index], SIGNAL (downloaded()), signalMapper, SLOT (map()));
@ -60,13 +60,16 @@ void AutoTester::downloadImage(QUrl url) {
++_index;
}
void AutoTester::downloadImages(QStringList listOfURLs) {
_numberOfImagesToDownload = listOfURLs.size();
void AutoTester::downloadImages(const QStringList& URLs, const QString& directoryName, const QStringList& filenames) {
_directoryName = directoryName;
_filenames = filenames;
_numberOfImagesToDownload = URLs.size();
_numberOfImagesDownloaded = 0;
_index = 0;
for (int i = 0; i < _numberOfImagesToDownload; ++i) {
QUrl imageURL(listOfURLs[i]);
QUrl imageURL(URLs[i]);
downloadImage(imageURL);
}
@ -77,10 +80,8 @@ void AutoTester::saveImage(int index) {
QPixmap image;
image.loadFromData(downloaders[index]->downloadedData());
int w = image.width();
int h = image.height();
image.save(_directoryName + "/" + _filenames[index]);
++_numberOfImagesDownloaded;
image.save("D:/Dicom/lll_" + QString::number(index) + ".jpg");
}

View file

@ -22,8 +22,8 @@ class AutoTester : public QMainWindow {
public:
AutoTester(QWidget *parent = Q_NULLPTR);
void downloadImage(QUrl url);
void downloadImages(QStringList listOfURLs);
void downloadImage(const QUrl& url);
void downloadImages(const QStringList& URLs, const QString& directoryName, const QStringList& filenames);
private slots:
void on_evaluateTestsButton_clicked();
@ -38,10 +38,15 @@ private slots:
private:
Ui::AutoTesterClass ui;
Test* test;
std::vector<Downloader*> downloaders;
// local storage for parameters - folder to store downloaded files in, and a list of their names
QString _directoryName;
QStringList _filenames;
// Used to enable passing a parameter to slots
QSignalMapper* signalMapper;
int _numberOfImagesToDownload;