summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/tests/Makefile.am1
-rw-r--r--src/tests/elm_suite.h1
-rw-r--r--src/tests/elm_test_fileselector.c6
-rw-r--r--src/tests/elm_test_helper.c41
-rw-r--r--src/tests/elm_test_helper.h8
5 files changed, 55 insertions, 2 deletions
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
index 11dcd878e..12fc454a5 100644
--- a/src/tests/Makefile.am
+++ b/src/tests/Makefile.am
@@ -6,6 +6,7 @@ TESTS = elm_suite
6check_PROGRAMS = elm_suite 6check_PROGRAMS = elm_suite
7elm_suite_SOURCES = \ 7elm_suite_SOURCES = \
8 elm_suite.c \ 8 elm_suite.c \
9 elm_test_helper.c \
9 elm_test_atspi.c \ 10 elm_test_atspi.c \
10 elm_test_check.c \ 11 elm_test_check.c \
11 elm_test_colorselector.c \ 12 elm_test_colorselector.c \
diff --git a/src/tests/elm_suite.h b/src/tests/elm_suite.h
index 7918a4efb..1a191793b 100644
--- a/src/tests/elm_suite.h
+++ b/src/tests/elm_suite.h
@@ -2,6 +2,7 @@
2#define _ELM_SUITE_H 2#define _ELM_SUITE_H
3 3
4#include <check.h> 4#include <check.h>
5#include "elm_test_helper.h"
5 6
6void elm_test_init(TCase *tc); 7void elm_test_init(TCase *tc);
7void elm_test_check(TCase *tc); 8void elm_test_check(TCase *tc);
diff --git a/src/tests/elm_test_fileselector.c b/src/tests/elm_test_fileselector.c
index e5dd0677b..a20491730 100644
--- a/src/tests/elm_test_fileselector.c
+++ b/src/tests/elm_test_fileselector.c
@@ -69,12 +69,14 @@ START_TEST (elm_fileselector_selected)
69 69
70 selected = EINA_FALSE; 70 selected = EINA_FALSE;
71 ck_assert(elm_fileselector_selected_set(fileselector, path)); 71 ck_assert(elm_fileselector_selected_set(fileselector, path));
72 while (!selected) ecore_main_loop_iterate(); 72 ck_assert(elm_test_helper_wait_flag(&selected));
73
73 ck_assert_str_eq(elm_fileselector_selected_get(fileselector), path); 74 ck_assert_str_eq(elm_fileselector_selected_get(fileselector), path);
74 75
75 selected = EINA_FALSE; 76 selected = EINA_FALSE;
76 ck_assert(elm_fileselector_selected_set(fileselector, exist)); 77 ck_assert(elm_fileselector_selected_set(fileselector, exist));
77 while (!selected) ecore_main_loop_iterate(); 78 ck_assert(elm_test_helper_wait_flag(&selected));
79
78 ck_assert_str_eq(elm_fileselector_selected_get(fileselector), exist); 80 ck_assert_str_eq(elm_fileselector_selected_get(fileselector), exist);
79 81
80 eina_stringshare_del(exist); 82 eina_stringshare_del(exist);
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}
diff --git a/src/tests/elm_test_helper.h b/src/tests/elm_test_helper.h
new file mode 100644
index 000000000..62974f1f2
--- /dev/null
+++ b/src/tests/elm_test_helper.h
@@ -0,0 +1,8 @@
1#ifndef _ELM_TEST_HELPER_H
2#define _ELM_TEST_HELPER_H
3
4#include <Eina.h>
5
6Eina_Bool elm_test_helper_wait_flag(Eina_Bool *done);
7
8#endif /* _ELM_TEST_HELPER_H */