ecore_timer: Check for the valid callback func

Summary:
This patch checks whether the callback function is valid or not.
Callback function must be set up for the class.

Test Plan: Execute test suite

Reviewers: cedric, raster, stefan, Jaehyun_Cho

Subscribers: jpeg

Differential Revision: https://phab.enlightenment.org/D5762
This commit is contained in:
Myoungwoon Roy, Kim 2018-01-30 14:43:11 +09:00 committed by Jean-Philippe Andre
parent 7f43866707
commit 6bb2b8b402
2 changed files with 21 additions and 2 deletions

View File

@ -176,7 +176,11 @@ ecore_timer_add(double in, Ecore_Task_Cb func, const void *data)
EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
legacy = calloc(1, sizeof (Ecore_Timer_Legacy));
if (!legacy) return NULL;
if (!func)
{
ERR("Callback function must be set up for the class.");
return NULL;
}
legacy->func = func;
legacy->data = data;
timer = efl_add(MY_CLASS, efl_main_loop_get(),
@ -195,7 +199,11 @@ ecore_timer_loop_add(double in, Ecore_Task_Cb func, const void *data)
EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
legacy = calloc(1, sizeof (Ecore_Timer_Legacy));
if (!legacy) return NULL;
if (!func)
{
ERR("Callback function must be set up for the class.");
return NULL;
}
legacy->func = func;
legacy->data = data;
timer = efl_add(MY_CLASS, efl_main_loop_get(),

View File

@ -286,6 +286,16 @@ START_TEST(ecore_test_timer_lifecycle)
}
END_TEST
START_TEST(ecore_test_timer_valid_callbackfunc)
{
fail_if(!ecore_init(), "ERROR: Cannot init Ecore!\n");
Ecore_Timer *t = NULL;
fail_if((t = ecore_timer_add(0.5, NULL, NULL)), "ERROR: Invalid callback func!\n");
ecore_shutdown();
}
END_TEST
void ecore_test_timer(TCase *tc)
{
tcase_add_test(tc, ecore_test_timers);
@ -293,4 +303,5 @@ void ecore_test_timer(TCase *tc)
tcase_add_test(tc, ecore_test_timer_lifecycle);
*/
tcase_add_test(tc, ecore_test_timer_inside_call);
tcase_add_test(tc, ecore_test_timer_valid_callbackfunc);
}