summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWonki Kim <wonki_.kim@samsung.com>2019-11-06 13:46:42 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-11-06 14:03:29 +0100
commitdc52516397188a111e6ce71a8cf5f2b8e3c7202c (patch)
tree1a9bb5466663b2811a7047b0b81974f49419b707 /src
parentd4d9ecc92fe897e29a7c14c5856db617e8a16340 (diff)
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 <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D10591
Diffstat (limited to 'src')
-rw-r--r--src/lib/elementary/efl_ui_check.c3
-rw-r--r--src/tests/elementary/elm_test_check.c68
2 files changed, 71 insertions, 0 deletions
diff --git a/src/lib/elementary/efl_ui_check.c b/src/lib/elementary/efl_ui_check.c
index 15f5281..1ac817e 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
319 319
320 pd->selected = value; 320 pd->selected = value;
321 321
322 pd->legacy_changed_emitted_select = !pd->selected;
323 pd->legacy_changed_emitted_unselect = pd->selected;
324
322 if (!elm_widget_is_legacy(obj)) 325 if (!elm_widget_is_legacy(obj))
323 efl_event_callback_call(obj, EFL_UI_EVENT_SELECTED_CHANGED, &pd->selected); 326 efl_event_callback_call(obj, EFL_UI_EVENT_SELECTED_CHANGED, &pd->selected);
324} 327}
diff --git a/src/tests/elementary/elm_test_check.c b/src/tests/elementary/elm_test_check.c
index 4881aaa..0cdc18f 100644
--- a/src/tests/elementary/elm_test_check.c
+++ b/src/tests/elementary/elm_test_check.c
@@ -6,6 +6,13 @@
6#include <Elementary.h> 6#include <Elementary.h>
7#include "elm_suite.h" 7#include "elm_suite.h"
8 8
9typedef struct _Check_Data
10{
11 Evas_Object *check1;
12 Evas_Object *check2;
13 int value;
14} Check_Data;
15
9EFL_START_TEST(elm_test_check_size) 16EFL_START_TEST(elm_test_check_size)
10{ 17{
11 Evas_Object *win, *check, *box; 18 Evas_Object *win, *check, *box;
@@ -146,6 +153,66 @@ EFL_START_TEST(elm_atspi_role_get)
146} 153}
147EFL_END_TEST 154EFL_END_TEST
148 155
156static void
157_check_changed_cb(void *ptr, Evas_Object *obj, void *e EINA_UNUSED)
158{
159 Check_Data *data = (Check_Data*) ptr;
160
161 if (obj == data->check1) {
162 elm_check_state_set(data->check2, EINA_TRUE);
163 } else if ( obj == data->check2) {
164 elm_check_state_set(data->check1, EINA_FALSE);
165 } else {
166 ck_assert(EINA_FALSE);
167 }
168 data->value ++;
169}
170
171EFL_START_TEST(elm_test_check_api_call)
172{
173 Evas_Object *win, *check1, *check2, *box;
174 Check_Data data ={0,};
175
176 win = elm_win_util_standard_add("check", "Check");
177
178 box = elm_box_add(win);
179 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
180 elm_win_resize_object_add(win, box);
181 evas_object_show(box);
182
183 data.check1 = check1 = elm_check_add(box);
184 elm_object_text_set(check1, "TEST TEST TEST");
185 evas_object_smart_callback_add(check1, "changed", _check_changed_cb, &data);
186 elm_box_pack_end(box, check1);
187 evas_object_show(check1);
188
189 data.check2 = check2 = elm_check_add(box);
190 elm_object_text_set(check2, "TEST TEST TEST");
191 evas_object_smart_callback_add(check2, "changed", _check_changed_cb, &data);
192 elm_box_pack_end(box, check2);
193 evas_object_show(check2);
194
195 evas_object_show(win);
196
197 get_me_to_those_events(check1);
198
199 data.value = 0;
200 click_object(data.check1);
201 ecore_main_loop_iterate();
202 ck_assert_int_eq(data.value, 1);
203
204 data.value = 0;
205 click_object(data.check2);
206 ecore_main_loop_iterate();
207 ck_assert_int_eq(data.value, 1);
208
209 data.value = 0;
210 click_object(data.check1);
211 ecore_main_loop_iterate();
212 ck_assert_int_eq(data.value, 1);
213}
214EFL_END_TEST
215
149void elm_test_check(TCase *tc) 216void elm_test_check(TCase *tc)
150{ 217{
151 tcase_add_test(tc, elm_test_check_size); 218 tcase_add_test(tc, elm_test_check_size);
@@ -154,4 +221,5 @@ void elm_test_check(TCase *tc)
154 tcase_add_test(tc, elm_test_check_state); 221 tcase_add_test(tc, elm_test_check_state);
155 tcase_add_loop_test(tc, elm_test_check_callbacks, 0, 2); 222 tcase_add_loop_test(tc, elm_test_check_callbacks, 0, 2);
156 tcase_add_test(tc, elm_atspi_role_get); 223 tcase_add_test(tc, elm_atspi_role_get);
224 tcase_add_test(tc, elm_test_check_api_call);
157} 225}