diff --git a/tools/auto-tester/src/Test.cpp b/tools/auto-tester/src/Test.cpp index ac10d1ab33..d30349b395 100644 --- a/tools/auto-tester/src/Test.cpp +++ b/tools/auto-tester/src/Test.cpp @@ -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"); diff --git a/tools/auto-tester/src/ui/AutoTester.cpp b/tools/auto-tester/src/ui/AutoTester.cpp index c3ab88b7f4..5fd726ad72 100644 --- a/tools/auto-tester/src/ui/AutoTester.cpp +++ b/tools/auto-tester/src/ui/AutoTester.cpp @@ -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"); } diff --git a/tools/auto-tester/src/ui/AutoTester.h b/tools/auto-tester/src/ui/AutoTester.h index 5c1f217421..d5bab6d8a4 100644 --- a/tools/auto-tester/src/ui/AutoTester.h +++ b/tools/auto-tester/src/ui/AutoTester.h @@ -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 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;