mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
No more use of JPG files.
This commit is contained in:
parent
d55d3c54da
commit
79293310e5
3 changed files with 9 additions and 34 deletions
|
@ -15,10 +15,8 @@
|
|||
// Computes SSIM - see https://en.wikipedia.org/wiki/Structural_similarity
|
||||
// The value is computed for the luminance component and the average value is returned
|
||||
double ImageComparer::compareImages(QImage resultImage, QImage expectedImage) const {
|
||||
// Make sure the image is 8 bits per colour
|
||||
QImage::Format format = expectedImage.format();
|
||||
|
||||
const int L = 255; // (2^number of bits per pixel) - 1
|
||||
|
||||
const double K1 { 0.01 };
|
||||
const double K2 { 0.03 };
|
||||
const double c1 = pow((K1 * L), 2);
|
||||
|
|
|
@ -202,17 +202,6 @@ void Test::startTestsEvaluation(const QString& testFolder, const QString& branch
|
|||
return;
|
||||
}
|
||||
|
||||
// Before any processing - all images are converted to PNGs, as this is the format stored on GitHub
|
||||
QStringList sortedSnapshotFilenames = createListOfAll_imagesInDirectory("jpg", snapshotDirectory);
|
||||
foreach(QString filename, sortedSnapshotFilenames) {
|
||||
QString filenameWithoutExtension = filename.left(filename.length() - 4);
|
||||
copyJPGtoPNG(snapshotDirectory + "/" + filenameWithoutExtension + ".jpg",
|
||||
snapshotDirectory + "/" + filenameWithoutExtension + ".png"
|
||||
);
|
||||
|
||||
QFile::remove(snapshotDirectory + "/" + filenameWithoutExtension + ".jpg");
|
||||
}
|
||||
|
||||
// Create two lists. The first is the test results, the second is the expected images
|
||||
// The expected images are represented as a URL to enable download from GitHub
|
||||
// Images that are in the wrong format are ignored.
|
||||
|
@ -513,13 +502,13 @@ void Test::createTests() {
|
|||
return;
|
||||
}
|
||||
|
||||
QStringList sortedImageFilenames = createListOfAll_imagesInDirectory("jpg", snapshotDirectory);
|
||||
QStringList sortedImageFilenames = createListOfAll_imagesInDirectory("png", snapshotDirectory);
|
||||
|
||||
int i = 1;
|
||||
const int maxImages = pow(10, NUM_DIGITS);
|
||||
foreach (QString currentFilename, sortedImageFilenames) {
|
||||
QString fullCurrentFilename = snapshotDirectory + "/" + currentFilename;
|
||||
if (isInSnapshotFilenameFormat("jpg", currentFilename)) {
|
||||
if (isInSnapshotFilenameFormat("png", currentFilename)) {
|
||||
if (i >= maxImages) {
|
||||
QMessageBox::critical(0, "Error", "More than " + QString::number(maxImages) + " images not supported");
|
||||
exit(-1);
|
||||
|
@ -543,9 +532,12 @@ void Test::createTests() {
|
|||
fullNewFileName += "/" + newFilename;
|
||||
|
||||
try {
|
||||
copyJPGtoPNG(fullCurrentFilename, fullNewFileName);
|
||||
if (QFile::exists(fullNewFileName)) {
|
||||
QFile::remove(fullNewFileName);
|
||||
}
|
||||
QFile::copy(fullCurrentFilename, fullNewFileName);
|
||||
} catch (...) {
|
||||
QMessageBox::critical(0, "Error", "Could not delete existing file: " + currentFilename + "\nTest creation aborted");
|
||||
QMessageBox::critical(0, "Error", "Could not copy file: " + fullCurrentFilename + " to " + fullNewFileName + "\n");
|
||||
exit(-1);
|
||||
}
|
||||
++i;
|
||||
|
@ -824,19 +816,6 @@ void Test::createTestsOutline() {
|
|||
QMessageBox::information(0, "Success", "Test outline file " + testsOutlineFilename + " has been created");
|
||||
}
|
||||
|
||||
void Test::copyJPGtoPNG(const QString& sourceJPGFullFilename, const QString& destinationPNGFullFilename) {
|
||||
QFile::remove(destinationPNGFullFilename);
|
||||
|
||||
QImageReader reader;
|
||||
reader.setFileName(sourceJPGFullFilename);
|
||||
|
||||
QImage image = reader.read();
|
||||
|
||||
QImageWriter writer;
|
||||
writer.setFileName(destinationPNGFullFilename);
|
||||
writer.write(image);
|
||||
}
|
||||
|
||||
QStringList Test::createListOfAll_imagesInDirectory(const QString& imageFormat, const QString& pathToImageDirectory) {
|
||||
imageDirectory = QDir(pathToImageDirectory);
|
||||
QStringList nameFilters;
|
||||
|
|
|
@ -69,14 +69,12 @@ public:
|
|||
QString getExpectedImageDestinationDirectory(const QString& filename);
|
||||
QString getExpectedImagePartialSourceDirectory(const QString& filename);
|
||||
|
||||
void copyJPGtoPNG(const QString& sourceJPGFullFilename, const QString& destinationPNGFullFilename);
|
||||
|
||||
private:
|
||||
const QString TEST_FILENAME { "test.js" };
|
||||
const QString TEST_RESULTS_FOLDER { "TestResults" };
|
||||
const QString TEST_RESULTS_FILENAME { "TestResults.txt" };
|
||||
|
||||
const double THRESHOLD{ 0.999 };
|
||||
const double THRESHOLD{ 0.96 };
|
||||
|
||||
QDir imageDirectory;
|
||||
|
||||
|
|
Loading…
Reference in a new issue