summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-06-06 14:59:36 -0700
committerCedric BAIL <cedric@osg.samsung.com>2016-06-06 15:41:24 -0700
commitcd0b50fada2543b3cc5f4706736a1154a7f258ac (patch)
tree89d77bdeb8ab8e7f879bd21fad54fa10829b6a36 /src/tests
parentd8d00bd228ffdade02db8528fd70eeb5af7f1862 (diff)
ecore: add a tests that ensure we do implement lifecycle correctly.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/ecore/ecore_test_timer.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/tests/ecore/ecore_test_timer.c b/src/tests/ecore/ecore_test_timer.c
index 747e33ed6f..336538f164 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)
242} 242}
243END_TEST 243END_TEST
244 244
245static Eina_Bool
246_test_time_cb(void *data)
247{
248 Eina_Bool *run = data;
249
250 *run = EINA_TRUE;
251
252 return EINA_TRUE;
253}
254
255static Eina_Bool
256_test_death_cb(void *data, const Eo_Event *ev EINA_UNUSED)
257{
258 Eina_Bool *die = data;
259
260 *die = EINA_TRUE;
261
262 return EINA_TRUE;
263}
264
265static Eina_Bool
266_test_run_cb(void *data, const Eo_Event *ev EINA_UNUSED)
267{
268 return _test_time_cb(data);
269}
270
271START_TEST(ecore_test_timer_lifecycle)
272{
273 Eina_Bool rl = EINA_FALSE, re = EINA_FALSE;
274 Eina_Bool dl = EINA_FALSE, de = EINA_FALSE;
275 Ecore_Timer *t;
276 Eo *et;
277
278 eo_init();
279 ecore_init();
280
281 t = ecore_timer_add(1.0, _test_time_cb, &rl);
282 eo_event_callback_add((Eo*) t, EO_EVENT_DEL, _test_death_cb, &dl);
283
284 et = eo_add(EFL_LOOP_TIMER_CLASS, ecore_main_loop_get(),
285 eo_event_callback_add(eo_self, EFL_LOOP_TIMER_EVENT_TICK, _test_run_cb, &re),
286 eo_event_callback_add(eo_self, EO_EVENT_DEL, _test_death_cb, &de),
287 efl_loop_timer_interval_set(eo_self, 1.0));
288 eo_ref(et);
289
290 ecore_shutdown();
291
292 fail_if(re == EINA_TRUE &&! rl == EINA_TRUE);
293 fail_if(dl == EINA_FALSE);
294 fail_if(de == EINA_TRUE);
295
296 eo_del(et);
297 fail_if(de == EINA_FALSE);
298
299 eo_shutdown();
300}
301END_TEST
302
245void ecore_test_timer(TCase *tc) 303void ecore_test_timer(TCase *tc)
246{ 304{
247 tcase_add_test(tc, ecore_test_timers); 305 tcase_add_test(tc, ecore_test_timers);
248 tcase_add_test(tc, ecore_test_timeout); 306 tcase_add_test(tc, ecore_test_timeout);
249 tcase_add_test(tc, ecore_test_timeout_cancel); 307 tcase_add_test(tc, ecore_test_timeout_cancel);
308 tcase_add_test(tc, ecore_test_timer_lifecycle);
250} 309}