Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Split the filter mask test into two cases: with and without transparent pixels
Maciej Jesionowskibb0707d1aed8
diff --git a/libs/image/tests/kis_filter_mask_test.cpp b/libs/image/tests/kis_filter_mask_test.cppindex a1e7617522..57a517ce27 100644--- a/libs/image/tests/kis_filter_mask_test.cpp+++ b/libs/image/tests/kis_filter_mask_test.cpp@@ -89,18 +89,47 @@ void KisFilterMaskTest::testProjectionSelected()mask->select(qimage.rect(), MAX_SELECTED);mask->apply(projection, qimage.rect(), qimage.rect(), KisNode::N_FILTHY, KisRenderPassFlag::None);- if (f->needsTransparentPixels(kfc, image->colorSpace())) {- QCOMPARE(mask->exactBounds(), QRect(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT));- } else {- QVERIFY2(mask->exactBounds().contains(layer->exactBounds()), "The mask bounds are smaller than the layer bounds");- }+ QCOMPARE(mask->exactBounds(), QRect(0, 0, qimage.width(), qimage.height()));QPoint errpoint;if (!TestUtil::compareQImages(errpoint, inverted, projection->convertToQImage(0, 0, 0, qimage.width(), qimage.height()))) {projection->convertToQImage(0, 0, 0, qimage.width(), qimage.height()).save("filtermasktest2.png");QFAIL(QString("Failed to create inverted image, first different pixel: %1,%2 ").arg(errpoint.x()).arg(errpoint.y()).toLatin1());}+}++void KisFilterMaskTest::testProjectionSelectedTransparentPixels()+{+ TestUtil::MaskParent p(QRect(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT));+ KisImageSP image = p.image;+ KisPaintLayerSP layer = p.layer;+ KisPaintDeviceSP projection = layer->paintDevice();+ QImage qimage(QString(FILES_DATA_DIR) + '/' + "transparency_mask_test_3.png");+ projection->convertFromQImage(qimage, 0, 0, 0);++ KisFilterSP f = KisFilterRegistry::instance()->value("resettransparent");+ Q_ASSERT(f);+ KisFilterConfigurationSP kfc = f->defaultConfiguration(KisGlobalResourcesInterface::instance());+ Q_ASSERT(kfc);++ KisFilterMaskSP mask = new KisFilterMask(image, "mask");+ image->addNode(mask, layer);++ mask->setFilter(kfc->cloneWithResourcesSnapshot());+ mask->createNodeProgressProxy();++ mask->initSelection(layer);+ mask->select(qimage.rect(), MAX_SELECTED);+ mask->apply(projection, qimage.rect(), qimage.rect(), KisNode::N_FILTHY, KisRenderPassFlag::None);++ QCOMPARE(mask->exactBounds(), QRect(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT));++ QPoint errpoint;+ if (!TestUtil::compareQImages(errpoint, qimage, projection->convertToQImage(0, 0, 0, qimage.width(), qimage.height()))) {+ projection->convertToQImage(0, 0, 0, qimage.width(), qimage.height()).save("filtermasktest3.png");+ QFAIL(QString("Failed to create identical image, first different pixel: %1,%2 ").arg(errpoint.x()).arg(errpoint.y()).toLatin1());+ }}SIMPLE_TEST_MAIN(KisFilterMaskTest)diff --git a/libs/image/tests/kis_filter_mask_test.h b/libs/image/tests/kis_filter_mask_test.hindex a2628a8fb7..c5c40fc268 100644--- a/libs/image/tests/kis_filter_mask_test.h+++ b/libs/image/tests/kis_filter_mask_test.h@@ -19,6 +19,7 @@ private Q_SLOTS:void testProjectionNotSelected();void testProjectionSelected();+ void testProjectionSelectedTransparentPixels();};