forked from enlightenment/efl
ecore: add a tests that ensure we do implement lifecycle correctly.
This commit is contained in:
parent
d8d00bd228
commit
cd0b50fada
|
@ -242,9 +242,68 @@ START_TEST(ecore_test_timeout_cancel)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
static Eina_Bool
|
||||
_test_time_cb(void *data)
|
||||
{
|
||||
Eina_Bool *run = data;
|
||||
|
||||
*run = EINA_TRUE;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_test_death_cb(void *data, const Eo_Event *ev EINA_UNUSED)
|
||||
{
|
||||
Eina_Bool *die = data;
|
||||
|
||||
*die = EINA_TRUE;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_test_run_cb(void *data, const Eo_Event *ev EINA_UNUSED)
|
||||
{
|
||||
return _test_time_cb(data);
|
||||
}
|
||||
|
||||
START_TEST(ecore_test_timer_lifecycle)
|
||||
{
|
||||
Eina_Bool rl = EINA_FALSE, re = EINA_FALSE;
|
||||
Eina_Bool dl = EINA_FALSE, de = EINA_FALSE;
|
||||
Ecore_Timer *t;
|
||||
Eo *et;
|
||||
|
||||
eo_init();
|
||||
ecore_init();
|
||||
|
||||
t = ecore_timer_add(1.0, _test_time_cb, &rl);
|
||||
eo_event_callback_add((Eo*) t, EO_EVENT_DEL, _test_death_cb, &dl);
|
||||
|
||||
et = eo_add(EFL_LOOP_TIMER_CLASS, ecore_main_loop_get(),
|
||||
eo_event_callback_add(eo_self, EFL_LOOP_TIMER_EVENT_TICK, _test_run_cb, &re),
|
||||
eo_event_callback_add(eo_self, EO_EVENT_DEL, _test_death_cb, &de),
|
||||
efl_loop_timer_interval_set(eo_self, 1.0));
|
||||
eo_ref(et);
|
||||
|
||||
ecore_shutdown();
|
||||
|
||||
fail_if(re == EINA_TRUE &&! rl == EINA_TRUE);
|
||||
fail_if(dl == EINA_FALSE);
|
||||
fail_if(de == EINA_TRUE);
|
||||
|
||||
eo_del(et);
|
||||
fail_if(de == EINA_FALSE);
|
||||
|
||||
eo_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
void ecore_test_timer(TCase *tc)
|
||||
{
|
||||
tcase_add_test(tc, ecore_test_timers);
|
||||
tcase_add_test(tc, ecore_test_timeout);
|
||||
tcase_add_test(tc, ecore_test_timeout_cancel);
|
||||
tcase_add_test(tc, ecore_test_timer_lifecycle);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue