cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=cd0b50fada2543b3cc5f4706736a1154a7f258ac

commit cd0b50fada2543b3cc5f4706736a1154a7f258ac
Author: Cedric BAIL <[email protected]>
Date:   Mon Jun 6 14:59:36 2016 -0700

    ecore: add a tests that ensure we do implement lifecycle correctly.
---
 src/tests/ecore/ecore_test_timer.c | 59 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/src/tests/ecore/ecore_test_timer.c 
b/src/tests/ecore/ecore_test_timer.c
index 747e33e..336538f 100644
--- a/src/tests/ecore/ecore_test_timer.c
+++ b/src/tests/ecore/ecore_test_timer.c
@@ -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);
 }

-- 


Reply via email to