diff options
Diffstat (limited to 'libraries/ecore/src/bin/ecore_test.c')
-rw-r--r-- | libraries/ecore/src/bin/ecore_test.c | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/libraries/ecore/src/bin/ecore_test.c b/libraries/ecore/src/bin/ecore_test.c new file mode 100644 index 0000000..851b2dd --- /dev/null +++ b/libraries/ecore/src/bin/ecore_test.c | |||
@@ -0,0 +1,109 @@ | |||
1 | #include "config.h" | ||
2 | |||
3 | #include <Ecore.h> | ||
4 | #include <assert.h> | ||
5 | #include <unistd.h> | ||
6 | |||
7 | const char *called = NULL; | ||
8 | |||
9 | static const char *idler_str = "idler"; | ||
10 | static const char *idle_enterer_str = "idler_enterer"; | ||
11 | static const char *idle_exiter_str = "idler_exiter"; | ||
12 | static const char *timer1_str = "timer 1"; | ||
13 | static const char *timer2_str = "timer 2"; | ||
14 | static const char *pipe_read_str = "pipe read"; | ||
15 | |||
16 | int count; | ||
17 | Ecore_Pipe *the_pipe; | ||
18 | |||
19 | Eina_Bool timer_one(void *data __UNUSED__) | ||
20 | { | ||
21 | fprintf(stderr, "timer 1\n"); | ||
22 | assert(called == pipe_read_str); | ||
23 | called = timer1_str; | ||
24 | ecore_pipe_write(the_pipe, "b", 1); | ||
25 | |||
26 | count++; | ||
27 | if (count == 10) | ||
28 | { | ||
29 | ecore_main_loop_quit(); | ||
30 | return EINA_FALSE; | ||
31 | } | ||
32 | |||
33 | return EINA_TRUE; | ||
34 | } | ||
35 | |||
36 | Eina_Bool timer_two(void *data __UNUSED__) | ||
37 | { | ||
38 | fprintf(stderr, "timer 2\n"); | ||
39 | assert(called == timer1_str); | ||
40 | called = timer2_str; | ||
41 | |||
42 | return EINA_TRUE; | ||
43 | } | ||
44 | |||
45 | Eina_Bool idle_enterer_one(void *data __UNUSED__) | ||
46 | { | ||
47 | fprintf(stderr, "idle enterer!\n"); | ||
48 | switch (count) | ||
49 | { | ||
50 | default: | ||
51 | assert(called == timer2_str); | ||
52 | break; | ||
53 | case 1: | ||
54 | assert(called == timer1_str); | ||
55 | break; | ||
56 | case 0: | ||
57 | assert(called == NULL); | ||
58 | } | ||
59 | called = idle_enterer_str; | ||
60 | return EINA_TRUE; | ||
61 | } | ||
62 | |||
63 | Eina_Bool idler_one(void *data __UNUSED__) | ||
64 | { | ||
65 | fprintf(stderr, "idler!\n"); | ||
66 | assert(called == idle_enterer_str); | ||
67 | called = idler_str; | ||
68 | if (count == 0) | ||
69 | ecore_timer_add(0.0, timer_two, NULL); | ||
70 | return EINA_TRUE; | ||
71 | } | ||
72 | |||
73 | Eina_Bool idle_exiter_one(void *data __UNUSED__) | ||
74 | { | ||
75 | fprintf(stderr, "idle exiter!\n"); | ||
76 | assert(called == idler_str); | ||
77 | called = idle_exiter_str; | ||
78 | return EINA_TRUE; | ||
79 | } | ||
80 | |||
81 | void pipe_read(void *data __UNUSED__, void *buffer __UNUSED__, unsigned int nbyte __UNUSED__) | ||
82 | { | ||
83 | fprintf(stderr, "pipe read\n"); | ||
84 | assert(called == idle_exiter_str); | ||
85 | called = pipe_read_str; | ||
86 | } | ||
87 | |||
88 | int main(int argc __UNUSED__, char **argv __UNUSED__) | ||
89 | { | ||
90 | assert(1 == ecore_init()); | ||
91 | |||
92 | the_pipe = ecore_pipe_add(&pipe_read, NULL); | ||
93 | assert(the_pipe != NULL); | ||
94 | assert(EINA_TRUE == ecore_pipe_write(the_pipe, "a", 1)); | ||
95 | |||
96 | assert(NULL != ecore_timer_add(0.0, timer_one, NULL)); | ||
97 | |||
98 | assert(NULL != ecore_idle_enterer_add(&idle_enterer_one, NULL)); | ||
99 | assert(NULL != ecore_idler_add(&idler_one, NULL)); | ||
100 | assert(NULL != ecore_idle_exiter_add(&idle_exiter_one, NULL)); | ||
101 | |||
102 | ecore_main_loop_begin(); | ||
103 | |||
104 | /* glib main loop exits on an idle enterer */ | ||
105 | assert(called == idle_enterer_str); | ||
106 | |||
107 | assert(0 == ecore_shutdown()); | ||
108 | return 0; | ||
109 | } | ||