forked from enlightenment/efl
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:
parent
7f43866707
commit
6bb2b8b402
|
@ -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(),
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue