diff --git a/plugins/impex/brush/tests/KisBrushTest.cpp b/plugins/impex/brush/tests/KisBrushTest.cpp index ee0ae4036d..32877619f1 100644 --- a/plugins/impex/brush/tests/KisBrushTest.cpp +++ b/plugins/impex/brush/tests/KisBrushTest.cpp @@ -1,57 +1,57 @@ /* - * Copyright (C) 2007 Cyrille Berger + * Copyright (C) 2019 Agata Cacko * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "KisBrushTest.h" #include #include #include "filestest.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" #endif const QString BrushMimetype = "image/x-gimp-brush"; void KisBrushTest::testImportFromWriteonly() { TestUtil::testImportFromWriteonly(QString(FILES_DATA_DIR), BrushMimetype); } void KisBrushTest::testExportToReadonly() { TestUtil::testExportToReadonly(QString(FILES_DATA_DIR), BrushMimetype); } void KisBrushTest::testImportIncorrectFormat() { TestUtil::testImportIncorrectFormat(QString(FILES_DATA_DIR), BrushMimetype); } KISTEST_MAIN(KisBrushTest) diff --git a/plugins/impex/gif/CMakeLists.txt b/plugins/impex/gif/CMakeLists.txt index 31ad0a488d..bb7f582b6c 100644 --- a/plugins/impex/gif/CMakeLists.txt +++ b/plugins/impex/gif/CMakeLists.txt @@ -1,26 +1,28 @@ +add_subdirectory(tests) + set(kritagifexport_SOURCES kis_gif_export.cpp qgiflibhandler.cpp ) ki18n_wrap_ui(kritagifexport_SOURCES ) add_library(kritagifexport MODULE ${kritagifexport_SOURCES}) target_link_libraries(kritagifexport kritaui kritaimpex ${GIF_LIBRARY}) install(TARGETS kritagifexport DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) set(kritagifimport_SOURCES kis_gif_import.cpp qgiflibhandler.cpp ) ki18n_wrap_ui(kritagifimport_SOURCES ) add_library(kritagifimport MODULE ${kritagifimport_SOURCES}) target_link_libraries(kritagifimport kritaui ${GIF_LIBRARY}) install(TARGETS kritagifimport DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) install( PROGRAMS krita_gif.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) diff --git a/plugins/impex/gif/tests/CMakeLists.txt b/plugins/impex/gif/tests/CMakeLists.txt new file mode 100644 index 0000000000..a58fb5b17f --- /dev/null +++ b/plugins/impex/gif/tests/CMakeLists.txt @@ -0,0 +1,11 @@ +set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} ) +include_directories( ${CMAKE_SOURCE_DIR}/sdk/tests ) + +include(KritaAddBrokenUnitTest) + +macro_add_unittest_definitions() + +ecm_add_test(KisGifTest.cpp + TEST_NAME KisGifTest + LINK_LIBRARIES kritaui Qt5::Test + NAME_PREFIX "plugins-impex-") diff --git a/plugins/impex/brush/tests/KisBrushTest.cpp b/plugins/impex/gif/tests/KisGifTest.cpp similarity index 68% copy from plugins/impex/brush/tests/KisBrushTest.cpp copy to plugins/impex/gif/tests/KisGifTest.cpp index ee0ae4036d..5c87288247 100644 --- a/plugins/impex/brush/tests/KisBrushTest.cpp +++ b/plugins/impex/gif/tests/KisGifTest.cpp @@ -1,57 +1,57 @@ /* - * Copyright (C) 2007 Cyrille Berger + * Copyright (C) 2019 Agata Cacko * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "KisBrushTest.h" +#include "KisGifTest.h" #include #include #include "filestest.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" #endif -const QString BrushMimetype = "image/x-gimp-brush"; +const QString GifMimetype = "image/gif"; -void KisBrushTest::testImportFromWriteonly() +void KisGifTest::testImportFromWriteonly() { - TestUtil::testImportFromWriteonly(QString(FILES_DATA_DIR), BrushMimetype); + TestUtil::testImportFromWriteonly(QString(FILES_DATA_DIR), GifMimetype); } -void KisBrushTest::testExportToReadonly() +void KisGifTest::testExportToReadonly() { - TestUtil::testExportToReadonly(QString(FILES_DATA_DIR), BrushMimetype); + TestUtil::testExportToReadonly(QString(FILES_DATA_DIR), GifMimetype); } -void KisBrushTest::testImportIncorrectFormat() +void KisGifTest::testImportIncorrectFormat() { - TestUtil::testImportIncorrectFormat(QString(FILES_DATA_DIR), BrushMimetype); + TestUtil::testImportIncorrectFormat(QString(FILES_DATA_DIR), GifMimetype); } -KISTEST_MAIN(KisBrushTest) +KISTEST_MAIN(KisGifTest) diff --git a/plugins/impex/libkra/tests/kis_kra_loader_test.h b/plugins/impex/gif/tests/KisGifTest.h similarity index 71% copy from plugins/impex/libkra/tests/kis_kra_loader_test.h copy to plugins/impex/gif/tests/KisGifTest.h index 88da2d5448..a65c46bead 100644 --- a/plugins/impex/libkra/tests/kis_kra_loader_test.h +++ b/plugins/impex/gif/tests/KisGifTest.h @@ -1,37 +1,35 @@ /* - * Copyright (c) 2007 Boudewijn Rempt boud@valdyas.org + * Copyright (C) 2019 Agata Cacko * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef KIS_KRA_LOADER_TEST_H -#define KIS_KRA_LOADER_TEST_H +#ifndef _KIS_GIF_TEST_H_ +#define _KIS_GIF_TEST_H_ #include -class KisKraLoaderTest : public QObject +class KisGifTest : public QObject { Q_OBJECT private Q_SLOTS: - void initTestCase(); - void testLoading(); - void testObligeSingleChild(); - void testObligeSingleChildNonTranspPixel(); - - void testLoadAnimated(); + void testImportFromWriteonly(); + void testExportToReadonly(); + void testImportIncorrectFormat(); }; -#endif +#endif // _KIS_BRUSH_TEST_H_ + diff --git a/plugins/impex/gif/tests/data/incorrectFormatFile.txt b/plugins/impex/gif/tests/data/incorrectFormatFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/gif/tests/data/readonlyFile.txt b/plugins/impex/gif/tests/data/readonlyFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/gif/tests/data/writeonlyFile.txt b/plugins/impex/gif/tests/data/writeonlyFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/heif/CMakeLists.txt b/plugins/impex/heif/CMakeLists.txt index 725e7afed3..d25f3e1704 100644 --- a/plugins/impex/heif/CMakeLists.txt +++ b/plugins/impex/heif/CMakeLists.txt @@ -1,31 +1,33 @@ +add_subdirectory(tests) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${HEIF_CFLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${HEIF_CFLAGS}") add_definitions(${HEIF_DEFINITIONS}) set(kritaheifimport_SOURCES HeifImport.cpp HeifError.cpp ) add_library(kritaheifimport MODULE ${kritaheifimport_SOURCES}) target_link_libraries(kritaheifimport kritaui kritalibkra ${HEIF_LDFLAGS} ${HEIF_LIBRARIES} ) install(TARGETS kritaheifimport DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) set(kritaheifexport_SOURCES HeifExport.cpp HeifError.cpp ) ki18n_wrap_ui(kritaheifexport_SOURCES WdgHeifExport.ui ) add_library(kritaheifexport MODULE ${kritaheifexport_SOURCES}) target_link_libraries(kritaheifexport kritaui kritalibkra kritaimpex ${HEIF_LDFLAGS} ${HEIF_LIBRARIES} ) install(TARGETS kritaheifexport DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) install( PROGRAMS krita_heif.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) diff --git a/plugins/impex/heif/tests/CMakeLists.txt b/plugins/impex/heif/tests/CMakeLists.txt new file mode 100644 index 0000000000..0f9cfe6c94 --- /dev/null +++ b/plugins/impex/heif/tests/CMakeLists.txt @@ -0,0 +1,11 @@ +set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} ) +include_directories( ${CMAKE_SOURCE_DIR}/sdk/tests ) + +include(KritaAddBrokenUnitTest) + +macro_add_unittest_definitions() + +ecm_add_test(KisHeifTest.cpp + TEST_NAME KisHeifTest + LINK_LIBRARIES kritaui Qt5::Test + NAME_PREFIX "plugins-impex-") diff --git a/plugins/impex/brush/tests/KisBrushTest.cpp b/plugins/impex/heif/tests/KisHeifTest.cpp similarity index 68% copy from plugins/impex/brush/tests/KisBrushTest.cpp copy to plugins/impex/heif/tests/KisHeifTest.cpp index ee0ae4036d..7b95b42ec7 100644 --- a/plugins/impex/brush/tests/KisBrushTest.cpp +++ b/plugins/impex/heif/tests/KisHeifTest.cpp @@ -1,57 +1,57 @@ /* - * Copyright (C) 2007 Cyrille Berger + * Copyright (C) 2019 Agata Cacko * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "KisBrushTest.h" +#include "KisHeifTest.h" #include #include #include "filestest.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" #endif -const QString BrushMimetype = "image/x-gimp-brush"; +const QString HeifMimetype = "image/heic"; -void KisBrushTest::testImportFromWriteonly() +void KisHeifTest::testImportFromWriteonly() { - TestUtil::testImportFromWriteonly(QString(FILES_DATA_DIR), BrushMimetype); + TestUtil::testImportFromWriteonly(QString(FILES_DATA_DIR), HeifMimetype); } -void KisBrushTest::testExportToReadonly() +void KisHeifTest::testExportToReadonly() { - TestUtil::testExportToReadonly(QString(FILES_DATA_DIR), BrushMimetype); + TestUtil::testExportToReadonly(QString(FILES_DATA_DIR), HeifMimetype); } -void KisBrushTest::testImportIncorrectFormat() +void KisHeifTest::testImportIncorrectFormat() { - TestUtil::testImportIncorrectFormat(QString(FILES_DATA_DIR), BrushMimetype); + TestUtil::testImportIncorrectFormat(QString(FILES_DATA_DIR), HeifMimetype); } -KISTEST_MAIN(KisBrushTest) +KISTEST_MAIN(KisHeifTest) diff --git a/plugins/impex/libkra/tests/kis_kra_loader_test.h b/plugins/impex/heif/tests/KisHeifTest.h similarity index 71% copy from plugins/impex/libkra/tests/kis_kra_loader_test.h copy to plugins/impex/heif/tests/KisHeifTest.h index 88da2d5448..ea09c9a836 100644 --- a/plugins/impex/libkra/tests/kis_kra_loader_test.h +++ b/plugins/impex/heif/tests/KisHeifTest.h @@ -1,37 +1,35 @@ /* - * Copyright (c) 2007 Boudewijn Rempt boud@valdyas.org + * Copyright (C) 2019 Agata Cacko * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef KIS_KRA_LOADER_TEST_H -#define KIS_KRA_LOADER_TEST_H +#ifndef _KIS_HEIF_TEST_H_ +#define _KIS_HEIF_TEST_H_ #include -class KisKraLoaderTest : public QObject +class KisHeifTest : public QObject { Q_OBJECT private Q_SLOTS: - void initTestCase(); - void testLoading(); - void testObligeSingleChild(); - void testObligeSingleChildNonTranspPixel(); - - void testLoadAnimated(); + void testImportFromWriteonly(); + void testExportToReadonly(); + void testImportIncorrectFormat(); }; -#endif +#endif // _KIS_HEIF_TEST_H_ + diff --git a/plugins/impex/heif/tests/data/incorrectFormatFile.txt b/plugins/impex/heif/tests/data/incorrectFormatFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/heif/tests/data/readonlyFile.txt b/plugins/impex/heif/tests/data/readonlyFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/heif/tests/data/writeonlyFile.txt b/plugins/impex/heif/tests/data/writeonlyFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/libkra/tests/data/incorrectFormatFile.txt b/plugins/impex/libkra/tests/data/incorrectFormatFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/libkra/tests/data/readonlyFile.txt b/plugins/impex/libkra/tests/data/readonlyFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/libkra/tests/data/writeonlyFile.txt b/plugins/impex/libkra/tests/data/writeonlyFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/libkra/tests/kis_kra_loader_test.cpp b/plugins/impex/libkra/tests/kis_kra_loader_test.cpp index 10350d829c..500295dcd7 100644 --- a/plugins/impex/libkra/tests/kis_kra_loader_test.cpp +++ b/plugins/impex/libkra/tests/kis_kra_loader_test.cpp @@ -1,173 +1,192 @@ /* * Copyright (c) 2007 Boudewijn Rempt boud@valdyas.org * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kis_kra_loader_test.h" #include #include #include #include #include #include #include "kis_image.h" #include "testutil.h" #include "KisPart.h" #include #include #include "kis_image_animation_interface.h" #include "kis_keyframe_channel.h" #include "kis_time_range.h" +#include + #include + +const QString KraMimetype = "application/x-krita"; + void KisKraLoaderTest::initTestCase() { KisFilterRegistry::instance(); KisGeneratorRegistry::instance(); } void KisKraLoaderTest::testLoading() { QScopedPointer doc(KisPart::instance()->createDocument()); doc->loadNativeFormat(QString(FILES_DATA_DIR) + QDir::separator() + "load_test.kra"); KisImageSP image = doc->image(); image->lock(); QCOMPARE(image->nlayers(), 12); QCOMPARE(doc->documentInfo()->aboutInfo("title"), QString("test image for loading")); QCOMPARE(image->height(), 753); QCOMPARE(image->width(), 1000); QCOMPARE(image->colorSpace()->id(), KoColorSpaceRegistry::instance()->rgb8()->id()); KisNodeSP node = image->root()->firstChild(); QVERIFY(node); QCOMPARE(node->name(), QString("Background")); QVERIFY(node->inherits("KisPaintLayer")); node = node->nextSibling(); QVERIFY(node); QCOMPARE(node->name(), QString("Group 1")); QVERIFY(node->inherits("KisGroupLayer")); QCOMPARE((int) node->childCount(), 2); } void testObligeSingleChildImpl(bool transpDefaultPixel) { QString id = !transpDefaultPixel ? "single_layer_no_channel_flags_nontransp_def_pixel.kra" : "single_layer_no_channel_flags_transp_def_pixel.kra"; QString fileName = TestUtil::fetchDataFileLazy(id); QScopedPointer doc(KisPart::instance()->createDocument()); const bool result = doc->loadNativeFormat(fileName); QVERIFY(result); KisImageSP image = doc->image(); QVERIFY(image); QCOMPARE(image->nlayers(), 2); KisNodeSP root = image->root(); KisNodeSP child = root->firstChild(); QVERIFY(child); QCOMPARE(root->original(), root->projection()); if (transpDefaultPixel) { QCOMPARE(root->original(), child->projection()); } else { QVERIFY(root->original() != child->projection()); } } void KisKraLoaderTest::testObligeSingleChild() { testObligeSingleChildImpl(true); } void KisKraLoaderTest::testObligeSingleChildNonTranspPixel() { testObligeSingleChildImpl(false); } void KisKraLoaderTest::testLoadAnimated() { QScopedPointer doc(KisPart::instance()->createDocument()); doc->loadNativeFormat(QString(FILES_DATA_DIR) + QDir::separator() + "load_test_animation.kra"); KisImageSP image = doc->image(); KisNodeSP node1 = image->root()->firstChild(); KisNodeSP node2 = node1->nextSibling(); QVERIFY(node1->inherits("KisPaintLayer")); QVERIFY(node2->inherits("KisPaintLayer")); KisPaintLayerSP layer1 = qobject_cast(node1.data()); KisPaintLayerSP layer2 = qobject_cast(node2.data()); QVERIFY(layer1->isAnimated()); QVERIFY(!layer2->isAnimated()); KisKeyframeChannel *channel1 = layer1->getKeyframeChannel(KisKeyframeChannel::Content.id()); QVERIFY(channel1); QCOMPARE(channel1->keyframeCount(), 3); QCOMPARE(image->animationInterface()->framerate(), 17); QCOMPARE(image->animationInterface()->fullClipRange(), KisTimeRange::fromTime(15, 45)); QCOMPARE(image->animationInterface()->currentTime(), 19); KisPaintDeviceSP dev = layer1->paintDevice(); const KoColorSpace *cs = dev->colorSpace(); KoColor transparent(Qt::transparent, cs); KoColor white(Qt::white, cs); KoColor red(Qt::red, cs); image->animationInterface()->switchCurrentTimeAsync(0); image->waitForDone(); QCOMPARE(dev->exactBounds(), QRect(506, 378, 198, 198)); QCOMPARE(dev->x(), -26); QCOMPARE(dev->y(), -128); QCOMPARE(dev->defaultPixel(), transparent); image->animationInterface()->switchCurrentTimeAsync(20); image->waitForDone(); QCOMPARE(dev->nonDefaultPixelArea(), QRect(615, 416, 129, 129)); QCOMPARE(dev->x(), 502); QCOMPARE(dev->y(), 224); QCOMPARE(dev->defaultPixel(), white); image->animationInterface()->switchCurrentTimeAsync(30); image->waitForDone(); QCOMPARE(dev->nonDefaultPixelArea(), QRect(729, 452, 45, 44)); QCOMPARE(dev->x(), 645); QCOMPARE(dev->y(), -10); QCOMPARE(dev->defaultPixel(), red); } + +void KisKraLoaderTest::testImportFromWriteonly() +{ + TestUtil::testImportFromWriteonly(QString(FILES_DATA_DIR), KraMimetype); +} + + +void KisKraLoaderTest::testImportIncorrectFormat() +{ + TestUtil::testImportIncorrectFormat(QString(FILES_DATA_DIR), KraMimetype); +} + + + KISTEST_MAIN(KisKraLoaderTest) diff --git a/plugins/impex/libkra/tests/kis_kra_loader_test.h b/plugins/impex/libkra/tests/kis_kra_loader_test.h index 88da2d5448..99a1caf0a4 100644 --- a/plugins/impex/libkra/tests/kis_kra_loader_test.h +++ b/plugins/impex/libkra/tests/kis_kra_loader_test.h @@ -1,37 +1,42 @@ /* * Copyright (c) 2007 Boudewijn Rempt boud@valdyas.org * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KIS_KRA_LOADER_TEST_H #define KIS_KRA_LOADER_TEST_H #include class KisKraLoaderTest : public QObject { Q_OBJECT private Q_SLOTS: void initTestCase(); void testLoading(); void testObligeSingleChild(); void testObligeSingleChildNonTranspPixel(); void testLoadAnimated(); + + void testImportFromWriteonly(); + void testImportIncorrectFormat(); + + }; #endif diff --git a/plugins/impex/libkra/tests/kis_kra_saver_test.cpp b/plugins/impex/libkra/tests/kis_kra_saver_test.cpp index bd7fbfb1ee..e9afb6f14c 100644 --- a/plugins/impex/libkra/tests/kis_kra_saver_test.cpp +++ b/plugins/impex/libkra/tests/kis_kra_saver_test.cpp @@ -1,543 +1,552 @@ /* * Copyright (c) 2007 Boudewijn Rempt boud@valdyas.org * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kis_kra_saver_test.h" #include #include #include #include #include #include #include "filter/kis_filter_registry.h" #include "filter/kis_filter_configuration.h" #include "filter/kis_filter.h" #include "kis_image.h" #include "kis_pixel_selection.h" #include "kis_group_layer.h" #include "kis_paint_layer.h" #include "kis_clone_layer.h" #include "kis_adjustment_layer.h" #include "kis_shape_layer.h" #include "kis_filter_mask.h" #include "kis_transparency_mask.h" #include "kis_selection_mask.h" #include "kis_selection.h" #include "kis_fill_painter.h" #include "kis_shape_selection.h" #include "util.h" #include "testutil.h" #include "kis_keyframe_channel.h" #include "kis_image_animation_interface.h" #include "kis_layer_properties_icons.h" #include "kis_transform_mask_params_interface.h" #include #include #include +#include + +const QString KraMimetype = "application/x-krita"; void KisKraSaverTest::initTestCase() { KoResourcePaths::addResourceDir("ko_patterns", QString(SYSTEM_RESOURCES_DATA_DIR) + "/patterns"); KisFilterRegistry::instance(); KisGeneratorRegistry::instance(); } void KisKraSaverTest::testCrashyShapeLayer() { /** * KisShapeLayer used to call setImage from its destructor and * therefore causing an infinite recursion (when at least one transparency * mask was preset. This testcase just checks that. */ //QScopedPointer doc(createCompleteDocument(true)); //Q_UNUSED(doc); } void KisKraSaverTest::testRoundTrip() { KisDocument* doc = createCompleteDocument(); KoColor bgColor(Qt::red, doc->image()->colorSpace()); doc->image()->setDefaultProjectionColor(bgColor); doc->exportDocumentSync(QUrl::fromLocalFile("roundtriptest.kra"), doc->mimeType()); QStringList list; KisCountVisitor cv1(list, KoProperties()); doc->image()->rootLayer()->accept(cv1); KisDocument *doc2 = KisPart::instance()->createDocument(); bool result = doc2->loadNativeFormat("roundtriptest.kra"); QVERIFY(result); KisCountVisitor cv2(list, KoProperties()); doc2->image()->rootLayer()->accept(cv2); QCOMPARE(cv1.count(), cv2.count()); // check whether the BG color is saved correctly QCOMPARE(doc2->image()->defaultProjectionColor(), bgColor); // test round trip of a transform mask KisNode* tnode = TestUtil::findNode(doc2->image()->rootLayer(), "testTransformMask").data(); QVERIFY(tnode); KisTransformMask *tmask = dynamic_cast(tnode); QVERIFY(tmask); KisDumbTransformMaskParams *params = dynamic_cast(tmask->transformParams().data()); QVERIFY(params); QTransform t = params->testingGetTransform(); QCOMPARE(t, createTestingTransform()); delete doc2; delete doc; } void KisKraSaverTest::testSaveEmpty() { KisDocument* doc = createEmptyDocument(); doc->exportDocumentSync(QUrl::fromLocalFile("emptytest.kra"), doc->mimeType()); QStringList list; KisCountVisitor cv1(list, KoProperties()); doc->image()->rootLayer()->accept(cv1); KisDocument *doc2 = KisPart::instance()->createDocument(); doc2->loadNativeFormat("emptytest.kra"); KisCountVisitor cv2(list, KoProperties()); doc2->image()->rootLayer()->accept(cv2); QCOMPARE(cv1.count(), cv2.count()); delete doc2; delete doc; } #include void testRoundTripFillLayerImpl(const QString &testName, KisFilterConfigurationSP config) { TestUtil::ReferenceImageChecker chk(testName, "fill_layer"); chk.setFuzzy(2); QScopedPointer doc(KisPart::instance()->createDocument()); // mask parent should be destructed before the document! QRect refRect(0,0,512,512); TestUtil::MaskParent p(refRect); doc->setCurrentImage(p.image); doc->documentInfo()->setAboutInfo("title", p.image->objectName()); KisSelectionSP selection; KisGeneratorLayerSP glayer = new KisGeneratorLayer(p.image, "glayer", config, selection); p.image->addNode(glayer, p.image->root(), KisNodeSP()); glayer->setDirty(); p.image->waitForDone(); chk.checkImage(p.image, "00_initial_layer_update"); doc->exportDocumentSync(QUrl::fromLocalFile("roundtrip_fill_layer_test.kra"), doc->mimeType()); QScopedPointer doc2(KisPart::instance()->createDocument()); doc2->loadNativeFormat("roundtrip_fill_layer_test.kra"); doc2->image()->waitForDone(); chk.checkImage(doc2->image(), "01_fill_layer_round_trip"); QVERIFY(chk.testPassed()); } void KisKraSaverTest::testRoundTripFillLayerColor() { const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8(); KisGeneratorSP generator = KisGeneratorRegistry::instance()->get("color"); Q_ASSERT(generator); // warning: we pass null paint device to the default constructed value KisFilterConfigurationSP config = generator->factoryConfiguration(); Q_ASSERT(config); QVariant v; v.setValue(KoColor(Qt::red, cs)); config->setProperty("color", v); testRoundTripFillLayerImpl("fill_layer_color", config); } void KisKraSaverTest::testRoundTripFillLayerPattern() { KisGeneratorSP generator = KisGeneratorRegistry::instance()->get("pattern"); QVERIFY(generator); // warning: we pass null paint device to the default constructed value KisFilterConfigurationSP config = generator->factoryConfiguration(); QVERIFY(config); QVariant v; v.setValue(QString("11_drawed_furry.png")); config->setProperty("pattern", v); testRoundTripFillLayerImpl("fill_layer_pattern", config); } #include "kis_psd_layer_style.h" void KisKraSaverTest::testRoundTripLayerStyles() { TestUtil::ReferenceImageChecker chk("kra_saver_test", "layer_styles"); QRect imageRect(0,0,512,512); // the document should be created before the image! QScopedPointer doc(KisPart::instance()->createDocument()); const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8(); KisImageSP image = new KisImage(new KisSurrogateUndoStore(), imageRect.width(), imageRect.height(), cs, "test image"); KisPaintLayerSP layer1 = new KisPaintLayer(image, "paint1", OPACITY_OPAQUE_U8); KisPaintLayerSP layer2 = new KisPaintLayer(image, "paint2", OPACITY_OPAQUE_U8); KisPaintLayerSP layer3 = new KisPaintLayer(image, "paint3", OPACITY_OPAQUE_U8); image->addNode(layer1); image->addNode(layer2); image->addNode(layer3); doc->setCurrentImage(image); doc->documentInfo()->setAboutInfo("title", image->objectName()); layer1->paintDevice()->fill(QRect(100, 100, 100, 100), KoColor(Qt::red, cs)); layer2->paintDevice()->fill(QRect(200, 200, 100, 100), KoColor(Qt::green, cs)); layer3->paintDevice()->fill(QRect(300, 300, 100, 100), KoColor(Qt::blue, cs)); KisPSDLayerStyleSP style(new KisPSDLayerStyle()); style->dropShadow()->setEffectEnabled(true); style->dropShadow()->setAngle(-90); style->dropShadow()->setUseGlobalLight(false); layer1->setLayerStyle(style->clone()); style->dropShadow()->setAngle(180); style->dropShadow()->setUseGlobalLight(true); layer2->setLayerStyle(style->clone()); style->dropShadow()->setAngle(90); style->dropShadow()->setUseGlobalLight(false); layer3->setLayerStyle(style->clone()); image->initialRefreshGraph(); chk.checkImage(image, "00_initial_layers"); doc->exportDocumentSync(QUrl::fromLocalFile("roundtrip_layer_styles.kra"), doc->mimeType()); QScopedPointer doc2(KisPart::instance()->createDocument()); doc2->loadNativeFormat("roundtrip_layer_styles.kra"); doc2->image()->waitForDone(); chk.checkImage(doc2->image(), "00_initial_layers"); QVERIFY(chk.testPassed()); } void KisKraSaverTest::testRoundTripAnimation() { QScopedPointer doc(KisPart::instance()->createDocument()); QRect imageRect(0,0,512,512); const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8(); KisImageSP image = new KisImage(new KisSurrogateUndoStore(), imageRect.width(), imageRect.height(), cs, "test image"); KisPaintLayerSP layer1 = new KisPaintLayer(image, "paint1", OPACITY_OPAQUE_U8); image->addNode(layer1); layer1->paintDevice()->fill(QRect(100, 100, 50, 50), KoColor(Qt::black, cs)); layer1->paintDevice()->setDefaultPixel(KoColor(Qt::red, cs)); KUndo2Command parentCommand; layer1->enableAnimation(); KisKeyframeChannel *rasterChannel = layer1->getKeyframeChannel(KisKeyframeChannel::Content.id(), true); QVERIFY(rasterChannel); rasterChannel->addKeyframe(10, &parentCommand); image->animationInterface()->switchCurrentTimeAsync(10); image->waitForDone(); layer1->paintDevice()->fill(QRect(200, 50, 10, 10), KoColor(Qt::black, cs)); layer1->paintDevice()->moveTo(25, 15); layer1->paintDevice()->setDefaultPixel(KoColor(Qt::green, cs)); rasterChannel->addKeyframe(20, &parentCommand); image->animationInterface()->switchCurrentTimeAsync(20); image->waitForDone(); layer1->paintDevice()->fill(QRect(150, 200, 30, 30), KoColor(Qt::black, cs)); layer1->paintDevice()->moveTo(100, 50); layer1->paintDevice()->setDefaultPixel(KoColor(Qt::blue, cs)); QVERIFY(!layer1->useInTimeline()); layer1->setUseInTimeline(true); doc->setCurrentImage(image); doc->exportDocumentSync(QUrl::fromLocalFile("roundtrip_animation.kra"), doc->mimeType()); QScopedPointer doc2(KisPart::instance()->createDocument()); doc2->loadNativeFormat("roundtrip_animation.kra"); KisImageSP image2 = doc2->image(); KisNodeSP node = image2->root()->firstChild(); QVERIFY(node->inherits("KisPaintLayer")); KisPaintLayerSP layer2 = qobject_cast(node.data()); cs = layer2->paintDevice()->colorSpace(); QCOMPARE(image2->animationInterface()->currentTime(), 20); KisKeyframeChannel *channel = layer2->getKeyframeChannel(KisKeyframeChannel::Content.id()); QVERIFY(channel); QCOMPARE(channel->keyframeCount(), 3); image2->animationInterface()->switchCurrentTimeAsync(0); image2->waitForDone(); QCOMPARE(layer2->paintDevice()->nonDefaultPixelArea(), QRect(64, 64, 128, 128)); QCOMPARE(layer2->paintDevice()->x(), 0); QCOMPARE(layer2->paintDevice()->y(), 0); QCOMPARE(layer2->paintDevice()->defaultPixel(), KoColor(Qt::red, cs)); image2->animationInterface()->switchCurrentTimeAsync(10); image2->waitForDone(); QCOMPARE(layer2->paintDevice()->nonDefaultPixelArea(), QRect(217, 15, 64, 64)); QCOMPARE(layer2->paintDevice()->x(), 25); QCOMPARE(layer2->paintDevice()->y(), 15); QCOMPARE(layer2->paintDevice()->defaultPixel(), KoColor(Qt::green, cs)); image2->animationInterface()->switchCurrentTimeAsync(20); image2->waitForDone(); QCOMPARE(layer2->paintDevice()->nonDefaultPixelArea(), QRect(228, 242, 64, 64)); QCOMPARE(layer2->paintDevice()->x(), 100); QCOMPARE(layer2->paintDevice()->y(), 50); QCOMPARE(layer2->paintDevice()->defaultPixel(), KoColor(Qt::blue, cs)); QVERIFY(layer2->useInTimeline()); } #include "lazybrush/kis_lazy_fill_tools.h" void KisKraSaverTest::testRoundTripColorizeMask() { QRect imageRect(0,0,512,512); const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8(); const KoColorSpace * weirdCS = KoColorSpaceRegistry::instance()->rgb16(); QScopedPointer doc(KisPart::instance()->createDocument()); KisImageSP image = new KisImage(new KisSurrogateUndoStore(), imageRect.width(), imageRect.height(), cs, "test image"); doc->setCurrentImage(image); KisPaintLayerSP layer1 = new KisPaintLayer(image, "paint1", OPACITY_OPAQUE_U8, weirdCS); image->addNode(layer1); KisColorizeMaskSP mask = new KisColorizeMask(); image->addNode(mask, layer1); mask->initializeCompositeOp(); delete mask->setColorSpace(layer1->colorSpace()); { KisPaintDeviceSP key1 = new KisPaintDevice(KoColorSpaceRegistry::instance()->alpha8()); key1->fill(QRect(50,50,10,20), KoColor(Qt::black, key1->colorSpace())); mask->testingAddKeyStroke(key1, KoColor(Qt::green, layer1->colorSpace())); // KIS_DUMP_DEVICE_2(key1, refRect, "key1", "dd"); } { KisPaintDeviceSP key2 = new KisPaintDevice(KoColorSpaceRegistry::instance()->alpha8()); key2->fill(QRect(150,50,10,20), KoColor(Qt::black, key2->colorSpace())); mask->testingAddKeyStroke(key2, KoColor(Qt::red, layer1->colorSpace())); // KIS_DUMP_DEVICE_2(key2, refRect, "key2", "dd"); } { KisPaintDeviceSP key3 = new KisPaintDevice(KoColorSpaceRegistry::instance()->alpha8()); key3->fill(QRect(0,0,10,10), KoColor(Qt::black, key3->colorSpace())); mask->testingAddKeyStroke(key3, KoColor(Qt::blue, layer1->colorSpace()), true); // KIS_DUMP_DEVICE_2(key3, refRect, "key3", "dd"); } KisLayerPropertiesIcons::setNodeProperty(mask, KisLayerPropertiesIcons::colorizeEditKeyStrokes, false, image); KisLayerPropertiesIcons::setNodeProperty(mask, KisLayerPropertiesIcons::colorizeShowColoring, false, image); doc->exportDocumentSync(QUrl::fromLocalFile("roundtrip_colorize.kra"), doc->mimeType()); QScopedPointer doc2(KisPart::instance()->createDocument()); doc2->loadNativeFormat("roundtrip_colorize.kra"); KisImageSP image2 = doc2->image(); KisNodeSP node = image2->root()->firstChild()->firstChild(); KisColorizeMaskSP mask2 = dynamic_cast(node.data()); QVERIFY(mask2); QCOMPARE(mask2->compositeOpId(), mask->compositeOpId()); QCOMPARE(mask2->colorSpace(), mask->colorSpace()); QCOMPARE(KisLayerPropertiesIcons::nodeProperty(mask, KisLayerPropertiesIcons::colorizeEditKeyStrokes, true).toBool(), false); QCOMPARE(KisLayerPropertiesIcons::nodeProperty(mask, KisLayerPropertiesIcons::colorizeShowColoring, true).toBool(), false); QList strokes = mask->fetchKeyStrokesDirect(); qDebug() << ppVar(strokes.size()); QCOMPARE(strokes[0].dev->exactBounds(), QRect(50,50,10,20)); QCOMPARE(strokes[0].isTransparent, false); QCOMPARE(strokes[0].color.colorSpace(), weirdCS); QCOMPARE(strokes[1].dev->exactBounds(), QRect(150,50,10,20)); QCOMPARE(strokes[1].isTransparent, false); QCOMPARE(strokes[1].color.colorSpace(), weirdCS); QCOMPARE(strokes[2].dev->exactBounds(), QRect(0,0,10,10)); QCOMPARE(strokes[2].isTransparent, true); QCOMPARE(strokes[2].color.colorSpace(), weirdCS); } #include void KisKraSaverTest::testRoundTripShapeLayer() { TestUtil::ReferenceImageChecker chk("kra_saver_test", "shape_layer"); QRect refRect(0,0,512,512); QScopedPointer doc(KisPart::instance()->createDocument()); TestUtil::MaskParent p(refRect); const qreal resolution = 144.0 / 72.0; p.image->setResolution(resolution, resolution); doc->setCurrentImage(p.image); doc->documentInfo()->setAboutInfo("title", p.image->objectName()); KoPathShape* path = new KoPathShape(); path->setShapeId(KoPathShapeId); path->moveTo(QPointF(10, 10)); path->lineTo(QPointF( 10, 110)); path->lineTo(QPointF(110, 110)); path->lineTo(QPointF(110, 10)); path->close(); path->normalize(); path->setBackground(toQShared(new KoColorBackground(Qt::red))); path->setName("my_precious_shape"); KisShapeLayerSP shapeLayer = new KisShapeLayer(doc->shapeController(), p.image, "shapeLayer1", 75); shapeLayer->addShape(path); p.image->addNode(shapeLayer); shapeLayer->setDirty(); qApp->processEvents(); p.image->waitForDone(); chk.checkImage(p.image, "00_initial_layer_update"); doc->exportDocumentSync(QUrl::fromLocalFile("roundtrip_shapelayer_test.kra"), doc->mimeType()); QScopedPointer doc2(KisPart::instance()->createDocument()); doc2->loadNativeFormat("roundtrip_shapelayer_test.kra"); qApp->processEvents(); doc2->image()->waitForDone(); QCOMPARE(doc2->image()->xRes(), resolution); QCOMPARE(doc2->image()->yRes(), resolution); chk.checkImage(doc2->image(), "01_shape_layer_round_trip"); QVERIFY(chk.testPassed()); } void KisKraSaverTest::testRoundTripShapeSelection() { TestUtil::ReferenceImageChecker chk("kra_saver_test", "shape_selection"); QRect refRect(0,0,512,512); QScopedPointer doc(KisPart::instance()->createDocument()); TestUtil::MaskParent p(refRect); doc->setCurrentImage(p.image); const qreal resolution = 144.0 / 72.0; p.image->setResolution(resolution, resolution); doc->setCurrentImage(p.image); doc->documentInfo()->setAboutInfo("title", p.image->objectName()); p.layer->paintDevice()->setDefaultPixel(KoColor(Qt::green, p.layer->colorSpace())); KisSelectionSP selection = new KisSelection(p.layer->paintDevice()->defaultBounds()); KisShapeSelection *shapeSelection = new KisShapeSelection(doc->shapeController(), p.image, selection); selection->setShapeSelection(shapeSelection); KoPathShape* path = new KoPathShape(); path->setShapeId(KoPathShapeId); path->moveTo(QPointF(10, 10)); path->lineTo(QPointF( 10, 110)); path->lineTo(QPointF(110, 110)); path->lineTo(QPointF(110, 10)); path->close(); path->normalize(); path->setBackground(toQShared(new KoColorBackground(Qt::red))); path->setName("my_precious_shape"); shapeSelection->addShape(path); KisTransparencyMaskSP tmask = new KisTransparencyMask(); tmask->setSelection(selection); p.image->addNode(tmask, p.layer); tmask->setDirty(p.image->bounds()); qApp->processEvents(); p.image->waitForDone(); chk.checkImage(p.image, "00_initial_shape_selection"); doc->exportDocumentSync(QUrl::fromLocalFile("roundtrip_shapeselection_test.kra"), doc->mimeType()); QScopedPointer doc2(KisPart::instance()->createDocument()); doc2->loadNativeFormat("roundtrip_shapeselection_test.kra"); qApp->processEvents(); doc2->image()->waitForDone(); QCOMPARE(doc2->image()->xRes(), resolution); QCOMPARE(doc2->image()->yRes(), resolution); chk.checkImage(doc2->image(), "00_initial_shape_selection"); KisNodeSP node = doc2->image()->root()->firstChild()->firstChild(); KisTransparencyMask *newMask = dynamic_cast(node.data()); QVERIFY(newMask); QVERIFY(newMask->selection()->hasShapeSelection()); QVERIFY(chk.testPassed()); } + +void KisKraSaverTest::testExportToReadonly() +{ + TestUtil::testExportToReadonly(QString(FILES_DATA_DIR), KraMimetype); +} + KISTEST_MAIN(KisKraSaverTest) diff --git a/plugins/impex/libkra/tests/kis_kra_saver_test.h b/plugins/impex/libkra/tests/kis_kra_saver_test.h index 04ff99c8d5..4a6c1310bb 100644 --- a/plugins/impex/libkra/tests/kis_kra_saver_test.h +++ b/plugins/impex/libkra/tests/kis_kra_saver_test.h @@ -1,51 +1,53 @@ /* * Copyright (c) 2007 Boudewijn Rempt boud@valdyas.org * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KIS_KRA_SAVER_TEST_H #define KIS_KRA_SAVER_TEST_H #include class KisKraSaverTest : public QObject { Q_OBJECT private Q_SLOTS: void initTestCase(); void testCrashyShapeLayer(); // XXX: Also test roundtripping of metadata void testRoundTrip(); void testSaveEmpty(); void testRoundTripFillLayerColor(); void testRoundTripFillLayerPattern(); void testRoundTripLayerStyles(); void testRoundTripAnimation(); void testRoundTripColorizeMask(); void testRoundTripShapeLayer(); void testRoundTripShapeSelection(); + void testExportToReadonly(); + }; #endif diff --git a/plugins/impex/ora/CMakeLists.txt b/plugins/impex/ora/CMakeLists.txt index 6cedf854e4..a476f422b4 100644 --- a/plugins/impex/ora/CMakeLists.txt +++ b/plugins/impex/ora/CMakeLists.txt @@ -1,32 +1,34 @@ +add_subdirectory(tests) + set(libkritaconverter_LIB_SRCS ora_converter.cpp kis_open_raster_load_context.cpp kis_open_raster_save_context.cpp kis_open_raster_stack_load_visitor.cpp kis_open_raster_stack_save_visitor.cpp ) set(kritaoraimport_SOURCES ora_import.cc ${libkritaconverter_LIB_SRCS} ) add_library(kritaoraimport MODULE ${kritaoraimport_SOURCES}) target_link_libraries(kritaoraimport kritaui ) install(TARGETS kritaoraimport DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) set(kritaoraexport_SOURCES ora_export.cc ${libkritaconverter_LIB_SRCS} ) add_library(kritaoraexport MODULE ${kritaoraexport_SOURCES}) target_link_libraries(kritaoraexport kritaui kritaimpex) install(TARGETS kritaoraexport DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) install( PROGRAMS krita_ora.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) diff --git a/plugins/impex/ora/tests/CMakeLists.txt b/plugins/impex/ora/tests/CMakeLists.txt new file mode 100644 index 0000000000..40a1fd500f --- /dev/null +++ b/plugins/impex/ora/tests/CMakeLists.txt @@ -0,0 +1,11 @@ +set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} ) +include_directories( ${CMAKE_SOURCE_DIR}/sdk/tests ) + +include(KritaAddBrokenUnitTest) + +macro_add_unittest_definitions() + +ecm_add_test(KisOraTest.cpp + TEST_NAME KisOraTest + LINK_LIBRARIES kritaui Qt5::Test + NAME_PREFIX "plugins-impex-") diff --git a/plugins/impex/brush/tests/KisBrushTest.cpp b/plugins/impex/ora/tests/KisOraTest.cpp similarity index 68% copy from plugins/impex/brush/tests/KisBrushTest.cpp copy to plugins/impex/ora/tests/KisOraTest.cpp index ee0ae4036d..39931639a0 100644 --- a/plugins/impex/brush/tests/KisBrushTest.cpp +++ b/plugins/impex/ora/tests/KisOraTest.cpp @@ -1,57 +1,57 @@ /* - * Copyright (C) 2007 Cyrille Berger + * Copyright (C) 2019 Agata Cacko * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "KisBrushTest.h" +#include "KisOraTest.h" #include #include #include "filestest.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" #endif -const QString BrushMimetype = "image/x-gimp-brush"; +const QString OraMimetype = "image/openraster"; -void KisBrushTest::testImportFromWriteonly() +void KisOraTest::testImportFromWriteonly() { - TestUtil::testImportFromWriteonly(QString(FILES_DATA_DIR), BrushMimetype); + TestUtil::testImportFromWriteonly(QString(FILES_DATA_DIR), OraMimetype); } -void KisBrushTest::testExportToReadonly() +void KisOraTest::testExportToReadonly() { - TestUtil::testExportToReadonly(QString(FILES_DATA_DIR), BrushMimetype); + TestUtil::testExportToReadonly(QString(FILES_DATA_DIR), OraMimetype); } -void KisBrushTest::testImportIncorrectFormat() +void KisOraTest::testImportIncorrectFormat() { - TestUtil::testImportIncorrectFormat(QString(FILES_DATA_DIR), BrushMimetype); + TestUtil::testImportIncorrectFormat(QString(FILES_DATA_DIR), OraMimetype); } -KISTEST_MAIN(KisBrushTest) +KISTEST_MAIN(KisOraTest) diff --git a/plugins/impex/libkra/tests/kis_kra_loader_test.h b/plugins/impex/ora/tests/KisOraTest.h similarity index 71% copy from plugins/impex/libkra/tests/kis_kra_loader_test.h copy to plugins/impex/ora/tests/KisOraTest.h index 88da2d5448..a044b20b25 100644 --- a/plugins/impex/libkra/tests/kis_kra_loader_test.h +++ b/plugins/impex/ora/tests/KisOraTest.h @@ -1,37 +1,35 @@ /* - * Copyright (c) 2007 Boudewijn Rempt boud@valdyas.org + * Copyright (C) 2019 Agata Cacko * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef KIS_KRA_LOADER_TEST_H -#define KIS_KRA_LOADER_TEST_H +#ifndef _KIS_ORA_TEST_H_ +#define _KIS_ORA_TEST_H_ #include -class KisKraLoaderTest : public QObject +class KisOraTest : public QObject { Q_OBJECT private Q_SLOTS: - void initTestCase(); - void testLoading(); - void testObligeSingleChild(); - void testObligeSingleChildNonTranspPixel(); - - void testLoadAnimated(); + void testImportFromWriteonly(); + void testExportToReadonly(); + void testImportIncorrectFormat(); }; -#endif +#endif // _KIS_ORA_TEST_H_ + diff --git a/plugins/impex/ora/tests/data/incorrectFormatFile.txt b/plugins/impex/ora/tests/data/incorrectFormatFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/ora/tests/data/readonlyFile.txt b/plugins/impex/ora/tests/data/readonlyFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/ora/tests/data/writeonlyFile.txt b/plugins/impex/ora/tests/data/writeonlyFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/pdf/CMakeLists.txt b/plugins/impex/pdf/CMakeLists.txt index d3ada35792..320da291a4 100644 --- a/plugins/impex/pdf/CMakeLists.txt +++ b/plugins/impex/pdf/CMakeLists.txt @@ -1,10 +1,12 @@ +add_subdirectory(tests) + set(kritapdfimport_SOURCES kis_pdf_import.cpp kis_pdf_import_widget.cpp ) ki18n_wrap_ui(kritapdfimport_SOURCES pdfimportwidgetbase.ui ) add_library(kritapdfimport MODULE ${kritapdfimport_SOURCES}) target_link_libraries(kritapdfimport kritaui Poppler::Qt5) install(TARGETS kritapdfimport DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) install(PROGRAMS krita_pdf.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) diff --git a/plugins/impex/pdf/tests/CMakeLists.txt b/plugins/impex/pdf/tests/CMakeLists.txt new file mode 100644 index 0000000000..19cb770163 --- /dev/null +++ b/plugins/impex/pdf/tests/CMakeLists.txt @@ -0,0 +1,11 @@ +set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} ) +include_directories( ${CMAKE_SOURCE_DIR}/sdk/tests ) + +include(KritaAddBrokenUnitTest) + +macro_add_unittest_definitions() + +ecm_add_test(KisPdfTest.cpp + TEST_NAME KisPdfTest + LINK_LIBRARIES kritaui Qt5::Test + NAME_PREFIX "plugins-impex-") diff --git a/plugins/impex/brush/tests/KisBrushTest.cpp b/plugins/impex/pdf/tests/KisPdfTest.cpp similarity index 68% copy from plugins/impex/brush/tests/KisBrushTest.cpp copy to plugins/impex/pdf/tests/KisPdfTest.cpp index ee0ae4036d..1f0dcec5ab 100644 --- a/plugins/impex/brush/tests/KisBrushTest.cpp +++ b/plugins/impex/pdf/tests/KisPdfTest.cpp @@ -1,57 +1,57 @@ /* - * Copyright (C) 2007 Cyrille Berger + * Copyright (C) 2019 Agata Cacko * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "KisBrushTest.h" +#include "KisPdfTest.h" #include #include #include "filestest.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" #endif -const QString BrushMimetype = "image/x-gimp-brush"; +const QString PdfMimetype = "image/x-gimp-brush"; -void KisBrushTest::testImportFromWriteonly() +void KisPdfTest::testImportFromWriteonly() { - TestUtil::testImportFromWriteonly(QString(FILES_DATA_DIR), BrushMimetype); + TestUtil::testImportFromWriteonly(QString(FILES_DATA_DIR), PdfMimetype); } -void KisBrushTest::testExportToReadonly() +void KisPdfTest::testExportToReadonly() { - TestUtil::testExportToReadonly(QString(FILES_DATA_DIR), BrushMimetype); + TestUtil::testExportToReadonly(QString(FILES_DATA_DIR), PdfMimetype); } -void KisBrushTest::testImportIncorrectFormat() +void KisPdfTest::testImportIncorrectFormat() { - TestUtil::testImportIncorrectFormat(QString(FILES_DATA_DIR), BrushMimetype); + TestUtil::testImportIncorrectFormat(QString(FILES_DATA_DIR), PdfMimetype); } -KISTEST_MAIN(KisBrushTest) +KISTEST_MAIN(KisPdfTest) diff --git a/plugins/impex/libkra/tests/kis_kra_loader_test.h b/plugins/impex/pdf/tests/KisPdfTest.h similarity index 71% copy from plugins/impex/libkra/tests/kis_kra_loader_test.h copy to plugins/impex/pdf/tests/KisPdfTest.h index 88da2d5448..a6d0203eed 100644 --- a/plugins/impex/libkra/tests/kis_kra_loader_test.h +++ b/plugins/impex/pdf/tests/KisPdfTest.h @@ -1,37 +1,35 @@ /* - * Copyright (c) 2007 Boudewijn Rempt boud@valdyas.org + * Copyright (C) 2019 Agata Cacko * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef KIS_KRA_LOADER_TEST_H -#define KIS_KRA_LOADER_TEST_H +#ifndef _KIS_PDF_TEST_H_ +#define _KIS_PDF_TEST_H_ #include -class KisKraLoaderTest : public QObject +class KisPdfTest : public QObject { Q_OBJECT private Q_SLOTS: - void initTestCase(); - void testLoading(); - void testObligeSingleChild(); - void testObligeSingleChildNonTranspPixel(); - - void testLoadAnimated(); + void testImportFromWriteonly(); + void testExportToReadonly(); + void testImportIncorrectFormat(); }; -#endif +#endif // _KIS_PDF_TEST_H_ + diff --git a/plugins/impex/pdf/tests/data/incorrectFormatFile.txt b/plugins/impex/pdf/tests/data/incorrectFormatFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/pdf/tests/data/readonlyFile.txt b/plugins/impex/pdf/tests/data/readonlyFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/pdf/tests/data/writeonlyFile.txt b/plugins/impex/pdf/tests/data/writeonlyFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/qimageio/CMakeLists.txt b/plugins/impex/qimageio/CMakeLists.txt index 1c4c9d8616..07221802c9 100644 --- a/plugins/impex/qimageio/CMakeLists.txt +++ b/plugins/impex/qimageio/CMakeLists.txt @@ -1,25 +1,27 @@ +add_subdirectory(tests) + set(kritaqimageioexport_SOURCES kis_qimageio_export.cpp ) ki18n_wrap_ui(kritaqimageioexport_SOURCES ) add_library(kritaqimageioexport MODULE ${kritaqimageioexport_SOURCES}) target_link_libraries(kritaqimageioexport kritaui kritaimpex) install(TARGETS kritaqimageioexport DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) set(kritaqimageioimport_SOURCES kis_qimageio_import.cpp ) ki18n_wrap_ui(kritaqimageioimport_SOURCES ) add_library(kritaqimageioimport MODULE ${kritaqimageioimport_SOURCES}) target_link_libraries(kritaqimageioimport kritaui) install(TARGETS kritaqimageioimport DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) install( PROGRAMS krita_qimageio.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) diff --git a/plugins/impex/qimageio/tests/CMakeLists.txt b/plugins/impex/qimageio/tests/CMakeLists.txt new file mode 100644 index 0000000000..bed630f553 --- /dev/null +++ b/plugins/impex/qimageio/tests/CMakeLists.txt @@ -0,0 +1,11 @@ +set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} ) +include_directories( ${CMAKE_SOURCE_DIR}/sdk/tests ) + +include(KritaAddBrokenUnitTest) + +macro_add_unittest_definitions() + +ecm_add_test(KisQImageIOTest.cpp + TEST_NAME KisQImageIOTest + LINK_LIBRARIES kritaui Qt5::Test + NAME_PREFIX "plugins-impex-") diff --git a/plugins/impex/brush/tests/KisBrushTest.cpp b/plugins/impex/qimageio/tests/KisQImageIOTest.cpp similarity index 67% copy from plugins/impex/brush/tests/KisBrushTest.cpp copy to plugins/impex/qimageio/tests/KisQImageIOTest.cpp index ee0ae4036d..65d4cb9ce2 100644 --- a/plugins/impex/brush/tests/KisBrushTest.cpp +++ b/plugins/impex/qimageio/tests/KisQImageIOTest.cpp @@ -1,57 +1,57 @@ /* - * Copyright (C) 2007 Cyrille Berger + * Copyright (C) 2019 Agata Cacko * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "KisBrushTest.h" +#include "KisQImageIOTest.h" #include #include #include "filestest.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" #endif -const QString BrushMimetype = "image/x-gimp-brush"; +const QString QImageIOMimetype = "image/x-gimp-brush"; -void KisBrushTest::testImportFromWriteonly() +void KisQImageIOTest::testImportFromWriteonly() { - TestUtil::testImportFromWriteonly(QString(FILES_DATA_DIR), BrushMimetype); + TestUtil::testImportFromWriteonly(QString(FILES_DATA_DIR), QImageIOMimetype); } -void KisBrushTest::testExportToReadonly() +void KisQImageIOTest::testExportToReadonly() { - TestUtil::testExportToReadonly(QString(FILES_DATA_DIR), BrushMimetype); + TestUtil::testExportToReadonly(QString(FILES_DATA_DIR), QImageIOMimetype); } -void KisBrushTest::testImportIncorrectFormat() +void KisQImageIOTest::testImportIncorrectFormat() { - TestUtil::testImportIncorrectFormat(QString(FILES_DATA_DIR), BrushMimetype); + TestUtil::testImportIncorrectFormat(QString(FILES_DATA_DIR), QImageIOMimetype); } -KISTEST_MAIN(KisBrushTest) +KISTEST_MAIN(KisQImageIOTest) diff --git a/plugins/impex/libkra/tests/kis_kra_loader_test.h b/plugins/impex/qimageio/tests/KisQImageIOTest.h similarity index 71% copy from plugins/impex/libkra/tests/kis_kra_loader_test.h copy to plugins/impex/qimageio/tests/KisQImageIOTest.h index 88da2d5448..ea154f3dbc 100644 --- a/plugins/impex/libkra/tests/kis_kra_loader_test.h +++ b/plugins/impex/qimageio/tests/KisQImageIOTest.h @@ -1,37 +1,35 @@ /* - * Copyright (c) 2007 Boudewijn Rempt boud@valdyas.org + * Copyright (C) 2019 Agata Cacko * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef KIS_KRA_LOADER_TEST_H -#define KIS_KRA_LOADER_TEST_H +#ifndef _KIS_QIMAGEIO_TEST_H_ +#define _KIS_QIMAGEIO_TEST_H_ #include -class KisKraLoaderTest : public QObject +class KisQImageIOTest : public QObject { Q_OBJECT private Q_SLOTS: - void initTestCase(); - void testLoading(); - void testObligeSingleChild(); - void testObligeSingleChildNonTranspPixel(); - - void testLoadAnimated(); + void testImportFromWriteonly(); + void testExportToReadonly(); + void testImportIncorrectFormat(); }; -#endif +#endif // _KIS_QIMAGEIO_TEST_H_ + diff --git a/plugins/impex/qimageio/tests/data/incorrectFormatFile.txt b/plugins/impex/qimageio/tests/data/incorrectFormatFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/qimageio/tests/data/readonlyFile.txt b/plugins/impex/qimageio/tests/data/readonlyFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/qimageio/tests/data/writeonlyFile.txt b/plugins/impex/qimageio/tests/data/writeonlyFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/qml/CMakeLists.txt b/plugins/impex/qml/CMakeLists.txt index 2f3826d5d1..e53156905a 100644 --- a/plugins/impex/qml/CMakeLists.txt +++ b/plugins/impex/qml/CMakeLists.txt @@ -1,10 +1,12 @@ +add_subdirectory(tests) + set(kritaqmlexport_SOURCES qml_converter.cc qml_export.cc ) add_library(kritaqmlexport MODULE ${kritaqmlexport_SOURCES}) target_link_libraries(kritaqmlexport kritaui kritaimpex) install(TARGETS kritaqmlexport DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) diff --git a/plugins/impex/qml/tests/CMakeLists.txt b/plugins/impex/qml/tests/CMakeLists.txt new file mode 100644 index 0000000000..d197d45935 --- /dev/null +++ b/plugins/impex/qml/tests/CMakeLists.txt @@ -0,0 +1,11 @@ +set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} ) +include_directories( ${CMAKE_SOURCE_DIR}/sdk/tests ) + +include(KritaAddBrokenUnitTest) + +macro_add_unittest_definitions() + +ecm_add_test(KisQmlTest.cpp + TEST_NAME KisQmlTest + LINK_LIBRARIES kritaui Qt5::Test + NAME_PREFIX "plugins-impex-") diff --git a/plugins/impex/brush/tests/KisBrushTest.cpp b/plugins/impex/qml/tests/KisQmlTest.cpp similarity index 63% copy from plugins/impex/brush/tests/KisBrushTest.cpp copy to plugins/impex/qml/tests/KisQmlTest.cpp index ee0ae4036d..c92533ae76 100644 --- a/plugins/impex/brush/tests/KisBrushTest.cpp +++ b/plugins/impex/qml/tests/KisQmlTest.cpp @@ -1,57 +1,43 @@ /* - * Copyright (C) 2007 Cyrille Berger + * Copyright (C) 2019 Agata Cacko * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "KisBrushTest.h" +#include "KisQmlTest.h" #include #include #include "filestest.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" #endif -const QString BrushMimetype = "image/x-gimp-brush"; +const QString QmlMimetype = "text/x-qml"; - -void KisBrushTest::testImportFromWriteonly() -{ - TestUtil::testImportFromWriteonly(QString(FILES_DATA_DIR), BrushMimetype); -} - - -void KisBrushTest::testExportToReadonly() +void KisQmlTest::testExportToReadonly() { - TestUtil::testExportToReadonly(QString(FILES_DATA_DIR), BrushMimetype); + TestUtil::testExportToReadonly(QString(FILES_DATA_DIR), QmlMimetype); } -void KisBrushTest::testImportIncorrectFormat() -{ - TestUtil::testImportIncorrectFormat(QString(FILES_DATA_DIR), BrushMimetype); -} - - - -KISTEST_MAIN(KisBrushTest) +KISTEST_MAIN(KisQmlTest) diff --git a/plugins/impex/libkra/tests/kis_kra_loader_test.h b/plugins/impex/qml/tests/KisQmlTest.h similarity index 71% copy from plugins/impex/libkra/tests/kis_kra_loader_test.h copy to plugins/impex/qml/tests/KisQmlTest.h index 88da2d5448..9944e9ca65 100644 --- a/plugins/impex/libkra/tests/kis_kra_loader_test.h +++ b/plugins/impex/qml/tests/KisQmlTest.h @@ -1,37 +1,33 @@ /* - * Copyright (c) 2007 Boudewijn Rempt boud@valdyas.org + * Copyright (C) 2019 Agata Cacko * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef KIS_KRA_LOADER_TEST_H -#define KIS_KRA_LOADER_TEST_H +#ifndef _KIS_QML_TEST_H_ +#define _KIS_QML_TEST_H_ #include -class KisKraLoaderTest : public QObject +class KisQmlTest : public QObject { Q_OBJECT private Q_SLOTS: - void initTestCase(); - void testLoading(); - void testObligeSingleChild(); - void testObligeSingleChildNonTranspPixel(); - - void testLoadAnimated(); + void testExportToReadonly(); }; -#endif +#endif // _KIS_QML_TEST_H_ + diff --git a/plugins/impex/qml/tests/data/readonlyFile.txt b/plugins/impex/qml/tests/data/readonlyFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/raw/CMakeLists.txt b/plugins/impex/raw/CMakeLists.txt index f03ae6dd5c..f7b63c845c 100644 --- a/plugins/impex/raw/CMakeLists.txt +++ b/plugins/impex/raw/CMakeLists.txt @@ -1,33 +1,35 @@ +add_subdirectory(tests) + if(OPENEXR_FOUND) include_directories(${OPENEXR_INCLUDE_DIR}) endif() include_directories(${LibRaw_INCLUDE_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/libkdcraw/src) set(krita_raw_import_SOURCES kis_raw_import.cpp 3rdparty/libkdcraw/src/dcrawinfocontainer.cpp 3rdparty/libkdcraw/src/dcrawsettingswidget.cpp 3rdparty/libkdcraw/src/kdcraw.cpp 3rdparty/libkdcraw/src/kdcraw_p.cpp 3rdparty/libkdcraw/src/libkdcraw_debug.cpp 3rdparty/libkdcraw/src/ractionjob.cpp 3rdparty/libkdcraw/src/ractionthreadbase.cpp 3rdparty/libkdcraw/src/rawdecodingsettings.cpp 3rdparty/libkdcraw/src/rcombobox.cpp 3rdparty/libkdcraw/src/rexpanderbox.cpp 3rdparty/libkdcraw/src/rnuminput.cpp 3rdparty/libkdcraw/src/rsliderspinbox.cpp 3rdparty/libkdcraw/src/rwidgetutils.cpp 3rdparty/libkdcraw/src/squeezedcombobox.cpp ) ki18n_wrap_ui(krita_raw_import_SOURCES wdgrawimport.ui ) add_library(krita_raw_import MODULE ${krita_raw_import_SOURCES}) target_link_libraries(krita_raw_import kritaui ${LibRaw_LIBRARIES}) install(TARGETS krita_raw_import DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) install( PROGRAMS krita_raw.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) diff --git a/plugins/impex/raw/tests/CMakeLists.txt b/plugins/impex/raw/tests/CMakeLists.txt new file mode 100644 index 0000000000..9057477638 --- /dev/null +++ b/plugins/impex/raw/tests/CMakeLists.txt @@ -0,0 +1,11 @@ +set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} ) +include_directories( ${CMAKE_SOURCE_DIR}/sdk/tests ) + +include(KritaAddBrokenUnitTest) + +macro_add_unittest_definitions() + +ecm_add_test(KisRawTest.cpp + TEST_NAME KisRawTest + LINK_LIBRARIES kritaui Qt5::Test + NAME_PREFIX "plugins-impex-") diff --git a/plugins/impex/brush/tests/KisBrushTest.cpp b/plugins/impex/raw/tests/KisRawTest.cpp similarity index 68% copy from plugins/impex/brush/tests/KisBrushTest.cpp copy to plugins/impex/raw/tests/KisRawTest.cpp index ee0ae4036d..3799f9a608 100644 --- a/plugins/impex/brush/tests/KisBrushTest.cpp +++ b/plugins/impex/raw/tests/KisRawTest.cpp @@ -1,57 +1,57 @@ /* - * Copyright (C) 2007 Cyrille Berger + * Copyright (C) 2019 Agata Cacko * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "KisBrushTest.h" +#include "KisRawTest.h" #include #include #include "filestest.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" #endif -const QString BrushMimetype = "image/x-gimp-brush"; +const QString RawMimetype = "image/x-krita-raw"; -void KisBrushTest::testImportFromWriteonly() +void KisRawTest::testImportFromWriteonly() { - TestUtil::testImportFromWriteonly(QString(FILES_DATA_DIR), BrushMimetype); + TestUtil::testImportFromWriteonly(QString(FILES_DATA_DIR), RawMimetype); } -void KisBrushTest::testExportToReadonly() +void KisRawTest::testExportToReadonly() { - TestUtil::testExportToReadonly(QString(FILES_DATA_DIR), BrushMimetype); + TestUtil::testExportToReadonly(QString(FILES_DATA_DIR), RawMimetype); } -void KisBrushTest::testImportIncorrectFormat() +void KisRawTest::testImportIncorrectFormat() { - TestUtil::testImportIncorrectFormat(QString(FILES_DATA_DIR), BrushMimetype); + TestUtil::testImportIncorrectFormat(QString(FILES_DATA_DIR), RawMimetype); } -KISTEST_MAIN(KisBrushTest) +KISTEST_MAIN(KisRawTest) diff --git a/plugins/impex/libkra/tests/kis_kra_loader_test.h b/plugins/impex/raw/tests/KisRawTest.h similarity index 71% copy from plugins/impex/libkra/tests/kis_kra_loader_test.h copy to plugins/impex/raw/tests/KisRawTest.h index 88da2d5448..37ba6e20cb 100644 --- a/plugins/impex/libkra/tests/kis_kra_loader_test.h +++ b/plugins/impex/raw/tests/KisRawTest.h @@ -1,37 +1,35 @@ /* - * Copyright (c) 2007 Boudewijn Rempt boud@valdyas.org + * Copyright (C) 2019 Agata Cacko * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef KIS_KRA_LOADER_TEST_H -#define KIS_KRA_LOADER_TEST_H +#ifndef _KIS_RAW_TEST_H_ +#define _KIS_RAW_TEST_H_ #include -class KisKraLoaderTest : public QObject +class KisRawTest : public QObject { Q_OBJECT private Q_SLOTS: - void initTestCase(); - void testLoading(); - void testObligeSingleChild(); - void testObligeSingleChildNonTranspPixel(); - - void testLoadAnimated(); + void testImportFromWriteonly(); + void testExportToReadonly(); + void testImportIncorrectFormat(); }; -#endif +#endif // _KIS_RAW_TEST_H_ + diff --git a/plugins/impex/raw/tests/data/incorrectFormatFile.txt b/plugins/impex/raw/tests/data/incorrectFormatFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/raw/tests/data/readonlyFile.txt b/plugins/impex/raw/tests/data/readonlyFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/raw/tests/data/writeonlyFile.txt b/plugins/impex/raw/tests/data/writeonlyFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/tga/CMakeLists.txt b/plugins/impex/tga/CMakeLists.txt index a9546c3326..b7fe804897 100644 --- a/plugins/impex/tga/CMakeLists.txt +++ b/plugins/impex/tga/CMakeLists.txt @@ -1,24 +1,26 @@ +add_subdirectory(tests) + set(kritatgaexport_SOURCES kis_tga_export.cpp ) ki18n_wrap_ui(kritatgaexport_SOURCES ) add_library(kritatgaexport MODULE ${kritatgaexport_SOURCES}) target_link_libraries(kritatgaexport kritaui kritaimpex) install(TARGETS kritatgaexport DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) set(kritatgaimport_SOURCES kis_tga_import.cpp ) ki18n_wrap_ui(kritatgaimport_SOURCES ) add_library(kritatgaimport MODULE ${kritatgaimport_SOURCES}) target_link_libraries(kritatgaimport kritaui) install(TARGETS kritatgaimport DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) install( PROGRAMS krita_tga.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) diff --git a/plugins/impex/tga/tests/CMakeLists.txt b/plugins/impex/tga/tests/CMakeLists.txt new file mode 100644 index 0000000000..7180181703 --- /dev/null +++ b/plugins/impex/tga/tests/CMakeLists.txt @@ -0,0 +1,11 @@ +set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} ) +include_directories( ${CMAKE_SOURCE_DIR}/sdk/tests ) + +include(KritaAddBrokenUnitTest) + +macro_add_unittest_definitions() + +ecm_add_test(KisTgaTest.cpp + TEST_NAME KisTgaTest + LINK_LIBRARIES kritaui Qt5::Test + NAME_PREFIX "plugins-impex-") diff --git a/plugins/impex/brush/tests/KisBrushTest.cpp b/plugins/impex/tga/tests/KisTgaTest.cpp similarity index 68% copy from plugins/impex/brush/tests/KisBrushTest.cpp copy to plugins/impex/tga/tests/KisTgaTest.cpp index ee0ae4036d..b3b83d1c05 100644 --- a/plugins/impex/brush/tests/KisBrushTest.cpp +++ b/plugins/impex/tga/tests/KisTgaTest.cpp @@ -1,57 +1,57 @@ /* - * Copyright (C) 2007 Cyrille Berger + * Copyright (C) 2019 Agata Cacko * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "KisBrushTest.h" +#include "KisTgaTest.h" #include #include #include "filestest.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" #endif -const QString BrushMimetype = "image/x-gimp-brush"; +const QString TgaMimetype = "image/x-gimp-brush"; -void KisBrushTest::testImportFromWriteonly() +void KisTgaTest::testImportFromWriteonly() { - TestUtil::testImportFromWriteonly(QString(FILES_DATA_DIR), BrushMimetype); + TestUtil::testImportFromWriteonly(QString(FILES_DATA_DIR), TgaMimetype); } -void KisBrushTest::testExportToReadonly() +void KisTgaTest::testExportToReadonly() { - TestUtil::testExportToReadonly(QString(FILES_DATA_DIR), BrushMimetype); + TestUtil::testExportToReadonly(QString(FILES_DATA_DIR), TgaMimetype); } -void KisBrushTest::testImportIncorrectFormat() +void KisTgaTest::testImportIncorrectFormat() { - TestUtil::testImportIncorrectFormat(QString(FILES_DATA_DIR), BrushMimetype); + TestUtil::testImportIncorrectFormat(QString(FILES_DATA_DIR), TgaMimetype); } -KISTEST_MAIN(KisBrushTest) +KISTEST_MAIN(KisTgaTest) diff --git a/plugins/impex/libkra/tests/kis_kra_loader_test.h b/plugins/impex/tga/tests/KisTgaTest.h similarity index 71% copy from plugins/impex/libkra/tests/kis_kra_loader_test.h copy to plugins/impex/tga/tests/KisTgaTest.h index 88da2d5448..172bf40374 100644 --- a/plugins/impex/libkra/tests/kis_kra_loader_test.h +++ b/plugins/impex/tga/tests/KisTgaTest.h @@ -1,37 +1,35 @@ /* - * Copyright (c) 2007 Boudewijn Rempt boud@valdyas.org + * Copyright (C) 2019 Agata Cacko * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef KIS_KRA_LOADER_TEST_H -#define KIS_KRA_LOADER_TEST_H +#ifndef _KIS_TGA_TEST_H_ +#define _KIS_TGA_TEST_H_ #include -class KisKraLoaderTest : public QObject +class KisTgaTest : public QObject { Q_OBJECT private Q_SLOTS: - void initTestCase(); - void testLoading(); - void testObligeSingleChild(); - void testObligeSingleChildNonTranspPixel(); - - void testLoadAnimated(); + void testImportFromWriteonly(); + void testExportToReadonly(); + void testImportIncorrectFormat(); }; -#endif +#endif // _KIS_TGA_TEST_H_ + diff --git a/plugins/impex/tga/tests/data/incorrectFormatFile.txt b/plugins/impex/tga/tests/data/incorrectFormatFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/tga/tests/data/readonlyFile.txt b/plugins/impex/tga/tests/data/readonlyFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/tga/tests/data/writeonlyFile.txt b/plugins/impex/tga/tests/data/writeonlyFile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/impex/tiff/tests/data/writeonlyFile.txt b/plugins/impex/tiff/tests/data/writeonlyFile.txt new file mode 100644 index 0000000000..e69de29bb2