Paste P215

WIP - KisMaskApplicaTorBase based UnitTest -- beta. Empty QImage
ActivePublic

Authored by vanyossi on May 12 2018, 5:50 AM.
diff --git a/libs/image/tests/CMakeLists.txt b/libs/image/tests/CMakeLists.txt
index 90a5e6289e..bee73832f4 100644
--- a/libs/image/tests/CMakeLists.txt
+++ b/libs/image/tests/CMakeLists.txt
@@ -124,6 +124,7 @@ ecm_add_tests(
kis_marker_painter_test.cpp
kis_lazy_brush_test.cpp
kis_colorize_mask_test.cpp
+ kis_mask_similarity_test.cpp
NAME_PREFIX "krita-image-"
LINK_LIBRARIES kritaimage Qt5::Test)
diff --git a/libs/image/tests/kis_mask_similarity_test.cpp b/libs/image/tests/kis_mask_similarity_test.cpp
new file mode 100644
index 0000000000..cd08552db2
--- /dev/null
+++ b/libs/image/tests/kis_mask_similarity_test.cpp
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2018 Iván Santa María <ghevan@gmail.com>
+ *
+ * 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_mask_similarity_test.h"
+
+#include <QTest>
+#include <KoColor.h>
+#include <testutil.h>
+
+#include "kis_brush_mask_applicator_base.h"
+#include "kis_mask_generator.h"
+
+class KisMaskSimilarityTester
+{
+public:
+ KisMaskSimilarityTester(KisBrushMaskApplicatorBase* _legacy, KisBrushMaskApplicatorBase* _vectorized, QRect _bounds)
+ : legacy(_legacy)
+ , vectorized(_vectorized)
+ , m_bounds(_bounds)
+ {
+ KoColor color(Qt::black, colorSpace);
+ KisFixedPaintDeviceSP m_paintDev = new KisFixedPaintDevice(colorSpace);
+
+ m_paintDev->setRect(m_bounds);
+ m_paintDev->initialize();
+
+
+ MaskProcessingData data(m_paintDev, colorSpace,
+ 0.0, 1.0,
+ m_bounds.width() / 2, m_bounds.height() / 2,0);
+
+ legacy->initializeData(&data);
+ legacy->process(m_bounds);
+
+ QImage scalarImage = m_paintDev->convertToQImage(colorSpace->profile());
+ scalarImage.save(QString("scalar_v2.png"),"PNG");
+
+
+ for (int i = 0; i < scalarImage.width(); ++i) {
+ for (int j = 0; j < scalarImage.height(); ++j) {
+ qDebug() << scalarImage.pixelColor(i,j);
+ }
+ }
+ }
+
+private:
+
+protected:
+ const KoColorSpace* colorSpace = KoColorSpaceRegistry::instance()->rgb8();
+
+ KisBrushMaskApplicatorBase* legacy;
+ KisBrushMaskApplicatorBase* vectorized;
+ QRect m_bounds;
+ KisFixedPaintDeviceSP m_paintDev;
+};
+
+
+void KisMaskSimilarityTest::testCircleMask()
+{
+ QRect bounds(0,0,40,40);
+ KisMaskSimilarityTester(
+ (new KisCircleMaskGenerator(40, 1.0, 0.5, 0.5, 3, true))->applicator(),
+ (new KisCircleMaskGenerator(40, 1.0, 0.5, 0.5, 2, true))->applicator(), bounds);
+}
+
+
+QTEST_MAIN(KisMaskSimilarityTest)
diff --git a/libs/image/tests/kis_mask_similarity_test.h b/libs/image/tests/kis_mask_similarity_test.h
new file mode 100644
index 0000000000..045a05e8fd
--- /dev/null
+++ b/libs/image/tests/kis_mask_similarity_test.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2018 Iván Santa María <ghevan@gmail.com>
+ *
+ * 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_MASK_SIMILARITY_TEST
+#define KIS_MASK_SIMILARITY_TEST
+
+#include <QtTest>
+
+class KisMaskSimilarityTest : public QObject
+{
+ Q_OBJECT
+private Q_SLOTS:
+
+ void testCircleMask();
+};
+
+#endif
vanyossi created this paste.May 12 2018, 5:50 AM
vanyossi created this object in space S1 KDE Community.
vanyossi updated the paste's language from autodetect to cpp.

T8581

Attempting new Unit Test based on KisBaseMaskApplicatorBase

As it is, I seem to be overwritting the MaskProcessingData from the KisCircleMaskGenerator original applicator, however the code as is will not access the KisFixedPaintDeviceSP device of the MaskProcessingData.

New Mask is created to allow processing to work. Maybe the problem is on how Am I generating the QImage from the device?