cedric pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=f176c1589ccfc518858978a7f08735db7911b130

commit f176c1589ccfc518858978a7f08735db7911b130
Author: Cedric BAIL <ced...@osg.samsung.com>
Date:   Fri Jan 16 14:29:23 2015 +0100

    tests: actually run the main loop properly to be able to enter in idle 
state.
    
    Note that the iterate function will never trigger the idler that are 
registered
    in Ecore. That's by definition. I changed the code to actually use the full
    main loop and trigger the change detection on idle enterer. That should be 
enough
    for Elementary as all idler should logically affect the visual aspect of 
something
    at some point and exit idle.
    
    Thanks marcel-hollerb...@t-online.de for helping me debug this issue.
---
 src/tests/elm_test_helper.c | 40 +++++++++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/src/tests/elm_test_helper.c b/src/tests/elm_test_helper.c
index 6e11ef3..81ab0d1 100644
--- a/src/tests/elm_test_helper.c
+++ b/src/tests/elm_test_helper.c
@@ -5,35 +5,41 @@
 #include <Ecore.h>
 #include "elm_suite.h"
 
-typedef struct _Callback_Data
+static Eina_Bool
+timer_expired_cb(void *user_data)
 {
-   Ecore_Timer *timer;
-   Eina_Bool did_timeout;
-} Callback_Data;
+   Eina_Bool *did_timeout = user_data;
+
+   *did_timeout = EINA_TRUE;
+   ecore_main_loop_quit();
+
+   return EINA_TRUE;
+}
 
 static Eina_Bool
-timer_expired_cb(void *user_data)
+idler_done_cb(void *user_data)
 {
-   Callback_Data *data = user_data;
-   data->did_timeout = EINA_TRUE;
-   data->timer = NULL;
+   Eina_Bool *done = user_data;
+
+   if (*done) ecore_main_loop_quit();
 
-   return ECORE_CALLBACK_CANCEL;
+   return EINA_TRUE;
 }
 
 Eina_Bool
 elm_test_helper_wait_flag(double in, Eina_Bool *done)
 {
-   Callback_Data data;
+   Eina_Bool did_timeout = EINA_FALSE;
+   Ecore_Timer *tm;
+   Ecore_Idle_Enterer *idle;
 
-   data.did_timeout = EINA_FALSE;
-   data.timer = ecore_timer_add(in, timer_expired_cb, &data);
+   tm = ecore_timer_add(in, timer_expired_cb, &did_timeout);
+   idle = ecore_idle_enterer_add(idler_done_cb, done);
 
-   while (*done == EINA_FALSE && data.did_timeout == EINA_FALSE)
-     ecore_main_loop_iterate();
+   ecore_main_loop_begin();
 
-   if (data.timer)
-     ecore_timer_del(data.timer);
+   ecore_idle_enterer_del(idle);
+   ecore_timer_del(tm);
 
-   return !data.did_timeout;
+   return !did_timeout;
 }

-- 


Reply via email to