summaryrefslogtreecommitdiff
path: root/src/tests/ecore/ecore_test_ecore.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-06-06 16:28:52 -0700
committerCedric BAIL <cedric@osg.samsung.com>2016-06-06 16:29:16 -0700
commit2db02da4bd28866d16f48762a4c089421f5c914c (patch)
treef878c96a32fa3119096da3bb579df3e22cfb7baf /src/tests/ecore/ecore_test_ecore.c
parentef0df96da197e2018ce1ecd84c67b246c34a1f90 (diff)
ecore: make sure lifecycle of Efl.Loop.Fd is correct.
Diffstat (limited to 'src/tests/ecore/ecore_test_ecore.c')
-rw-r--r--src/tests/ecore/ecore_test_ecore.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/tests/ecore/ecore_test_ecore.c b/src/tests/ecore/ecore_test_ecore.c
index 3c65e52bb8..338bb74a20 100644
--- a/src/tests/ecore/ecore_test_ecore.c
+++ b/src/tests/ecore/ecore_test_ecore.c
@@ -310,6 +310,59 @@ START_TEST(ecore_test_efl_loop_fd)
310} 310}
311END_TEST 311END_TEST
312 312
313static Eina_Bool
314_eo_del_cb(void *data, const Eo_Event *ev EINA_UNUSED)
315{
316 Eina_Bool *dead = data;
317
318 *dead = EINA_TRUE;
319
320 return EINA_TRUE;
321}
322
323START_TEST(ecore_test_efl_loop_fd_lifecycle)
324{
325 Eina_Bool did = EINA_FALSE;
326 Eina_Bool dead = EINA_FALSE;
327 Eo *fd;
328 int comm[2];
329 int ret;
330
331 eo_init();
332
333 ret = ecore_init();
334 fail_if(ret < 1);
335
336 ret = pipe(comm);
337 fail_if(ret != 0);
338
339 fd = eo_add(EFL_LOOP_FD_CLASS, ecore_main_loop_get(),
340 efl_loop_fd_set(eo_self, comm[0]),
341 eo_event_callback_add(eo_self, EFL_LOOP_FD_EVENT_READ, _eo_read_cb, &did),
342 eo_event_callback_add(eo_self, EO_EVENT_DEL, _eo_del_cb, &dead));
343 eo_ref(fd);
344 fail_if(fd == NULL);
345
346 ret = write(comm[1], &did, 1);
347 fail_if(ret != 1);
348
349 ecore_main_loop_begin();
350
351 close(comm[0]);
352 close(comm[1]);
353
354 fail_if(did == EINA_FALSE);
355 fail_if(dead == EINA_TRUE);
356
357 ret = ecore_shutdown();
358
359 eo_del(fd);
360 fail_if(dead == EINA_FALSE);
361
362 eo_shutdown();
363}
364END_TEST
365
313START_TEST(ecore_test_ecore_main_loop_fd_handler_activate_modify) 366START_TEST(ecore_test_ecore_main_loop_fd_handler_activate_modify)
314{ 367{
315 Eina_Bool did = EINA_FALSE; 368 Eina_Bool did = EINA_FALSE;
@@ -789,4 +842,5 @@ void ecore_test_ecore(TCase *tc)
789 tcase_add_test(tc, ecore_test_ecore_main_loop_poller); 842 tcase_add_test(tc, ecore_test_ecore_main_loop_poller);
790 tcase_add_test(tc, ecore_test_ecore_main_loop_poller_add_del); 843 tcase_add_test(tc, ecore_test_ecore_main_loop_poller_add_del);
791 tcase_add_test(tc, ecore_test_efl_loop_fd); 844 tcase_add_test(tc, ecore_test_efl_loop_fd);
845 tcase_add_test(tc, ecore_test_efl_loop_fd_lifecycle);
792} 846}