tests/elm: break out event callback function

Summary:
now we have a function we can reuse which verifies that it is called exactly
one time

Reviewers: bu5hm4n

Reviewed By: bu5hm4n

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9330
This commit is contained in:
Mike Blumenkrantz 2019-07-16 13:38:28 -04:00
parent 4b1a1e85b2
commit ab0c71803b
3 changed files with 11 additions and 9 deletions

View File

@ -43,14 +43,6 @@ EFL_END_TEST
static const char *test_val;
static void
test_pos_changed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
int *called = data;
(*called)++;
}
static void
test_selected_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
{
@ -80,7 +72,7 @@ EFL_START_TEST(elm_actionslider_test_callbacks)
elm_actionslider_enabled_pos_set(as, ELM_ACTIONSLIDER_LEFT |
ELM_ACTIONSLIDER_CENTER | ELM_ACTIONSLIDER_RIGHT);
evas_object_smart_callback_add(as, "pos_changed",
test_pos_changed_cb, &called);
event_callback_that_is_called_exactly_one_time_and_sets_a_single_int_data_pointer_when_called, &called);
evas_object_smart_callback_add(as, "selected", test_selected_cb, &called);
get_me_to_those_events(as);

View File

@ -456,3 +456,12 @@ click_part(Eo *obj, const char *part)
edje_object_message_signal_process(obj);
efl_unref(part_obj);
}
void
event_callback_that_is_called_exactly_one_time_and_sets_a_single_int_data_pointer_when_called(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
int *called = data;
ck_assert_int_eq(*called, 0);
*called = 1;
}

View File

@ -13,4 +13,5 @@ void fail_on_errors_setup(void);
void get_me_to_those_events(Eo *obj);
void click_object(Eo *obj);
void click_part(Eo *obj, const char *part);
void event_callback_that_is_called_exactly_one_time_and_sets_a_single_int_data_pointer_when_called(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED);
#endif