check_PROGRAMS = elm_suite
elm_suite_SOURCES = \
elm_suite.c \
+ elm_test_helper.c \
elm_test_atspi.c \
elm_test_check.c \
elm_test_colorselector.c \
#define _ELM_SUITE_H
#include <check.h>
+#include "elm_test_helper.h"
void elm_test_init(TCase *tc);
void elm_test_check(TCase *tc);
selected = EINA_FALSE;
ck_assert(elm_fileselector_selected_set(fileselector, path));
- while (!selected) ecore_main_loop_iterate();
+ ck_assert(elm_test_helper_wait_flag(&selected));
+
ck_assert_str_eq(elm_fileselector_selected_get(fileselector), path);
selected = EINA_FALSE;
ck_assert(elm_fileselector_selected_set(fileselector, exist));
- while (!selected) ecore_main_loop_iterate();
+ ck_assert(elm_test_helper_wait_flag(&selected));
+
ck_assert_str_eq(elm_fileselector_selected_get(fileselector), exist);
eina_stringshare_del(exist);
--- /dev/null
+#ifdef HAVE_CONFIG_H
+# include "elementary_config.h"
+#endif
+
+#include <Ecore.h>
+#include "elm_suite.h"
+
+const double timeout = 10;
+
+typedef struct _Callback_Data
+{
+ Ecore_Timer *timer;
+ Eina_Bool did_timeout;
+} Callback_Data;
+
+static Eina_Bool
+timer_expired_cb(void *user_data)
+{
+ Callback_Data *data = user_data;
+ data->did_timeout = EINA_TRUE;
+ data->timer = NULL;
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+Eina_Bool
+elm_test_helper_wait_flag(Eina_Bool *done)
+{
+ Callback_Data data;
+
+ data.did_timeout = EINA_FALSE;
+ data.timer = ecore_timer_add(timeout, timer_expired_cb, &data);
+
+ while (*done == EINA_FALSE && data.did_timeout == EINA_FALSE)
+ ecore_main_loop_iterate();
+
+ if (data.timer)
+ ecore_timer_del(data.timer);
+
+ return !data.did_timeout;
+}
--- /dev/null
+#ifndef _ELM_TEST_HELPER_H
+#define _ELM_TEST_HELPER_H
+
+#include <Eina.h>
+
+Eina_Bool elm_test_helper_wait_flag(Eina_Bool *done);
+
+#endif /* _ELM_TEST_HELPER_H */