summaryrefslogtreecommitdiffstats
path: root/chalk/core/tests
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-26 00:41:16 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-26 00:41:16 +0000
commit698569f8428ca088f764d704034a1330517b98c0 (patch)
treebf45be6946ebbbee9cce5a5bcf838f4c952d87e6 /chalk/core/tests
parent2785103a6bd4de55bd26d79e34d0fdd4b329a73a (diff)
downloadkoffice-698569f8428ca088f764d704034a1330517b98c0.tar.gz
koffice-698569f8428ca088f764d704034a1330517b98c0.zip
Finish rebranding of Krita as Chalk
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1238363 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'chalk/core/tests')
-rw-r--r--chalk/core/tests/Makefile.am30
-rw-r--r--chalk/core/tests/kis_filter_configuration_tester.cc67
-rw-r--r--chalk/core/tests/kis_filter_configuration_tester.h34
-rw-r--r--chalk/core/tests/kis_image_tester.cpp88
-rw-r--r--chalk/core/tests/kis_image_tester.h32
-rw-r--r--chalk/core/tests/kis_integer_maths_tester.cpp93
-rw-r--r--chalk/core/tests/kis_integer_maths_tester.h34
7 files changed, 378 insertions, 0 deletions
diff --git a/chalk/core/tests/Makefile.am b/chalk/core/tests/Makefile.am
new file mode 100644
index 00000000..239c1ba6
--- /dev/null
+++ b/chalk/core/tests/Makefile.am
@@ -0,0 +1,30 @@
+AM_CPPFLAGS = \
+ -I$(srcdir)/../ \
+ -I$(srcdir)/../tiles \
+ -I$(srcdir)/../../sdk \
+ -I$(srcdir)/../../chalkcolor \
+ -I$(srcdir)/../../colorspaces/rgb_u8 \
+ $(KOFFICE_INCLUDES) \
+ $(KOPAINTER_INCLUDES) \
+ $(all_includes)
+
+# The check_ target makes sure we don't install the modules,
+# $(KDE_CHECK_PLUGIN) assures a shared library is created.
+check_LTLIBRARIES = kunittest_kis_integer_maths_tester.la kunittest_kis_image_tester.la kunittest_kis_filter_configuration_tester.la
+
+kunittest_kis_integer_maths_tester_la_SOURCES = kis_integer_maths_tester.cpp
+kunittest_kis_integer_maths_tester_la_LIBADD = -lkunittest ../../libchalkcommon.la
+kunittest_kis_integer_maths_tester_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) $(all_libraries)
+
+kunittest_kis_image_tester_la_SOURCES = kis_image_tester.cpp
+kunittest_kis_image_tester_la_LIBADD = -lkunittest ../../libchalkcommon.la
+kunittest_kis_image_tester_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) $(all_libraries)
+
+
+kunittest_kis_filter_configuration_tester_la_SOURCES = kis_filter_configuration_tester.cc
+kunittest_kis_filter_configuration_tester_la_LIBADD = -lkunittest ../../libchalkcommon.la
+kunittest_kis_filter_configuration_tester_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) $(all_libraries)
+
+
+check-local: kunittest_kis_integer_maths_tester.la kunittest_kis_image_tester.la kunittest_kis_filter_configuration_tester.la
+ kunittestmodrunner
diff --git a/chalk/core/tests/kis_filter_configuration_tester.cc b/chalk/core/tests/kis_filter_configuration_tester.cc
new file mode 100644
index 00000000..6a4a2631
--- /dev/null
+++ b/chalk/core/tests/kis_filter_configuration_tester.cc
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2006 Boudewijn Rempt <[email protected]>
+ *
+ * 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 <tqapplication.h>
+
+#include <kdebug.h>
+#include <kunittest/runner.h>
+#include <kunittest/module.h>
+
+#include "kis_filter_configuration_tester.h"
+#include "../kis_filter_configuration.h"
+
+using namespace KUnitTest;
+
+KUNITTEST_MODULE(kunittest_kis_filter_configuration_tester, "KisFilterConfiguration Tester");
+KUNITTEST_MODULE_REGISTER_TESTER(KisFilterConfigurationTester);
+
+void KisFilterConfigurationTester::allTests()
+{
+ testCreation();
+ testSetGetProperty();
+ testRoundTrip();
+}
+
+void KisFilterConfigurationTester::testCreation()
+{
+ KisFilterConfiguration * kfc = new KisFilterConfiguration("test", 1);
+ if ( kfc == 0 ) failure("Could not create test filter configuration");
+ CHECK(kfc->version(), 1);
+ CHECK(kfc->name(), TQString("test"));
+
+ delete kfc;
+ success("testCreation success");
+}
+
+void KisFilterConfigurationTester::testRoundTrip()
+{
+ KisFilterConfiguration * kfc = new KisFilterConfiguration("test", 1);
+ CHECK(kfc->version(), 1);
+ CHECK(kfc->name(), TQString("test"));
+ TQString s = kfc->toString();
+ delete kfc;
+ kfc = new KisFilterConfiguration(s);
+ CHECK(kfc->version(), 1);
+ CHECK(kfc->name(), TQString("test"));
+ delete kfc;
+ success("testDeserializaton success");
+}
+
+void KisFilterConfigurationTester::testSetGetProperty()
+{
+}
diff --git a/chalk/core/tests/kis_filter_configuration_tester.h b/chalk/core/tests/kis_filter_configuration_tester.h
new file mode 100644
index 00000000..6e1ca2e5
--- /dev/null
+++ b/chalk/core/tests/kis_filter_configuration_tester.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2006 Boudewijn Rempt <[email protected]>
+ *
+ * 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_FILTER_CONFIGURATION_TESTER_H
+#define KIS_FILTER_CONFIGURATION_TESTER_H
+
+#include <kunittest/tester.h>
+
+class KisFilterConfigurationTester : public KUnitTest::Tester
+{
+public:
+ void allTests();
+ void testCreation();
+ void testRoundTrip();
+ void testSetGetProperty();
+};
+
+#endif
+
diff --git a/chalk/core/tests/kis_image_tester.cpp b/chalk/core/tests/kis_image_tester.cpp
new file mode 100644
index 00000000..f660f394
--- /dev/null
+++ b/chalk/core/tests/kis_image_tester.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2005 Adrian Page <[email protected]>
+ *
+ * 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 <tqapplication.h>
+
+#include <kunittest/runner.h>
+#include <kunittest/module.h>
+
+#include "kis_image_tester.h"
+#include "kis_image.h"
+#include "kis_meta_registry.h"
+#include "kis_rgb_colorspace.h"
+#include "kis_colorspace_factory_registry.h"
+#include "kis_color.h"
+#include "kis_paint_layer.h"
+#include "kis_group_layer.h"
+
+using namespace KUnitTest;
+
+KUNITTEST_MODULE(kunittest_kis_image_tester, "KisImage Tester");
+KUNITTEST_MODULE_REGISTER_TESTER(KisImageTester);
+
+void KisImageTester::allTests()
+{
+ mergeTests();
+}
+
+#define IMAGE_WIDTH 1
+#define IMAGE_HEIGHT 1
+
+void KisImageTester::mergeTests()
+{
+ KisColorSpace * colorSpace = KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""), "");
+
+ KisImageSP image = new KisImage(0, IMAGE_WIDTH, IMAGE_HEIGHT, colorSpace, "merge test");
+
+ KisColor mergedPixel = image->mergedPixel(0, 0);
+
+ TQColor colour;
+ TQ_UINT8 opacity;
+
+ mergedPixel.toTQColor(&colour, &opacity);
+
+ CHECK(opacity, OPACITY_TRANSPARENT);
+
+ KisPaintLayer * layer = new KisPaintLayer(image, "layer 1", OPACITY_OPAQUE);
+ image->addLayer(layer, image->rootLayer(), 0);
+
+ layer->paintDevice()->setPixel(0, 0, TQColor(255, 128, 64), OPACITY_OPAQUE);
+
+ mergedPixel = image->mergedPixel(0, 0);
+ mergedPixel.toTQColor(&colour, &opacity);
+
+ CHECK(opacity, OPACITY_OPAQUE);
+ CHECK(colour.red(), 255);
+ CHECK(colour.green(), 128);
+ CHECK(colour.blue(), 64);
+
+ KisPaintLayer * layer2 = new KisPaintLayer(image, "layer 2", OPACITY_OPAQUE / 2);
+ image->addLayer(layer2, image->rootLayer(), layer);
+
+ layer2->paintDevice()->setPixel(0, 0, TQColor(255, 255, 255), OPACITY_OPAQUE);
+
+ mergedPixel = image->mergedPixel(0, 0);
+ mergedPixel.toTQColor(&colour, &opacity);
+
+ CHECK(opacity, OPACITY_OPAQUE);
+ CHECK(colour.red(), 255);
+ CHECK(colour.green(), 128 + ((255 - 128) / 2));
+ CHECK(colour.blue(), 64 + ((255 - 64) / 2));
+}
+
+
diff --git a/chalk/core/tests/kis_image_tester.h b/chalk/core/tests/kis_image_tester.h
new file mode 100644
index 00000000..4e676838
--- /dev/null
+++ b/chalk/core/tests/kis_image_tester.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2005 Adrian Page <[email protected]>
+ *
+ * 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_IMAGE_TESTER_H
+#define KIS_IMAGE_TESTER_H
+
+#include <kunittest/tester.h>
+
+class KisImageTester : public KUnitTest::Tester
+{
+public:
+ void allTests();
+ void mergeTests();
+};
+
+#endif
+
diff --git a/chalk/core/tests/kis_integer_maths_tester.cpp b/chalk/core/tests/kis_integer_maths_tester.cpp
new file mode 100644
index 00000000..1878731b
--- /dev/null
+++ b/chalk/core/tests/kis_integer_maths_tester.cpp
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2005 Adrian Page <[email protected]>
+ *
+ * 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 <kunittest/runner.h>
+#include <kunittest/module.h>
+
+#include "kis_integer_maths_tester.h"
+#include "kis_integer_maths.h"
+
+using namespace KUnitTest;
+
+KUNITTEST_MODULE(kunittest_kis_integer_maths_tester, "Integer Maths Tester");
+KUNITTEST_MODULE_REGISTER_TESTER(KisIntegerMathsTester);
+
+void KisIntegerMathsTester::allTests()
+{
+ UINT8Tests();
+ UINT16Tests();
+ conversionTests();
+}
+
+void KisIntegerMathsTester::UINT8Tests()
+{
+ CHECK((int)UINT8_MULT(0, 255), 0);
+ CHECK((int)UINT8_MULT(255, 255), 255);
+
+ CHECK((int)UINT8_MULT(128, 255), 128);
+ CHECK((int)UINT8_MULT(255, 128), 128);
+
+ CHECK((int)UINT8_MULT(1, 255), 1);
+ CHECK((int)UINT8_MULT(1, 127), 0);
+ CHECK((int)UINT8_MULT(64, 128), 32);
+
+ CHECK((int)UINT8_DIVIDE(255, 255), 255);
+ CHECK((int)UINT8_DIVIDE(64, 128), 128);
+ CHECK((int)UINT8_DIVIDE(1, 64), 4);
+ CHECK((int)UINT8_DIVIDE(0, 1), 0);
+
+ CHECK((int)UINT8_BLEND(255, 0, 0), 0);
+ CHECK((int)UINT8_BLEND(255, 0, 128), 128);
+ CHECK((int)UINT8_BLEND(255, 128, 128), 192);
+ CHECK((int)UINT8_BLEND(128, 64, 255), 128);
+}
+
+void KisIntegerMathsTester::UINT16Tests()
+{
+ CHECK((int)UINT16_MULT(0, 65535), 0);
+ CHECK((int)UINT16_MULT(65535, 65535), 65535);
+
+ CHECK((int)UINT16_MULT(32768, 65535), 32768);
+ CHECK((int)UINT16_MULT(65535, 32768), 32768);
+
+ CHECK((int)UINT16_MULT(1, 65535), 1);
+ CHECK((int)UINT16_MULT(1, 32767), 0);
+ CHECK((int)UINT16_MULT(16384, 32768), 8192);
+
+ CHECK((int)UINT16_DIVIDE(65535, 65535), 65535);
+ CHECK((int)UINT16_DIVIDE(16384, 32768), 32768);
+ CHECK((int)UINT16_DIVIDE(1, 16384), 4);
+ CHECK((int)UINT16_DIVIDE(0, 1), 0);
+
+ CHECK((int)UINT16_BLEND(65535, 0, 0), 0);
+ CHECK((int)UINT16_BLEND(65535, 0, 32768), 32768);
+ CHECK((int)UINT16_BLEND(65535, 32768, 32768), 49152);
+ CHECK((int)UINT16_BLEND(32768, 16384, 65535), 32768);
+}
+
+void KisIntegerMathsTester::conversionTests()
+{
+ CHECK((int)UINT8_TO_UINT16(255), 65535);
+ CHECK((int)UINT8_TO_UINT16(0), 0);
+ CHECK((int)UINT8_TO_UINT16(128), 128 * 257);
+
+ CHECK((int)UINT16_TO_UINT8(65535), 255);
+ CHECK((int)UINT16_TO_UINT8(0), 0);
+ CHECK((int)UINT16_TO_UINT8(128 * 257), 128);
+}
+
diff --git a/chalk/core/tests/kis_integer_maths_tester.h b/chalk/core/tests/kis_integer_maths_tester.h
new file mode 100644
index 00000000..2a9a9a20
--- /dev/null
+++ b/chalk/core/tests/kis_integer_maths_tester.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2005 Adrian Page <[email protected]>
+ *
+ * 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_INTEGER_MATHS_TESTER_H
+#define KIS_INTEGER_MATHS_TESTER_H
+
+#include <kunittest/tester.h>
+
+class KisIntegerMathsTester : public KUnitTest::Tester
+{
+public:
+ void allTests();
+ void UINT8Tests();
+ void UINT16Tests();
+ void conversionTests();
+};
+
+#endif
+