summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-08-20 15:57:13 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-08-26 14:42:48 +0200
commit35f9fc26e3d3c08d1404184ad15ef4035dc3d896 (patch)
tree93b6c03271d2745ce7f9684f9f26296c46981deb /src/tests
parentc467dc6e813cf5725e9f45f86e2d6db6e5b5ae8f (diff)
efl_ui_multi_selectable: add APIs for selecting
this can be used to select / unselect a range or all selectables in a container. The range selectable APIs do not have a strong ordering on a and b, b does not have to come after a. ref T8057 Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Differential Revision: https://phab.enlightenment.org/D9660
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/elementary/spec/efl_test_multi_selectable.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/tests/elementary/spec/efl_test_multi_selectable.c b/src/tests/elementary/spec/efl_test_multi_selectable.c
index 94a55749a0..5d5c1ed824 100644
--- a/src/tests/elementary/spec/efl_test_multi_selectable.c
+++ b/src/tests/elementary/spec/efl_test_multi_selectable.c
@@ -213,6 +213,91 @@ EFL_START_TEST(test_none_select)
213} 213}
214EFL_END_TEST 214EFL_END_TEST
215 215
216EFL_START_TEST(select_all_api)
217{
218 Eina_Array *arr_selected;
219
220 efl_ui_select_mode_set(widget, EFL_UI_SELECT_MODE_MULTI);
221 efl_ui_select_all(widget);
222 _iterator_to_array(&arr_selected, efl_ui_selected_items_get(widget));
223
224 ck_assert_int_eq(eina_array_count(arr_selected), 3);
225
226 ck_assert_ptr_eq(eina_array_data_get(arr_selected, 0), efl_pack_content_get(widget, 0));
227 ck_assert_ptr_eq(eina_array_data_get(arr_selected, 1), efl_pack_content_get(widget, 1));
228 ck_assert_ptr_eq(eina_array_data_get(arr_selected, 2), efl_pack_content_get(widget, 2));
229}
230EFL_END_TEST
231
232EFL_START_TEST(unselect_all_api)
233{
234 Eina_Array *arr_selected;
235
236 efl_ui_select_mode_set(widget, EFL_UI_SELECT_MODE_MULTI);
237 efl_ui_selectable_selected_set(efl_pack_content_get(widget, 0), EINA_TRUE);
238
239 efl_ui_unselect_all(widget);
240 _iterator_to_array(&arr_selected, efl_ui_selected_items_get(widget));
241
242 ck_assert_int_eq(eina_array_count(arr_selected), 0);
243 ck_assert_int_eq(efl_ui_selectable_selected_get(efl_pack_content_get(widget, 0)), EINA_FALSE);
244}
245EFL_END_TEST
246
247EFL_START_TEST(unselect_range)
248{
249 Eina_Array *arr_selected;
250
251 efl_ui_select_mode_set(widget, EFL_UI_SELECT_MODE_MULTI);
252 efl_ui_select_all(widget);
253
254 efl_ui_unselect_range(widget, efl_pack_content_get(widget, 1), efl_pack_content_get(widget, 2));
255 _iterator_to_array(&arr_selected, efl_ui_selected_items_get(widget));
256 ck_assert_int_eq(eina_array_count(arr_selected), 1);
257 ck_assert_ptr_eq(eina_array_data_get(arr_selected, 0), efl_pack_content_get(widget, 0));
258}
259EFL_END_TEST
260
261EFL_START_TEST(unselect_range2)
262{
263 Eina_Array *arr_selected;
264
265 efl_ui_select_mode_set(widget, EFL_UI_SELECT_MODE_MULTI);
266 efl_ui_select_all(widget);
267
268 efl_ui_unselect_range(widget, efl_pack_content_get(widget, 2), efl_pack_content_get(widget, 1));
269 _iterator_to_array(&arr_selected, efl_ui_selected_items_get(widget));
270 ck_assert_int_eq(eina_array_count(arr_selected), 1);
271 ck_assert_ptr_eq(eina_array_data_get(arr_selected, 0), efl_pack_content_get(widget, 0));
272}
273EFL_END_TEST
274
275EFL_START_TEST(select_range)
276{
277 Eina_Array *arr_selected;
278
279 efl_ui_select_mode_set(widget, EFL_UI_SELECT_MODE_MULTI);
280 efl_ui_select_range(widget, efl_pack_content_get(widget, 1), efl_pack_content_get(widget, 2));
281 _iterator_to_array(&arr_selected, efl_ui_selected_items_get(widget));
282 ck_assert_int_eq(eina_array_count(arr_selected), 2);
283 ck_assert_ptr_eq(eina_array_data_get(arr_selected, 0), efl_pack_content_get(widget, 1));
284 ck_assert_ptr_eq(eina_array_data_get(arr_selected, 1), efl_pack_content_get(widget, 2));
285}
286EFL_END_TEST
287
288EFL_START_TEST(select_range2)
289{
290 Eina_Array *arr_selected;
291
292 efl_ui_select_mode_set(widget, EFL_UI_SELECT_MODE_MULTI);
293 efl_ui_select_range(widget, efl_pack_content_get(widget, 2), efl_pack_content_get(widget, 1));
294 _iterator_to_array(&arr_selected, efl_ui_selected_items_get(widget));
295 ck_assert_int_eq(eina_array_count(arr_selected), 2);
296 ck_assert_ptr_eq(eina_array_data_get(arr_selected, 0), efl_pack_content_get(widget, 1));
297 ck_assert_ptr_eq(eina_array_data_get(arr_selected, 1), efl_pack_content_get(widget, 2));
298}
299EFL_END_TEST
300
216void 301void
217efl_ui_multi_selectable_behavior_test(TCase *tc) 302efl_ui_multi_selectable_behavior_test(TCase *tc)
218{ 303{
@@ -222,5 +307,11 @@ efl_ui_multi_selectable_behavior_test(TCase *tc)
222 tcase_add_test(tc, test_single_select); 307 tcase_add_test(tc, test_single_select);
223 tcase_add_test(tc, test_none_select); 308 tcase_add_test(tc, test_none_select);
224 tcase_add_test(tc, test_single_select_always); 309 tcase_add_test(tc, test_single_select_always);
310 tcase_add_test(tc, select_all_api);
311 tcase_add_test(tc, unselect_all_api);
312 tcase_add_test(tc, unselect_range);
313 tcase_add_test(tc, unselect_range2);
314 tcase_add_test(tc, select_range);
315 tcase_add_test(tc, select_range2);
225 efl_ui_single_selectable_behavior_test(tc); 316 efl_ui_single_selectable_behavior_test(tc);
226} 317}