summaryrefslogtreecommitdiff
path: root/src/tests/edje
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-04-25 16:20:57 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-04-26 14:09:36 +0900
commitf19da66843552cccc8479cb3bee7d42264f598ce (patch)
treeb1e9ed50329ae769bda38cccd988f0449c766c09 /src/tests/edje
parent12146ddea63a47ff0cdacc47e4f02a13221eb84b (diff)
Edje: Add test case for edje table
This tests the EO and Legacy APIs
Diffstat (limited to 'src/tests/edje')
-rw-r--r--src/tests/edje/data/test_table.edc116
-rw-r--r--src/tests/edje/edje_test_edje.c156
2 files changed, 272 insertions, 0 deletions
diff --git a/src/tests/edje/data/test_table.edc b/src/tests/edje/data/test_table.edc
index e69de29bb2..6ba175c316 100644
--- a/src/tests/edje/data/test_table.edc
+++ b/src/tests/edje/data/test_table.edc
@@ -0,0 +1,116 @@
1collections {
2 group { "item1";
3 parts {
4 text { "text";
5 desc {
6 text {
7 font: "Sans";
8 size: 42;
9 text: "0,0";
10 ellipsis: -1;
11 }
12 min: 1 1;
13 }
14 }
15 }
16 }
17 group { "item2";
18 parts {
19 text { "text";
20 desc {
21 text {
22 font: "Sans";
23 size: 42;
24 text: "1,0";
25 ellipsis: -1;
26 }
27 min: 1 1;
28 }
29 }
30 }
31 }
32 group { "item3";
33 parts {
34 text { "text";
35 desc {
36 text {
37 font: "Sans";
38 size: 42;
39 text: "0,1";
40 ellipsis: -1;
41 }
42 min: 1 1;
43 }
44 }
45 }
46 }
47 group { "item4";
48 parts {
49 text { "text";
50 desc {
51 text {
52 font: "Sans";
53 size: 42;
54 text: "1,1";
55 ellipsis: -1;
56 }
57 min: 1 1;
58 }
59 }
60 }
61 }
62 group { "test_group";
63 parts {
64 rect { "rect";
65 desc {
66 rel.to: "table";
67 color: 12 32 64 128;
68 }
69 }
70 table { "table";
71 desc {
72 table {
73 homogeneous: TABLE;
74 padding: 10 10;
75 }
76 }
77 table {
78 items {
79 item {
80 type: GROUP;
81 source: "item1";
82 position: 0 0;
83 span: 1 1;
84 weight: 1 1;
85 align: -1 -1;
86 }
87 item {
88 type: GROUP;
89 source: "item2";
90 position: 1 0;
91 span: 1 1;
92 weight: 1 1;
93 align: -1 -1;
94 }
95 item {
96 type: GROUP;
97 source: "item3";
98 position: 0 1;
99 span: 1 1;
100 weight: 1 1;
101 align: -1 -1;
102 }
103 item {
104 type: GROUP;
105 source: "item4";
106 position: 1 1;
107 span: 1 1;
108 weight: 1 1;
109 align: -1 -1;
110 }
111 }
112 }
113 }
114 }
115 }
116} \ No newline at end of file
diff --git a/src/tests/edje/edje_test_edje.c b/src/tests/edje/edje_test_edje.c
index 1ac5971da3..5fd77b86e7 100644
--- a/src/tests/edje/edje_test_edje.c
+++ b/src/tests/edje/edje_test_edje.c
@@ -560,6 +560,160 @@ START_TEST(edje_test_box_eoapi)
560} 560}
561END_TEST 561END_TEST
562 562
563START_TEST(edje_test_table)
564{
565 Evas *evas;
566 Evas_Object *obj, *sobj, *sobjs[4];
567 int i, k, l, cols, rows;
568
569 evas = EDJE_TEST_INIT_EVAS();
570
571 obj = edje_object_add(evas);
572 fail_unless(edje_object_file_set(obj, test_layout_get("test_table.edj"), "test_group"));
573
574 /* check items from EDC */
575 for (l = 0; l < 2; l++)
576 for (k = 0; k < 2; k++)
577 {
578 const char *txt;
579 char buf[20];
580
581 /* items have a text part "text" containing their position */
582 sprintf(buf, "%d,%d", k, l);
583 sobj = edje_object_part_table_child_get(obj, "table", k, l);
584 fail_if(!sobj);
585 txt = edje_object_part_text_get(sobj, "text");
586 fail_if(!txt);
587 fail_if(strcmp(txt, buf) != 0);
588 }
589
590 /* Add more items */
591 for (l = 0; l < 2; l++)
592 for (k = 0; k < 2; k++)
593 {
594 i = l*2 + k;
595 sobjs[i] = evas_object_rectangle_add(evas);
596 fail_if(!sobjs[i]);
597 edje_object_part_table_pack(obj, "table", sobjs[i], k, l + 2, 1, 1);
598 }
599
600 for (l = 0; l < 2; l++)
601 for (k = 0; k < 2; k++)
602 {
603 i = l*2 + k;
604 sobj = edje_object_part_table_child_get(obj, "table", k, l + 2);
605 fail_if(sobj != sobjs[i]);
606 }
607
608 /* table size and clear */
609 edje_object_part_table_col_row_size_get(obj, "table", &cols, &rows);
610 fail_if(cols != 2);
611 fail_if(rows != 4);
612
613 edje_object_part_table_clear(obj, "table", EINA_TRUE);
614
615 edje_object_part_table_col_row_size_get(obj, "table", &cols, &rows);
616 fail_if(cols != 2);
617 fail_if(rows != 2);
618
619 for (l = 0; l < 2; l++)
620 for (k = 0; k < 2; k++)
621 {
622 const char *txt;
623 char buf[20];
624
625 /* items have a text part "text" containing their position */
626 sprintf(buf, "%d,%d", k, l);
627 sobj = edje_object_part_table_child_get(obj, "table", k, l);
628 fail_if(!sobj);
629 txt = edje_object_part_text_get(sobj, "text");
630 fail_if(!txt);
631 fail_if(strcmp(txt, buf) != 0);
632 }
633
634 EDJE_TEST_FREE_EVAS();
635}
636END_TEST
637
638START_TEST(edje_test_table_eoapi)
639{
640 Evas *evas;
641 Evas_Object *obj, *sobj, *sobjs[4];
642 Eina_Iterator *it;
643 Eo *table;
644 int i, k, l, cs, rs, cols, rows;
645
646 evas = EDJE_TEST_INIT_EVAS();
647
648 obj = edje_object_add(evas);
649 fail_unless(edje_object_file_set(obj, test_layout_get("test_table.edj"), "test_group"));
650
651 table = efl_content_get(obj, "table");
652 fail_if(!table);
653
654 /* check items from EDC */
655 fail_if(efl_content_count(table) != 4);
656 for (l = 0; l < 2; l++)
657 for (k = 0; k < 2; k++)
658 {
659 const char *txt;
660 char buf[20];
661
662 /* items have a text part "text" containing their position */
663 sprintf(buf, "%d,%d", k, l);
664 sobj = efl_pack_grid_content_at(table, k, l);
665 fail_if(!sobj);
666 //txt = efl_part_text_get(sobj, "text");
667 txt = edje_object_part_text_get(sobj, "text");
668 fail_if(!txt);
669 fail_if(strcmp(txt, buf) != 0);
670 }
671
672 /* Add more items */
673 for (l = 0; l < 2; l++)
674 for (k = 0; k < 2; k++)
675 {
676 i = l*2 + k;
677 sobjs[i] = eo_add(EVAS_RECTANGLE_CLASS, evas);
678 fail_if(!sobjs[i]);
679 efl_pack_grid(table, sobjs[i], k, l + 2, 1, 1);
680 }
681
682 fail_if(efl_content_count(table) != 8);
683
684 i = 0;
685 it = efl_content_iterate(table);
686 EINA_ITERATOR_FOREACH(it, sobj)
687 {
688 efl_pack_grid_content_position_get(table, sobj, &k, &l, &cs, &rs);
689 fail_if(cs != 1);
690 fail_if(rs != 1);
691 if (l >= 2)
692 fail_if(sobj != sobjs[(l - 2)*2 + k]);
693 i++;
694 }
695 eina_iterator_free(it);
696 fail_if(i != 8);
697
698 /* table size and clear */
699 efl_pack_grid_size_get(table, &cols, &rows);
700 fail_if(cols != 2);
701 fail_if(rows != 4);
702
703 efl_pack_clear(table);
704 fail_if(efl_content_count(table) != 4);
705
706 efl_pack_grid_size_get(table, &cols, &rows);
707 fail_if(cols != 2);
708 fail_if(rows != 2);
709
710 /* release handle - not required */
711 eo_del(table);
712
713 EDJE_TEST_FREE_EVAS();
714}
715END_TEST
716
563void edje_test_edje(TCase *tc) 717void edje_test_edje(TCase *tc)
564{ 718{
565 tcase_add_test(tc, edje_test_edje_init); 719 tcase_add_test(tc, edje_test_edje_init);
@@ -578,4 +732,6 @@ void edje_test_edje(TCase *tc)
578 tcase_add_test(tc, edje_test_access); 732 tcase_add_test(tc, edje_test_access);
579 tcase_add_test(tc, edje_test_box); 733 tcase_add_test(tc, edje_test_box);
580 tcase_add_test(tc, edje_test_box_eoapi); 734 tcase_add_test(tc, edje_test_box_eoapi);
735 tcase_add_test(tc, edje_test_table);
736 tcase_add_test(tc, edje_test_table_eoapi);
581} 737}