From a9cb1d40a52f227945d923da8232dce91fbc5546 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 25 Oct 2019 09:42:41 -0400 Subject: [PATCH] tests/layout: add legacy layout test to verify behavior with legacy size hints Summary: this verifies that user-set legacy size hints will be applied accurately during calc, and that the size of a layout can accurately decrease when its contents min sizes decrease ref 95b5731461c53df2691ef43db61f321de5b366d3 Reviewers: cedric Reviewed By: cedric Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10453 --- src/tests/elementary/elm_test_layout.c | 45 ++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/tests/elementary/elm_test_layout.c b/src/tests/elementary/elm_test_layout.c index 5184086538..7ddffc9345 100644 --- a/src/tests/elementary/elm_test_layout.c +++ b/src/tests/elementary/elm_test_layout.c @@ -70,9 +70,54 @@ EFL_START_TEST(elm_layout_test_swallows) } EFL_END_TEST +EFL_START_TEST(elm_layout_test_sizing) +{ + Evas_Object *win, *ly, *rect; + int w, h; + + win = win_add(NULL, "layout", ELM_WIN_BASIC); + evas_object_show(win); + + rect = evas_object_rectangle_add(evas_object_evas_get(win)); + + ly = elm_button_add(win); + elm_object_text_set(ly, "test"); + elm_object_content_set(ly, rect); + evas_object_show(ly); + + /* verify that the button calc is the size of the text */ + evas_object_smart_need_recalculate_set(ly, 1); + evas_object_smart_calculate(ly); + evas_object_size_hint_min_get(ly, &w, &h); + ck_assert_int_lt(w, 100); + ck_assert_int_gt(w, 0); + ck_assert_int_lt(h, 100); + ck_assert_int_gt(h, 0); + + /* verify that the button calc is the size of the text + minsize of rect */ + evas_object_size_hint_min_set(rect, 100, 100); + evas_object_smart_need_recalculate_set(ly, 1); + evas_object_smart_calculate(ly); + evas_object_size_hint_min_get(ly, &w, &h); + ck_assert_int_ge(w, 100); + ck_assert_int_ge(h, 100); + + /* verify that the button calc is once again the size of the text */ + evas_object_size_hint_min_set(rect, 0, 0); + evas_object_smart_need_recalculate_set(ly, 1); + evas_object_smart_calculate(ly); + evas_object_size_hint_min_get(ly, &w, &h); + ck_assert_int_lt(w, 100); + ck_assert_int_gt(w, 0); + ck_assert_int_lt(h, 100); + ck_assert_int_gt(h, 0); +} +EFL_END_TEST + void elm_test_layout(TCase *tc) { tcase_add_test(tc, elm_layout_test_legacy_type_check); tcase_add_test(tc, elm_atspi_role_get); tcase_add_test(tc, elm_layout_test_swallows); + tcase_add_test(tc, elm_layout_test_sizing); }