Skip to content

armgit / krita

Public Imported from GitHub
0

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++

WebP: add export unittest on several color profiles

Rasyuqa A. H.0f00a0ffc423
diff --git a/plugins/impex/webp/tests/kis_webp_test.cpp b/plugins/impex/webp/tests/kis_webp_test.cpp
index 820a82f6e2..f5fcd6b1c5 100644
--- a/plugins/impex/webp/tests/kis_webp_test.cpp
+++ b/plugins/impex/webp/tests/kis_webp_test.cpp
@@ -113,6 +113,35 @@ void KisWebPTest::testAnimationWithTail()
QCOMPARE(image->animationInterface()->currentTime(), 0);
}
+inline void testSaveColorSpace(const QString &colorModel, const QString &colorDepth, const QString &colorProfile)
+{
+ const KoColorSpace *space = KoColorSpaceRegistry::instance()->colorSpace(colorModel, colorDepth, colorProfile);
+ if (space) {
+ TestUtil::testExportToColorSpace(MIMETYPE, space, ImportExportCodes::OK);
+ }
+}
+
+void KisWebPTest::testSaveRgbaColorSpace()
+{
+ QString profile = "sRGB-elle-V2-srgbtrc";
+ testSaveColorSpace(RGBAColorModelID.id(), Integer8BitsColorDepthID.id(), profile);
+}
+
+void KisWebPTest::testSaveUnsupportedColorSpace()
+{
+ // Non-RGBA color model will trigger color conversion and dithering path on WebP exports,
+ // therefore it's sufficient to only test for U8 depths.
+
+ QString profile = "Gray-D50-elle-V2-srgbtrc";
+ testSaveColorSpace(GrayAColorModelID.id(), Integer8BitsColorDepthID.id(), profile);
+
+ profile = "Chemical proof";
+ testSaveColorSpace(CMYKAColorModelID.id(), Integer8BitsColorDepthID.id(), profile);
+
+ profile = "Lab identity built-in";
+ testSaveColorSpace(LABAColorModelID.id(), Integer8BitsColorDepthID.id(), profile);
+}
+
#ifndef _WIN32
void KisWebPTest::testImportFromWriteonly()
{
diff --git a/plugins/impex/webp/tests/kis_webp_test.h b/plugins/impex/webp/tests/kis_webp_test.h
index 9cad99f0dd..796bac5275 100644
--- a/plugins/impex/webp/tests/kis_webp_test.h
+++ b/plugins/impex/webp/tests/kis_webp_test.h
@@ -16,6 +16,8 @@ class KisWebPTest : public QObject
private Q_SLOTS:
void testAnimation();
void testAnimationWithTail();
+ void testSaveRgbaColorSpace();
+ void testSaveUnsupportedColorSpace();
void testFiles();
void testImportIncorrectFormat();