Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Add unittests for loading legacy PQ profile in PNG and TIFF
Dmitry Kazakovffb1bbc97372
diff --git a/plugins/impex/png/tests/data/test-png-with-legacy-hdr-profile.png b/plugins/impex/png/tests/data/test-png-with-legacy-hdr-profile.pngnew file mode 100644index 0000000000..54a27b5bebBinary files /dev/null and b/plugins/impex/png/tests/data/test-png-with-legacy-hdr-profile.png differdiff --git a/plugins/impex/png/tests/kis_png_test.cpp b/plugins/impex/png/tests/kis_png_test.cppindex b11041865e..9c0911f944 100644--- a/plugins/impex/png/tests/kis_png_test.cpp+++ b/plugins/impex/png/tests/kis_png_test.cpp@@ -214,5 +214,31 @@ void KisPngTest::testRoundtripCicpIccProfile()QVERIFY(image2->colorSpace()->profile()->getTransferCharacteristics() == transfer);}+void KisPngTest::testLoadPngWithLegacyProfile()+{+ const QString pngFilePath = TestUtil::fetchDataFileLazy("test-png-with-legacy-hdr-profile.png");+ KIS_ASSERT(QFile::exists(pngFilePath));++ QScopedPointer<KisDocument> doc(KisPart::instance()->createDocument());+ KisImportExportManager manager(doc.data());+ doc->setFileBatchMode(true);++ KisImportExportErrorCode loadingStatus =+ manager.importDocument(pngFilePath, QString());++ QVERIFY(loadingStatus.isOk());++ /**+ * A PNG with the legacy profile should use the default Krita profille+ * for a PQ space with all the cicp information set properly. The embedded+ * profile should be ignored.+ */+ const KoColorProfile *profile = doc->image()->colorSpace()->profile();++ QCOMPARE(profile->name(), KoColorSpaceRegistry::instance()->p2020PQProfile()->name());+ QCOMPARE(profile->getColorPrimaries(), PRIMARIES_ITU_R_BT_2020_2_AND_2100_0);+ QCOMPARE(profile->getTransferCharacteristics(), TRC_ITU_R_BT_2100_0_PQ);+}+KISTEST_MAIN(KisPngTest)diff --git a/plugins/impex/png/tests/kis_png_test.h b/plugins/impex/png/tests/kis_png_test.hindex 5d6fd934b6..b5da349c5c 100644--- a/plugins/impex/png/tests/kis_png_test.h+++ b/plugins/impex/png/tests/kis_png_test.h@@ -19,6 +19,8 @@ private Q_SLOTS:void testRoundtripCicpIccProfile_data();void testRoundtripCicpIccProfile();++ void testLoadPngWithLegacyProfile();};#endifdiff --git a/plugins/impex/tiff/tests/data/test-tiff-with-legacy-hdr-profile.tif b/plugins/impex/tiff/tests/data/test-tiff-with-legacy-hdr-profile.tifnew file mode 100644index 0000000000..b094f09438Binary files /dev/null and b/plugins/impex/tiff/tests/data/test-tiff-with-legacy-hdr-profile.tif differdiff --git a/plugins/impex/tiff/tests/kis_tiff_test.cpp b/plugins/impex/tiff/tests/kis_tiff_test.cppindex adb8d4c8ac..b263a97d84 100644--- a/plugins/impex/tiff/tests/kis_tiff_test.cpp+++ b/plugins/impex/tiff/tests/kis_tiff_test.cpp@@ -137,6 +137,31 @@ void KisTiffTest::testImportIncorrectFormat()TestUtil::testImportIncorrectFormat(TiffMimetype);}+void KisTiffTest::testLoadTiffWithLegacyPQProfile()+{+ const QString tiffFilePath = TestUtil::fetchDataFileLazy("test-tiff-with-legacy-hdr-profile.tif");+ KIS_ASSERT(QFile::exists(tiffFilePath));++ QScopedPointer<KisDocument> doc(KisPart::instance()->createDocument());+ KisImportExportManager manager(doc.data());+ doc->setFileBatchMode(true);++ KisImportExportErrorCode loadingStatus =+ manager.importDocument(tiffFilePath, QString());++ QVERIFY(loadingStatus.isOk());++ /**+ * A PNG with the legacy profile should use the default Krita profille+ * for a PQ space with all the cicp information set properly. The embedded+ * profile should be ignored.+ */+ const KoColorProfile *profile = doc->image()->colorSpace()->profile();++ QCOMPARE(profile->name(), KoColorSpaceRegistry::instance()->p2020PQProfile()->name());+ QCOMPARE(profile->getColorPrimaries(), PRIMARIES_ITU_R_BT_2020_2_AND_2100_0);+ QCOMPARE(profile->getTransferCharacteristics(), TRC_ITU_R_BT_2100_0_PQ);+}KISTEST_MAIN(KisTiffTest)diff --git a/plugins/impex/tiff/tests/kis_tiff_test.h b/plugins/impex/tiff/tests/kis_tiff_test.hindex 8d468c3465..f70f200c6c 100644--- a/plugins/impex/tiff/tests/kis_tiff_test.h+++ b/plugins/impex/tiff/tests/kis_tiff_test.h@@ -25,6 +25,8 @@ private Q_SLOTS:void testImportFromWriteonly();void testExportToReadonly();void testImportIncorrectFormat();++ void testLoadTiffWithLegacyPQProfile();};#endif