forked from enlightenment/efl
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
This commit is contained in:
parent
c9399b2154
commit
6088557233
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue