From ba1c94d051ebfd3c57a9220e8553bd7a950b0fce Mon Sep 17 00:00:00 2001 From: Yeongjong Lee Date: Thu, 14 Mar 2019 11:11:32 -0400 Subject: [PATCH] efl_ui_layout: fix elm_layout_text_set behavior Summary: Since commit 649433560b5b, elm_layout_text_set didn't work on some widgets. This patch fixes invisible text issues. Test Plan: 1. make check 2. elementary_test -to 'popup' Reviewers: zmike, segfaultxavi, bu5hm4n Reviewed By: zmike Subscribers: cedric, #reviewers, herb, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D8326 --- src/lib/elementary/efl_ui_layout.c | 15 ++++++++++++++- src/tests/elementary/elm_test_entry.c | 20 ++++++++++++++++++++ src/tests/elementary/elm_test_popup.c | 15 +++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/lib/elementary/efl_ui_layout.c b/src/lib/elementary/efl_ui_layout.c index d50bd84674..a1580aa693 100644 --- a/src/lib/elementary/efl_ui_layout.c +++ b/src/lib/elementary/efl_ui_layout.c @@ -2756,6 +2756,7 @@ elm_layout_table_clear(Eo *obj, const char *part, Eina_Bool clear) EAPI Eina_Bool elm_layout_text_set(Eo *obj, const char *part, const char *text) { + Eo *part_obj; if (!part) { part = efl_ui_widget_default_text_part_get(obj); @@ -2764,7 +2765,19 @@ elm_layout_text_set(Eo *obj, const char *part, const char *text) else if (!_elm_layout_part_aliasing_eval(obj, &part, EINA_TRUE)) return EINA_FALSE; - efl_text_set(efl_part(obj, part), text); + part_obj = efl_ref(efl_part(obj, part)); + + if (!efl_isa(part_obj, EFL_TEXT_INTERFACE) || + !efl_isa(part_obj, EFL_UI_LAYOUT_PART_CLASS)) + { + efl_unref(part_obj); + return EINA_FALSE; + } + + efl_text_set(part_obj, text); + + efl_unref(part_obj); + return EINA_TRUE; } diff --git a/src/tests/elementary/elm_test_entry.c b/src/tests/elementary/elm_test_entry.c index 969681f4e4..cbeaed1d10 100644 --- a/src/tests/elementary/elm_test_entry.c +++ b/src/tests/elementary/elm_test_entry.c @@ -393,6 +393,25 @@ EFL_START_TEST(elm_atspi_role_get) } EFL_END_TEST +EFL_START_TEST(elm_entry_text_set) +{ + Evas_Object *win, *entry; + const char *entry_text = "hello world"; + const char *entry_text2 = "scrollable"; + + win = win_add(NULL, "entry", ELM_WIN_BASIC); + + entry = elm_entry_add(win); + + ck_assert(elm_layout_text_set(entry, NULL, entry_text)); + ck_assert_str_eq(elm_object_text_get(entry), entry_text); + + elm_entry_scrollable_set(entry, EINA_TRUE); + ck_assert(elm_layout_text_set(entry, NULL, entry_text2)); + ck_assert_str_eq(elm_object_text_get(entry), entry_text2); +} +EFL_END_TEST + void elm_test_entry(TCase *tc) { tcase_add_test(tc, elm_entry_legacy_type_check); @@ -407,4 +426,5 @@ void elm_test_entry(TCase *tc) tcase_add_test(tc, elm_entry_atspi_text_text_get); tcase_add_test(tc, elm_entry_atspi_text_selections); tcase_add_test(tc, elm_atspi_role_get); + tcase_add_test(tc, elm_entry_text_set); } diff --git a/src/tests/elementary/elm_test_popup.c b/src/tests/elementary/elm_test_popup.c index d4dc75e79c..ba3143eb17 100644 --- a/src/tests/elementary/elm_test_popup.c +++ b/src/tests/elementary/elm_test_popup.c @@ -70,9 +70,24 @@ EFL_START_TEST(elm_popup_focus_get) } EFL_END_TEST +EFL_START_TEST(elm_popup_text_set) +{ + Evas_Object *win, *popup; + const char *popup_text = "hello world"; + + win = win_add(NULL, "popup", ELM_WIN_BASIC); + + popup = elm_popup_add(win); + + ck_assert(elm_layout_text_set(popup, NULL, popup_text)); + ck_assert_str_eq(elm_object_text_get(popup), popup_text); +} +EFL_END_TEST + void elm_test_popup(TCase *tc) { tcase_add_test(tc, elm_popup_focus_get); tcase_add_test(tc, elm_popup_legacy_type_check); + tcase_add_test(tc, elm_popup_text_set); tcase_add_test(tc, elm_atspi_role_get); }