mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 12:54:30 +02:00
First version - can download fixed URL to fixed location.
This commit is contained in:
parent
b3b40d68c2
commit
5bb4023fb5
6 changed files with 76 additions and 45 deletions
|
@ -5,7 +5,7 @@ project(${TARGET_NAME})
|
||||||
SET (CMAKE_AUTOUIC ON)
|
SET (CMAKE_AUTOUIC ON)
|
||||||
SET (CMAKE_AUTOMOC ON)
|
SET (CMAKE_AUTOMOC ON)
|
||||||
|
|
||||||
setup_hifi_project (Core Widgets)
|
setup_hifi_project (Core Widgets Network)
|
||||||
link_hifi_libraries ()
|
link_hifi_libraries ()
|
||||||
|
|
||||||
# FIX: Qt was built with -reduce-relocations
|
# FIX: Qt was built with -reduce-relocations
|
||||||
|
|
|
@ -16,8 +16,13 @@
|
||||||
#include <quazip5/quazip.h>
|
#include <quazip5/quazip.h>
|
||||||
#include <quazip5/JlCompress.h>
|
#include <quazip5/JlCompress.h>
|
||||||
|
|
||||||
|
#include "ui/AutoTester.h"
|
||||||
|
extern AutoTester* autoTester;
|
||||||
|
|
||||||
Test::Test() {
|
Test::Test() {
|
||||||
expectedImageFilenameFormat = QRegularExpression("ExpectedImage_\\d+.jpg");
|
QString regex(EXPECTED_IMAGE_PREFIX + QString("\\\\d").repeated(NUM_DIGITS) + EXPECTED_IMAGE_TYPE);
|
||||||
|
|
||||||
|
expectedImageFilenameFormat = QRegularExpression(regex);
|
||||||
|
|
||||||
mismatchWindow.setModal(true);
|
mismatchWindow.setModal(true);
|
||||||
}
|
}
|
||||||
|
@ -178,49 +183,45 @@ void Test::appendTestResultsToFile(QString testResultsFolderPath, TestFailure te
|
||||||
|
|
||||||
void Test::evaluateTests(bool interactiveMode, QProgressBar* progressBar) {
|
void Test::evaluateTests(bool interactiveMode, QProgressBar* progressBar) {
|
||||||
// Get list of JPEG images in folder, sorted by name
|
// Get list of JPEG images in folder, sorted by name
|
||||||
QString pathToImageDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder containing the test images", ".", QFileDialog::ShowDirsOnly);
|
QString pathToTestResultsDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder containing the test images", ".", QFileDialog::ShowDirsOnly);
|
||||||
if (pathToImageDirectory == "") {
|
if (pathToTestResultsDirectory == "") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Leave if test results folder could not be created
|
// Leave if test results folder could not be created
|
||||||
if (!createTestResultsFolderPathIfNeeded(pathToImageDirectory)) {
|
if (!createTestResultsFolderPathIfNeeded(pathToTestResultsDirectory)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList sortedImageFilenames = createListOfAllJPEGimagesInDirectory(pathToImageDirectory);
|
// Create two lists. The first is the test results, the second is the expected images
|
||||||
|
|
||||||
// Separate images into two lists. The first is the expected images, the second is the test results
|
|
||||||
// Images that are in the wrong format are ignored.
|
// Images that are in the wrong format are ignored.
|
||||||
|
|
||||||
|
QStringList sortedTestResultsFilenames = createListOfAllJPEGimagesInDirectory(pathToTestResultsDirectory);
|
||||||
QStringList expectedImages;
|
QStringList expectedImages;
|
||||||
QStringList resultImages;
|
QStringList resultImages;
|
||||||
foreach(QString currentFilename, sortedImageFilenames) {
|
foreach(QString currentFilename, sortedTestResultsFilenames) {
|
||||||
QString fullCurrentFilename = pathToImageDirectory + "/" + currentFilename;
|
QString fullCurrentFilename = pathToTestResultsDirectory + "/" + currentFilename;
|
||||||
if (isInExpectedImageFilenameFormat(currentFilename)) {
|
if (isInSnapshotFilenameFormat(currentFilename)) {
|
||||||
expectedImages << fullCurrentFilename;
|
|
||||||
} else if (isInSnapshotFilenameFormat(currentFilename)) {
|
|
||||||
resultImages << fullCurrentFilename;
|
resultImages << fullCurrentFilename;
|
||||||
|
|
||||||
|
QString expectedImageDirectory = getExpectedImageDestinationDirectory(currentFilename);
|
||||||
|
|
||||||
|
// extract the digits at the end of the filename (exluding the file extension)
|
||||||
|
QString expectedImageFilenameTail = currentFilename.left(currentFilename.length() - 4).right(NUM_DIGITS);
|
||||||
|
|
||||||
|
QString expectedImageFilename = EXPECTED_IMAGE_PREFIX + expectedImageFilenameTail + EXPECTED_IMAGE_TYPE;
|
||||||
|
expectedImages << (expectedImageDirectory + "/" + expectedImageFilename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The number of images in each list should be identical
|
autoTester->downloadImage(QUrl("http://ribafreixo.com/wp-content/uploads/2017/03/Order-Now-Button-300x113.png"));
|
||||||
if (expectedImages.length() != resultImages.length()) {
|
////bool success = compareImageLists(expectedImages, resultImages, pathToImageDirectory, interactiveMode, progressBar);
|
||||||
messageBox.critical(0,
|
|
||||||
"Test failed",
|
|
||||||
"Found " + QString::number(resultImages.length()) + " images in directory" +
|
|
||||||
"\nExpected to find " + QString::number(expectedImages.length()) + " images"
|
|
||||||
);
|
|
||||||
|
|
||||||
exit(-1);
|
////if (success) {
|
||||||
}
|
//// messageBox.information(0, "Success", "All images are as expected");
|
||||||
|
////} else {
|
||||||
bool success = compareImageLists(expectedImages, resultImages, pathToImageDirectory, interactiveMode, progressBar);
|
//// messageBox.information(0, "Failure", "One or more images are not as expected");
|
||||||
|
////}
|
||||||
if (success) {
|
|
||||||
messageBox.information(0, "Success", "All images are as expected");
|
|
||||||
} else {
|
|
||||||
messageBox.information(0, "Failure", "One or more images are not as expected");
|
|
||||||
}
|
|
||||||
|
|
||||||
zipAndDeleteTestResultsFolder();
|
zipAndDeleteTestResultsFolder();
|
||||||
}
|
}
|
||||||
|
@ -407,7 +408,7 @@ void Test::createTest() {
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
QString newFilename = "ExpectedImage_" + QString::number(i - 1).rightJustified(5, '0') + ".jpg";
|
QString newFilename = "ExpectedImage_" + QString::number(i - 1).rightJustified(5, '0') + ".jpg";
|
||||||
QString imageDestinationDirectory = getImageDestinationDirectory(currentFilename);
|
QString imageDestinationDirectory = getExpectedImageDestinationDirectory(currentFilename);
|
||||||
QString fullNewFileName = imageDestinationDirectory + "/" + newFilename;
|
QString fullNewFileName = imageDestinationDirectory + "/" + newFilename;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -489,7 +490,7 @@ bool Test::isInSnapshotFilenameFormat(QString filename) {
|
||||||
// D:/GitHub/hifi-tests/tests/content/entity/zone/create
|
// D:/GitHub/hifi-tests/tests/content/entity/zone/create
|
||||||
// This method assumes the filename is in the correct format
|
// This method assumes the filename is in the correct format
|
||||||
// The final part of the filename is the image number. This is checked for sanity
|
// The final part of the filename is the image number. This is checked for sanity
|
||||||
QString Test::getImageDestinationDirectory(QString filename) {
|
QString Test::getExpectedImageDestinationDirectory(QString filename) {
|
||||||
QString filenameWithoutExtension = filename.split(".")[0];
|
QString filenameWithoutExtension = filename.split(".")[0];
|
||||||
QStringList filenameParts = filenameWithoutExtension.split("_");
|
QStringList filenameParts = filenameWithoutExtension.split("_");
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
|
|
||||||
bool isAValidDirectory(QString pathname);
|
bool isAValidDirectory(QString pathname);
|
||||||
|
|
||||||
QString getImageDestinationDirectory(QString filename);
|
QString getExpectedImageDestinationDirectory(QString filename);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QString TEST_FILENAME { "test.js" };
|
const QString TEST_FILENAME { "test.js" };
|
||||||
|
@ -65,6 +65,11 @@ private:
|
||||||
|
|
||||||
QString testResultsFolderPath { "" };
|
QString testResultsFolderPath { "" };
|
||||||
int index { 1 };
|
int index { 1 };
|
||||||
|
|
||||||
|
// Expected images are in the format ExpectedImage_dddd.jpg (d == decimal digit)
|
||||||
|
const int NUM_DIGITS { 5 };
|
||||||
|
const QString EXPECTED_IMAGE_PREFIX { "ExpectedImage_" };
|
||||||
|
const QString EXPECTED_IMAGE_TYPE { ".jpg" };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_test_h
|
#endif // hifi_test_h
|
|
@ -10,11 +10,13 @@
|
||||||
#include <QtWidgets/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
#include "ui/AutoTester.h"
|
#include "ui/AutoTester.h"
|
||||||
|
|
||||||
|
AutoTester* autoTester;
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
QApplication application(argc, argv);
|
QApplication application(argc, argv);
|
||||||
|
|
||||||
AutoTester autoTester;
|
autoTester = new AutoTester();
|
||||||
autoTester.show();
|
autoTester->show();
|
||||||
|
|
||||||
return application.exec();
|
return application.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,36 +12,53 @@
|
||||||
|
|
||||||
AutoTester::AutoTester(QWidget *parent) : QMainWindow(parent) {
|
AutoTester::AutoTester(QWidget *parent) : QMainWindow(parent) {
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
ui.checkBoxInteractiveMode->setChecked(true);
|
ui.checkBoxInteractiveMode->setChecked(true);
|
||||||
|
|
||||||
ui.progressBar->setVisible(false);
|
ui.progressBar->setVisible(false);
|
||||||
|
|
||||||
|
test = new Test();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoTester::on_evaluateTestsButton_clicked() {
|
void AutoTester::on_evaluateTestsButton_clicked() {
|
||||||
test.evaluateTests(ui.checkBoxInteractiveMode->isChecked(), ui.progressBar);
|
////QUrl imageUrl("http://ribafreixo.com/wp-content/uploads/2017/03/Order-Now-Button-300x113.png");
|
||||||
|
////downloader = new Downloader(imageUrl, this);
|
||||||
|
////connect(downloader, SIGNAL (downloaded()), this, SLOT (saveImage()));
|
||||||
|
test->evaluateTests(ui.checkBoxInteractiveMode->isChecked(), ui.progressBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoTester::on_evaluateTestsRecursivelyButton_clicked() {
|
void AutoTester::on_evaluateTestsRecursivelyButton_clicked() {
|
||||||
test.evaluateTestsRecursively(ui.checkBoxInteractiveMode->isChecked(), ui.progressBar);
|
test->evaluateTestsRecursively(ui.checkBoxInteractiveMode->isChecked(), ui.progressBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoTester::on_createRecursiveScriptButton_clicked() {
|
void AutoTester::on_createRecursiveScriptButton_clicked() {
|
||||||
test.createRecursiveScript();
|
test->createRecursiveScript();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoTester::on_createRecursiveScriptsRecursivelyButton_clicked() {
|
void AutoTester::on_createRecursiveScriptsRecursivelyButton_clicked() {
|
||||||
test.createRecursiveScriptsRecursively();
|
test->createRecursiveScriptsRecursively();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoTester::on_createTestButton_clicked() {
|
void AutoTester::on_createTestButton_clicked() {
|
||||||
test.createTest();
|
test->createTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoTester::on_deleteOldSnapshotsButton_clicked() {
|
void AutoTester::on_deleteOldSnapshotsButton_clicked() {
|
||||||
test.deleteOldSnapshots();
|
test->deleteOldSnapshots();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoTester::on_closeButton_clicked() {
|
void AutoTester::on_closeButton_clicked() {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AutoTester::downloadImage(QUrl url) {
|
||||||
|
downloader = new Downloader(url, this);
|
||||||
|
|
||||||
|
connect(downloader, SIGNAL (downloaded()), this, SLOT (saveImage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void AutoTester::saveImage() {
|
||||||
|
QPixmap image;
|
||||||
|
image.loadFromData(downloader->downloadedData());
|
||||||
|
int er = image.width();
|
||||||
|
int df = image.height();
|
||||||
|
image.save("D:/Dicom/lll.png");
|
||||||
|
}
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
|
|
||||||
#include <QtWidgets/QMainWindow>
|
#include <QtWidgets/QMainWindow>
|
||||||
#include "ui_AutoTester.h"
|
#include "ui_AutoTester.h"
|
||||||
|
|
||||||
|
#include "../Downloader.h"
|
||||||
#include "../Test.h"
|
#include "../Test.h"
|
||||||
|
|
||||||
class AutoTester : public QMainWindow {
|
class AutoTester : public QMainWindow {
|
||||||
|
@ -19,6 +21,7 @@ class AutoTester : public QMainWindow {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AutoTester(QWidget *parent = Q_NULLPTR);
|
AutoTester(QWidget *parent = Q_NULLPTR);
|
||||||
|
void downloadImage(QUrl url);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_evaluateTestsButton_clicked();
|
void on_evaluateTestsButton_clicked();
|
||||||
|
@ -29,10 +32,13 @@ private slots:
|
||||||
void on_deleteOldSnapshotsButton_clicked();
|
void on_deleteOldSnapshotsButton_clicked();
|
||||||
void on_closeButton_clicked();
|
void on_closeButton_clicked();
|
||||||
|
|
||||||
|
void saveImage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::AutoTesterClass ui;
|
Ui::AutoTesterClass ui;
|
||||||
|
|
||||||
Test test;
|
Test* test;
|
||||||
|
Downloader* downloader;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_AutoTester_h
|
#endif // hifi_AutoTester_h
|
Loading…
Reference in a new issue