summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/eina/eina_test_simple_xml_parser.c2
-rw-r--r--src/tests/evas/evas_suite.c1
-rw-r--r--src/tests/evas/evas_suite.h1
-rw-r--r--src/tests/evas/evas_test_map.c128
-rw-r--r--src/tests/evas/meson.build1
5 files changed, 132 insertions, 1 deletions
diff --git a/src/tests/eina/eina_test_simple_xml_parser.c b/src/tests/eina/eina_test_simple_xml_parser.c
index 34c8d69002..5f41d2b038 100644
--- a/src/tests/eina/eina_test_simple_xml_parser.c
+++ b/src/tests/eina/eina_test_simple_xml_parser.c
@@ -237,7 +237,7 @@ EFL_START_TEST(eina_simple_xml_parser_parse_with_custom_callback)
237 237
238 if (buf) 238 if (buf)
239 { 239 {
240 if (fread(buf, 1, sz, f)) 240 if (fread(buf, 1, sz, f) > 0)
241 { 241 {
242 int parse_current_state = simple_xml_parser_current_state_begin; 242 int parse_current_state = simple_xml_parser_current_state_begin;
243 eina_simple_xml_parse(buf, 243 eina_simple_xml_parse(buf,
diff --git a/src/tests/evas/evas_suite.c b/src/tests/evas/evas_suite.c
index 523c10dc76..dedf6841db 100644
--- a/src/tests/evas/evas_suite.c
+++ b/src/tests/evas/evas_suite.c
@@ -25,6 +25,7 @@ static const Efl_Test_Case etc[] = {
25 { "Object Smart", evas_test_object_smart }, 25 { "Object Smart", evas_test_object_smart },
26 { "Events", evas_test_events }, 26 { "Events", evas_test_events },
27 { "Efl Canvas Animation", efl_test_canvas_animation }, 27 { "Efl Canvas Animation", efl_test_canvas_animation },
28 { "Map", evas_test_map },
28 { NULL, NULL } 29 { NULL, NULL }
29}; 30};
30 31
diff --git a/src/tests/evas/evas_suite.h b/src/tests/evas/evas_suite.h
index ec106315b5..af5decaf51 100644
--- a/src/tests/evas/evas_suite.h
+++ b/src/tests/evas/evas_suite.h
@@ -19,5 +19,6 @@ void evas_test_evasgl(TCase *tc);
19void evas_test_object_smart(TCase *tc); 19void evas_test_object_smart(TCase *tc);
20void evas_test_events(TCase *tc); 20void evas_test_events(TCase *tc);
21void efl_test_canvas_animation(TCase *tc); 21void efl_test_canvas_animation(TCase *tc);
22void evas_test_map(TCase *tc);
22 23
23#endif /* _EVAS_SUITE_H */ 24#endif /* _EVAS_SUITE_H */
diff --git a/src/tests/evas/evas_test_map.c b/src/tests/evas/evas_test_map.c
new file mode 100644
index 0000000000..9e1b9ddc78
--- /dev/null
+++ b/src/tests/evas/evas_test_map.c
@@ -0,0 +1,128 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <stdio.h>
6#include <sys/types.h>
7#include <sys/stat.h>
8#include <unistd.h>
9
10#include <Evas.h>
11#include <Ecore_Evas.h>
12#include <Ecore.h>
13
14#include "evas_suite.h"
15#include "evas_tests_helpers.h"
16
17EFL_START_TEST(evas_object_map_api)
18{
19 Evas_Coord x, y, z;
20 int r, g, b, a;
21 Evas_Map *map;
22
23 map = evas_map_new(4);
24 ck_assert_int_eq(evas_map_count_get(map), 4);
25
26 evas_map_alpha_set(map, EINA_TRUE);
27 ck_assert(evas_map_alpha_get(map));
28
29 evas_map_alpha_set(map, EINA_FALSE);
30 ck_assert(!evas_map_alpha_get(map));
31
32 evas_map_smooth_set(map, EINA_TRUE);
33 ck_assert(evas_map_smooth_get(map));
34
35 evas_map_smooth_set(map, EINA_FALSE);
36 ck_assert(!evas_map_smooth_get(map));
37
38 evas_map_util_object_move_sync_set(map, EINA_TRUE);
39 ck_assert(evas_map_util_object_move_sync_get(map));
40
41 evas_map_util_object_move_sync_set(map, EINA_FALSE);
42 ck_assert(!evas_map_util_object_move_sync_get(map));
43
44 evas_map_point_coord_set(map, 0, 10, 20, 30);
45 evas_map_point_coord_get(map, 0, &x, &y, &z);
46 ck_assert((x == 10) && (y == 20) && (z == 30));
47
48 evas_map_point_coord_set(map, 1, 40, 50, 60);
49 evas_map_point_coord_get(map, 1, &x, &y, &z);
50 ck_assert((x == 40) && (y == 50) && (z == 60));
51
52 evas_map_point_coord_set(map, 2, 70, 80, 90);
53 evas_map_point_coord_get(map, 2, &x, &y, &z);
54 ck_assert((x == 70) && (y == 80) && (z == 90));
55
56 evas_map_point_coord_set(map, 3, 100, 110, 120);
57 evas_map_point_coord_get(map, 3, &x, &y, &z);
58 ck_assert((x == 100) && (y == 110) && (z == 120));
59
60 evas_map_point_color_set(map, 0, 0, 0, 0, 255);
61 evas_map_point_color_get(map, 0, &r, &g, &b, &a);
62 ck_assert((r == 0) && (g == 0) && (b == 0) && (a == 255));
63
64 evas_map_point_color_set(map, 1, 255, 0, 0, 255);
65 evas_map_point_color_get(map, 1, &r, &g, &b, &a);
66 ck_assert((r == 255) && (g == 0) && (b == 0) && (a == 255));
67
68 evas_map_point_color_set(map, 2, 255, 255, 0, 255);
69 evas_map_point_color_get(map, 2, &r, &g, &b, &a);
70 ck_assert((r == 255) && (g == 255) && (b == 0) && (a == 255));
71
72 evas_map_point_color_set(map, 3, 255, 255, 255, 255);
73 evas_map_point_color_get(map, 3, &r, &g, &b, &a);
74 ck_assert((r == 255) && (g == 255) && (b == 255) && (a == 255));
75
76 evas_map_free(map);
77}
78EFL_END_TEST
79
80EFL_START_TEST(evas_object_map_rect)
81{
82 Evas *e;
83 Evas_Object *rect;
84 Evas_Map *map;
85 Evas_Coord x, y, z;
86 double u, v;
87
88 e = _setup_evas();
89 rect = evas_object_rectangle_add(e);
90 evas_object_resize(rect, 100, 100);
91
92 map = evas_map_new(4);
93 evas_map_util_points_populate_from_object(map, rect);
94
95 evas_map_point_coord_get(map, 0, &x, &y, &z);
96 ck_assert((x == 0) && (y == 0) && (z == 0));
97
98 evas_map_point_coord_get(map, 1, &x, &y, &z);
99 ck_assert((x == 100) && (y == 0) && (z == 0));
100
101 evas_map_point_coord_get(map, 2, &x, &y, &z);
102 ck_assert((x == 100) && (y == 100) && (z == 0));
103
104 evas_map_point_coord_get(map, 3, &x, &y, &z);
105 ck_assert((x == 0) && (y == 100) && (z == 0));
106
107 evas_map_point_image_uv_get(map, 0, &u, &v);
108 ck_assert((u == 0) && (v == 0));
109
110 evas_map_point_image_uv_get(map, 1, &u, &v);
111 ck_assert((u == 100) && (v == 0));
112
113 evas_map_point_image_uv_get(map, 2, &u, &v);
114 ck_assert((u == 100) && (v == 100));
115
116 evas_map_point_image_uv_get(map, 3, &u, &v);
117 ck_assert((u == 0) && (v == 100));
118
119 evas_map_free(map);
120 evas_free(e);
121}
122EFL_END_TEST
123
124void evas_test_map(TCase *tc)
125{
126 tcase_add_test(tc, evas_object_map_api);
127 tcase_add_test(tc, evas_object_map_rect);
128}
diff --git a/src/tests/evas/meson.build b/src/tests/evas/meson.build
index bee736035f..01681ffb1d 100644
--- a/src/tests/evas/meson.build
+++ b/src/tests/evas/meson.build
@@ -21,6 +21,7 @@ evas_suite_src = [
21 'efl_test_canvas2.c', 21 'efl_test_canvas2.c',
22 'efl_test_canvas3.c', 22 'efl_test_canvas3.c',
23 'efl_canvas_animation.c', 23 'efl_canvas_animation.c',
24 'evas_test_map.c',
24] 25]
25 26
26evas_suite = executable('evas_suite', 27evas_suite = executable('evas_suite',