summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile_Edje.am6
-rw-r--r--src/tests/edje/edje_suite.c37
-rw-r--r--src/tests/edje/edje_suite.h9
-rw-r--r--src/tests/edje/edje_test_container.c282
-rw-r--r--src/tests/edje/edje_test_edje.c927
-rw-r--r--src/tests/edje/edje_test_features.c229
-rw-r--r--src/tests/edje/edje_test_signal.c240
-rw-r--r--src/tests/edje/edje_test_swallow.c104
-rw-r--r--src/tests/edje/edje_test_text.c120
-rw-r--r--src/tests/edje/edje_tests_helpers.h42
10 files changed, 1041 insertions, 955 deletions
diff --git a/src/Makefile_Edje.am b/src/Makefile_Edje.am
index 745da03..fc83eaa 100644
--- a/src/Makefile_Edje.am
+++ b/src/Makefile_Edje.am
@@ -283,7 +283,6 @@ bin/edje/edje_convert.c \
283bin/edje/edje_data_convert.c \ 283bin/edje/edje_data_convert.c \
284bin/edje/edje_convert_main.c \ 284bin/edje/edje_convert_main.c \
285lib/edje/edje_convert.c \ 285lib/edje/edje_convert.c \
286tests/edje/edje_tests_helpers.h \
287tests/edje/data/complex_layout.edc \ 286tests/edje/data/complex_layout.edc \
288tests/edje/data/test_layout.edc \ 287tests/edje/data/test_layout.edc \
289tests/edje/data/test_parens.edc \ 288tests/edje/data/test_parens.edc \
@@ -318,7 +317,12 @@ TESTS += tests/edje/edje_suite
318 317
319tests_edje_edje_suite_SOURCES = \ 318tests_edje_edje_suite_SOURCES = \
320tests/edje/edje_suite.c \ 319tests/edje/edje_suite.c \
320tests/edje/edje_test_container.c \
321tests/edje/edje_test_edje.c \ 321tests/edje/edje_test_edje.c \
322tests/edje/edje_test_features.c \
323tests/edje/edje_test_signal.c \
324tests/edje/edje_test_swallow.c \
325tests/edje/edje_test_text.c \
322tests/edje/edje_suite.h 326tests/edje/edje_suite.h
323 327
324tests/edje/data/%.edj: tests/edje/data/%.edc bin/edje/edje_cc${EXEEXT} 328tests/edje/data/%.edj: tests/edje/data/%.edc bin/edje/edje_cc${EXEEXT}
diff --git a/src/tests/edje/edje_suite.c b/src/tests/edje/edje_suite.c
index 80cb84a..e8f39cf 100644
--- a/src/tests/edje/edje_suite.c
+++ b/src/tests/edje/edje_suite.c
@@ -4,21 +4,56 @@
4 4
5#include "edje_suite.h" 5#include "edje_suite.h"
6#include "../efl_check.h" 6#include "../efl_check.h"
7#include <Edje.h> 7#include <Ecore_Evas.h>
8 8
9static const Efl_Test_Case etc[] = { 9static const Efl_Test_Case etc[] = {
10 { "Edje", edje_test_edje }, 10 { "Edje", edje_test_edje },
11 { "Container", edje_test_container },
12 { "Features", edje_test_features },
13 { "Signal", edje_test_signal },
14 { "Swallow", edje_test_swallow },
15 { "Text", edje_test_text },
11 { NULL, NULL } 16 { NULL, NULL }
12}; 17};
13 18
19const char *
20test_layout_get(const char *name)
21{
22 static char filename[PATH_MAX];
23
24 snprintf(filename, PATH_MAX, TESTS_BUILD_DIR"/data/%s", name);
25
26 return filename;
27}
28
29Evas *
30_setup_evas(void)
31{
32 Evas *evas;
33 Evas_Engine_Info *einfo;
34
35 evas = evas_new();
36
37 evas_output_method_set(evas, evas_render_method_lookup("buffer"));
38 einfo = evas_engine_info_get(evas);
39 evas_engine_info_set(evas, einfo);
40
41 evas_output_size_set(evas, 500, 500);
42 evas_output_viewport_set(evas, 0, 0, 500, 500);
43
44 return evas;
45}
46
14SUITE_INIT(edje) 47SUITE_INIT(edje)
15{ 48{
49 ck_assert_int_eq(ecore_evas_init(), 1);
16 ck_assert_int_eq(edje_init(), 1); 50 ck_assert_int_eq(edje_init(), 1);
17} 51}
18 52
19SUITE_SHUTDOWN(edje) 53SUITE_SHUTDOWN(edje)
20{ 54{
21 ck_assert_int_eq(edje_shutdown(), 0); 55 ck_assert_int_eq(edje_shutdown(), 0);
56 ck_assert_int_eq(ecore_evas_shutdown(), 0);
22} 57}
23 58
24int 59int
diff --git a/src/tests/edje/edje_suite.h b/src/tests/edje/edje_suite.h
index a6f1354..6f4ee5b 100644
--- a/src/tests/edje/edje_suite.h
+++ b/src/tests/edje/edje_suite.h
@@ -3,7 +3,16 @@
3 3
4#include <check.h> 4#include <check.h>
5#include "../efl_check.h" 5#include "../efl_check.h"
6#include <Edje.h>
7Evas *_setup_evas(void);
8const char *test_layout_get(const char *name);
9
6void edje_test_edje(TCase *tc); 10void edje_test_edje(TCase *tc);
11void edje_test_container(TCase *tc);
12void edje_test_features(TCase *tc);
13void edje_test_signal(TCase *tc);
14void edje_test_swallow(TCase *tc);
15void edje_test_text(TCase *tc);
7 16
8 17
9#endif /* _EDJE_SUITE_H */ 18#endif /* _EDJE_SUITE_H */
diff --git a/src/tests/edje/edje_test_container.c b/src/tests/edje/edje_test_container.c
new file mode 100644
index 0000000..018de4d
--- /dev/null
+++ b/src/tests/edje/edje_test_container.c
@@ -0,0 +1,282 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <unistd.h>
6#include <stdio.h>
7
8#define EFL_GFX_FILTER_BETA
9#define EFL_CANVAS_LAYOUT_BETA
10
11#include "edje_suite.h"
12
13#define EVAS_DATA_DIR TESTS_SRC_DIR "/../../lib/evas"
14
15
16
17EFL_START_TEST(edje_test_box)
18{
19 Evas *evas;
20 Evas_Object *obj, *sobj, *sobjs[5];
21 const Evas_Object *box;
22 Eina_Iterator *it;
23 int i;
24
25 evas = _setup_evas();
26
27 obj = edje_object_add(evas);
28 fail_unless(edje_object_file_set(obj, test_layout_get("test_box.edj"), "test_group"));
29
30 for (i = 0; i < 5; i++)
31 {
32 sobjs[i] = evas_object_rectangle_add(evas);
33 fail_if(!sobjs[i]);
34 }
35
36 edje_object_part_box_append(obj, "box", sobjs[3]);
37 edje_object_part_box_prepend(obj, "box", sobjs[1]);
38 edje_object_part_box_insert_before(obj, "box", sobjs[0], sobjs[1]);
39 edje_object_part_box_insert_after(obj, "box", sobjs[4], sobjs[3]);
40 edje_object_part_box_insert_at(obj, "box", sobjs[2], 2);
41
42 edje_object_freeze(obj);
43 box = edje_object_part_object_get(obj, "box");
44 edje_object_thaw(obj);
45 it = evas_object_box_iterator_new(box);
46
47 i = 0;
48 EINA_ITERATOR_FOREACH(it, sobj)
49 {
50 fail_if(sobj != sobjs[i++]);
51 }
52 eina_iterator_free(it);
53
54 evas_free(evas);
55}
56EFL_END_TEST
57
58EFL_START_TEST(edje_test_box_eoapi)
59{
60 Evas *evas;
61 Evas_Object *obj, *sobj, *sobjs[5];
62 Eina_Iterator *it;
63 int i;
64
65 evas = _setup_evas();
66
67 obj = edje_object_add(evas);
68 fail_unless(edje_object_file_set(obj, test_layout_get("test_box.edj"), "test_group"));
69
70 for (i = 0; i < 5; i++)
71 {
72 sobjs[i] = evas_object_rectangle_add(evas);
73 fail_if(!sobjs[i]);
74 }
75
76 /* same test case as legacy api above */
77 efl_pack_end(efl_part(obj, "box"), sobjs[3]);
78 efl_pack_begin(efl_part(obj, "box"), sobjs[1]);
79 efl_pack_before(efl_part(obj, "box"), sobjs[0], sobjs[1]);
80 efl_pack_after(efl_part(obj, "box"), sobjs[4], sobjs[3]);
81 efl_pack_at(efl_part(obj, "box"), sobjs[2], 2);
82 fail_if(efl_content_count(efl_part(obj, "box")) != 5);
83
84 it = efl_content_iterate(efl_part(obj, "box"));
85 i = 0;
86 EINA_ITERATOR_FOREACH(it, sobj)
87 fail_if(sobj != sobjs[i++]);
88 fail_if(i != 5);
89 eina_iterator_free(it);
90
91 /* clear up and test a bit more */
92 efl_pack_unpack_all(efl_part(obj, "box"));
93 fail_if(efl_content_count(efl_part(obj, "box")) != 0);
94
95 efl_pack(efl_part(obj, "box"), sobjs[1]);
96 efl_pack_at(efl_part(obj, "box"), sobjs[0], 0);
97 efl_pack_at(efl_part(obj, "box"), sobjs[2], -1);
98 it = efl_content_iterate(efl_part(obj, "box"));
99 i = 0;
100 EINA_ITERATOR_FOREACH(it, sobj)
101 fail_if(sobj != sobjs[i++]);
102 fail_if(i != 3);
103 eina_iterator_free(it);
104
105 fail_if(!efl_content_remove(efl_part(obj, "box"), sobjs[0]));
106 fail_if(efl_content_count(efl_part(obj, "box")) != 2);
107 fail_if(!efl_pack_unpack_at(efl_part(obj, "box"), 1));
108 fail_if(efl_content_count(efl_part(obj, "box")) != 1);
109 fail_if(efl_pack_index_get(efl_part(obj, "box"), sobjs[1]) != 0);
110
111 efl_pack_clear(efl_part(obj, "box"));
112 fail_if(efl_content_count(efl_part(obj, "box")) != 0);
113
114 evas_free(evas);
115}
116EFL_END_TEST
117
118EFL_START_TEST(edje_test_table)
119{
120 Evas *evas;
121 Evas_Object *obj, *sobj, *sobjs[4];
122 int i, k, l, cols, rows;
123
124 evas = _setup_evas();
125
126 obj = edje_object_add(evas);
127 fail_unless(edje_object_file_set(obj, test_layout_get("test_table.edj"), "test_group"));
128
129 /* check items from EDC */
130 for (l = 0; l < 2; l++)
131 for (k = 0; k < 2; k++)
132 {
133 const char *txt;
134 char buf[20];
135
136 /* items have a text part "text" containing their position */
137 sprintf(buf, "%d,%d", k, l);
138 sobj = edje_object_part_table_child_get(obj, "table", k, l);
139 fail_if(!sobj);
140 txt = edje_object_part_text_get(sobj, "text");
141 fail_if(!txt);
142 fail_if(strcmp(txt, buf) != 0);
143 }
144
145 /* Add more items */
146 for (l = 0; l < 2; l++)
147 for (k = 0; k < 2; k++)
148 {
149 i = l*2 + k;
150 sobjs[i] = evas_object_rectangle_add(evas);
151 fail_if(!sobjs[i]);
152 edje_object_part_table_pack(obj, "table", sobjs[i], k, l + 2, 1, 1);
153 }
154
155 for (l = 0; l < 2; l++)
156 for (k = 0; k < 2; k++)
157 {
158 i = l*2 + k;
159 sobj = edje_object_part_table_child_get(obj, "table", k, l + 2);
160 fail_if(sobj != sobjs[i]);
161 }
162
163 /* table size and clear */
164 edje_object_part_table_col_row_size_get(obj, "table", &cols, &rows);
165 fail_if(cols != 2);
166 fail_if(rows != 4);
167
168 edje_object_part_table_clear(obj, "table", EINA_TRUE);
169
170 edje_object_part_table_col_row_size_get(obj, "table", &cols, &rows);
171 fail_if(cols != 2);
172 fail_if(rows != 2);
173
174 for (l = 0; l < 2; l++)
175 for (k = 0; k < 2; k++)
176 {
177 const char *txt;
178 char buf[20];
179
180 /* items have a text part "text" containing their position */
181 sprintf(buf, "%d,%d", k, l);
182 sobj = edje_object_part_table_child_get(obj, "table", k, l);
183 fail_if(!sobj);
184 txt = edje_object_part_text_get(sobj, "text");
185 fail_if(!txt);
186 fail_if(strcmp(txt, buf) != 0);
187 }
188
189 evas_free(evas);
190}
191EFL_END_TEST
192
193EFL_START_TEST(edje_test_table_eoapi)
194{
195 Evas *evas;
196 Evas_Object *obj, *sobj, *sobjs[4], *proxy;
197 Eina_Iterator *it;
198 int i, k, l, cs, rs, cols, rows;
199
200 evas = _setup_evas();
201
202 obj = edje_object_add(evas);
203 fail_unless(edje_object_file_set(obj, test_layout_get("test_table.edj"), "test_group"));
204
205 /* check items from EDC */
206 fail_if(efl_content_count(efl_part(obj, "table")) != 4);
207 for (l = 0; l < 2; l++)
208 for (k = 0; k < 2; k++)
209 {
210 const char *txt;
211 char buf[20];
212
213 /* items have a text part "text" containing their position */
214 sprintf(buf, "%d,%d", k, l);
215 sobj = efl_pack_table_content_get(efl_part(obj, "table"), k, l);
216 fail_if(!sobj);
217 //txt = efl_part_text_get(sobj, "text");
218 txt = edje_object_part_text_get(sobj, "text");
219 fail_if(!txt);
220 fail_if(strcmp(txt, buf) != 0);
221 }
222
223 /* Add more items */
224 for (l = 0; l < 2; l++)
225 for (k = 0; k < 2; k++)
226 {
227 i = l*2 + k;
228 sobjs[i] = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas);
229 fail_if(!sobjs[i]);
230 efl_pack_table(efl_part(obj, "table"), sobjs[i], k, l + 2, 1, 1);
231 }
232
233 fail_if(efl_content_count(efl_part(obj, "table")) != 8);
234
235 i = 0;
236 it = efl_content_iterate(efl_part(obj, "table"));
237 EINA_ITERATOR_FOREACH(it, sobj)
238 {
239 efl_pack_table_position_get(efl_part(obj, "table"), sobj, &k, &l, &cs, &rs);
240 fail_if(cs != 1);
241 fail_if(rs != 1);
242 if (l >= 2)
243 fail_if(sobj != sobjs[(l - 2)*2 + k]);
244 i++;
245 }
246 eina_iterator_free(it);
247 fail_if(i != 8);
248
249 /* table size and clear */
250 efl_pack_table_size_get(efl_part(obj, "table"), &cols, &rows);
251 fail_if(cols != 2);
252 fail_if(rows != 4);
253
254 efl_pack_clear(efl_part(obj, "table"));
255 fail_if(efl_content_count(efl_part(obj, "table")) != 4);
256
257 efl_pack_table_size_get(efl_part(obj, "table"), &cols, &rows);
258 fail_if(cols != 2);
259 fail_if(rows != 2);
260
261 /* test multiple ops on a proxy object */
262 proxy = efl_ref(efl_part(obj, "table"));
263 fail_if(!proxy);
264 fail_if(!efl_pack_clear(proxy));
265 fail_if(efl_content_count(efl_part(obj, "table")) != 4);
266 fail_if(!efl_pack_clear(proxy));
267 fail_if(efl_content_count(efl_part(obj, "table2")) != 1);
268 fail_if(efl_content_count(proxy) != 4);
269 efl_del(proxy);
270
271 evas_free(evas);
272}
273EFL_END_TEST
274
275
276void edje_test_container(TCase *tc)
277{
278 tcase_add_test(tc, edje_test_box);
279 tcase_add_test(tc, edje_test_box_eoapi);
280 tcase_add_test(tc, edje_test_table);
281 tcase_add_test(tc, edje_test_table_eoapi);
282}
diff --git a/src/tests/edje/edje_test_edje.c b/src/tests/edje/edje_test_edje.c
index b8c8179..15e42f1 100644
--- a/src/tests/edje/edje_test_edje.c
+++ b/src/tests/edje/edje_test_edje.c
@@ -8,11 +8,7 @@
8#define EFL_GFX_FILTER_BETA 8#define EFL_GFX_FILTER_BETA
9#define EFL_CANVAS_LAYOUT_BETA 9#define EFL_CANVAS_LAYOUT_BETA
10 10
11#include <Eina.h>
12#include <Edje.h>
13
14#include "edje_suite.h" 11#include "edje_suite.h"
15#include "edje_tests_helpers.h"
16 12
17#define EVAS_DATA_DIR TESTS_SRC_DIR "/../../lib/evas" 13#define EVAS_DATA_DIR TESTS_SRC_DIR "/../../lib/evas"
18 14
@@ -23,7 +19,7 @@ EFL_END_TEST
23 19
24EFL_START_TEST(edje_test_edje_load) 20EFL_START_TEST(edje_test_edje_load)
25{ 21{
26 Evas *evas = EDJE_TEST_INIT_EVAS(); 22 Evas *evas = _setup_evas();
27 Edje_Load_Error error; 23 Edje_Load_Error error;
28 Evas_Object *obj; 24 Evas_Object *obj;
29 25
@@ -32,23 +28,13 @@ EFL_START_TEST(edje_test_edje_load)
32 error = edje_object_load_error_get(obj); 28 error = edje_object_load_error_get(obj);
33 fail_if(error != EDJE_LOAD_ERROR_DOES_NOT_EXIST); 29 fail_if(error != EDJE_LOAD_ERROR_DOES_NOT_EXIST);
34 30
35 EDJE_TEST_FREE_EVAS(); 31 evas_free(evas);
36} 32}
37EFL_END_TEST 33EFL_END_TEST
38 34
39static const char *
40test_layout_get(const char *name)
41{
42 static char filename[PATH_MAX];
43
44 snprintf(filename, PATH_MAX, TESTS_BUILD_DIR"/data/%s", name);
45
46 return filename;
47}
48
49EFL_START_TEST(edje_test_load_simple_layout) 35EFL_START_TEST(edje_test_load_simple_layout)
50{ 36{
51 Evas *evas = EDJE_TEST_INIT_EVAS(); 37 Evas *evas = _setup_evas();
52 Evas_Object *obj; 38 Evas_Object *obj;
53 39
54 obj = edje_object_add(evas); 40 obj = edje_object_add(evas);
@@ -58,7 +44,7 @@ EFL_START_TEST(edje_test_load_simple_layout)
58 fail_unless(edje_object_part_exists(obj, "background")); 44 fail_unless(edje_object_part_exists(obj, "background"));
59 45
60 46
61 EDJE_TEST_FREE_EVAS(); 47 evas_free(evas);
62} 48}
63EFL_END_TEST 49EFL_END_TEST
64 50
@@ -66,7 +52,7 @@ EFL_START_TEST(edje_test_simple_layout_geometry)
66{ 52{
67 int x, y, w, h; 53 int x, y, w, h;
68 int r, g, b, a; 54 int r, g, b, a;
69 Evas *evas = EDJE_TEST_INIT_EVAS(); 55 Evas *evas = _setup_evas();
70 Evas_Object *obj; 56 Evas_Object *obj;
71 const Evas_Object *bg; 57 const Evas_Object *bg;
72 58
@@ -87,14 +73,14 @@ EFL_START_TEST(edje_test_simple_layout_geometry)
87 evas_object_color_get(bg, &r, &g, &b, &a); 73 evas_object_color_get(bg, &r, &g, &b, &a);
88 fail_if(r != 255 || g != 255 || b != 255 || a != 255); 74 fail_if(r != 255 || g != 255 || b != 255 || a != 255);
89 75
90 EDJE_TEST_FREE_EVAS(); 76 evas_free(evas);
91} 77}
92EFL_END_TEST 78EFL_END_TEST
93 79
94EFL_START_TEST(edje_test_complex_layout) 80EFL_START_TEST(edje_test_complex_layout)
95{ 81{
96 int x, y, w, h; 82 int x, y, w, h;
97 Evas *evas = EDJE_TEST_INIT_EVAS(); 83 Evas *evas = _setup_evas();
98 Evas_Object *obj; 84 Evas_Object *obj;
99 85
100 obj = edje_object_add(evas); 86 obj = edje_object_add(evas);
@@ -135,14 +121,14 @@ EFL_START_TEST(edje_test_complex_layout)
135 fail_if(x != 5 || y != 500+2); 121 fail_if(x != 5 || y != 500+2);
136 fail_if(w != 1000-5-5 + 1 || h != 500-5-2 + 1); 122 fail_if(w != 1000-5-5 + 1 || h != 500-5-2 + 1);
137 123
138 EDJE_TEST_FREE_EVAS(); 124 evas_free(evas);
139} 125}
140EFL_END_TEST 126EFL_END_TEST
141 127
142EFL_START_TEST(edje_test_calculate_parens) 128EFL_START_TEST(edje_test_calculate_parens)
143{ 129{
144 int x, y, w, h; 130 int x, y, w, h;
145 Evas *evas = EDJE_TEST_INIT_EVAS(); 131 Evas *evas = _setup_evas();
146 Evas_Object *obj; 132 Evas_Object *obj;
147 Eina_Rect rect; 133 Eina_Rect rect;
148 134
@@ -158,301 +144,13 @@ EFL_START_TEST(edje_test_calculate_parens)
158 edje_object_part_geometry_get(obj, "background", &x, &y, &w, &h); 144 edje_object_part_geometry_get(obj, "background", &x, &y, &w, &h);
159 fail_if(x != 0 || y != 0 || w != 100 || h != 100); 145 fail_if(x != 0 || y != 0 || w != 100 || h != 100);
160 146
161 EDJE_TEST_FREE_EVAS(); 147 evas_free(evas);
162}
163EFL_END_TEST
164
165EFL_START_TEST(edje_test_masking)
166{
167 int x, y, w, h;
168 Evas *evas = EDJE_TEST_INIT_EVAS();
169 const Evas_Object *sub, *clip2, *clip;
170 Evas_Object *obj;
171
172 obj = edje_object_add(evas);
173 fail_unless(edje_object_file_set(obj, test_layout_get("test_masking.edj"), "test_group"));
174
175 evas_object_resize(obj, 100, 100);
176 edje_object_part_geometry_get(obj, "background", &x, &y, &w, &h);
177 fail_if(x != 0 || y != 0 || w != 100 || h != 100);
178
179 edje_object_freeze(obj);
180 clip = edje_object_part_object_get(obj, "clip2");
181 edje_object_thaw(obj);
182 fail_if(!clip);
183
184 /* check value of no_render flag as seen from evas land */
185 edje_object_freeze(obj);
186 sub = edje_object_part_object_get(obj, "mask");
187 edje_object_thaw(obj);
188 fail_if(!efl_canvas_object_no_render_get(sub));
189
190 /* check that text has a clip (based on description.clip_to) */
191 edje_object_freeze(obj);
192 sub = edje_object_part_object_get(obj, "text");
193 edje_object_thaw(obj);
194 fail_if(!efl_canvas_object_clip_get(sub));
195
196 /* test description.clip_to override */
197 edje_object_freeze(obj);
198 sub = edje_object_part_object_get(obj, "noclip");
199 edje_object_thaw(obj);
200 clip2 = efl_canvas_object_clip_get(sub);
201 fail_if(clip != clip2);
202
203 EDJE_TEST_FREE_EVAS();
204}
205EFL_END_TEST
206
207EFL_START_TEST(edje_test_filters)
208{
209 Evas *evas = EDJE_TEST_INIT_EVAS();
210 const Evas_Object *text, *sub;
211 Evas_Object *obj, *src = NULL;
212 const char *prg, *name;
213
214 setenv("EVAS_DATA_DIR", EVAS_DATA_DIR, 1);
215
216 obj = edje_object_add(evas);
217 fail_unless(edje_object_file_set(obj, test_layout_get("test_filters.edj"), "test_group"));
218
219 evas_object_resize(obj, 200, 200);
220
221 /* check value of no_render flag as seen from evas land */
222 edje_object_freeze(obj);
223 sub = edje_object_part_object_get(obj, "mask");
224 edje_object_thaw(obj);
225 fail_if(!efl_canvas_object_no_render_get(sub));
226
227 /* check no_render inheritance */
228 edje_object_freeze(obj);
229 sub = edje_object_part_object_get(obj, "mask2");
230 edje_object_thaw(obj);
231 fail_if(efl_canvas_object_no_render_get(sub));
232 edje_object_freeze(obj);
233 sub = edje_object_part_object_get(obj, "mask3");
234 edje_object_thaw(obj);
235 fail_if(!efl_canvas_object_no_render_get(sub));
236
237 /* text part: check filter status */
238 edje_object_freeze(obj);
239 text = edje_object_part_object_get(obj, "text");
240 edje_object_thaw(obj);
241 fail_if(!text);
242
243 efl_gfx_filter_program_get(text, &prg, &name);
244 fail_if(!prg);
245 fail_if(!name || strcmp(name, "filterfile"));
246
247 src = efl_gfx_filter_source_get(text, "mask");
248 fail_if(!src);
249
250 // TODO: Verify properly that the filter runs well
251
252 EDJE_TEST_FREE_EVAS();
253}
254EFL_END_TEST
255
256EFL_START_TEST(edje_test_snapshot)
257{
258 Evas *evas = EDJE_TEST_INIT_EVAS();
259 const Evas_Object *sub;
260 Evas_Object *obj;
261
262 setenv("EVAS_DATA_DIR", EVAS_DATA_DIR, 1);
263
264 obj = edje_object_add(evas);
265 fail_unless(edje_object_file_set(obj, test_layout_get("test_snapshot.edj"), "test_group"));
266
267 evas_object_resize(obj, 200, 200);
268
269 /* check value of no_render flag as seen from evas land */
270 edje_object_freeze(obj);
271 sub = edje_object_part_object_get(obj, "snap");
272 edje_object_thaw(obj);
273 fail_if(!efl_isa(sub, EFL_CANVAS_SNAPSHOT_CLASS) &&
274 !evas_object_image_snapshot_get(sub));
275
276 // TODO: Verify that evas snapshot actually works (and has a filter)
277
278 EDJE_TEST_FREE_EVAS();
279}
280EFL_END_TEST
281
282EFL_START_TEST(edje_test_size_class)
283{
284 int minw, minh, minw2, minh2;
285 Evas *evas = EDJE_TEST_INIT_EVAS();
286 Eina_List *l;
287 Eina_Stringshare *name;
288 Evas_Object *obj, *obj2;
289 Eina_Bool b;
290
291 obj = edje_object_add(evas);
292 fail_unless(edje_object_file_set(obj, test_layout_get("test_size_class.edj"), "test_group"));
293
294 obj2 = edje_object_add(evas);
295 fail_unless(edje_object_file_set(obj2, test_layout_get("test_size_class.edj"), "test_group"));
296
297 evas_object_resize(obj, 200, 200);
298 evas_object_resize(obj2, 200, 200);
299
300 /* check predefined min size of rect part by edc */
301 edje_object_part_geometry_get(obj, "rect", NULL, NULL, &minw, &minh);
302 fail_if(minw != 50 || minh != 50);
303
304 /* check that edje_size_class_set works */
305 b = edje_size_class_set("rect_size", 100, 100, -1, -1);
306 edje_object_part_geometry_get(obj, "rect", NULL, NULL, &minw, &minh);
307 edje_object_part_geometry_get(obj2, "rect", NULL, NULL, &minw2, &minh2);
308 fail_if(!b || minw != 100 || minh != 100 || minw2 != 100 || minh2 != 100);
309
310 /* check that edje_size_class_get works */
311 b = edje_size_class_get("rect_size", &minw, &minh, NULL, NULL);
312 fail_if(!b || minw != 100 || minh != 100);
313
314 /* check that edje_size_class_list works */
315 l = edje_size_class_list();
316 EINA_LIST_FREE(l, name)
317 {
318 fail_if(strcmp(name, "rect_size"));
319 eina_stringshare_del(name);
320 }
321
322 /* check that edje_object_size_class_set works */
323 b = edje_object_size_class_set(obj, "rect_size", 150, 150, -1, -1);
324 edje_object_part_geometry_get(obj, "rect", NULL, NULL, &minw, &minh);
325 edje_object_part_geometry_get(obj2, "rect", NULL, NULL, &minw2, &minh2);
326 fail_if(!b || minw != 150 || minh != 150 || minw2 != 100 || minh2 != 100);
327
328 /* check that edje_object_size_class_get works */
329 b = edje_object_size_class_get(obj, "rect_size", &minw, &minh, NULL, NULL);
330 fail_if(!b || minw != 150 || minh != 150);
331
332 EDJE_TEST_FREE_EVAS();
333}
334EFL_END_TEST
335
336EFL_START_TEST(edje_test_color_class)
337{
338 Evas *evas = EDJE_TEST_INIT_EVAS();
339
340 Eina_File *f;
341 Eina_Iterator *it;
342 Edje_Color_Class *itcc, *cc = NULL;
343 char *filename;
344
345 filename = realpath(test_layout_get("test_color_class.edj"), NULL);
346 fail_if(!filename);
347
348 f = eina_file_open(filename, EINA_FALSE);
349 fail_if(!f);
350
351 it = edje_mmap_color_class_iterator_new(f);
352 fail_if(!it);
353 EINA_ITERATOR_FOREACH(it, itcc)
354 {
355 if (!strcmp(itcc->name, "test_color_class"))
356 {
357 cc = itcc;
358 break;
359 }
360 }
361 fail_if((!cc) || (cc->r != 100) || (cc->g != 100) || (cc->b != 100) || (cc->a != 100));
362
363 eina_iterator_free(it);
364 eina_file_close(f);
365 free(filename);
366
367 EDJE_TEST_FREE_EVAS();
368}
369EFL_END_TEST
370
371EFL_START_TEST(edje_test_swallows)
372{
373 Evas *evas = EDJE_TEST_INIT_EVAS();
374 Evas_Object *ly, *o1, *o2;
375
376 ly = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas);
377 fail_unless(edje_object_file_set(ly, test_layout_get("test_swallows.edj"), "test_group"));
378
379 fail_unless(edje_object_part_exists(ly, "swallow"));
380
381
382 o1 = efl_add(EFL_CANVAS_LAYOUT_CLASS, ly);
383 fail_if(!edje_object_part_swallow(ly, "swallow", o1));
384 ck_assert_ptr_eq(efl_parent_get(o1), ly);
385
386 edje_object_part_unswallow(ly, o1);
387 ck_assert_ptr_eq(efl_parent_get(o1), evas_object_evas_get(o1));
388
389 fail_if(!edje_object_part_swallow(ly, "swallow", o1));
390 ck_assert_ptr_eq(efl_parent_get(o1), ly);
391
392 o2 = efl_add(EFL_CANVAS_LAYOUT_CLASS, ly);
393 fail_if(!edje_object_part_swallow(ly, "swallow", o2));
394 ck_assert_ptr_eq(efl_parent_get(o2), ly);
395 /* o1 is deleted at this point. */
396 ck_assert_ptr_eq(efl_parent_get(o1), evas_object_evas_get(o1));
397
398 EDJE_TEST_FREE_EVAS();
399}
400EFL_END_TEST
401
402EFL_START_TEST(edje_test_swallows_lifetime)
403{
404 Evas *evas = EDJE_TEST_INIT_EVAS();
405 Evas_Object *ly, *o1;
406
407 ly = edje_object_add(evas);
408 fail_unless(edje_object_file_set(ly, test_layout_get("test_swallows.edj"), "test_group"));
409
410 fail_unless(edje_object_part_exists(ly, "swallow"));
411
412 o1 = edje_object_add(ly);
413 fail_if(!edje_object_part_swallow(ly, "swallow", o1));
414
415 evas_object_del(ly);
416 fail_if(!efl_parent_get(o1));
417
418 EDJE_TEST_FREE_EVAS();
419}
420EFL_END_TEST
421
422EFL_START_TEST(edje_test_swallows_eoapi)
423{
424 Evas *evas = EDJE_TEST_INIT_EVAS();
425 Evas_Object *ly, *o1, *o2;
426
427 ly = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas);
428 fail_unless(edje_object_file_set(ly, test_layout_get("test_swallows.edj"), "test_group"));
429
430 fail_unless(edje_object_part_exists(ly, "swallow"));
431
432
433 o1 = efl_add(EFL_CANVAS_LAYOUT_CLASS, ly);
434 fail_if(!efl_content_set(efl_part(ly, "swallow"), o1));
435 ck_assert_ptr_eq(efl_parent_get(o1), ly);
436
437 efl_content_remove(ly, o1);
438 ck_assert_ptr_eq(efl_parent_get(o1), evas_object_evas_get(o1));
439
440 fail_if(!efl_content_set(efl_part(ly, "swallow"), o1));
441 ck_assert_ptr_eq(efl_parent_get(o1), ly);
442
443 o2 = efl_add(EFL_CANVAS_LAYOUT_CLASS, ly);
444 fail_if(!efl_content_set(efl_part(ly, "swallow"), o2));
445 ck_assert_ptr_eq(efl_parent_get(o2), ly);
446 /* o1 is deleted at this point. */
447 ck_assert_ptr_eq(efl_parent_get(o1), evas_object_evas_get(o1));
448
449 EDJE_TEST_FREE_EVAS();
450} 148}
451EFL_END_TEST 149EFL_END_TEST
452 150
453EFL_START_TEST(edje_test_access) 151EFL_START_TEST(edje_test_access)
454{ 152{
455 Evas *evas = EDJE_TEST_INIT_EVAS(); 153 Evas *evas = _setup_evas();
456 const char *name; 154 const char *name;
457 Evas_Object *obj; 155 Evas_Object *obj;
458 Eina_Iterator *it; 156 Eina_Iterator *it;
@@ -489,265 +187,7 @@ EFL_START_TEST(edje_test_access)
489 } 187 }
490 fail_if(i != 2); 188 fail_if(i != 2);
491 189
492 EDJE_TEST_FREE_EVAS(); 190 evas_free(evas);
493}
494EFL_END_TEST
495
496EFL_START_TEST(edje_test_box)
497{
498 Evas *evas;
499 Evas_Object *obj, *sobj, *sobjs[5];
500 const Evas_Object *box;
501 Eina_Iterator *it;
502 int i;
503
504 evas = EDJE_TEST_INIT_EVAS();
505
506 obj = edje_object_add(evas);
507 fail_unless(edje_object_file_set(obj, test_layout_get("test_box.edj"), "test_group"));
508
509 for (i = 0; i < 5; i++)
510 {
511 sobjs[i] = evas_object_rectangle_add(evas);
512 fail_if(!sobjs[i]);
513 }
514
515 edje_object_part_box_append(obj, "box", sobjs[3]);
516 edje_object_part_box_prepend(obj, "box", sobjs[1]);
517 edje_object_part_box_insert_before(obj, "box", sobjs[0], sobjs[1]);
518 edje_object_part_box_insert_after(obj, "box", sobjs[4], sobjs[3]);
519 edje_object_part_box_insert_at(obj, "box", sobjs[2], 2);
520
521 edje_object_freeze(obj);
522 box = edje_object_part_object_get(obj, "box");
523 edje_object_thaw(obj);
524 it = evas_object_box_iterator_new(box);
525
526 i = 0;
527 EINA_ITERATOR_FOREACH(it, sobj)
528 {
529 fail_if(sobj != sobjs[i++]);
530 }
531 eina_iterator_free(it);
532
533 EDJE_TEST_FREE_EVAS();
534}
535EFL_END_TEST
536
537EFL_START_TEST(edje_test_box_eoapi)
538{
539 Evas *evas;
540 Evas_Object *obj, *sobj, *sobjs[5];
541 Eina_Iterator *it;
542 int i;
543
544 evas = EDJE_TEST_INIT_EVAS();
545
546 obj = edje_object_add(evas);
547 fail_unless(edje_object_file_set(obj, test_layout_get("test_box.edj"), "test_group"));
548
549 for (i = 0; i < 5; i++)
550 {
551 sobjs[i] = evas_object_rectangle_add(evas);
552 fail_if(!sobjs[i]);
553 }
554
555 /* same test case as legacy api above */
556 efl_pack_end(efl_part(obj, "box"), sobjs[3]);
557 efl_pack_begin(efl_part(obj, "box"), sobjs[1]);
558 efl_pack_before(efl_part(obj, "box"), sobjs[0], sobjs[1]);
559 efl_pack_after(efl_part(obj, "box"), sobjs[4], sobjs[3]);
560 efl_pack_at(efl_part(obj, "box"), sobjs[2], 2);
561 fail_if(efl_content_count(efl_part(obj, "box")) != 5);
562
563 it = efl_content_iterate(efl_part(obj, "box"));
564 i = 0;
565 EINA_ITERATOR_FOREACH(it, sobj)
566 fail_if(sobj != sobjs[i++]);
567 fail_if(i != 5);
568 eina_iterator_free(it);
569
570 /* clear up and test a bit more */
571 efl_pack_unpack_all(efl_part(obj, "box"));
572 fail_if(efl_content_count(efl_part(obj, "box")) != 0);
573
574 efl_pack(efl_part(obj, "box"), sobjs[1]);
575 efl_pack_at(efl_part(obj, "box"), sobjs[0], 0);
576 efl_pack_at(efl_part(obj, "box"), sobjs[2], -1);
577 it = efl_content_iterate(efl_part(obj, "box"));
578 i = 0;
579 EINA_ITERATOR_FOREACH(it, sobj)
580 fail_if(sobj != sobjs[i++]);
581 fail_if(i != 3);
582 eina_iterator_free(it);
583
584 fail_if(!efl_content_remove(efl_part(obj, "box"), sobjs[0]));
585 fail_if(efl_content_count(efl_part(obj, "box")) != 2);
586 fail_if(!efl_pack_unpack_at(efl_part(obj, "box"), 1));
587 fail_if(efl_content_count(efl_part(obj, "box")) != 1);
588 fail_if(efl_pack_index_get(efl_part(obj, "box"), sobjs[1]) != 0);
589
590 efl_pack_clear(efl_part(obj, "box"));
591 fail_if(efl_content_count(efl_part(obj, "box")) != 0);
592
593 EDJE_TEST_FREE_EVAS();
594}
595EFL_END_TEST
596
597EFL_START_TEST(edje_test_table)
598{
599 Evas *evas;
600 Evas_Object *obj, *sobj, *sobjs[4];
601 int i, k, l, cols, rows;
602
603 evas = EDJE_TEST_INIT_EVAS();
604
605 obj = edje_object_add(evas);
606 fail_unless(edje_object_file_set(obj, test_layout_get("test_table.edj"), "test_group"));
607
608 /* check items from EDC */
609 for (l = 0; l < 2; l++)
610 for (k = 0; k < 2; k++)
611 {
612 const char *txt;
613 char buf[20];
614
615 /* items have a text part "text" containing their position */
616 sprintf(buf, "%d,%d", k, l);
617 sobj = edje_object_part_table_child_get(obj, "table", k, l);
618 fail_if(!sobj);
619 txt = edje_object_part_text_get(sobj, "text");
620 fail_if(!txt);
621 fail_if(strcmp(txt, buf) != 0);
622 }
623
624 /* Add more items */
625 for (l = 0; l < 2; l++)
626 for (k = 0; k < 2; k++)
627 {
628 i = l*2 + k;
629 sobjs[i] = evas_object_rectangle_add(evas);
630 fail_if(!sobjs[i]);
631 edje_object_part_table_pack(obj, "table", sobjs[i], k, l + 2, 1, 1);
632 }
633
634 for (l = 0; l < 2; l++)
635 for (k = 0; k < 2; k++)
636 {
637 i = l*2 + k;
638 sobj = edje_object_part_table_child_get(obj, "table", k, l + 2);
639 fail_if(sobj != sobjs[i]);
640 }
641
642 /* table size and clear */
643 edje_object_part_table_col_row_size_get(obj, "table", &cols, &rows);
644 fail_if(cols != 2);
645 fail_if(rows != 4);
646
647 edje_object_part_table_clear(obj, "table", EINA_TRUE);
648
649 edje_object_part_table_col_row_size_get(obj, "table", &cols, &rows);
650 fail_if(cols != 2);
651 fail_if(rows != 2);
652
653 for (l = 0; l < 2; l++)
654 for (k = 0; k < 2; k++)
655 {
656 const char *txt;
657 char buf[20];
658
659 /* items have a text part "text" containing their position */
660 sprintf(buf, "%d,%d", k, l);
661 sobj = edje_object_part_table_child_get(obj, "table", k, l);
662 fail_if(!sobj);
663 txt = edje_object_part_text_get(sobj, "text");
664 fail_if(!txt);
665 fail_if(strcmp(txt, buf) != 0);
666 }
667
668 EDJE_TEST_FREE_EVAS();
669}
670EFL_END_TEST
671
672EFL_START_TEST(edje_test_table_eoapi)
673{
674 Evas *evas;
675 Evas_Object *obj, *sobj, *sobjs[4], *proxy;
676 Eina_Iterator *it;
677 int i, k, l, cs, rs, cols, rows;
678
679 evas = EDJE_TEST_INIT_EVAS();
680
681 obj = edje_object_add(evas);
682 fail_unless(edje_object_file_set(obj, test_layout_get("test_table.edj"), "test_group"));
683
684 /* check items from EDC */
685 fail_if(efl_content_count(efl_part(obj, "table")) != 4);
686 for (l = 0; l < 2; l++)
687 for (k = 0; k < 2; k++)
688 {
689 const char *txt;
690 char buf[20];
691
692 /* items have a text part "text" containing their position */
693 sprintf(buf, "%d,%d", k, l);
694 sobj = efl_pack_table_content_get(efl_part(obj, "table"), k, l);
695 fail_if(!sobj);
696 //txt = efl_part_text_get(sobj, "text");
697 txt = edje_object_part_text_get(sobj, "text");
698 fail_if(!txt);
699 fail_if(strcmp(txt, buf) != 0);
700 }
701
702 /* Add more items */
703 for (l = 0; l < 2; l++)
704 for (k = 0; k < 2; k++)
705 {
706 i = l*2 + k;
707 sobjs[i] = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas);
708 fail_if(!sobjs[i]);
709 efl_pack_table(efl_part(obj, "table"), sobjs[i], k, l + 2, 1, 1);
710 }
711
712 fail_if(efl_content_count(efl_part(obj, "table")) != 8);
713
714 i = 0;
715 it = efl_content_iterate(efl_part(obj, "table"));
716 EINA_ITERATOR_FOREACH(it, sobj)
717 {
718 efl_pack_table_position_get(efl_part(obj, "table"), sobj, &k, &l, &cs, &rs);
719 fail_if(cs != 1);
720 fail_if(rs != 1);
721 if (l >= 2)
722 fail_if(sobj != sobjs[(l - 2)*2 + k]);
723 i++;
724 }
725 eina_iterator_free(it);
726 fail_if(i != 8);
727
728 /* table size and clear */
729 efl_pack_table_size_get(efl_part(obj, "table"), &cols, &rows);
730 fail_if(cols != 2);
731 fail_if(rows != 4);
732
733 efl_pack_clear(efl_part(obj, "table"));
734 fail_if(efl_content_count(efl_part(obj, "table")) != 4);
735
736 efl_pack_table_size_get(efl_part(obj, "table"), &cols, &rows);
737 fail_if(cols != 2);
738 fail_if(rows != 2);
739
740 /* test multiple ops on a proxy object */
741 proxy = efl_ref(efl_part(obj, "table"));
742 fail_if(!proxy);
743 fail_if(!efl_pack_clear(proxy));
744 fail_if(efl_content_count(efl_part(obj, "table")) != 4);
745 fail_if(!efl_pack_clear(proxy));
746 fail_if(efl_content_count(efl_part(obj, "table2")) != 1);
747 fail_if(efl_content_count(proxy) != 4);
748 efl_del(proxy);
749
750 EDJE_TEST_FREE_EVAS();
751} 191}
752EFL_END_TEST 192EFL_END_TEST
753 193
@@ -756,316 +196,18 @@ EFL_START_TEST(edje_test_combine_keywords)
756 Evas *evas; 196 Evas *evas;
757 Evas_Object *obj; 197 Evas_Object *obj;
758 198
759 evas = EDJE_TEST_INIT_EVAS(); 199 evas = _setup_evas();
760 200
761 obj = edje_object_add(evas); 201 obj = edje_object_add(evas);
762 fail_unless(edje_object_file_set(obj, test_layout_get("test_combine_keywords.edj"), "test_group")); 202 fail_unless(edje_object_file_set(obj, test_layout_get("test_combine_keywords.edj"), "test_group"));
763 203
764 EDJE_TEST_FREE_EVAS(); 204 evas_free(evas);
765}
766EFL_END_TEST
767
768static void
769_message_signal_reply_cb(void *data, Evas_Object *obj EINA_UNUSED,
770 const char *emission, const char *source)
771{
772 int *id = data;
773
774 fprintf(stderr, "source %s emit %s id %d\n", source, emission, *id);
775 fflush(stderr);
776 ck_assert_str_eq(source, "edc");
777 ck_assert_ptr_ne(emission, NULL);
778
779 if (!strncmp(emission, "int set", 7))
780 ck_assert_str_eq(emission, "int set 7 12 42 255");
781 else if (!strncmp(emission, "int", 3))
782 ck_assert_str_eq(emission, "int 42");
783 else if (!strncmp(emission, "float", 5))
784 {
785 char buf[64];
786 sprintf(buf, "float %f", 0.12);
787 ck_assert_str_eq(emission, buf);
788 }
789 else if (!strncmp(emission, "str", 3))
790 ck_assert_str_eq(emission, "str hello world");
791 else ck_abort_msg("Invalid emission!");
792
793 (*id)++;
794}
795
796EFL_START_TEST(edje_test_message_send_legacy)
797{
798 Evas *evas;
799 Evas_Object *obj;
800 Edje_Message_Int msgi;
801 Edje_Message_Float msgf;
802 Edje_Message_String msgs;
803 Edje_Message_Int_Set *msgis;
804 int id = 0;
805
806 /* Ugly calls to process:
807 *
808 * 1. Send edje message (async)
809 * 2. Process edje message (sync)
810 * 3. EDC program emits edje signal (async)
811 * 4. Process edje signal (sync)
812 * 5. Finally reached signal cb
813 */
814
815 evas = EDJE_TEST_INIT_EVAS();
816
817 obj = edje_object_add(evas);
818 fail_unless(edje_object_file_set(obj, test_layout_get("test_messages.edj"), "test_group"));
819 edje_object_signal_callback_add(obj, "*", "edc", _message_signal_reply_cb, &id);
820
821 msgs.str = "hello world";
822 edje_object_message_send(obj, EDJE_MESSAGE_STRING, 0, &msgs);
823 edje_message_signal_process();
824 ck_assert_int_eq(id, 1);
825
826 msgi.val = 42;
827 edje_object_message_send(obj, EDJE_MESSAGE_INT, 1, &msgi);
828 edje_message_signal_process();
829 ck_assert_int_eq(id, 2);
830
831 msgf.val = 0.12;
832 edje_object_message_send(obj, EDJE_MESSAGE_FLOAT, 2, &msgf);
833 edje_message_signal_process();
834 ck_assert_int_eq(id, 3);
835
836 msgis = alloca(sizeof(*msgis) + 4 * sizeof(msgis->val));
837 msgis->count = 4;
838 msgis->val[0] = 7;
839 msgis->val[1] = 12;
840 msgis->val[2] = 42;
841 msgis->val[3] = 255;
842 edje_object_message_send(obj, EDJE_MESSAGE_INT_SET, 3, msgis);
843 edje_message_signal_process();
844 ck_assert_int_eq(id, 4);
845
846 evas_object_del(obj);
847
848 EDJE_TEST_FREE_EVAS();
849}
850EFL_END_TEST
851
852EFL_START_TEST(edje_test_message_send_eo)
853{
854 Evas *evas;
855 Evas_Object *obj;
856 Eina_Value v, *va;
857 int id = 0;
858
859 evas = EDJE_TEST_INIT_EVAS();
860
861 obj = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
862 efl_file_set(efl_added, test_layout_get("test_messages.edj"), "test_group"));
863
864 // FIXME: EO API HERE
865 edje_object_signal_callback_add(obj, "*", "edc", _message_signal_reply_cb, &id);
866
867 // NOTE: edje_object_message_signal_process may or may not be in EO (TBD)
868
869 eina_value_setup(&v, EINA_VALUE_TYPE_STRING);
870 eina_value_set(&v, "hello world");
871 efl_layout_signal_message_send(obj, 0, v);
872 eina_value_flush(&v);
873 edje_message_signal_process();
874 edje_object_calc_force(obj);
875 ck_assert_int_eq(id, 1);
876
877 eina_value_setup(&v, EINA_VALUE_TYPE_INT);
878 eina_value_set(&v, 42);
879 efl_layout_signal_message_send(obj, 1, v);
880 eina_value_flush(&v);
881 edje_message_signal_process();
882 edje_object_calc_force(obj);
883 ck_assert_int_eq(id, 2);
884
885 eina_value_setup(&v, EINA_VALUE_TYPE_FLOAT);
886 eina_value_set(&v, 0.12);
887 efl_layout_signal_message_send(obj, 2, v);
888 eina_value_flush(&v);
889 edje_message_signal_process();
890 edje_object_calc_force(obj);
891 ck_assert_int_eq(id, 3);
892
893 va = eina_value_array_new(EINA_VALUE_TYPE_INT, 4);
894 eina_value_array_append(va, 7);
895 eina_value_array_append(va, 12);
896 eina_value_array_append(va, 42);
897 eina_value_array_append(va, 255);
898 efl_layout_signal_message_send(obj, 3, *va);
899 eina_value_free(va);
900 edje_message_signal_process();
901 edje_object_calc_force(obj);
902 ck_assert_int_eq(id, 4);
903
904 efl_del(obj);
905
906 EDJE_TEST_FREE_EVAS();
907}
908EFL_END_TEST
909
910EFL_START_TEST(edje_test_signals)
911{
912 Evas *evas;
913 Evas_Object *obj;
914 const char *state;
915
916 evas = EDJE_TEST_INIT_EVAS();
917
918 obj = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
919 efl_file_set(efl_added, test_layout_get("test_signals.edj"), "level1"),
920 efl_gfx_entity_size_set(efl_added, EINA_SIZE2D(320, 240)),
921 efl_gfx_entity_visible_set(efl_added, 1));
922
923 edje_object_signal_emit(obj, "mouse,in", "text");
924
925 edje_object_message_signal_process(obj);
926 state = edje_object_part_state_get(obj, "group:group:text", NULL);
927 ck_assert_str_eq(state, "default");
928
929 edje_object_message_signal_process(obj);
930 state = edje_object_part_state_get(obj, "group:group:text", NULL);
931 ck_assert_str_eq(state, "default");
932
933 edje_object_message_signal_recursive_process(obj);
934 state = edje_object_part_state_get(obj, "group:group:text", NULL);
935 ck_assert_str_eq(state, "over");
936
937 efl_del(obj);
938
939 EDJE_TEST_FREE_EVAS();
940}
941EFL_END_TEST
942
943static int _signal_count;
944
945static void
946_signal_callback_count_cb(void *data, Evas_Object *obj EINA_UNUSED,
947 const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
948{
949 int *_data = data;
950 _signal_count += *_data;
951}
952
953EFL_START_TEST(edje_test_signal_callback_del_full)
954{
955 Evas *evas;
956 Evas_Object *obj;
957 int data[4] = { 1, 2, 4, 8 };
958
959 evas = EDJE_TEST_INIT_EVAS();
960
961 obj = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
962 efl_file_set(efl_added,
963 test_layout_get("test_signal_callback_del_full.edj"), "test"),
964 efl_gfx_entity_size_set(efl_added, EINA_SIZE2D(320, 240)),
965 efl_gfx_entity_visible_set(efl_added, 1));
966
967 edje_object_signal_callback_add(obj, "some_signal", "event", _signal_callback_count_cb, &data[0]);
968 edje_object_signal_callback_add(obj, "some_signal", "event", _signal_callback_count_cb, &data[1]);
969 edje_object_signal_callback_add(obj, "some_signal", "event", _signal_callback_count_cb, &data[2]);
970 edje_object_signal_callback_add(obj, "some_signal", "event", _signal_callback_count_cb, &data[3]);
971
972 edje_object_signal_callback_del_full(obj, "some_signal", "event", _signal_callback_count_cb, &data[0]);
973 edje_object_signal_callback_del_full(obj, "some_signal", "event", _signal_callback_count_cb, &data[3]);
974
975 edje_object_signal_emit(obj, "some_signal", "event");
976
977 edje_object_message_signal_process(obj);
978 ck_assert_int_eq(_signal_count, (data[1] + data[2]));
979
980 efl_del(obj);
981
982 EDJE_TEST_FREE_EVAS();
983}
984EFL_END_TEST
985
986EFL_START_TEST(edje_test_text_cursor)
987{
988 Evas *evas;
989 Evas_Object *obj;
990 const char *buf = "ABC<br/>DEF";
991 const char *txt;
992 int i, old_pos, new_pos;
993
994 evas = EDJE_TEST_INIT_EVAS();
995
996 obj = edje_object_add(evas);
997 fail_unless(edje_object_file_set(obj, test_layout_get("test_text_cursor.edj"), "test_text_cursor"));
998 edje_object_part_text_set(obj, "text", buf);
999 txt = edje_object_part_text_get(obj, "text");
1000 fail_if(!txt || strcmp(txt, buf));
1001
1002 edje_object_part_text_cursor_pos_set(obj, "text", EDJE_CURSOR_MAIN, 0);
1003 ck_assert_int_eq(edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN), 0);
1004 edje_object_part_text_cursor_pos_set(obj, "text", EDJE_CURSOR_MAIN, 1);
1005 ck_assert_int_eq(edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN), 1);
1006
1007 /* Move cursor to the 0 pos from 1 pos */
1008 old_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
1009 ck_assert(edje_object_part_text_cursor_prev(obj, "text", EDJE_CURSOR_MAIN));
1010 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
1011 ck_assert_int_ne(old_pos, new_pos);
1012
1013 /* Move cursor to the -1 pos from 0 pos. It has to fail. */
1014 old_pos = new_pos;
1015 ck_assert(!edje_object_part_text_cursor_prev(obj, "text", EDJE_CURSOR_MAIN));
1016 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
1017 ck_assert_int_eq(old_pos, new_pos);
1018
1019 /* Jump to 2nd line from 1st line.
1020 * It has to return EINA_TRUE which means success. */
1021 old_pos = new_pos;
1022 ck_assert(edje_object_part_text_cursor_down(obj, "text", EDJE_CURSOR_MAIN));
1023 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
1024 ck_assert_int_ne(old_pos, new_pos);
1025
1026 /* Try to jump to 3rd line from 2nd line. But, 3rd line does not exist.
1027 * So, it has to return EINA_FALSE which means failure. */
1028 old_pos = new_pos;
1029 ck_assert(!edje_object_part_text_cursor_down(obj, "text", EDJE_CURSOR_MAIN));
1030 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
1031 ck_assert_int_eq(old_pos, new_pos);
1032
1033 /* Move cursor to the end of 2nd line. */
1034 for (i = 0; i < 3; i++)
1035 {
1036 old_pos = new_pos;
1037 ck_assert(edje_object_part_text_cursor_next(obj, "text", EDJE_CURSOR_MAIN));
1038 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
1039 ck_assert_int_ne(old_pos, new_pos);
1040 }
1041
1042 /* Move cursor to the next of the end of 2nd line which does not exist. */
1043 old_pos = new_pos;
1044 ck_assert(!edje_object_part_text_cursor_next(obj, "text", EDJE_CURSOR_MAIN));
1045 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
1046 ck_assert_int_eq(old_pos, new_pos);
1047
1048 /* Jump to 1st line from 2nd line.
1049 * It has to return EINA_TRUE which means success. */
1050 old_pos = new_pos;
1051 ck_assert(edje_object_part_text_cursor_up(obj, "text", EDJE_CURSOR_MAIN));
1052 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
1053 ck_assert_int_ne(old_pos, new_pos);
1054
1055 /* Try to jump to the above of 1st line from 1st line. But, there is no such line.
1056 * So, it has to return EINA_FALSE which means failure. */
1057 old_pos = new_pos;
1058 ck_assert(!edje_object_part_text_cursor_up(obj, "text", EDJE_CURSOR_MAIN));
1059 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
1060 ck_assert_int_eq(old_pos, new_pos);
1061
1062 EDJE_TEST_FREE_EVAS();
1063} 205}
1064EFL_END_TEST 206EFL_END_TEST
1065 207
1066EFL_START_TEST(edje_test_part_caching) 208EFL_START_TEST(edje_test_part_caching)
1067{ 209{
1068 Evas *evas = EDJE_TEST_INIT_EVAS(); 210 Evas *evas = _setup_evas();
1069 Evas_Object *ly, *o1, *global_p = NULL; 211 Evas_Object *ly, *o1, *global_p = NULL;
1070 212
1071 ly = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas, 213 ly = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
@@ -1088,26 +230,7 @@ EFL_START_TEST(edje_test_part_caching)
1088 230
1089 } 231 }
1090 232
1091 EDJE_TEST_FREE_EVAS(); 233 evas_free(evas);
1092}
1093EFL_END_TEST
1094
1095EFL_START_TEST(edje_test_textblock)
1096{
1097 Evas *evas;
1098 Evas_Object *obj;
1099 const char *buf = "Hello";
1100 const char *txt;
1101
1102 evas = EDJE_TEST_INIT_EVAS();
1103
1104 obj = edje_object_add(evas);
1105 fail_unless(edje_object_file_set(obj, test_layout_get("test_textblock.edj"), "test_textblock"));
1106 edje_object_part_text_set(obj, "text", buf);
1107 txt = edje_object_part_text_get(obj, "text");
1108 fail_if(!txt || strcmp(txt, buf));
1109
1110 EDJE_TEST_FREE_EVAS();
1111} 234}
1112EFL_END_TEST 235EFL_END_TEST
1113 236
@@ -1119,25 +242,7 @@ void edje_test_edje(TCase *tc)
1119 tcase_add_test(tc, edje_test_simple_layout_geometry); 242 tcase_add_test(tc, edje_test_simple_layout_geometry);
1120 tcase_add_test(tc, edje_test_complex_layout); 243 tcase_add_test(tc, edje_test_complex_layout);
1121 tcase_add_test(tc, edje_test_calculate_parens); 244 tcase_add_test(tc, edje_test_calculate_parens);
1122 tcase_add_test(tc, edje_test_masking);
1123 tcase_add_test(tc, edje_test_filters);
1124 tcase_add_test(tc, edje_test_snapshot);
1125 tcase_add_test(tc, edje_test_size_class);
1126 tcase_add_test(tc, edje_test_color_class);
1127 tcase_add_test(tc, edje_test_swallows);
1128 tcase_add_test(tc, edje_test_swallows_lifetime);
1129 tcase_add_test(tc, edje_test_swallows_eoapi);
1130 tcase_add_test(tc, edje_test_access); 245 tcase_add_test(tc, edje_test_access);
1131 tcase_add_test(tc, edje_test_box);
1132 tcase_add_test(tc, edje_test_box_eoapi);
1133 tcase_add_test(tc, edje_test_table);
1134 tcase_add_test(tc, edje_test_table_eoapi);
1135 tcase_add_test(tc, edje_test_combine_keywords); 246 tcase_add_test(tc, edje_test_combine_keywords);
1136 tcase_add_test(tc, edje_test_message_send_legacy);
1137 tcase_add_test(tc, edje_test_message_send_eo);
1138 tcase_add_test(tc, edje_test_signals);
1139 tcase_add_test(tc, edje_test_signal_callback_del_full);
1140 tcase_add_test(tc, edje_test_text_cursor);
1141 tcase_add_test(tc, edje_test_part_caching); 247 tcase_add_test(tc, edje_test_part_caching);
1142 tcase_add_test(tc, edje_test_textblock);
1143} 248}
diff --git a/src/tests/edje/edje_test_features.c b/src/tests/edje/edje_test_features.c
new file mode 100644
index 0000000..1cff283
--- /dev/null
+++ b/src/tests/edje/edje_test_features.c
@@ -0,0 +1,229 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <unistd.h>
6#include <stdio.h>
7
8#define EFL_GFX_FILTER_BETA
9#define EFL_CANVAS_LAYOUT_BETA
10
11#include "edje_suite.h"
12
13#define EVAS_DATA_DIR TESTS_SRC_DIR "/../../lib/evas"
14
15
16EFL_START_TEST(edje_test_masking)
17{
18 int x, y, w, h;
19 Evas *evas = _setup_evas();
20 const Evas_Object *sub, *clip2, *clip;
21 Evas_Object *obj;
22
23 obj = edje_object_add(evas);
24 fail_unless(edje_object_file_set(obj, test_layout_get("test_masking.edj"), "test_group"));
25
26 evas_object_resize(obj, 100, 100);
27 edje_object_part_geometry_get(obj, "background", &x, &y, &w, &h);
28 fail_if(x != 0 || y != 0 || w != 100 || h != 100);
29
30 edje_object_freeze(obj);
31 clip = edje_object_part_object_get(obj, "clip2");
32 edje_object_thaw(obj);
33 fail_if(!clip);
34
35 /* check value of no_render flag as seen from evas land */
36 edje_object_freeze(obj);
37 sub = edje_object_part_object_get(obj, "mask");
38 edje_object_thaw(obj);
39 fail_if(!efl_canvas_object_no_render_get(sub));
40
41 /* check that text has a clip (based on description.clip_to) */
42 edje_object_freeze(obj);
43 sub = edje_object_part_object_get(obj, "text");
44 edje_object_thaw(obj);
45 fail_if(!efl_canvas_object_clip_get(sub));
46
47 /* test description.clip_to override */
48 edje_object_freeze(obj);
49 sub = edje_object_part_object_get(obj, "noclip");
50 edje_object_thaw(obj);
51 clip2 = efl_canvas_object_clip_get(sub);
52 fail_if(clip != clip2);
53
54 evas_free(evas);
55}
56EFL_END_TEST
57
58EFL_START_TEST(edje_test_filters)
59{
60 Evas *evas = _setup_evas();
61 const Evas_Object *text, *sub;
62 Evas_Object *obj, *src = NULL;
63 const char *prg, *name;
64
65 setenv("EVAS_DATA_DIR", EVAS_DATA_DIR, 1);
66
67 obj = edje_object_add(evas);
68 fail_unless(edje_object_file_set(obj, test_layout_get("test_filters.edj"), "test_group"));
69
70 evas_object_resize(obj, 200, 200);
71
72 /* check value of no_render flag as seen from evas land */
73 edje_object_freeze(obj);
74 sub = edje_object_part_object_get(obj, "mask");
75 edje_object_thaw(obj);
76 fail_if(!efl_canvas_object_no_render_get(sub));
77
78 /* check no_render inheritance */
79 edje_object_freeze(obj);
80 sub = edje_object_part_object_get(obj, "mask2");
81 edje_object_thaw(obj);
82 fail_if(efl_canvas_object_no_render_get(sub));
83 edje_object_freeze(obj);
84 sub = edje_object_part_object_get(obj, "mask3");
85 edje_object_thaw(obj);
86 fail_if(!efl_canvas_object_no_render_get(sub));
87
88 /* text part: check filter status */
89 edje_object_freeze(obj);
90 text = edje_object_part_object_get(obj, "text");
91 edje_object_thaw(obj);
92 fail_if(!text);
93
94 efl_gfx_filter_program_get(text, &prg, &name);
95 fail_if(!prg);
96 fail_if(!name || strcmp(name, "filterfile"));
97
98 src = efl_gfx_filter_source_get(text, "mask");
99 fail_if(!src);
100
101 // TODO: Verify properly that the filter runs well
102
103 evas_free(evas);
104}
105EFL_END_TEST
106
107EFL_START_TEST(edje_test_snapshot)
108{
109 Evas *evas = _setup_evas();
110 const Evas_Object *sub;
111 Evas_Object *obj;
112
113 setenv("EVAS_DATA_DIR", EVAS_DATA_DIR, 1);
114
115 obj = edje_object_add(evas);
116 fail_unless(edje_object_file_set(obj, test_layout_get("test_snapshot.edj"), "test_group"));
117
118 evas_object_resize(obj, 200, 200);
119
120 /* check value of no_render flag as seen from evas land */
121 edje_object_freeze(obj);
122 sub = edje_object_part_object_get(obj, "snap");
123 edje_object_thaw(obj);
124 fail_if(!efl_isa(sub, EFL_CANVAS_SNAPSHOT_CLASS) &&
125 !evas_object_image_snapshot_get(sub));
126
127 // TODO: Verify that evas snapshot actually works (and has a filter)
128
129 evas_free(evas);
130}
131EFL_END_TEST
132
133EFL_START_TEST(edje_test_size_class)
134{
135 int minw, minh, minw2, minh2;
136 Evas *evas = _setup_evas();
137 Eina_List *l;
138 Eina_Stringshare *name;
139 Evas_Object *obj, *obj2;
140 Eina_Bool b;
141
142 obj = edje_object_add(evas);
143 fail_unless(edje_object_file_set(obj, test_layout_get("test_size_class.edj"), "test_group"));
144
145 obj2 = edje_object_add(evas);
146 fail_unless(edje_object_file_set(obj2, test_layout_get("test_size_class.edj"), "test_group"));
147
148 evas_object_resize(obj, 200, 200);
149 evas_object_resize(obj2, 200, 200);
150
151 /* check predefined min size of rect part by edc */
152 edje_object_part_geometry_get(obj, "rect", NULL, NULL, &minw, &minh);
153 fail_if(minw != 50 || minh != 50);
154
155 /* check that edje_size_class_set works */
156 b = edje_size_class_set("rect_size", 100, 100, -1, -1);
157 edje_object_part_geometry_get(obj, "rect", NULL, NULL, &minw, &minh);
158 edje_object_part_geometry_get(obj2, "rect", NULL, NULL, &minw2, &minh2);
159 fail_if(!b || minw != 100 || minh != 100 || minw2 != 100 || minh2 != 100);
160
161 /* check that edje_size_class_get works */
162 b = edje_size_class_get("rect_size", &minw, &minh, NULL, NULL);
163 fail_if(!b || minw != 100 || minh != 100);
164
165 /* check that edje_size_class_list works */
166 l = edje_size_class_list();
167 EINA_LIST_FREE(l, name)
168 {
169 fail_if(strcmp(name, "rect_size"));
170 eina_stringshare_del(name);
171 }
172
173 /* check that edje_object_size_class_set works */
174 b = edje_object_size_class_set(obj, "rect_size", 150, 150, -1, -1);
175 edje_object_part_geometry_get(obj, "rect", NULL, NULL, &minw, &minh);
176 edje_object_part_geometry_get(obj2, "rect", NULL, NULL, &minw2, &minh2);
177 fail_if(!b || minw != 150 || minh != 150 || minw2 != 100 || minh2 != 100);
178
179 /* check that edje_object_size_class_get works */
180 b = edje_object_size_class_get(obj, "rect_size", &minw, &minh, NULL, NULL);
181 fail_if(!b || minw != 150 || minh != 150);
182
183 evas_free(evas);
184}
185EFL_END_TEST
186
187EFL_START_TEST(edje_test_color_class)
188{
189 Evas *evas = _setup_evas();
190
191 Eina_File *f;
192 Eina_Iterator *it;
193 Edje_Color_Class *itcc, *cc = NULL;
194 char *filename;
195
196 filename = realpath(test_layout_get("test_color_class.edj"), NULL);
197 fail_if(!filename);
198
199 f = eina_file_open(filename, EINA_FALSE);
200 fail_if(!f);
201
202 it = edje_mmap_color_class_iterator_new(f);
203 fail_if(!it);
204 EINA_ITERATOR_FOREACH(it, itcc)
205 {
206 if (!strcmp(itcc->name, "test_color_class"))
207 {
208 cc = itcc;
209 break;
210 }
211 }
212 fail_if((!cc) || (cc->r != 100) || (cc->g != 100) || (cc->b != 100) || (cc->a != 100));
213
214 eina_iterator_free(it);
215 eina_file_close(f);
216 free(filename);
217
218 evas_free(evas);
219}
220EFL_END_TEST
221
222void edje_test_features(TCase *tc)
223{
224 tcase_add_test(tc, edje_test_masking);
225 tcase_add_test(tc, edje_test_filters);
226 tcase_add_test(tc, edje_test_snapshot);
227 tcase_add_test(tc, edje_test_size_class);
228 tcase_add_test(tc, edje_test_color_class);
229}
diff --git a/src/tests/edje/edje_test_signal.c b/src/tests/edje/edje_test_signal.c
new file mode 100644
index 0000000..2dc42b0
--- /dev/null
+++ b/src/tests/edje/edje_test_signal.c
@@ -0,0 +1,240 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <unistd.h>
6#include <stdio.h>
7
8#define EFL_GFX_FILTER_BETA
9#define EFL_CANVAS_LAYOUT_BETA
10
11#include "edje_suite.h"
12
13#define EVAS_DATA_DIR TESTS_SRC_DIR "/../../lib/evas"
14
15static void
16_message_signal_reply_cb(void *data, Evas_Object *obj EINA_UNUSED,
17 const char *emission, const char *source)
18{
19 int *id = data;
20
21 fprintf(stderr, "source %s emit %s id %d\n", source, emission, *id);
22 fflush(stderr);
23 ck_assert_str_eq(source, "edc");
24 ck_assert_ptr_ne(emission, NULL);
25
26 if (!strncmp(emission, "int set", 7))
27 ck_assert_str_eq(emission, "int set 7 12 42 255");
28 else if (!strncmp(emission, "int", 3))
29 ck_assert_str_eq(emission, "int 42");
30 else if (!strncmp(emission, "float", 5))
31 {
32 char buf[64];
33 sprintf(buf, "float %f", 0.12);
34 ck_assert_str_eq(emission, buf);
35 }
36 else if (!strncmp(emission, "str", 3))
37 ck_assert_str_eq(emission, "str hello world");
38 else ck_abort_msg("Invalid emission!");
39
40 (*id)++;
41}
42
43EFL_START_TEST(edje_test_message_send_legacy)
44{
45 Evas *evas;
46 Evas_Object *obj;
47 Edje_Message_Int msgi;
48 Edje_Message_Float msgf;
49 Edje_Message_String msgs;
50 Edje_Message_Int_Set *msgis;
51 int id = 0;
52
53 /* Ugly calls to process:
54 *
55 * 1. Send edje message (async)
56 * 2. Process edje message (sync)
57 * 3. EDC program emits edje signal (async)
58 * 4. Process edje signal (sync)
59 * 5. Finally reached signal cb
60 */
61
62 evas = _setup_evas();
63
64 obj = edje_object_add(evas);
65 fail_unless(edje_object_file_set(obj, test_layout_get("test_messages.edj"), "test_group"));
66 edje_object_signal_callback_add(obj, "*", "edc", _message_signal_reply_cb, &id);
67
68 msgs.str = "hello world";
69 edje_object_message_send(obj, EDJE_MESSAGE_STRING, 0, &msgs);
70 edje_message_signal_process();
71 ck_assert_int_eq(id, 1);
72
73 msgi.val = 42;
74 edje_object_message_send(obj, EDJE_MESSAGE_INT, 1, &msgi);
75 edje_message_signal_process();
76 ck_assert_int_eq(id, 2);
77
78 msgf.val = 0.12;
79 edje_object_message_send(obj, EDJE_MESSAGE_FLOAT, 2, &msgf);
80 edje_message_signal_process();
81 ck_assert_int_eq(id, 3);
82
83 msgis = alloca(sizeof(*msgis) + 4 * sizeof(msgis->val));
84 msgis->count = 4;
85 msgis->val[0] = 7;
86 msgis->val[1] = 12;
87 msgis->val[2] = 42;
88 msgis->val[3] = 255;
89 edje_object_message_send(obj, EDJE_MESSAGE_INT_SET, 3, msgis);
90 edje_message_signal_process();
91 ck_assert_int_eq(id, 4);
92
93 evas_object_del(obj);
94
95 evas_free(evas);
96}
97EFL_END_TEST
98
99EFL_START_TEST(edje_test_message_send_eo)
100{
101 Evas *evas;
102 Evas_Object *obj;
103 Eina_Value v, *va;
104 int id = 0;
105
106 evas = _setup_evas();
107
108 obj = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
109 efl_file_set(efl_added, test_layout_get("test_messages.edj"), "test_group"));
110
111 // FIXME: EO API HERE
112 edje_object_signal_callback_add(obj, "*", "edc", _message_signal_reply_cb, &id);
113
114 // NOTE: edje_object_message_signal_process may or may not be in EO (TBD)
115
116 eina_value_setup(&v, EINA_VALUE_TYPE_STRING);
117 eina_value_set(&v, "hello world");
118 efl_layout_signal_message_send(obj, 0, v);
119 eina_value_flush(&v);
120 edje_message_signal_process();
121 edje_object_calc_force(obj);
122 ck_assert_int_eq(id, 1);
123
124 eina_value_setup(&v, EINA_VALUE_TYPE_INT);
125 eina_value_set(&v, 42);
126 efl_layout_signal_message_send(obj, 1, v);
127 eina_value_flush(&v);
128 edje_message_signal_process();
129 edje_object_calc_force(obj);
130 ck_assert_int_eq(id, 2);
131
132 eina_value_setup(&v, EINA_VALUE_TYPE_FLOAT);
133 eina_value_set(&v, 0.12);
134 efl_layout_signal_message_send(obj, 2, v);
135 eina_value_flush(&v);
136 edje_message_signal_process();
137 edje_object_calc_force(obj);
138 ck_assert_int_eq(id, 3);
139
140 va = eina_value_array_new(EINA_VALUE_TYPE_INT, 4);
141 eina_value_array_append(va, 7);
142 eina_value_array_append(va, 12);
143 eina_value_array_append(va, 42);
144 eina_value_array_append(va, 255);
145 efl_layout_signal_message_send(obj, 3, *va);
146 eina_value_free(va);
147 edje_message_signal_process();
148 edje_object_calc_force(obj);
149 ck_assert_int_eq(id, 4);
150
151 efl_del(obj);
152
153 evas_free(evas);
154}
155EFL_END_TEST
156
157EFL_START_TEST(edje_test_signals)
158{
159 Evas *evas;
160 Evas_Object *obj;
161 const char *state;
162
163 evas = _setup_evas();
164
165 obj = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
166 efl_file_set(efl_added, test_layout_get("test_signals.edj"), "level1"),
167 efl_gfx_entity_size_set(efl_added, EINA_SIZE2D(320, 240)),
168 efl_gfx_entity_visible_set(efl_added, 1));
169
170 edje_object_signal_emit(obj, "mouse,in", "text");
171
172 edje_object_message_signal_process(obj);
173 state = edje_object_part_state_get(obj, "group:group:text", NULL);
174 ck_assert_str_eq(state, "default");
175
176 edje_object_message_signal_process(obj);
177 state = edje_object_part_state_get(obj, "group:group:text", NULL);
178 ck_assert_str_eq(state, "default");
179
180 edje_object_message_signal_recursive_process(obj);
181 state = edje_object_part_state_get(obj, "group:group:text", NULL);
182 ck_assert_str_eq(state, "over");
183
184 efl_del(obj);
185
186 evas_free(evas);
187}
188EFL_END_TEST
189
190static int _signal_count;
191
192static void
193_signal_callback_count_cb(void *data, Evas_Object *obj EINA_UNUSED,
194 const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
195{
196 int *_data = data;
197 _signal_count += *_data;
198}
199
200EFL_START_TEST(edje_test_signal_callback_del_full)
201{
202 Evas *evas;
203 Evas_Object *obj;
204 int data[4] = { 1, 2, 4, 8 };
205
206 evas = _setup_evas();
207
208 obj = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
209 efl_file_set(efl_added,
210 test_layout_get("test_signal_callback_del_full.edj"), "test"),
211 efl_gfx_entity_size_set(efl_added, EINA_SIZE2D(320, 240)),
212 efl_gfx_entity_visible_set(efl_added, 1));
213
214 edje_object_signal_callback_add(obj, "some_signal", "event", _signal_callback_count_cb, &data[0]);
215 edje_object_signal_callback_add(obj, "some_signal", "event", _signal_callback_count_cb, &data[1]);
216 edje_object_signal_callback_add(obj, "some_signal", "event", _signal_callback_count_cb, &data[2]);
217 edje_object_signal_callback_add(obj, "some_signal", "event", _signal_callback_count_cb, &data[3]);
218
219 edje_object_signal_callback_del_full(obj, "some_signal", "event", _signal_callback_count_cb, &data[0]);
220 edje_object_signal_callback_del_full(obj, "some_signal", "event", _signal_callback_count_cb, &data[3]);
221
222 edje_object_signal_emit(obj, "some_signal", "event");
223
224 edje_object_message_signal_process(obj);
225 ck_assert_int_eq(_signal_count, (data[1] + data[2]));
226
227 efl_del(obj);
228
229 evas_free(evas);
230}
231EFL_END_TEST
232
233void edje_test_signal(TCase *tc)
234{
235 tcase_add_test(tc, edje_test_message_send_legacy);
236 tcase_add_test(tc, edje_test_message_send_eo);
237 tcase_add_test(tc, edje_test_signals);
238 tcase_add_test(tc, edje_test_signal_callback_del_full);
239
240}
diff --git a/src/tests/edje/edje_test_swallow.c b/src/tests/edje/edje_test_swallow.c
new file mode 100644
index 0000000..d255937
--- /dev/null
+++ b/src/tests/edje/edje_test_swallow.c
@@ -0,0 +1,104 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <unistd.h>
6#include <stdio.h>
7
8#define EFL_GFX_FILTER_BETA
9#define EFL_CANVAS_LAYOUT_BETA
10
11#include "edje_suite.h"
12
13#define EVAS_DATA_DIR TESTS_SRC_DIR "/../../lib/evas"
14
15
16EFL_START_TEST(edje_test_swallows)
17{
18 Evas *evas = _setup_evas();
19 Evas_Object *ly, *o1, *o2;
20
21 ly = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas);
22 fail_unless(edje_object_file_set(ly, test_layout_get("test_swallows.edj"), "test_group"));
23
24 fail_unless(edje_object_part_exists(ly, "swallow"));
25
26
27 o1 = efl_add(EFL_CANVAS_LAYOUT_CLASS, ly);
28 fail_if(!edje_object_part_swallow(ly, "swallow", o1));
29 ck_assert_ptr_eq(efl_parent_get(o1), ly);
30
31 edje_object_part_unswallow(ly, o1);
32 ck_assert_ptr_eq(efl_parent_get(o1), evas_object_evas_get(o1));
33
34 fail_if(!edje_object_part_swallow(ly, "swallow", o1));
35 ck_assert_ptr_eq(efl_parent_get(o1), ly);
36
37 o2 = efl_add(EFL_CANVAS_LAYOUT_CLASS, ly);
38 fail_if(!edje_object_part_swallow(ly, "swallow", o2));
39 ck_assert_ptr_eq(efl_parent_get(o2), ly);
40 /* o1 is deleted at this point. */
41 ck_assert_ptr_eq(efl_parent_get(o1), evas_object_evas_get(o1));
42
43 evas_free(evas);
44}
45EFL_END_TEST
46
47EFL_START_TEST(edje_test_swallows_lifetime)
48{
49 Evas *evas = _setup_evas();
50 Evas_Object *ly, *o1;
51
52 ly = edje_object_add(evas);
53 fail_unless(edje_object_file_set(ly, test_layout_get("test_swallows.edj"), "test_group"));
54
55 fail_unless(edje_object_part_exists(ly, "swallow"));
56
57 o1 = edje_object_add(ly);
58 fail_if(!edje_object_part_swallow(ly, "swallow", o1));
59
60 evas_object_del(ly);
61 fail_if(!efl_parent_get(o1));
62
63 evas_free(evas);
64}
65EFL_END_TEST
66
67EFL_START_TEST(edje_test_swallows_eoapi)
68{
69 Evas *evas = _setup_evas();
70 Evas_Object *ly, *o1, *o2;
71
72 ly = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas);
73 fail_unless(edje_object_file_set(ly, test_layout_get("test_swallows.edj"), "test_group"));
74
75 fail_unless(edje_object_part_exists(ly, "swallow"));
76
77
78 o1 = efl_add(EFL_CANVAS_LAYOUT_CLASS, ly);
79 fail_if(!efl_content_set(efl_part(ly, "swallow"), o1));
80 ck_assert_ptr_eq(efl_parent_get(o1), ly);
81
82 efl_content_remove(ly, o1);
83 ck_assert_ptr_eq(efl_parent_get(o1), evas_object_evas_get(o1));
84
85 fail_if(!efl_content_set(efl_part(ly, "swallow"), o1));
86 ck_assert_ptr_eq(efl_parent_get(o1), ly);
87
88 o2 = efl_add(EFL_CANVAS_LAYOUT_CLASS, ly);
89 fail_if(!efl_content_set(efl_part(ly, "swallow"), o2));
90 ck_assert_ptr_eq(efl_parent_get(o2), ly);
91 /* o1 is deleted at this point. */
92 ck_assert_ptr_eq(efl_parent_get(o1), evas_object_evas_get(o1));
93
94 evas_free(evas);
95}
96EFL_END_TEST
97
98
99void edje_test_swallow(TCase *tc)
100{
101 tcase_add_test(tc, edje_test_swallows);
102 tcase_add_test(tc, edje_test_swallows_lifetime);
103 tcase_add_test(tc, edje_test_swallows_eoapi);
104}
diff --git a/src/tests/edje/edje_test_text.c b/src/tests/edje/edje_test_text.c
new file mode 100644
index 0000000..d87ab48
--- /dev/null
+++ b/src/tests/edje/edje_test_text.c
@@ -0,0 +1,120 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <unistd.h>
6#include <stdio.h>
7
8#define EFL_GFX_FILTER_BETA
9#define EFL_CANVAS_LAYOUT_BETA
10
11#include "edje_suite.h"
12
13#define EVAS_DATA_DIR TESTS_SRC_DIR "/../../lib/evas"
14
15
16EFL_START_TEST(edje_test_text_cursor)
17{
18 Evas *evas;
19 Evas_Object *obj;
20 const char *buf = "ABC<br/>DEF";
21 const char *txt;
22 int i, old_pos, new_pos;
23
24 evas = _setup_evas();
25
26 obj = edje_object_add(evas);
27 fail_unless(edje_object_file_set(obj, test_layout_get("test_text_cursor.edj"), "test_text_cursor"));
28 edje_object_part_text_set(obj, "text", buf);
29 txt = edje_object_part_text_get(obj, "text");
30 fail_if(!txt || strcmp(txt, buf));
31
32 edje_object_part_text_cursor_pos_set(obj, "text", EDJE_CURSOR_MAIN, 0);
33 ck_assert_int_eq(edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN), 0);
34 edje_object_part_text_cursor_pos_set(obj, "text", EDJE_CURSOR_MAIN, 1);
35 ck_assert_int_eq(edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN), 1);
36
37 /* Move cursor to the 0 pos from 1 pos */
38 old_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
39 ck_assert(edje_object_part_text_cursor_prev(obj, "text", EDJE_CURSOR_MAIN));
40 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
41 ck_assert_int_ne(old_pos, new_pos);
42
43 /* Move cursor to the -1 pos from 0 pos. It has to fail. */
44 old_pos = new_pos;
45 ck_assert(!edje_object_part_text_cursor_prev(obj, "text", EDJE_CURSOR_MAIN));
46 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
47 ck_assert_int_eq(old_pos, new_pos);
48
49 /* Jump to 2nd line from 1st line.
50 * It has to return EINA_TRUE which means success. */
51 old_pos = new_pos;
52 ck_assert(edje_object_part_text_cursor_down(obj, "text", EDJE_CURSOR_MAIN));
53 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
54 ck_assert_int_ne(old_pos, new_pos);
55
56 /* Try to jump to 3rd line from 2nd line. But, 3rd line does not exist.
57 * So, it has to return EINA_FALSE which means failure. */
58 old_pos = new_pos;
59 ck_assert(!edje_object_part_text_cursor_down(obj, "text", EDJE_CURSOR_MAIN));
60 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
61 ck_assert_int_eq(old_pos, new_pos);
62
63 /* Move cursor to the end of 2nd line. */
64 for (i = 0; i < 3; i++)
65 {
66 old_pos = new_pos;
67 ck_assert(edje_object_part_text_cursor_next(obj, "text", EDJE_CURSOR_MAIN));
68 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
69 ck_assert_int_ne(old_pos, new_pos);
70 }
71
72 /* Move cursor to the next of the end of 2nd line which does not exist. */
73 old_pos = new_pos;
74 ck_assert(!edje_object_part_text_cursor_next(obj, "text", EDJE_CURSOR_MAIN));
75 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
76 ck_assert_int_eq(old_pos, new_pos);
77
78 /* Jump to 1st line from 2nd line.
79 * It has to return EINA_TRUE which means success. */
80 old_pos = new_pos;
81 ck_assert(edje_object_part_text_cursor_up(obj, "text", EDJE_CURSOR_MAIN));
82 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
83 ck_assert_int_ne(old_pos, new_pos);
84
85 /* Try to jump to the above of 1st line from 1st line. But, there is no such line.
86 * So, it has to return EINA_FALSE which means failure. */
87 old_pos = new_pos;
88 ck_assert(!edje_object_part_text_cursor_up(obj, "text", EDJE_CURSOR_MAIN));
89 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
90 ck_assert_int_eq(old_pos, new_pos);
91
92 evas_free(evas);
93}
94EFL_END_TEST
95
96
97EFL_START_TEST(edje_test_textblock)
98{
99 Evas *evas;
100 Evas_Object *obj;
101 const char *buf = "Hello";
102 const char *txt;
103
104 evas = _setup_evas();
105
106 obj = edje_object_add(evas);
107 fail_unless(edje_object_file_set(obj, test_layout_get("test_textblock.edj"), "test_textblock"));
108 edje_object_part_text_set(obj, "text", buf);
109 txt = edje_object_part_text_get(obj, "text");
110 fail_if(!txt || strcmp(txt, buf));
111
112 evas_free(evas);
113}
114EFL_END_TEST
115
116void edje_test_text(TCase *tc)
117{
118 tcase_add_test(tc, edje_test_text_cursor);
119 tcase_add_test(tc, edje_test_textblock);
120}
diff --git a/src/tests/edje/edje_tests_helpers.h b/src/tests/edje/edje_tests_helpers.h
deleted file mode 100644
index 530d10e..0000000
--- a/src/tests/edje/edje_tests_helpers.h
+++ /dev/null
@@ -1,42 +0,0 @@
1#ifndef EDJE_TEST_HELPERS_H
2#define EDJE_TEST_HELPERS_H
3
4#include <Ecore_Evas.h>
5
6/* FIXME: Currently depends on the buffer engine, should we do anything
7 * fancier? */
8
9#define EDJE_TEST_INIT_EVAS() _setup_evas()
10
11#define EDJE_TEST_FREE_EVAS() \
12 do \
13 { \
14 edje_shutdown(); \
15 evas_free(evas); \
16 ecore_evas_shutdown(); \
17 } \
18 while (0)
19
20static Evas *
21_setup_evas()
22{
23 Evas *evas;
24 Evas_Engine_Info *einfo;
25
26 ecore_evas_init();
27 edje_init();
28
29 evas = evas_new();
30
31 evas_output_method_set(evas, evas_render_method_lookup("buffer"));
32 einfo = evas_engine_info_get(evas);
33 evas_engine_info_set(evas, einfo);
34
35 evas_output_size_set(evas, 500, 500);
36 evas_output_viewport_set(evas, 0, 0, 500, 500);
37
38 return evas;
39}
40
41#endif
42