summaryrefslogtreecommitdiff
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
parentd64ef328f3712a012b3b215b6d0de22486b43290 (diff)
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 = \
204tests/scenegraph/suite/scenegraph_suite.c \ 204tests/scenegraph/suite/scenegraph_suite.c \
205tests/scenegraph/suite/scenegraph_suite.h \ 205tests/scenegraph/suite/scenegraph_suite.h \
206tests/scenegraph/suite/scenegraph_test_nodes.c \ 206tests/scenegraph/suite/scenegraph_test_nodes.c \
207tests/scenegraph/suite/scenegraph_test_region.c \
208tests/scenegraph/suite/scenegraph_test_rle.c \
207$(scenegraph_sources) 209$(scenegraph_sources)
208 210
209 211
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
2 scenegraph_suite.c 2 scenegraph_suite.c
3 scenegraph_suite.h 3 scenegraph_suite.h
4 scenegraph_test_nodes.c 4 scenegraph_test_nodes.c
5 scenegraph_test_region.c
6 scenegraph_test_rle.c
5) 7)
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 @@
25 25
26static const Efl_Test_Case etc[] = { 26static const Efl_Test_Case etc[] = {
27 { "Scenegraph Node", scenegraph_test_nodes }, 27 { "Scenegraph Node", scenegraph_test_nodes },
28 { "Region Utility", scenegraph_test_region },
29 { "Rle Utility", scenegraph_test_rle },
28 { NULL, NULL } 30 { NULL, NULL }
29}; 31};
30 32
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 @@
4#include <check.h> 4#include <check.h>
5 5
6void scenegraph_test_nodes(TCase *tc); 6void scenegraph_test_nodes(TCase *tc);
7void scenegraph_test_rle(TCase *tc);
8void scenegraph_test_region(TCase *tc);
7 9
8#endif 10#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 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <Ector.h>
6
7#include "scenegraph_suite.h"
8#include "../../../static_libs/scenegraph/Scenegraph.h"
9
10static Eina_Bool
11_rect_not_equal(Eina_Rect r1, Eina_Rect r2)
12{
13 if ((r1.x != r2.x) ||
14 (r1.y != r2.y) ||
15 (r1.w != r2.w) ||
16 (r1.h != r2.h) )
17 return EINA_TRUE;
18 else
19 return EINA_FALSE;
20}
21
22START_TEST(scenegraph_region_create)
23{
24 SG_Region r = sg_region_new();
25 r.fn->add_rect(&r, EINA_RECT(0, 0, 10,10));
26
27 SG_Region r1 = r.fn->ref(&r);
28 r1.fn->add_rect(&r1, EINA_RECT(5, 5, 10,10));
29
30 fail_if (r.fn->rect_count(&r) != 1);
31 fail_if (_rect_not_equal(r.fn->rect_at(&r, 0), EINA_RECT(0, 0, 10,10)));
32
33 fail_if (r1.fn->rect_count(&r1) != 3);
34 fail_if (_rect_not_equal(r1.fn->rect_at(&r1, 0), EINA_RECT(0, 0, 10,5)));
35 fail_if (_rect_not_equal(r1.fn->rect_at(&r1, 1), EINA_RECT(0, 5, 15,5)));
36 fail_if (_rect_not_equal(r1.fn->rect_at(&r1, 2), EINA_RECT(5, 10, 10,5)));
37
38 sg_region_free(&r);
39
40 fail_if (r1.fn->rect_count(&r1) != 3);
41 sg_region_free(&r1);
42
43}
44
45END_TEST
46
47void
48scenegraph_test_region(TCase *tc)
49{
50 tcase_add_test(tc, scenegraph_region_create);
51} \ 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 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <Ector.h>
6
7#include "scenegraph_suite.h"
8#include "../../../static_libs/scenegraph/Scenegraph.h"
9
10static Eina_Bool
11_rect_not_equal(Eina_Rect r1, Eina_Rect r2)
12{
13 if ((r1.x != r2.x) ||
14 (r1.y != r2.y) ||
15 (r1.w != r2.w) ||
16 (r1.h != r2.h) )
17 return EINA_TRUE;
18 else
19 return EINA_FALSE;
20}
21
22SG_Span SPAN[250];
23SG_Rle
24_rle_create(int x, int y, int w, int h)
25{
26 SG_Rle rle = sg_rle_new();
27 int i;
28 for(i=0; i< h; i++)
29 {
30 SPAN[i].x = x;
31 SPAN[i].len = w;
32 SPAN[i].y = y + i;
33 SPAN[i].coverage = 255;
34 //printf("%d %d %d \n", SPAN[i].y, SPAN[i].x, SPAN[i].len);
35 }
36 rle.fn->append_spans(&rle, SPAN, i);
37
38 return rle;
39}
40
41// void print_rect(Eina_Rect r)
42// {
43// printf("rect : %d %d %d %d \n",r.x, r.y, r.w, r.h);
44// }
45
46START_TEST(scenegraph_rle_create)
47{
48 SG_Rle r = _rle_create(0, 0, 10, 10);
49
50 SG_Rle r1 = r.fn->ref(&r);
51
52 fail_if (_rect_not_equal(r.fn->bounding_rect(&r), EINA_RECT(0, 0, 10,10)));
53 fail_if (_rect_not_equal(r1.fn->bounding_rect(&r1), EINA_RECT(0, 0, 10,10)));
54 fail_if (r.fn->empty(&r));
55
56 r1.fn->intersect_rect(&r1, EINA_RECT(0, 0, 5,5));
57 fail_if (_rect_not_equal(r.fn->bounding_rect(&r), EINA_RECT(0, 0, 10,10)));
58 fail_if (_rect_not_equal(r1.fn->bounding_rect(&r1), EINA_RECT(0, 0, 5,5)));
59
60 r.fn->translate(&r, 2, 2);
61 r.fn->intersect_rect(&r, EINA_RECT(0, 0, 6,6));
62 fail_if (_rect_not_equal(r.fn->bounding_rect(&r), EINA_RECT(0, 0, 4,4)));
63
64 sg_rle_free(&r);
65 sg_rle_free(&r1);
66
67}
68
69END_TEST
70
71void
72scenegraph_test_rle(TCase *tc)
73{
74 tcase_add_test(tc, scenegraph_rle_create);
75} \ No newline at end of file