aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsubhransu mohanty <sub.mohanty@samsung.com>2017-11-20 10:04:39 +0900
committersubhransu mohanty <sub.mohanty@samsung.com>2017-11-20 11:26:45 +0900
commit0a4e0de8d7b0c913838ccfe262674350821154dc (patch)
treef3c4d3d2fe4b9fd47d4a194afca4dd1a5759346d
parentscenegraph: added a utility class to handle operation on rle data (diff)
downloadefl-devs/subhransu/scenegraph.tar.gz
scenegraph: added testsuit for region and rle utility classdevs/subhransu/scenegraph
-rw-r--r--src/Makefile_Ector.am2
-rw-r--r--src/tests/scenegraph/suite/CMakeLists.txt2
-rw-r--r--src/tests/scenegraph/suite/scenegraph_suite.c2
-rw-r--r--src/tests/scenegraph/suite/scenegraph_suite.h2
-rw-r--r--src/tests/scenegraph/suite/scenegraph_test_region.c51
-rw-r--r--src/tests/scenegraph/suite/scenegraph_test_rle.c75
6 files changed, 134 insertions, 0 deletions
diff --git a/src/Makefile_Ector.am b/src/Makefile_Ector.am
index 6a08a3dd2e..1c0e2d6f2e 100644
--- a/src/Makefile_Ector.am
+++ b/src/Makefile_Ector.am
@@ -204,6 +204,8 @@ tests_scenegraph_suite_scenegraph_suite_SOURCES = \
tests/scenegraph/suite/scenegraph_suite.c \
tests/scenegraph/suite/scenegraph_suite.h \
tests/scenegraph/suite/scenegraph_test_nodes.c \
+tests/scenegraph/suite/scenegraph_test_region.c \
+tests/scenegraph/suite/scenegraph_test_rle.c \
$(scenegraph_sources)
diff --git a/src/tests/scenegraph/suite/CMakeLists.txt b/src/tests/scenegraph/suite/CMakeLists.txt
index 8b0b839cd2..1d23f4b34b 100644
--- a/src/tests/scenegraph/suite/CMakeLists.txt
+++ b/src/tests/scenegraph/suite/CMakeLists.txt
@@ -2,4 +2,6 @@ set(SOURCES
scenegraph_suite.c
scenegraph_suite.h
scenegraph_test_nodes.c
+ scenegraph_test_region.c
+ scenegraph_test_rle.c
)
diff --git a/src/tests/scenegraph/suite/scenegraph_suite.c b/src/tests/scenegraph/suite/scenegraph_suite.c
index 69c7de9c75..e43fd8f45d 100644
--- a/src/tests/scenegraph/suite/scenegraph_suite.c
+++ b/src/tests/scenegraph/suite/scenegraph_suite.c
@@ -25,6 +25,8 @@
static const Efl_Test_Case etc[] = {
{ "Scenegraph Node", scenegraph_test_nodes },
+ { "Region Utility", scenegraph_test_region },
+ { "Rle Utility", scenegraph_test_rle },
{ NULL, NULL }
};
diff --git a/src/tests/scenegraph/suite/scenegraph_suite.h b/src/tests/scenegraph/suite/scenegraph_suite.h
index 7a51174dee..63725f54aa 100644
--- a/src/tests/scenegraph/suite/scenegraph_suite.h
+++ b/src/tests/scenegraph/suite/scenegraph_suite.h
@@ -4,5 +4,7 @@
#include <check.h>
void scenegraph_test_nodes(TCase *tc);
+void scenegraph_test_rle(TCase *tc);
+void scenegraph_test_region(TCase *tc);
#endif
diff --git a/src/tests/scenegraph/suite/scenegraph_test_region.c b/src/tests/scenegraph/suite/scenegraph_test_region.c
new file mode 100644
index 0000000000..9f0ed758f9
--- /dev/null
+++ b/src/tests/scenegraph/suite/scenegraph_test_region.c
@@ -0,0 +1,51 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <Ector.h>
+
+#include "scenegraph_suite.h"
+#include "../../../static_libs/scenegraph/Scenegraph.h"
+
+static Eina_Bool
+_rect_not_equal(Eina_Rect r1, Eina_Rect r2)
+{
+ if ((r1.x != r2.x) ||
+ (r1.y != r2.y) ||
+ (r1.w != r2.w) ||
+ (r1.h != r2.h) )
+ return EINA_TRUE;
+ else
+ return EINA_FALSE;
+}
+
+START_TEST(scenegraph_region_create)
+{
+ SG_Region r = sg_region_new();
+ r.fn->add_rect(&r, EINA_RECT(0, 0, 10,10));
+
+ SG_Region r1 = r.fn->ref(&r);
+ r1.fn->add_rect(&r1, EINA_RECT(5, 5, 10,10));
+
+ fail_if (r.fn->rect_count(&r) != 1);
+ fail_if (_rect_not_equal(r.fn->rect_at(&r, 0), EINA_RECT(0, 0, 10,10)));
+
+ fail_if (r1.fn->rect_count(&r1) != 3);
+ fail_if (_rect_not_equal(r1.fn->rect_at(&r1, 0), EINA_RECT(0, 0, 10,5)));
+ fail_if (_rect_not_equal(r1.fn->rect_at(&r1, 1), EINA_RECT(0, 5, 15,5)));
+ fail_if (_rect_not_equal(r1.fn->rect_at(&r1, 2), EINA_RECT(5, 10, 10,5)));
+
+ sg_region_free(&r);
+
+ fail_if (r1.fn->rect_count(&r1) != 3);
+ sg_region_free(&r1);
+
+}
+
+END_TEST
+
+void
+scenegraph_test_region(TCase *tc)
+{
+ tcase_add_test(tc, scenegraph_region_create);
+} \ No newline at end of file
diff --git a/src/tests/scenegraph/suite/scenegraph_test_rle.c b/src/tests/scenegraph/suite/scenegraph_test_rle.c
new file mode 100644
index 0000000000..465a804f78
--- /dev/null
+++ b/src/tests/scenegraph/suite/scenegraph_test_rle.c
@@ -0,0 +1,75 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <Ector.h>
+
+#include "scenegraph_suite.h"
+#include "../../../static_libs/scenegraph/Scenegraph.h"
+
+static Eina_Bool
+_rect_not_equal(Eina_Rect r1, Eina_Rect r2)
+{
+ if ((r1.x != r2.x) ||
+ (r1.y != r2.y) ||
+ (r1.w != r2.w) ||
+ (r1.h != r2.h) )
+ return EINA_TRUE;
+ else
+ return EINA_FALSE;
+}
+
+SG_Span SPAN[250];
+SG_Rle
+_rle_create(int x, int y, int w, int h)
+{
+ SG_Rle rle = sg_rle_new();
+ int i;
+ for(i=0; i< h; i++)
+ {
+ SPAN[i].x = x;
+ SPAN[i].len = w;
+ SPAN[i].y = y + i;
+ SPAN[i].coverage = 255;
+ //printf("%d %d %d \n", SPAN[i].y, SPAN[i].x, SPAN[i].len);
+ }
+ rle.fn->append_spans(&rle, SPAN, i);
+
+ return rle;
+}
+
+// void print_rect(Eina_Rect r)
+// {
+// printf("rect : %d %d %d %d \n",r.x, r.y, r.w, r.h);
+// }
+
+START_TEST(scenegraph_rle_create)
+{
+ SG_Rle r = _rle_create(0, 0, 10, 10);
+
+ SG_Rle r1 = r.fn->ref(&r);
+
+ fail_if (_rect_not_equal(r.fn->bounding_rect(&r), EINA_RECT(0, 0, 10,10)));
+ fail_if (_rect_not_equal(r1.fn->bounding_rect(&r1), EINA_RECT(0, 0, 10,10)));
+ fail_if (r.fn->empty(&r));
+
+ r1.fn->intersect_rect(&r1, EINA_RECT(0, 0, 5,5));
+ fail_if (_rect_not_equal(r.fn->bounding_rect(&r), EINA_RECT(0, 0, 10,10)));
+ fail_if (_rect_not_equal(r1.fn->bounding_rect(&r1), EINA_RECT(0, 0, 5,5)));
+
+ r.fn->translate(&r, 2, 2);
+ r.fn->intersect_rect(&r, EINA_RECT(0, 0, 6,6));
+ fail_if (_rect_not_equal(r.fn->bounding_rect(&r), EINA_RECT(0, 0, 4,4)));
+
+ sg_rle_free(&r);
+ sg_rle_free(&r1);
+
+}
+
+END_TEST
+
+void
+scenegraph_test_rle(TCase *tc)
+{
+ tcase_add_test(tc, scenegraph_rle_create);
+} \ No newline at end of file