summaryrefslogtreecommitdiff
path: root/src/tests/edje/edje_test_edje.c
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2018-07-12 16:25:15 +0900
committerHermet Park <hermetpark@gmail.com>2018-07-12 16:25:15 +0900
commitb05a5cb4c73d890ab4cd65d8872a470193439bcc (patch)
treebbeca6357e2ddc38e1b2fb6b70dcef98da1f4ab5 /src/tests/edje/edje_test_edje.c
parenta62420ce36c38a85433c22185ed5dec9ce73e398 (diff)
tests/edje: split edje tests into separate files
Summary: this will speed up tests and make it slightly less intimidating to add new tests Reviewers: devilhorns Subscribers: cedric, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D6554
Diffstat (limited to 'src/tests/edje/edje_test_edje.c')
-rw-r--r--src/tests/edje/edje_test_edje.c927
1 files changed, 16 insertions, 911 deletions
diff --git a/src/tests/edje/edje_test_edje.c b/src/tests/edje/edje_test_edje.c
index b8c8179436..15e42f1243 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}