summaryrefslogtreecommitdiff
path: root/src/tests/elementary/efl_ui_test_group_item.c
blob: 248ffcc2f89fcd1194539ddcae6fd506e520ec44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#define EFL_NOLEGACY_API_SUPPORT
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#define EFL_LAYOUT_CALC_PROTECTED
#include <Efl_Ui.h>
#include "efl_ui_suite.h"

static Eo *win;
static Eo *grid;

static void
create_ui(void)
{
   win = win_add();
   grid = efl_add(EFL_UI_GRID_CLASS, win);

}

static void
_ordering_equals(Efl_Ui_Widget **wid, unsigned int len)
{
   for (unsigned int i = 0; i < len; ++i)
     {
        ck_assert_ptr_eq(efl_pack_content_get(grid, i), wid[i]);
     }
   ck_assert_int_eq(efl_content_count(grid), len);
}

EFL_START_TEST(non_linear_insertion_pack_at)
{
   Eo *group[3];
   Eo *order[12];

   for (int i = 0; i < 3; ++i)
     {
        order[i*4] = group[i] = efl_add(EFL_UI_GROUP_ITEM_CLASS, grid);
        efl_pack_at(grid, group[i], i);
     }

   for (int i = 0; i < 3; ++i)
     {
        for (int j = 0; j < 3; ++j)
          {
             Eo *item = order[4*i+(1+j)] = efl_add(EFL_UI_GRID_DEFAULT_ITEM_CLASS, grid);
             efl_pack_at(group[i], item, j);
          }
     }
   _ordering_equals(order, 12);
}
EFL_END_TEST

EFL_START_TEST(non_linear_insertion_pack_end)
{
   Eo *group[3];
   Eo *order[12];

   for (int i = 0; i < 3; ++i)
     {
        order[i*4] = group[i] = efl_add(EFL_UI_GROUP_ITEM_CLASS, grid);
        efl_pack_end(grid, group[i]);
     }

   for (int i = 0; i < 3; ++i)
     {
        for (int j = 0; j < 3; ++j)
          {
             Eo *item = order[4*i+(1+j)] = efl_add(EFL_UI_GRID_DEFAULT_ITEM_CLASS, grid);
             efl_pack_end(group[i], item);
          }
     }
   _ordering_equals(order, 12);
}
EFL_END_TEST

void efl_ui_test_group_item(TCase *tc)
{
   tcase_add_checked_fixture(tc, fail_on_errors_setup, fail_on_errors_teardown);
   tcase_add_checked_fixture(tc, create_ui, NULL);
   tcase_add_test(tc, non_linear_insertion_pack_at);
   tcase_add_test(tc, non_linear_insertion_pack_end);
}