diff --git a/libs/ui/tests/CMakeLists.txt b/libs/ui/tests/CMakeLists.txt index df77a02ec9..c6ed2dcc93 100644 --- a/libs/ui/tests/CMakeLists.txt +++ b/libs/ui/tests/CMakeLists.txt @@ -1,184 +1,189 @@ set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} ) #add_subdirectory(scratchpad) include_directories(${CMAKE_SOURCE_DIR}/libs/image/metadata ${CMAKE_SOURCE_DIR}/sdk/tests ) include(ECMAddTests) macro_add_unittest_definitions() ecm_add_tests( kis_image_view_converter_test.cpp kis_shape_selection_test.cpp kis_doc2_test.cpp kis_coordinates_converter_test.cpp kis_grid_config_test.cpp kis_stabilized_events_sampler_test.cpp kis_derived_resources_test.cpp kis_brush_hud_properties_config_test.cpp kis_shape_commands_test.cpp kis_shape_layer_test.cpp kis_stop_gradient_editor_test.cpp NAME_PREFIX "krita-ui-" LINK_LIBRARIES kritaui Qt5::Test ) ecm_add_tests( kis_file_layer_test.cpp kis_multinode_property_test.cpp NAME_PREFIX "krita-ui-" LINK_LIBRARIES kritaui kritaimage Qt5::Test ) ecm_add_test( KisFrameSerializerTest.cpp TEST_NAME krita-ui-KisFrameSerializerTest LINK_LIBRARIES kritaui kritaimage Qt5::Test) ecm_add_test( KisFrameCacheStoreTest.cpp TEST_NAME krita-ui-KisFrameCacheStoreTest LINK_LIBRARIES kritaui kritaimage Qt5::Test) ecm_add_test( kis_selection_decoration_test.cpp ../../../sdk/tests/stroke_testing_utils.cpp TEST_NAME krita-ui-KisSelectionDecorationTest LINK_LIBRARIES kritaui kritaimage Qt5::Test) ecm_add_test( kis_node_dummies_graph_test.cpp ../../../sdk/tests/testutil.cpp TEST_NAME krita-ui-KisNodeDummiesGraphTest LINK_LIBRARIES kritaui kritaimage Qt5::Test) ecm_add_test( kis_node_shapes_graph_test.cpp ../../../sdk/tests/testutil.cpp TEST_NAME krita-ui-KisNodeShapesGraphTest LINK_LIBRARIES kritaui kritaimage Qt5::Test) ecm_add_test( kis_model_index_converter_test.cpp ../../../sdk/tests/testutil.cpp TEST_NAME krita-ui-KisModelIndexConverterTest LINK_LIBRARIES kritaui kritaimage Qt5::Test) ecm_add_test( kis_categorized_list_model_test.cpp modeltest.cpp TEST_NAME krita-ui-KisCategorizedListModelTest LINK_LIBRARIES kritaui kritaimage Qt5::Test) ecm_add_test( kis_node_juggler_compressed_test.cpp ../../../sdk/tests/testutil.cpp TEST_NAME krita-image-BaseNodeTest LINK_LIBRARIES kritaimage kritaui Qt5::Test) ecm_add_test( kis_animation_exporter_test.cpp TEST_NAME kritaui-animation_exporter_test LINK_LIBRARIES kritaui kritaimage Qt5::Test) set(kis_node_view_test_SRCS kis_node_view_test.cpp ../../../sdk/tests/testutil.cpp) qt5_add_resources(kis_node_view_test_SRCS ${krita_QRCS}) ecm_add_test(${kis_node_view_test_SRCS} TEST_NAME krita-image-kis_node_view_test LINK_LIBRARIES kritaimage kritaui Qt5::Test) ##### Tests that currently fail and should be fixed ##### include(KritaAddBrokenUnitTest) krita_add_broken_unit_test( kis_node_model_test.cpp modeltest.cpp TEST_NAME krita-ui-kis_node_model_test LINK_LIBRARIES kritaui Qt5::Test) krita_add_broken_unit_test( kis_shape_controller_test.cpp kis_dummies_facade_base_test.cpp TEST_NAME krita-ui-kis_shape_controller_test LINK_LIBRARIES kritaimage kritaui Qt5::Test) krita_add_broken_unit_test( kis_prescaled_projection_test.cpp TEST_NAME krita-ui-kis_prescaled_projection_test LINK_LIBRARIES kritaui Qt5::Test) krita_add_broken_unit_test( kis_exiv2_test.cpp TEST_NAME krita-ui-KisExiv2Test LINK_LIBRARIES kritaimage kritaui Qt5::Test) krita_add_broken_unit_test( kis_clipboard_test.cpp TEST_NAME krita-ui-KisClipboardTest LINK_LIBRARIES kritaui kritaimage Qt5::Test) krita_add_broken_unit_test( freehand_stroke_test.cpp ${CMAKE_SOURCE_DIR}/sdk/tests/stroke_testing_utils.cpp TEST_NAME krita-ui-FreehandStrokeTest LINK_LIBRARIES kritaui kritaimage Qt5::Test) krita_add_broken_unit_test( FreehandStrokeBenchmark.cpp ${CMAKE_SOURCE_DIR}/sdk/tests/stroke_testing_utils.cpp TEST_NAME krita-ui-FreehandStrokeBenchmark LINK_LIBRARIES kritaui kritaimage Qt5::Test) +krita_add_broken_unit_test( + KisPaintOnTransparencyMaskTest.cpp ${CMAKE_SOURCE_DIR}/sdk/tests/stroke_testing_utils.cpp + TEST_NAME krita-ui-KisPaintOnTransparencyMaskTest + LINK_LIBRARIES kritaui kritaimage Qt5::Test) + krita_add_broken_unit_test( fill_processing_visitor_test.cpp ${CMAKE_SOURCE_DIR}/sdk/tests/stroke_testing_utils.cpp TEST_NAME krita-ui-FillProcessingVisitorTest LINK_LIBRARIES kritaui kritaimage Qt5::Test) krita_add_broken_unit_test( filter_stroke_test.cpp ../../../sdk/tests/stroke_testing_utils.cpp TEST_NAME krita-ui-FilterStrokeTest LINK_LIBRARIES kritaui kritaimage Qt5::Test) krita_add_broken_unit_test( kis_selection_manager_test.cpp TEST_NAME krita-ui-KisSelectionManagerTest LINK_LIBRARIES kritaui kritaimage Qt5::Test) #set_tests_properties(krita-ui-KisSelectionManagerTest PROPERTIES TIMEOUT 300) krita_add_broken_unit_test( kis_node_manager_test.cpp TEST_NAME krita-ui-KisNodeManagerTest LINK_LIBRARIES kritaui kritaimage Qt5::Test) krita_add_broken_unit_test( kis_dummies_facade_test.cpp kis_dummies_facade_base_test.cpp ../../../sdk/tests/testutil.cpp TEST_NAME krita-ui-KisDummiesFacadeTest LINK_LIBRARIES kritaui kritaimage Qt5::Test) krita_add_broken_unit_test( kis_zoom_and_pan_test.cpp ../../../sdk/tests/testutil.cpp TEST_NAME krita-ui-KisZoomAndPanTest LINK_LIBRARIES kritaui kritaimage Qt5::Test) #set_tests_properties(krita-ui-KisZoomAndPanTest PROPERTIES TIMEOUT 300) krita_add_broken_unit_test( kis_action_manager_test.cpp TEST_NAME krita-ui-KisActionManagerTest LINK_LIBRARIES kritaui kritaimage Qt5::Test) krita_add_broken_unit_test( kis_categories_mapper_test.cpp testing_categories_mapper.cpp TEST_NAME krita-ui-KisCategoriesMapperTest LINK_LIBRARIES kritaui kritaimage Qt5::Test) krita_add_broken_unit_test( kis_asl_layer_style_serializer_test.cpp TEST_NAME krita-ui-KisAslLayerStyleSerializerTest LINK_LIBRARIES kritaui kritaimage Qt5::Test) krita_add_broken_unit_test( kis_animation_importer_test.cpp TEST_NAME kritaui-animation_importer_test LINK_LIBRARIES kritaui kritaimage Qt5::Test) krita_add_broken_unit_test( kis_animation_frame_cache_test.cpp TEST_NAME kritaui-animation_frame_cache_test LINK_LIBRARIES kritaui kritaimage Qt5::Test) krita_add_broken_unit_test( ResourceBundleTest.cpp TEST_NAME krita-resourcemanager-ResourceBundleTest LINK_LIBRARIES kritaui kritalibbrush kritalibpaintop Qt5::Test) # FIXME this test doesn't compile #ecm_add_test( # kis_input_manager_test.cpp ../../../sdk/tests/testutil.cpp # TEST_NAME krita-ui-KisInputManagerTest # LINK_LIBRARIES kritaui kritaimage Qt5::Test) diff --git a/libs/ui/tests/KisPaintOnTransparencyMaskTest.cpp b/libs/ui/tests/KisPaintOnTransparencyMaskTest.cpp new file mode 100644 index 0000000000..141359b0c7 --- /dev/null +++ b/libs/ui/tests/KisPaintOnTransparencyMaskTest.cpp @@ -0,0 +1,134 @@ +#include "KisPaintOnTransparencyMaskTest.h" + +#include +#include +#include +#include "stroke_testing_utils.h" +#include "strokes/freehand_stroke.h" +#include "strokes/KisFreehandStrokeInfo.h" +#include "kis_resources_snapshot.h" +#include "kis_image.h" +#include +#include "kis_transparency_mask.h" + +#include "kis_paint_device_debug_utils.h" +#include "kis_tool_utils.h" + +#include "kis_sequential_iterator.h" + +class PaintOnTransparencyMaskTester : public utils::StrokeTester +{ +public: + PaintOnTransparencyMaskTester(const QString &presetFilename) + : StrokeTester("freehand_benchmark", QSize(5000, 5000), presetFilename) + { + setBaseFuzziness(3); + } + +protected: + using utils::StrokeTester::initImage; + void initImage(KisImageWSP image, KisNodeSP activeNode) override { + + activeNode->paintDevice()->fill(QRect(0,0,1024,1024), KoColor(Qt::red, image->colorSpace())); + m_mask = new KisTransparencyMask(); + m_mask->setSelection(new KisSelection()); + m_mask->paintDevice()->clear(); + image->addNode(m_mask, activeNode); + image->setWorkingThreadsLimit(8); + } + + using utils::StrokeTester::modifyResourceManager; + void modifyResourceManager(KoCanvasResourceManager *manager, + KisImageWSP image) { + + KoColor color(Qt::red, image->colorSpace()); + color.setOpacity(0.5); + + QVariant i; + i.setValue(color); + manager->setResource(KoCanvasResourceManager::ForegroundColor, i); + } + + KisStrokeStrategy* createStroke(KisResourcesSnapshotSP resources, + KisImageWSP image) override { + Q_UNUSED(image); + + resources->setCurrentNode(m_mask); + + KisFreehandStrokeInfo *strokeInfo = new KisFreehandStrokeInfo(); + + QScopedPointer stroke( + new FreehandStrokeStrategy(resources, strokeInfo, kundo2_noi18n("Freehand Stroke"))); + + return stroke.take(); + } + + void addPaintingJobs(KisImageWSP image, + KisResourcesSnapshotSP resources) override + { + addPaintingJobs(image, resources, 0); + } + + void addPaintingJobs(KisImageWSP image, KisResourcesSnapshotSP resources, int iteration) override { + Q_UNUSED(iteration); + Q_UNUSED(resources); + + + KisPaintInformation pi1; + KisPaintInformation pi2; + + pi1 = KisPaintInformation(QPointF(100, 100), 1.0); + pi2 = KisPaintInformation(QPointF(800, 800), 1.0); + + QScopedPointer data( + new FreehandStrokeStrategy::Data(0, pi1, pi2)); + + image->addJob(strokeId(), data.take()); + + image->addJob(strokeId(), new FreehandStrokeStrategy::UpdateData(true)); + } + + + void checkDeviceIsEmpty(KisPaintDeviceSP dev, const QString &name) + { + const KoColorSpace *cs = dev->colorSpace(); + KisSequentialConstIterator it(dev, QRect(0,0,1024,1024)); + while (it.nextPixel()) { + if (cs->opacityU8(it.rawDataConst()) > 0) { + KIS_DUMP_DEVICE_2(dev, QRect(0,0,1024,1024), "image", "dd"); + qFatal(QString("failed: %1").arg(name).toLatin1().data()); + } + } + } + + void beforeCheckingResult(KisImageWSP image, KisNodeSP activeNode) { + ENTER_FUNCTION() << ppVar(image) << ppVar(activeNode); + + KisToolUtils::clearImage(image, activeNode, 0); + image->waitForDone(); + + checkDeviceIsEmpty(m_mask->paintDevice(), "mask"); + checkDeviceIsEmpty(m_mask->parent()->projection(), "projection"); + checkDeviceIsEmpty(image->projection(), "image"); + } + +private: + KisMaskSP m_mask; +}; + +#include + +void KisPaintOnTransparencyMaskTest::initTestCase() +{ + KoResourcePaths::addResourceType("kis_brushes", "data", FILES_DATA_DIR); +} + +void KisPaintOnTransparencyMaskTest::test() +{ + for (int i = 0; i < 1000; i++) { + PaintOnTransparencyMaskTester tester("testing_wet_circle.kpp"); + tester.testSimpleStrokeNoVerification(); + } +} + +QTEST_MAIN(KisPaintOnTransparencyMaskTest) diff --git a/libs/ui/tests/KisPaintOnTransparencyMaskTest.h b/libs/ui/tests/KisPaintOnTransparencyMaskTest.h new file mode 100644 index 0000000000..7e83c544e1 --- /dev/null +++ b/libs/ui/tests/KisPaintOnTransparencyMaskTest.h @@ -0,0 +1,15 @@ +#ifndef KISPAINTONTRANSPARENCYMASKTEST_H +#define KISPAINTONTRANSPARENCYMASKTEST_H + +#include + +class KisPaintOnTransparencyMaskTest : public QObject +{ + Q_OBJECT +private Q_SLOTS: + + void initTestCase(); + void test(); +}; + +#endif // KISPAINTONTRANSPARENCYMASKTEST_H diff --git a/libs/ui/tests/data/testing_wet_circle.kpp b/libs/ui/tests/data/testing_wet_circle.kpp new file mode 100644 index 0000000000..983646e219 Binary files /dev/null and b/libs/ui/tests/data/testing_wet_circle.kpp differ diff --git a/sdk/tests/stroke_testing_utils.cpp b/sdk/tests/stroke_testing_utils.cpp index 1c98f7eb6f..4e8942b15d 100644 --- a/sdk/tests/stroke_testing_utils.cpp +++ b/sdk/tests/stroke_testing_utils.cpp @@ -1,364 +1,369 @@ /* * Copyright (c) 2011 Dmitry Kazakov * * 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 "stroke_testing_utils.h" #include #include #include #include #include #include #include #include #include "kis_canvas_resource_provider.h" #include "kis_image.h" #include "kis_paint_device.h" #include "kis_paint_layer.h" #include "kis_group_layer.h" #include #include "testutil.h" KisImageSP utils::createImage(KisUndoStore *undoStore, const QSize &imageSize) { QRect imageRect(0,0,imageSize.width(),imageSize.height()); const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8(); KisImageSP image = new KisImage(undoStore, imageRect.width(), imageRect.height(), cs, "stroke test"); KisPaintLayerSP paintLayer1 = new KisPaintLayer(image, "paint1", OPACITY_OPAQUE_U8); KisPaintLayerSP paintLayer2 = new KisPaintLayer(image, "paint2", OPACITY_OPAQUE_U8); KisPaintLayerSP paintLayer3 = new KisPaintLayer(image, "paint3", OPACITY_OPAQUE_U8); KisPaintLayerSP paintLayer4 = new KisPaintLayer(image, "paint4", OPACITY_OPAQUE_U8); KisPaintLayerSP paintLayer5 = new KisPaintLayer(image, "paint5", OPACITY_OPAQUE_U8); image->lock(); image->addNode(paintLayer1); image->addNode(paintLayer2); image->addNode(paintLayer3); image->addNode(paintLayer4); image->addNode(paintLayer5); image->unlock(); return image; } KoCanvasResourceManager* utils::createResourceManager(KisImageWSP image, KisNodeSP node, const QString &presetFileName) { KoCanvasResourceManager *manager = new KoCanvasResourceManager(); KisViewManager::initializeResourceManager(manager); QVariant i; i.setValue(KoColor(Qt::black, image->colorSpace())); manager->setResource(KoCanvasResourceManager::ForegroundColor, i); i.setValue(KoColor(Qt::white, image->colorSpace())); manager->setResource(KoCanvasResourceManager::BackgroundColor, i); i.setValue(static_cast(0)); manager->setResource(KisCanvasResourceProvider::CurrentPattern, i); manager->setResource(KisCanvasResourceProvider::CurrentGradient, i); manager->setResource(KisCanvasResourceProvider::CurrentGeneratorConfiguration, i); if(!node) { node = image->root(); while(node && !dynamic_cast(node.data())) { node = node->firstChild(); } Q_ASSERT(node && dynamic_cast(node.data())); } i.setValue(node); manager->setResource(KisCanvasResourceProvider::CurrentKritaNode, i); KisPaintOpPresetSP preset; if (!presetFileName.isEmpty()) { QString fullFileName = TestUtil::fetchDataFileLazy(presetFileName); preset = new KisPaintOpPreset(fullFileName); bool presetValid = preset->load(); Q_ASSERT(presetValid); Q_UNUSED(presetValid); i.setValue(preset); manager->setResource(KisCanvasResourceProvider::CurrentPaintOpPreset, i); } i.setValue(COMPOSITE_OVER); manager->setResource(KisCanvasResourceProvider::CurrentCompositeOp, i); i.setValue(false); manager->setResource(KisCanvasResourceProvider::MirrorHorizontal, i); i.setValue(false); manager->setResource(KisCanvasResourceProvider::MirrorVertical, i); i.setValue(1.0); manager->setResource(KisCanvasResourceProvider::Opacity, i); i.setValue(1.0); manager->setResource(KisCanvasResourceProvider::HdrExposure, i); return manager; } utils::StrokeTester::StrokeTester(const QString &name, const QSize &imageSize, const QString &presetFilename) : m_name(name), m_imageSize(imageSize), m_presetFilename(presetFilename), m_numIterations(1), m_baseFuzziness(1) { } utils::StrokeTester::~StrokeTester() { } void utils::StrokeTester::setNumIterations(int value) { m_numIterations = value; } void utils::StrokeTester::setBaseFuzziness(int value) { m_baseFuzziness = value; } void utils::StrokeTester::testSimpleStroke() { testOneStroke(false, true, false, true); } int utils::StrokeTester::lastStrokeTime() const { return m_strokeTime; } void utils::StrokeTester::test() { testOneStroke(false, false, false); testOneStroke(false, true, false); testOneStroke(true, false, false); testOneStroke(true, true, false); // The same but with updates (compare against projection) testOneStroke(false, false, false, true); testOneStroke(false, true, false, true); testOneStroke(true, false, false, true); testOneStroke(true, true, false, true); // The same, but with an external layer testOneStroke(false, false, true); testOneStroke(false, true, true); testOneStroke(true, false, true); testOneStroke(true, true, true); } void utils::StrokeTester::benchmark() { // not cancelled, indirect painting, internal, no updates, no qimage doStroke(false, false, false, false); } +void utils::StrokeTester::testSimpleStrokeNoVerification() +{ + doStroke(false, false, true, false); +} + void utils::StrokeTester::testOneStroke(bool cancelled, bool indirectPainting, bool externalLayer, bool testUpdates) { // TODO: indirectPainting option is not used anymore! The real value is // taken from the preset! QString testName = formatTestName(m_name, cancelled, indirectPainting, externalLayer); dbgKrita << "Testcase:" << testName << "(comare against " << (testUpdates ? "projection" : "layer") << ")"; QImage resultImage; resultImage = doStroke(cancelled, externalLayer, testUpdates); QImage refImage; refImage.load(referenceFile(testName)); QPoint temp; if(!TestUtil::compareQImages(temp, refImage, resultImage, m_baseFuzziness, m_baseFuzziness)) { refImage.save(dumpReferenceFile(testName)); resultImage.save(resultFile(testName)); QFAIL("Images do not coincide"); } } QString utils::StrokeTester::formatTestName(const QString &baseName, bool cancelled, bool indirectPainting, bool externalLayer) { QString result = baseName; result += "_" + m_presetFilename; result += indirectPainting ? "_indirect" : "_incremental"; result += cancelled ? "_cancelled" : "_finished"; result += externalLayer ? "_external" : "_internal"; return result; } QString utils::StrokeTester::referenceFile(const QString &testName) { QString path = QString(FILES_DATA_DIR) + QDir::separator() + m_name + QDir::separator(); path += testName; path += ".png"; return path; } QString utils::StrokeTester::dumpReferenceFile(const QString &testName) { QString path = QString(FILES_OUTPUT_DIR) + QDir::separator(); path += testName; path += "_expected"; path += ".png"; return path; } QString utils::StrokeTester::resultFile(const QString &testName) { QString path = QString(FILES_OUTPUT_DIR) + QDir::separator(); path += testName; path += ".png"; return path; } QImage utils::StrokeTester::doStroke(bool cancelled, bool externalLayer, bool testUpdates, bool needQImage) { KisImageSP image = utils::createImage(0, m_imageSize); KoCanvasResourceManager *manager = utils::createResourceManager(image, 0, m_presetFilename); KisNodeSP currentNode; for (int i = 0; i < m_numIterations; i++) { modifyResourceManager(manager, image, i); KisResourcesSnapshotSP resources = new KisResourcesSnapshot(image, image->rootLayer()->firstChild(), manager); if(externalLayer) { KisNodeSP externalNode = new KisPaintLayer(0, "extlyr", OPACITY_OPAQUE_U8, image->colorSpace()); resources->setCurrentNode(externalNode); Q_ASSERT(resources->currentNode() == externalNode); } initImage(image, resources->currentNode(), i); QElapsedTimer strokeTime; strokeTime.start(); KisStrokeStrategy *stroke = createStroke(resources, image); m_strokeId = image->startStroke(stroke); addPaintingJobs(image, resources, i); if(!cancelled) { image->endStroke(m_strokeId); } else { image->cancelStroke(m_strokeId); } image->waitForDone(); m_strokeTime = strokeTime.elapsed(); currentNode = resources->currentNode(); } beforeCheckingResult(image, currentNode); QImage resultImage; if(needQImage) { KisPaintDeviceSP device = testUpdates ? image->projection() : currentNode->paintDevice(); resultImage = device->convertToQImage(0, 0, 0, image->width(), image->height()); } image = 0; delete manager; return resultImage; } void utils::StrokeTester::modifyResourceManager(KoCanvasResourceManager *manager, KisImageWSP image, int iteration) { Q_UNUSED(iteration); modifyResourceManager(manager, image); } void utils::StrokeTester::modifyResourceManager(KoCanvasResourceManager *manager, KisImageWSP image) { Q_UNUSED(manager); Q_UNUSED(image); } void utils::StrokeTester::initImage(KisImageWSP image, KisNodeSP activeNode, int iteration) { Q_UNUSED(iteration); initImage(image, activeNode); } void utils::StrokeTester::initImage(KisImageWSP image, KisNodeSP activeNode) { Q_UNUSED(image); Q_UNUSED(activeNode); } void utils::StrokeTester::addPaintingJobs(KisImageWSP image, KisResourcesSnapshotSP resources, int iteration) { Q_UNUSED(iteration); addPaintingJobs(image, resources); } void utils::StrokeTester::addPaintingJobs(KisImageWSP image, KisResourcesSnapshotSP resources) { Q_UNUSED(image); Q_UNUSED(resources); } void utils::StrokeTester::beforeCheckingResult(KisImageWSP image, KisNodeSP activeNode) { Q_UNUSED(image); Q_UNUSED(activeNode); } diff --git a/sdk/tests/stroke_testing_utils.h b/sdk/tests/stroke_testing_utils.h index aa1362f1c7..b8a6b33333 100644 --- a/sdk/tests/stroke_testing_utils.h +++ b/sdk/tests/stroke_testing_utils.h @@ -1,109 +1,110 @@ /* * Copyright (c) 2011 Dmitry Kazakov * * 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 __STROKE_TESTING_UTILS_H #define __STROKE_TESTING_UTILS_H #include #include #include "kis_node.h" #include "kis_types.h" #include "kis_stroke_strategy.h" #include "kis_resources_snapshot.h" class KisUndoStore; namespace utils { KisImageSP createImage(KisUndoStore *undoStore, const QSize &imageSize); KoCanvasResourceManager* createResourceManager(KisImageWSP image, KisNodeSP node = 0, const QString &presetFileName = "autobrush_300px.kpp"); class StrokeTester { public: StrokeTester(const QString &name, const QSize &imageSize, const QString &presetFileName = "autobrush_300px.kpp"); virtual ~StrokeTester(); void testSimpleStroke(); void test(); void benchmark(); + void testSimpleStrokeNoVerification(); void setNumIterations(int value); void setBaseFuzziness(int value); int lastStrokeTime() const; protected: KisStrokeId strokeId() { return m_strokeId; } virtual void modifyResourceManager(KoCanvasResourceManager *manager, KisImageWSP image, int iteration); virtual void initImage(KisImageWSP image, KisNodeSP activeNode, int iteration); // overload virtual void modifyResourceManager(KoCanvasResourceManager *manager, KisImageWSP image); // overload virtual void initImage(KisImageWSP image, KisNodeSP activeNode); virtual void beforeCheckingResult(KisImageWSP image, KisNodeSP activeNode); virtual KisStrokeStrategy* createStroke(KisResourcesSnapshotSP resources, KisImageWSP image) = 0; virtual void addPaintingJobs(KisImageWSP image, KisResourcesSnapshotSP resources, int iteration); // overload virtual void addPaintingJobs(KisImageWSP image, KisResourcesSnapshotSP resources); private: void testOneStroke(bool cancelled, bool indirectPainting, bool externalLayer, bool testUpdates = false); QImage doStroke(bool cancelled, bool externalLayer, bool testUpdates = false, bool needQImage = true); QString formatTestName(const QString &baseName, bool cancelled, bool indirectPainting, bool externalLayer); QString referenceFile(const QString &testName); QString dumpReferenceFile(const QString &testName); QString resultFile(const QString &testName); private: KisStrokeId m_strokeId; QString m_name; QSize m_imageSize; QString m_presetFilename; int m_numIterations; int m_baseFuzziness; int m_strokeTime = 0; }; } #endif /* __STROKE_TESTING_UTILS_H */