cedric pushed a commit to branch master.

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

commit b7facb2f0b684f168aa4b9565f9c7b8d42844252
Author: Cedric BAIL <ced...@osg.samsung.com>
Date:   Fri Jun 3 16:59:55 2016 -0700

    ecore: add a test for detecting the double free problem.
---
 src/tests/ecore/ecore_test_timer.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/src/tests/ecore/ecore_test_timer.c 
b/src/tests/ecore/ecore_test_timer.c
index 25018bd..747e33e 100644
--- a/src/tests/ecore/ecore_test_timer.c
+++ b/src/tests/ecore/ecore_test_timer.c
@@ -208,8 +208,43 @@ START_TEST(ecore_test_timeout)
 }
 END_TEST
 
+static void
+_ecore_promise_then(void *data EINA_UNUSED, void *value EINA_UNUSED)
+{
+   abort();
+}
+
+static void
+_ecore_promise_cancel(void *data, Eina_Error error)
+{
+   Eina_Bool *bob = data;
+
+   fail_if(error != EINA_ERROR_PROMISE_CANCEL);
+   *bob = EINA_TRUE;
+}
+
+START_TEST(ecore_test_timeout_cancel)
+{
+   Eina_Promise *timeout = NULL;
+   Eina_Bool bob = EINA_FALSE;
+   double start;
+
+   ecore_init();
+
+   start = ecore_time_get();
+   timeout = efl_loop_timeout(ecore_main_loop_get(), 0.2, &start);
+   eina_promise_then(timeout, &_ecore_promise_then, &_ecore_promise_cancel, 
&bob);
+   eina_promise_cancel(timeout);
+
+   fail_if(bob != EINA_TRUE);
+
+   ecore_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);
 }

-- 


Reply via email to