Commit 3525af5d authored by Agata Cacko's avatar Agata Cacko

Add tiff import/export color space tests

Before this commit there was no tests to check if tiff can be exported
and imported using a specific color space. This commit adds those tests.

It also changes the way filestest.h works to make sure there is no files
left afterwards.
parent bebb0d60
......@@ -29,6 +29,7 @@
#include "kisexiv2/kis_exiv2.h"
#include <sdk/tests/kistest.h>
#include <KoColorModelStandardIdsUtils.h>
#ifndef FILES_DATA_DIR
#error "FILES_DATA_DIR not set. A directory with the data used for testing the importing of files in krita"
......@@ -117,6 +118,65 @@ void KisTiffTest::testRoundTripRGBF16()
#endif
}
void KisTiffTest::testSaveTiffColorSpace(QString colorModel, QString colorDepth, QString colorProfile)
{
KoColorSpaceRegistry registry;
const KoColorSpace *space = KoColorSpaceRegistry::instance()->colorSpace(colorModel, colorDepth, colorProfile);
TestUtil::testExportToColorSpace(QString(FILES_DATA_DIR), TiffMimetype, space, ImportExportCodes::OK, true);
}
void KisTiffTest::testSaveTiffRgbaColorSpace()
{
QString profile = "sRGB-elle-V2-srgbtrc";
testSaveTiffColorSpace(RGBAColorModelID.id(), Integer8BitsColorDepthID.id(), profile);
profile = "sRGB-elle-V2-g10";
testSaveTiffColorSpace(RGBAColorModelID.id(), Integer16BitsColorDepthID.id(), profile);
testSaveTiffColorSpace(RGBAColorModelID.id(), Float16BitsColorDepthID.id(), profile);
testSaveTiffColorSpace(RGBAColorModelID.id(), Float32BitsColorDepthID.id(), profile);
}
void KisTiffTest::testSaveTiffGreyAColorSpace()
{
QString profile = "Gray-D50-elle-V2-srgbtrc";
testSaveTiffColorSpace(GrayAColorModelID.id(), Integer8BitsColorDepthID.id(), profile);
profile = "Gray-D50-elle-V2-g10";
testSaveTiffColorSpace(GrayAColorModelID.id(), Integer16BitsColorDepthID.id(), profile);
testSaveTiffColorSpace(GrayAColorModelID.id(), Float16BitsColorDepthID.id(), profile);
testSaveTiffColorSpace(GrayAColorModelID.id(), Float32BitsColorDepthID.id(), profile);
}
void KisTiffTest::testSaveTiffCmykColorSpace()
{
QString profile = "Chemical proof";
testSaveTiffColorSpace(CMYKAColorModelID.id(), Integer8BitsColorDepthID.id(), profile);
testSaveTiffColorSpace(CMYKAColorModelID.id(), Integer16BitsColorDepthID.id(), profile);
testSaveTiffColorSpace(CMYKAColorModelID.id(), Float32BitsColorDepthID.id(), profile);
}
void KisTiffTest::testSaveTiffLabColorSpace()
{
const QString profile = "Lab identity build-in";
testSaveTiffColorSpace(LABAColorModelID.id(), Integer8BitsColorDepthID.id(), profile);
testSaveTiffColorSpace(LABAColorModelID.id(), Integer16BitsColorDepthID.id(), profile);
testSaveTiffColorSpace(LABAColorModelID.id(), Float32BitsColorDepthID.id(), profile);
}
void KisTiffTest::testSaveTiffYCrCbAColorSpace()
{
/*
* There is no public/open profile for YCrCbA, so no way to test it...
*
const QString profile = "";
testSaveTiffColorSpace(YCbCrAColorModelID.id(), Integer8BitsColorDepthID.id(), profile);
testSaveTiffColorSpace(YCbCrAColorModelID.id(), Integer16BitsColorDepthID.id(), profile);
testSaveTiffColorSpace(YCbCrAColorModelID.id(), Float32BitsColorDepthID.id(), profile);
*/
}
void KisTiffTest::testImportFromWriteonly()
{
......
......@@ -28,6 +28,13 @@ private Q_SLOTS:
void testFiles();
void testRoundTripRGBF16();
void testSaveTiffColorSpace(QString colorModel, QString colorDepth, QString colorProfile);
void testSaveTiffRgbaColorSpace();
void testSaveTiffGreyAColorSpace();
void testSaveTiffCmykColorSpace();
void testSaveTiffLabColorSpace();
void testSaveTiffYCrCbAColorSpace();
void testImportFromWriteonly();
void testExportToReadonly();
void testImportIncorrectFormat();
......
......@@ -326,11 +326,17 @@ void testExportToColorSpace(const QString& _dirname, QString mimetype, const KoC
}
statusImport = manager.importDocument(colorspaceFilename, mimetype.toUtf8());
QVERIFY(statusImport == ImportExportCodes::OK);
if (*(doc->image()->colorSpace()) != *space) {
if (!(statusImport == ImportExportCodes::OK)) {
fail = true;
failMessage = "Incorrect status";
}
bool mismatch = (*(doc->image()->colorSpace()) != *space) || (doc->image()->colorSpace()->profile() != space->profile());
if (mismatch) {
qDebug() << "Document color space = " << (doc->image()->colorSpace())->id();
qDebug() << "Saved color space = " << space->id();
QVERIFY(*(doc->image()->colorSpace()) == *space);
fail = true;
failMessage = "Mismatch of color spaces";
}
if (!useDocumentExport && statusExport == ImportExportCodes::FileFormatIncorrect) {
......@@ -351,13 +357,15 @@ void testExportToColorSpace(const QString& _dirname, QString mimetype, const KoC
QFile::remove(colorspaceFilename);
if (fail) {
QFAIL(failMessage.toUtf8());
}
QVERIFY(statusExport.isOk());
if (!useDocumentExport) {
QVERIFY(statusExport == expected);
}
if (fail) {
QFAIL(failMessage.toUtf8());
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment