bu5hm4n pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=dc52516397188a111e6ce71a8cf5f2b8e3c7202c

commit dc52516397188a111e6ce71a8cf5f2b8e3c7202c
Author: Wonki Kim <wonki_....@samsung.com>
Date:   Wed Nov 6 13:46:42 2019 +0100

    check: reset flags that used for legacy 'changed' cb
    
    Summary:
    in case of setting a state of check by calling a API,
    the flags that used for changed cb aren't changed.
    which causes that the callback not invoked when it should be.
    
    this patch resets the flags to make it work properly.
    
    Reviewers: bu5hm4n
    
    Subscribers: cedric, #reviewers, #committers
    
    Tags: #efl
    
    Reviewed-by: Marcel Hollerbach <m...@marcel-hollerbach.de>
    Differential Revision: https://phab.enlightenment.org/D10591
---
 src/lib/elementary/efl_ui_check.c     |  3 ++
 src/tests/elementary/elm_test_check.c | 68 +++++++++++++++++++++++++++++++++++
 2 files changed, 71 insertions(+)

diff --git a/src/lib/elementary/efl_ui_check.c 
b/src/lib/elementary/efl_ui_check.c
index 15f528168a..1ac817e29f 100644
--- a/src/lib/elementary/efl_ui_check.c
+++ b/src/lib/elementary/efl_ui_check.c
@@ -319,6 +319,9 @@ _efl_ui_check_efl_ui_selectable_selected_set(Eo *obj, 
Efl_Ui_Check_Data *pd, Ein
 
    pd->selected = value;
 
+   pd->legacy_changed_emitted_select = !pd->selected;
+   pd->legacy_changed_emitted_unselect = pd->selected;
+
    if (!elm_widget_is_legacy(obj))
      efl_event_callback_call(obj, EFL_UI_EVENT_SELECTED_CHANGED, 
&pd->selected);
 }
diff --git a/src/tests/elementary/elm_test_check.c 
b/src/tests/elementary/elm_test_check.c
index 4881aaa876..0cdc18fda3 100644
--- a/src/tests/elementary/elm_test_check.c
+++ b/src/tests/elementary/elm_test_check.c
@@ -6,6 +6,13 @@
 #include <Elementary.h>
 #include "elm_suite.h"
 
+typedef struct _Check_Data
+{
+   Evas_Object *check1;
+   Evas_Object *check2;
+   int value;
+} Check_Data;
+
 EFL_START_TEST(elm_test_check_size)
 {
    Evas_Object *win, *check, *box;
@@ -146,6 +153,66 @@ EFL_START_TEST(elm_atspi_role_get)
 }
 EFL_END_TEST
 
+static void
+_check_changed_cb(void *ptr, Evas_Object *obj, void *e EINA_UNUSED)
+{
+   Check_Data *data = (Check_Data*) ptr;
+
+   if (obj == data->check1) {
+      elm_check_state_set(data->check2, EINA_TRUE);
+   } else if ( obj == data->check2) {
+      elm_check_state_set(data->check1, EINA_FALSE);
+   } else {
+      ck_assert(EINA_FALSE);
+   }
+   data->value ++;
+}
+
+EFL_START_TEST(elm_test_check_api_call)
+{
+   Evas_Object *win, *check1, *check2, *box;
+   Check_Data data ={0,};
+
+   win = elm_win_util_standard_add("check", "Check");
+
+   box = elm_box_add(win);
+   evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   elm_win_resize_object_add(win, box);
+   evas_object_show(box);
+
+   data.check1 = check1 = elm_check_add(box);
+   elm_object_text_set(check1, "TEST TEST TEST");
+   evas_object_smart_callback_add(check1, "changed", _check_changed_cb, &data);
+   elm_box_pack_end(box, check1);
+   evas_object_show(check1);
+
+   data.check2 = check2 = elm_check_add(box);
+   elm_object_text_set(check2, "TEST TEST TEST");
+   evas_object_smart_callback_add(check2, "changed", _check_changed_cb, &data);
+   elm_box_pack_end(box, check2);
+   evas_object_show(check2);
+
+   evas_object_show(win);
+
+   get_me_to_those_events(check1);
+
+   data.value = 0;
+   click_object(data.check1);
+   ecore_main_loop_iterate();
+   ck_assert_int_eq(data.value, 1);
+
+   data.value = 0;
+   click_object(data.check2);
+   ecore_main_loop_iterate();
+   ck_assert_int_eq(data.value, 1);
+
+   data.value = 0;
+   click_object(data.check1);
+   ecore_main_loop_iterate();
+   ck_assert_int_eq(data.value, 1);
+}
+EFL_END_TEST
+
 void elm_test_check(TCase *tc)
 {
    tcase_add_test(tc, elm_test_check_size);
@@ -154,4 +221,5 @@ void elm_test_check(TCase *tc)
    tcase_add_test(tc, elm_test_check_state);
    tcase_add_loop_test(tc, elm_test_check_callbacks, 0, 2);
    tcase_add_test(tc, elm_atspi_role_get);
+   tcase_add_test(tc, elm_test_check_api_call);
 }

-- 


Reply via email to