summaryrefslogtreecommitdiff
path: root/src/tests/elm_test_helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/elm_test_helper.c')
-rw-r--r--src/tests/elm_test_helper.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/tests/elm_test_helper.c b/src/tests/elm_test_helper.c
new file mode 100644
index 000000000..453e888f1
--- /dev/null
+++ b/src/tests/elm_test_helper.c
@@ -0,0 +1,41 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Ecore.h>
6#include "elm_suite.h"
7
8const double timeout = 10;
9
10typedef struct _Callback_Data
11{
12 Ecore_Timer *timer;
13 Eina_Bool did_timeout;
14} Callback_Data;
15
16static Eina_Bool
17timer_expired_cb(void *user_data)
18{
19 Callback_Data *data = user_data;
20 data->did_timeout = EINA_TRUE;
21 data->timer = NULL;
22
23 return ECORE_CALLBACK_CANCEL;
24}
25
26Eina_Bool
27elm_test_helper_wait_flag(Eina_Bool *done)
28{
29 Callback_Data data;
30
31 data.did_timeout = EINA_FALSE;
32 data.timer = ecore_timer_add(timeout, timer_expired_cb, &data);
33
34 while (*done == EINA_FALSE && data.did_timeout == EINA_FALSE)
35 ecore_main_loop_iterate();
36
37 if (data.timer)
38 ecore_timer_del(data.timer);
39
40 return !data.did_timeout;
41}