[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [calligra/calligra/2.9] krita/plugins/formats/psd/tests: Added two unittests for checking loading an
From: Dmitry Kazakov <dimula73 () gmail ! com>
Date: 2015-08-13 17:15:20
Message-ID: E1ZPw64-0001eb-LK () scm ! kde ! org
[Download RAW message or body]
Git commit 67e8669c39123c4e9e7b43f02041c3221b66b209 by Dmitry Kazakov.
Committed on 13/08/2015 at 15:46.
Pushed by dkazakov into branch 'calligra/2.9'.
Added two unittests for checking loading and saving PSD files
The testing files themselves are stored in external unittests data
folder.
See
https://community.kde.org/Krita/Docs/Unittests_in_Krita
M +87 -0 krita/plugins/formats/psd/tests/kis_psd_test.cpp
M +2 -0 krita/plugins/formats/psd/tests/kis_psd_test.h
http://commits.kde.org/calligra/67e8669c39123c4e9e7b43f02041c3221b66b209
diff --git a/krita/plugins/formats/psd/tests/kis_psd_test.cpp \
b/krita/plugins/formats/psd/tests/kis_psd_test.cpp index d22cf85..58e0717 100644
--- a/krita/plugins/formats/psd/tests/kis_psd_test.cpp
+++ b/krita/plugins/formats/psd/tests/kis_psd_test.cpp
@@ -247,6 +247,93 @@ void KisPSDTest::testOpeningFromOpenCanvas()
QVERIFY(doc->image()->root()->firstChild());
}
+void KisPSDTest::testOpeningAllFormats()
+{
+ QDir dirSources(QString(FILES_DATA_DIR) + QDir::separator() + "format_set/");
+
+ foreach(QFileInfo sourceFileInfo, dirSources.entryInfoList()) {
+ Q_ASSERT(sourceFileInfo.exists());
+
+ if (sourceFileInfo.isHidden() || sourceFileInfo.isDir()) {
+ continue;
+ }
+
+ if (sourceFileInfo.fileName() != "sl_cmyk_8b.psd") {
+ continue;
+ }
+
+ //qDebug() << "Opening" << ppVar(sourceFileInfo.fileName());
+
+ QSharedPointer<KisDocument> doc = openPsdDocument(sourceFileInfo);
+
+ if (!doc->image()) {
+ qCritical() << "FAILED to open" << sourceFileInfo.fileName();
+ continue;
+ }
+
+ // just check visually if the file loads fine
+ KIS_DUMP_DEVICE_2(doc->image()->projection(), QRect(0,0,100,100), \
sourceFileInfo.fileName(), "dd"); + }
+}
+
+void KisPSDTest::testSavingAllFormats()
+{
+ QString path = TestUtil::fetchExternalDataFileName("psd_format_test_files");
+ QDir dirSources(path);
+
+ foreach(QFileInfo sourceFileInfo, dirSources.entryInfoList()) {
+ Q_ASSERT(sourceFileInfo.exists());
+
+ if (sourceFileInfo.isHidden() || sourceFileInfo.isDir()) {
+ continue;
+ }
+
+ if (sourceFileInfo.fileName() != "sl_rgb_8b.psd") {
+ //continue;
+ }
+
+ qDebug() << "Opening" << ppVar(sourceFileInfo.fileName());
+
+ QSharedPointer<KisDocument> doc = openPsdDocument(sourceFileInfo);
+
+ if (!doc->image()) {
+ qCritical() << "FAILED to open" << sourceFileInfo.fileName();
+ continue;
+ }
+
+ QString baseName = sourceFileInfo.fileName();
+
+ QString originalName = QString("%1_0orig").arg(baseName);
+ QString resultName = QString("%1_1result").arg(baseName);
+ QString tempPsdName = QString("%1_3interm.psd").arg(baseName);
+
+ QImage refImage = doc->image()->projection()->convertToQImage(0, \
QRect(0,0,100,100)); +
+ // uncomment to do a visual check
+ // KIS_DUMP_DEVICE_2(doc->image()->projection(), QRect(0,0,100,100), \
originalName, "dd"); +
+ doc->setBackupFile(false);
+ doc->setOutputMimeType("image/vnd.adobe.photoshop");
+ QFileInfo dstFileInfo(QDir::currentPath() + QDir::separator() + \
tempPsdName); +
+ qDebug() << "Saving" << ppVar(dstFileInfo.fileName());
+
+ bool retval = doc->saveAs(KUrl(dstFileInfo.absoluteFilePath()));
+ QVERIFY(retval);
+
+ {
+ QSharedPointer<KisDocument> doc = openPsdDocument(dstFileInfo);
+ QVERIFY(doc->image());
+
+ // uncomment to do a visual check
+ //KIS_DUMP_DEVICE_2(doc->image()->projection(), QRect(0,0,100,100), \
resultName, "dd"); +
+ QImage resultImage = doc->image()->projection()->convertToQImage(0, \
QRect(0,0,100,100)); + QCOMPARE(resultImage, refImage);
+ }
+ }
+}
+
QTEST_KDEMAIN(KisPSDTest, GUI)
diff --git a/krita/plugins/formats/psd/tests/kis_psd_test.h \
b/krita/plugins/formats/psd/tests/kis_psd_test.h index 9f010c9..c29d7bd 100644
--- a/krita/plugins/formats/psd/tests/kis_psd_test.h
+++ b/krita/plugins/formats/psd/tests/kis_psd_test.h
@@ -38,6 +38,8 @@ private Q_SLOTS:
void testSaveLayerStylesWithPatternMulti();
void testOpeningFromOpenCanvas();
+ void testOpeningAllFormats();
+ void testSavingAllFormats();
};
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic