summaryrefslogtreecommitdiff
path: root/src/tests/elementary/elm_test_list.c
blob: d15fb249f7eed1ad112e8466407639ef78a75678 (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif

#define EFL_ACCESS_SELECTION_PROTECTED
#define EFL_ACCESS_OBJECT_BETA
#define EFL_ACCESS_OBJECT_PROTECTED
#include <Elementary.h>
#include "elm_suite.h"

EFL_START_TEST(elm_list_legacy_type_check)
{
   Evas_Object *win, *list;
   const char *type;

   win = win_add(NULL, "list", ELM_WIN_BASIC);

   list = elm_list_add(win);

   type = elm_object_widget_type_get(list);
   ck_assert(type != NULL);
   ck_assert(!strcmp(type, "Elm_List"));

   type = evas_object_type_get(list);
   ck_assert(type != NULL);
   ck_assert(!strcmp(type, "elm_list"));

}
EFL_END_TEST

#if 0
// Skip following tests until Elm_Widget_Item will migrate to Eo infrastructure
// and following features can be implemented

EFL_START_TEST(elm_list_atspi_selection_selected_children_count_get)
{
 Evas_Object *win, *list;
 Elm_Object_Item *item;
 int val;


 win = win_add(NULL, "list", ELM_WIN_BASIC);

 list = elm_list_add(win);
 item = elm_list_item_append(list, "First Element", NULL, NULL, NULL, NULL);

 val = elm_interface_atspi_selection_selected_children_count_get(list);
 ck_assert(val == 0);

 elm_list_item_selected_set(item, EINA_TRUE);
 val = elm_interface_atspi_selection_selected_children_count_get(list);
 ck_assert(val == 1);

 elm_list_item_selected_set(item, EINA_FALSE);
 val = elm_interface_atspi_selection_selected_children_count_get(list);
 ck_assert(val == 0);

}
EFL_END_TEST

EFL_START_TEST(elm_list_atspi_selection_child_select)
{
 Evas_Object *win, *list;
 Elm_Object_Item *item;
 Eina_Bool val;


 win = win_add(NULL, "list", ELM_WIN_BASIC);

 list = elm_list_add(win);
 item = elm_list_item_append(list, "First Element", NULL, NULL, NULL, NULL);

 val = elm_interface_atspi_selection_child_select(list, 0);
 ck_assert(val == EINA_TRUE);
 ck_assert(EINA_TRUE == elm_list_item_selected_get(item));

}
EFL_END_TEST

EFL_START_TEST(elm_list_atspi_selection_selected_child_deselect)
{
 Evas_Object *win, *list;
 Elm_Object_Item *item;
 Eina_Bool val;


 win = win_add(NULL, "list", ELM_WIN_BASIC);

 list = elm_list_add(win);
 elm_list_multi_select_set(list, EINA_TRUE);
 elm_list_item_append(list, "First Element", NULL, NULL, NULL, NULL);
 item = elm_list_item_append(list, "Second Element", NULL, NULL, NULL, NULL);

 elm_list_item_selected_set(item, EINA_TRUE);
 val = elm_interface_atspi_selection_selected_child_deselect(list, 0);
 ck_assert(val == EINA_TRUE);
 ck_assert(EINA_FALSE == elm_list_item_selected_get(item));

}
EFL_END_TEST

EFL_START_TEST(elm_list_atspi_selection_is_child_selected)
{
 Evas_Object *win, *list;
 Elm_Object_Item *item;
 Eina_Bool val;


 win = win_add(NULL, "list", ELM_WIN_BASIC);

 list = elm_list_add(win);
 item = elm_list_item_append(list, "First Element", NULL, NULL, NULL, NULL);

 val = elm_interface_atspi_selection_is_child_selected(list, 0);
 ck_assert(val == EINA_FALSE);

 elm_list_item_selected_set(item, EINA_TRUE);
 val = elm_interface_atspi_selection_is_child_selected(list, 0);
 ck_assert(val == EINA_TRUE);

}
EFL_END_TEST

EFL_START_TEST(elm_list_atspi_selection_all_children_select)
{
 Evas_Object *win, *list;
 Elm_Object_Item *item1, *item2;
 Eina_Bool val;


 win = win_add(NULL, "list", ELM_WIN_BASIC);

 list = elm_list_add(win);

 item1 = elm_list_item_append(list, "First Element", NULL, NULL, NULL, NULL);
 item2 = elm_list_item_append(list, "Second Element", NULL, NULL, NULL, NULL);

 val = elm_interface_atspi_selection_all_children_select(list);
 ck_assert(val == EINA_FALSE);

 elm_list_multi_select_set(list, EINA_TRUE);
 val = elm_interface_atspi_selection_all_children_select(list);
 ck_assert(val == EINA_TRUE);
 ck_assert(EINA_TRUE == elm_list_item_selected_get(item1));
 ck_assert(EINA_TRUE == elm_list_item_selected_get(item2));

}
EFL_END_TEST


EFL_START_TEST(elm_list_atspi_selection_clear)
{
 Evas_Object *win, *list;
 Elm_Object_Item *item1, *item2;
 Eina_Bool val;


 win = win_add(NULL, "list", ELM_WIN_BASIC);

 list = elm_list_add(win);
 elm_list_multi_select_set(list, EINA_TRUE);
 item1 = elm_list_item_append(list, "First Element", NULL, NULL, NULL, NULL);
 item2 = elm_list_item_append(list, "Second Element", NULL, NULL, NULL, NULL);
 elm_list_item_selected_set(item1, EINA_TRUE);
 elm_list_item_selected_set(item2, EINA_TRUE);


 val = elm_interface_atspi_selection_clear(list);
 ck_assert(val == EINA_TRUE);
 ck_assert(EINA_FALSE == elm_list_item_selected_get(item1));
 ck_assert(EINA_FALSE == elm_list_item_selected_get(item2));

}
EFL_END_TEST

EFL_START_TEST(elm_list_atspi_selection_child_deselect)
{
 Evas_Object *win, *list;
 Elm_Object_Item *item;
 Eina_Bool val;


 win = win_add(NULL, "list", ELM_WIN_BASIC);

 list = elm_list_add(win);
 elm_list_multi_select_set(list, EINA_TRUE);
 elm_list_item_append(list, "First Element", NULL, NULL, NULL, NULL);
 item = elm_list_item_append(list, "Second Element", NULL, NULL, NULL, NULL);

 elm_list_item_selected_set(item, EINA_TRUE);
 val = elm_interface_atspi_selection_selected_child_deselect(list, 1);
 ck_assert(val == EINA_TRUE);
 ck_assert(EINA_FALSE == elm_list_item_selected_get(item));

}
EFL_END_TEST

#endif

EFL_START_TEST(elm_atspi_role_get)
{
 Evas_Object *win, *list;
 Efl_Access_Role role;


 win = win_add(NULL, "list", ELM_WIN_BASIC);

 list = elm_list_add(win);
 role = efl_access_object_role_get(list);

 ck_assert(role == EFL_ACCESS_ROLE_LIST);

}
EFL_END_TEST


/**
 * Validate if genlist implementation properly reset parent to Elm_Genlist_Item
 * from Elm_Genlist
 */
EFL_START_TEST(elm_atspi_children_parent)
{
   Efl_Access_Object *parent;
   Elm_Object_Item *it;

   Evas_Object *win = win_add(NULL, "list", ELM_WIN_BASIC);

   Evas_Object *icon = elm_icon_add(win);
   Evas_Object *end = elm_icon_add(win);

   Evas_Object *list = elm_list_add(win);
   it = elm_list_item_append(list, "First Element", icon, end, NULL, NULL);

   evas_object_show(list);

   parent = efl_provider_find(efl_parent_get(icon), EFL_ACCESS_OBJECT_MIXIN);
   ck_assert(it == parent);

   parent = efl_provider_find(efl_parent_get(end), EFL_ACCESS_OBJECT_MIXIN);
   ck_assert(it == parent);

}
EFL_END_TEST

void elm_test_list(TCase *tc)
{
   tcase_add_test(tc, elm_list_legacy_type_check);
   tcase_add_test(tc, elm_atspi_role_get);
#if 0
   tcase_add_test(tc, elm_list_atspi_selection_selected_children_count_get);
   tcase_add_test(tc, elm_list_atspi_selection_child_select);
   tcase_add_test(tc, elm_list_atspi_selection_selected_child_deselect);
   tcase_add_test(tc, elm_list_atspi_selection_is_child_selected);
   tcase_add_test(tc, elm_list_atspi_selection_all_children_select);
   tcase_add_test(tc, elm_list_atspi_selection_clear);
   tcase_add_test(tc, elm_list_atspi_selection_child_deselect);
#endif
   tcase_add_test(tc, elm_atspi_children_parent);
}