summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-09-11 13:38:07 -0400
committerMike Blumenkrantz <zmike@samsung.com>2019-09-11 13:38:07 -0400
commit6088557233f9c8fce259e58ae28d105ef1635bcd (patch)
treed937a1757bd5b0ef20624039932ede8ea70d2d06
parentc9399b2154d6cdad89fd2e8bc45627c3fcf8be05 (diff)
downloadefl-6088557233f9c8fce259e58ae28d105ef1635bcd.tar.gz
efl_ui_test_list_collection: add test for item placement
Summary: this test checks if the placement of the items is correct with and without scrolling, with and without groups. Depends on D9869 Reviewers: segfaultxavi, zmike, cedric Reviewed By: zmike Subscribers: #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9870
-rw-r--r--src/tests/elementary/efl_ui_test_list_collection.c281
1 files changed, 281 insertions, 0 deletions
diff --git a/src/tests/elementary/efl_ui_test_list_collection.c b/src/tests/elementary/efl_ui_test_list_collection.c
index 98af17e7ec..1d4f913901 100644
--- a/src/tests/elementary/efl_ui_test_list_collection.c
+++ b/src/tests/elementary/efl_ui_test_list_collection.c
@@ -16,6 +16,7 @@ item_container_setup()
win = win_add();
item_container = efl_add(EFL_UI_COLLECTION_CLASS, win,
efl_ui_collection_position_manager_set(efl_added, list));
+ efl_content_set(win, item_container);
}
@@ -27,10 +28,290 @@ item_container_teardown()
win = NULL;
}
+
+EFL_START_TEST(placement_test_only_items)
+{
+ Eo *item[3];
+
+ for (int i = 0; i < 2; ++i)
+ {
+ Eo *item = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, item_container);
+ efl_pack_end(item_container, item);
+ efl_gfx_hint_size_min_set(item, EINA_SIZE2D(40, 40));
+ }
+
+ for (int i = 0; i < 3; ++i)
+ {
+ item[i] = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, item_container);
+ efl_pack_end(item_container, item[i]);
+ efl_gfx_hint_size_min_set(item[i], EINA_SIZE2D(40, 40));
+
+ }
+
+ //now fill up to trigger the scrollbar to be visible
+ for (int i = 0; i < 10; ++i)
+ {
+ Eo *item = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, item_container);
+ efl_pack_end(item_container, item);
+ efl_gfx_hint_size_min_set(item, EINA_SIZE2D(40, 40));
+ }
+
+ efl_gfx_entity_geometry_set(win, EINA_RECT(0, 0, 200, 200));
+
+ get_me_to_those_events(item_container);
+
+ for (int i = 0; i < 3; ++i)
+ {
+ Eina_Rect r = efl_gfx_entity_geometry_get(item[i]);
+
+ ck_assert_int_eq(r.x, 1);
+ ck_assert_int_eq(r.y, 1+(i+2)*40);
+ ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
+ ck_assert_int_eq(r.h, 40);
+ }
+
+ efl_ui_scrollable_content_pos_set(item_container, EINA_POSITION2D(0, 80));
+
+ for (int i = 0; i < 3; ++i)
+ {
+ Eina_Rect r = efl_gfx_entity_geometry_get(item[i]);
+
+ ck_assert_int_eq(r.x, 1);
+ ck_assert_int_eq(r.y, 1+i*40);
+ ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
+ ck_assert_int_eq(r.h, 40);
+ }
+
+}
+EFL_END_TEST
+
+EFL_START_TEST(placement_test_group)
+{
+ Eo *core_item[4];
+ Eo *group;
+ Eina_Rect r;
+
+ for (int i = 0; i < 1; ++i)
+ {
+ Eo *item = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, item_container);
+ efl_pack_end(item_container, item);
+ efl_gfx_hint_size_min_set(item, EINA_SIZE2D(40, 40));
+ }
+
+ core_item[0] = group = efl_add(EFL_UI_GROUP_ITEM_CLASS, item_container);
+ efl_pack_end(item_container, group);
+ efl_gfx_hint_size_min_set(group, EINA_SIZE2D(40, 40));
+
+ Eo **item = core_item+1;
+ for (int i = 0; i < 3; ++i)
+ {
+ item[i] = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, item_container);
+ efl_pack_end(group, item[i]);
+ efl_gfx_hint_size_min_set(item[i], EINA_SIZE2D(40, 40));
+
+ }
+
+ //now fill up to trigger the scrollbar to be visible
+ for (int i = 0; i < 10; ++i)
+ {
+ Eo *item = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, item_container);
+ efl_pack_end(group, item);
+ efl_gfx_hint_size_min_set(item, EINA_SIZE2D(40, 40));
+ }
+
+ efl_gfx_entity_geometry_set(win, EINA_RECT(0, 0, 200, 200));
+
+ get_me_to_those_events(item_container);
+
+ for (int i = 0; i < 4; ++i)
+ {
+ r = efl_gfx_entity_geometry_get(core_item[i]);
+
+ ck_assert_int_eq(r.x, 1);
+ ck_assert_int_eq(r.y, 1+(i+1)*40);
+ ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
+ ck_assert_int_eq(r.h, 40);
+ }
+
+ // test when we have scrolled to the top of the group item - just testing normal scrolling
+ efl_ui_scrollable_content_pos_set(item_container, EINA_POSITION2D(0, 40));
+
+ for (int i = 0; i < 4; ++i)
+ {
+ r = efl_gfx_entity_geometry_get(core_item[i]);
+
+ ck_assert_int_eq(r.x, 1);
+ ck_assert_int_eq(r.y, 1+i*40);
+ ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
+ ck_assert_int_eq(r.h, 40);
+ }
+
+ //testing the placement in the middle of the item - group must already be warped
+ efl_ui_scrollable_content_pos_set(item_container, EINA_POSITION2D(0, 60));
+
+ r = efl_gfx_entity_geometry_get(core_item[0]);
+
+ ck_assert_int_eq(r.x, 1);
+ ck_assert_int_eq(r.y, 1);
+ ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
+ ck_assert_int_eq(r.h, 40);
+
+ for (int i = 1; i < 4; ++i)
+ {
+ r = efl_gfx_entity_geometry_get(core_item[i]);
+
+ ck_assert_int_eq(r.x, 1);
+ ck_assert_int_eq(r.y, 21+(i - 1)*40);
+ ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
+ ck_assert_int_eq(r.h, 40);
+ }
+
+ // testing if we have scrolled into the middle of the group the group item is not even in the calculated index anymore
+ efl_ui_scrollable_content_pos_set(item_container, EINA_POSITION2D(0, 120));
+
+ r = efl_gfx_entity_geometry_get(core_item[0]);
+
+ ck_assert_int_eq(r.x, 1);
+ ck_assert_int_eq(r.y, 1);
+ ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
+ ck_assert_int_eq(r.h, 40);
+
+ for (int i = 2; i < 4; ++i)
+ {
+ r = efl_gfx_entity_geometry_get(core_item[i]);
+
+ ck_assert_int_eq(r.x, 1);
+ ck_assert_int_eq(r.y, 1+(i-2)*40);
+ ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
+ ck_assert_int_eq(r.h, 40);
+ }
+
+}
+EFL_END_TEST
+
+EFL_START_TEST(placement_test_group_crazy)
+{
+ Eo *core_item[4];
+ Eo *group;
+ Eina_Rect r;
+
+ for (int i = 0; i < 1; ++i)
+ {
+ Eo *item = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, item_container);
+ efl_pack_end(item_container, item);
+ efl_gfx_hint_size_min_set(item, EINA_SIZE2D(40, 40));
+ }
+
+ core_item[0] = group = efl_add(EFL_UI_GROUP_ITEM_CLASS, item_container);
+ efl_pack_end(item_container, group);
+ efl_gfx_hint_size_min_set(group, EINA_SIZE2D(40, 40));
+
+ Eo **item = core_item+1;
+ for (int i = 0; i < 3; ++i)
+ {
+ item[i] = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, item_container);
+ efl_pack_end(group, item[i]);
+ efl_gfx_hint_size_min_set(item[i], EINA_SIZE2D(40, 40));
+
+ }
+
+ //now fill up to trigger the scrollbar to be visible
+ for (int i = 0; i < 10; ++i)
+ {
+ Eo *group2 = efl_add(EFL_UI_GROUP_ITEM_CLASS, item_container);
+ efl_pack_end(item_container, group2);
+ efl_gfx_hint_size_min_set(group2, EINA_SIZE2D(40, 40));
+ for (int i = 0; i < 3; ++i)
+ {
+ Eo *item = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, item_container);
+ efl_pack_end(group2, item);
+ efl_gfx_hint_size_min_set(item, EINA_SIZE2D(40, 40));
+ }
+ }
+
+ efl_gfx_entity_geometry_set(win, EINA_RECT(0, 0, 200, 800));
+
+ get_me_to_those_events(item_container);
+
+ for (int i = 0; i < 4; ++i)
+ {
+ r = efl_gfx_entity_geometry_get(core_item[i]);
+
+ ck_assert_int_eq(r.x, 1);
+ ck_assert_int_eq(r.y, 1+(i+1)*40);
+ ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
+ ck_assert_int_eq(r.h, 40);
+ ck_assert_int_eq(efl_gfx_entity_visible_get(core_item[i]), EINA_TRUE);
+ }
+
+ // test when we have scrolled to the top of the group item - just testing normal scrolling
+ efl_ui_scrollable_content_pos_set(item_container, EINA_POSITION2D(0, 40));
+
+ for (int i = 0; i < 4; ++i)
+ {
+ r = efl_gfx_entity_geometry_get(core_item[i]);
+
+ ck_assert_int_eq(r.x, 1);
+ ck_assert_int_eq(r.y, 1+i*40);
+ ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
+ ck_assert_int_eq(r.h, 40);
+ ck_assert_int_eq(efl_gfx_entity_visible_get(core_item[i]), EINA_TRUE);
+ }
+
+ //testing the placement in the middle of the item - group must already be warped
+ efl_ui_scrollable_content_pos_set(item_container, EINA_POSITION2D(0, 60));
+
+ r = efl_gfx_entity_geometry_get(core_item[0]);
+
+ ck_assert_int_eq(r.x, 1);
+ ck_assert_int_eq(r.y, 1);
+ ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
+ ck_assert_int_eq(r.h, 40);
+ ck_assert_int_eq(efl_gfx_entity_visible_get(core_item[0]), EINA_TRUE);
+
+ for (int i = 1; i < 4; ++i)
+ {
+ r = efl_gfx_entity_geometry_get(core_item[i]);
+
+ ck_assert_int_eq(r.x, 1);
+ ck_assert_int_eq(r.y, 21+(i - 1)*40);
+ ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
+ ck_assert_int_eq(r.h, 40);
+ ck_assert_int_eq(efl_gfx_entity_visible_get(core_item[i]), EINA_TRUE);
+ }
+
+ // testing if we have scrolled into the middle of the group the group item is not even in the calculated index anymore
+ efl_ui_scrollable_content_pos_set(item_container, EINA_POSITION2D(0, 120));
+
+ r = efl_gfx_entity_geometry_get(core_item[0]);
+
+ ck_assert_int_eq(r.x, 1);
+ ck_assert_int_eq(r.y, 1);
+ ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
+ ck_assert_int_eq(r.h, 40);
+ ck_assert_int_eq(efl_gfx_entity_visible_get(core_item[0]), EINA_TRUE);
+
+ for (int i = 2; i < 4; ++i)
+ {
+ r = efl_gfx_entity_geometry_get(core_item[i]);
+
+ ck_assert_int_eq(r.x, 1);
+ ck_assert_int_eq(r.y, 1+(i-2)*40);
+ ck_assert_int_eq(r.w, 183); // 200 - 2px border - X for the width of the scrollbar.
+ ck_assert_int_eq(r.h, 40);
+ ck_assert_int_eq(efl_gfx_entity_visible_get(core_item[i]), EINA_TRUE);
+ }
+
+}
+EFL_END_TEST
+
void efl_ui_test_list_container(TCase *tc)
{
tcase_add_checked_fixture(tc, fail_on_errors_setup, fail_on_errors_teardown);
tcase_add_checked_fixture(tc, item_container_setup, item_container_teardown);
efl_ui_test_item_container_common_add(tc);
efl_ui_test_position_manager_common_add(tc);
+ tcase_add_test(tc, placement_test_only_items);
+ tcase_add_test(tc, placement_test_group);
+ tcase_add_test(tc, placement_test_group_crazy);
}