diff options
author | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
commit | 07274513e984f0b5544586c74508ccd16e7dcafa (patch) | |
tree | b32ff2a9136fbc1a4a6a0ed1e4d79cde0f5f16d9 /libraries/ecore/src/tests/ecore_test_ecore.c | |
parent | Added Irrlicht 1.8, but without all the Windows binaries. (diff) | |
download | SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.zip SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.gz SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.bz2 SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.xz |
Remove EFL, since it's been released now.
Diffstat (limited to '')
-rw-r--r-- | libraries/ecore/src/tests/ecore_test_ecore.c | 367 |
1 files changed, 0 insertions, 367 deletions
diff --git a/libraries/ecore/src/tests/ecore_test_ecore.c b/libraries/ecore/src/tests/ecore_test_ecore.c deleted file mode 100644 index 3649196..0000000 --- a/libraries/ecore/src/tests/ecore_test_ecore.c +++ /dev/null | |||
@@ -1,367 +0,0 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif | ||
4 | |||
5 | #include <stdio.h> | ||
6 | #include <unistd.h> | ||
7 | |||
8 | #include <Eina.h> | ||
9 | #include <Ecore.h> | ||
10 | |||
11 | #include "ecore_suite.h" | ||
12 | |||
13 | static int _log_dom; | ||
14 | #define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__) | ||
15 | |||
16 | static Eina_Bool | ||
17 | _quit_cb(void *data) | ||
18 | { | ||
19 | Eina_Bool *val = data; | ||
20 | *val = EINA_TRUE; | ||
21 | ecore_main_loop_quit(); | ||
22 | return EINA_FALSE; | ||
23 | } | ||
24 | |||
25 | static Eina_Bool | ||
26 | _dummy_cb(void *data) | ||
27 | { | ||
28 | return !!data; | ||
29 | } | ||
30 | |||
31 | START_TEST(ecore_test_ecore_init) | ||
32 | { | ||
33 | int ret; | ||
34 | |||
35 | ret = ecore_init(); | ||
36 | fail_if(ret != 1); | ||
37 | |||
38 | ret = ecore_shutdown(); | ||
39 | fail_if(ret != 0); | ||
40 | } | ||
41 | END_TEST | ||
42 | |||
43 | START_TEST(ecore_test_ecore_main_loop) | ||
44 | { | ||
45 | Eina_Bool did = EINA_FALSE; | ||
46 | Ecore_Timer *timer; | ||
47 | int ret; | ||
48 | |||
49 | ret = ecore_init(); | ||
50 | fail_if(ret != 1); | ||
51 | |||
52 | timer = ecore_timer_add(0.0, _quit_cb, &did); | ||
53 | fail_if(timer == NULL); | ||
54 | |||
55 | ecore_main_loop_begin(); | ||
56 | |||
57 | fail_if(did == EINA_FALSE); | ||
58 | |||
59 | ret = ecore_shutdown(); | ||
60 | fail_if(ret != 0); | ||
61 | } | ||
62 | END_TEST | ||
63 | |||
64 | START_TEST(ecore_test_ecore_main_loop_idler) | ||
65 | { | ||
66 | Eina_Bool did = EINA_FALSE; | ||
67 | Ecore_Idler *idler; | ||
68 | int ret; | ||
69 | |||
70 | ret = ecore_init(); | ||
71 | fail_if(ret != 1); | ||
72 | |||
73 | idler = ecore_idler_add(_quit_cb, &did); | ||
74 | fail_if(idler == NULL); | ||
75 | |||
76 | ecore_main_loop_begin(); | ||
77 | |||
78 | fail_if(did == EINA_FALSE); | ||
79 | |||
80 | ret = ecore_shutdown(); | ||
81 | fail_if(ret != 0); | ||
82 | } | ||
83 | END_TEST | ||
84 | |||
85 | START_TEST(ecore_test_ecore_main_loop_idle_enterer) | ||
86 | { | ||
87 | Eina_Bool did = EINA_FALSE; | ||
88 | Ecore_Idle_Enterer *idle_enterer; | ||
89 | int ret; | ||
90 | |||
91 | ret = ecore_init(); | ||
92 | fail_if(ret != 1); | ||
93 | |||
94 | idle_enterer = ecore_idle_enterer_add(_quit_cb, &did); | ||
95 | fail_if(idle_enterer == NULL); | ||
96 | |||
97 | ecore_main_loop_begin(); | ||
98 | |||
99 | fail_if(did == EINA_FALSE); | ||
100 | |||
101 | ret = ecore_shutdown(); | ||
102 | fail_if(ret != 0); | ||
103 | } | ||
104 | END_TEST | ||
105 | |||
106 | START_TEST(ecore_test_ecore_main_loop_idle_exiter) | ||
107 | { | ||
108 | Eina_Bool did = EINA_FALSE; | ||
109 | Ecore_Timer *timer; | ||
110 | Ecore_Idle_Exiter *idle_exiter; | ||
111 | int ret; | ||
112 | |||
113 | ret = ecore_init(); | ||
114 | fail_if(ret != 1); | ||
115 | |||
116 | /* make system exit idle */ | ||
117 | timer = ecore_timer_add(0.0, _dummy_cb, (void *)(long)0); | ||
118 | fail_if(timer == NULL); | ||
119 | |||
120 | idle_exiter = ecore_idle_exiter_add(_quit_cb, &did); | ||
121 | fail_if(idle_exiter == NULL); | ||
122 | |||
123 | ecore_main_loop_begin(); | ||
124 | |||
125 | fail_if(did == EINA_FALSE); | ||
126 | |||
127 | ret = ecore_shutdown(); | ||
128 | fail_if(ret != 0); | ||
129 | } | ||
130 | END_TEST | ||
131 | |||
132 | START_TEST(ecore_test_ecore_main_loop_timer) | ||
133 | { | ||
134 | Eina_Bool did = EINA_FALSE; | ||
135 | Ecore_Timer *timer; | ||
136 | double start, end, elapsed; | ||
137 | int ret; | ||
138 | |||
139 | ret = ecore_init(); | ||
140 | fail_if(ret != 1); | ||
141 | |||
142 | timer = ecore_timer_add(2.0, _quit_cb, &did); | ||
143 | fail_if(timer == NULL); | ||
144 | |||
145 | start = ecore_time_get(); | ||
146 | ecore_main_loop_begin(); | ||
147 | end = ecore_time_get(); | ||
148 | elapsed = end - start; | ||
149 | |||
150 | fail_if(did == EINA_FALSE); | ||
151 | fail_if(elapsed < 2.0); | ||
152 | fail_if(elapsed > 3.0); /* 1 second "error margin" */ | ||
153 | |||
154 | ret = ecore_shutdown(); | ||
155 | fail_if(ret != 0); | ||
156 | } | ||
157 | END_TEST | ||
158 | |||
159 | static Eina_Bool _timer3(void *data) | ||
160 | { | ||
161 | /* timer 3, do nothing */ | ||
162 | return EINA_FALSE; | ||
163 | } | ||
164 | |||
165 | static Eina_Bool _timer2(void *data) | ||
166 | { | ||
167 | /* timer 2, quit inner mainloop */ | ||
168 | ecore_main_loop_quit(); | ||
169 | return EINA_FALSE; | ||
170 | } | ||
171 | |||
172 | static Eina_Bool _timer1(void *data) | ||
173 | { | ||
174 | /* timer 1, begin inner mainloop */ | ||
175 | int *times = data; | ||
176 | (*times)++; | ||
177 | |||
178 | ecore_timer_add(0.3, _timer2, NULL); | ||
179 | ecore_timer_add(0.1, _timer3, NULL); | ||
180 | ecore_main_loop_begin(); | ||
181 | |||
182 | ecore_main_loop_quit(); | ||
183 | |||
184 | return EINA_FALSE; | ||
185 | } | ||
186 | |||
187 | START_TEST(ecore_test_ecore_main_loop_timer_inner) | ||
188 | { | ||
189 | Ecore_Timer *timer; | ||
190 | int ret; | ||
191 | int times = 0; | ||
192 | |||
193 | ret = ecore_init(); | ||
194 | fail_if(ret != 1); | ||
195 | |||
196 | timer = ecore_timer_add(1.0, _timer1, ×); | ||
197 | fail_if(timer == NULL); | ||
198 | |||
199 | /* BEGIN: outer mainloop */ | ||
200 | ecore_main_loop_begin(); | ||
201 | /*END: outer mainloop */ | ||
202 | |||
203 | fail_if(times != 1); | ||
204 | } | ||
205 | END_TEST | ||
206 | |||
207 | static Eina_Bool | ||
208 | _fd_handler_cb(void *data, Ecore_Fd_Handler *handler __UNUSED__) | ||
209 | { | ||
210 | /* FIXME: why setting val if it is overwritten just after and what is its purpose ??? */ | ||
211 | Eina_Bool *val = data; | ||
212 | |||
213 | *val = EINA_TRUE; | ||
214 | ecore_main_loop_quit(); | ||
215 | return EINA_FALSE; | ||
216 | } | ||
217 | |||
218 | START_TEST(ecore_test_ecore_main_loop_fd_handler) | ||
219 | { | ||
220 | Eina_Bool did = EINA_FALSE; | ||
221 | Ecore_Fd_Handler *fd_handler; | ||
222 | int comm[2]; | ||
223 | int ret; | ||
224 | |||
225 | ret = ecore_init(); | ||
226 | fail_if(ret != 1); | ||
227 | |||
228 | ret = pipe(comm); | ||
229 | fail_if(ret != 0); | ||
230 | |||
231 | fd_handler = ecore_main_fd_handler_add | ||
232 | (comm[0], ECORE_FD_READ, _fd_handler_cb, &did, NULL, NULL); | ||
233 | fail_if(fd_handler == NULL); | ||
234 | |||
235 | ret = write(comm[1], &did, 1); | ||
236 | fail_if(ret != 1); | ||
237 | |||
238 | ecore_main_loop_begin(); | ||
239 | |||
240 | close(comm[0]); | ||
241 | close(comm[1]); | ||
242 | |||
243 | fail_if(did == EINA_FALSE); | ||
244 | |||
245 | ret = ecore_shutdown(); | ||
246 | fail_if(ret != 0); | ||
247 | } | ||
248 | END_TEST | ||
249 | |||
250 | static Eina_Bool | ||
251 | _event_handler_cb(void *data, int type __UNUSED__, void *event __UNUSED__) | ||
252 | { | ||
253 | /* FIXME: why setting val if it is overwritten just after and what is its purpose ??? */ | ||
254 | Eina_Bool *val = data; | ||
255 | |||
256 | *val = EINA_TRUE; | ||
257 | ecore_main_loop_quit(); | ||
258 | return EINA_FALSE; | ||
259 | } | ||
260 | |||
261 | START_TEST(ecore_test_ecore_main_loop_event) | ||
262 | { | ||
263 | Eina_Bool did = EINA_FALSE; | ||
264 | Ecore_Event_Handler *handler; | ||
265 | Ecore_Event *event; | ||
266 | int ret, type; | ||
267 | |||
268 | ret = ecore_init(); | ||
269 | fail_if(ret != 1); | ||
270 | |||
271 | type = ecore_event_type_new(); | ||
272 | fail_if(type < 1); | ||
273 | |||
274 | handler = ecore_event_handler_add(type, _event_handler_cb, &did); | ||
275 | fail_if(handler == NULL); | ||
276 | |||
277 | event = ecore_event_add(type, NULL, NULL, NULL); | ||
278 | fail_if(event == NULL); | ||
279 | |||
280 | ecore_main_loop_begin(); | ||
281 | |||
282 | fail_if(did == EINA_FALSE); | ||
283 | |||
284 | ret = ecore_shutdown(); | ||
285 | fail_if(ret != 0); | ||
286 | } | ||
287 | END_TEST | ||
288 | |||
289 | static Eina_Bool | ||
290 | _timer_quit_recursive(void *data) | ||
291 | { | ||
292 | INF(" _timer_quit_recursive: begin"); | ||
293 | ecore_main_loop_quit(); /* quits inner main loop */ | ||
294 | INF(" _timer_quit_recursive: end"); | ||
295 | return EINA_FALSE; | ||
296 | } | ||
297 | |||
298 | static Eina_Bool | ||
299 | _event_recursive_cb(void *data, int type, void *event) | ||
300 | { | ||
301 | Ecore_Event *e; | ||
302 | static int guard = 0; | ||
303 | |||
304 | /* If we enter this callback more than once, it's wrong! */ | ||
305 | fail_if(guard != 0); | ||
306 | guard++; | ||
307 | |||
308 | INF(" event_recursive_cb: begin"); | ||
309 | |||
310 | ecore_timer_add(1.0, _timer_quit_recursive, NULL); | ||
311 | INF(" add 1.0s timer (once) to trigger _timer_quit_recursive"); | ||
312 | |||
313 | INF(" inner main loop begin (recurse)"); | ||
314 | ecore_main_loop_begin(); | ||
315 | INF(" inner main loop end (recurse)"); | ||
316 | |||
317 | ecore_main_loop_quit(); /* quits outer main loop */ | ||
318 | |||
319 | INF(" guard = %d", guard); | ||
320 | INF(" event_recursive_cb: end"); | ||
321 | return EINA_FALSE; | ||
322 | } | ||
323 | |||
324 | |||
325 | START_TEST(ecore_test_ecore_main_loop_event_recursive) | ||
326 | { | ||
327 | /* This test tests if the event handlers are really called only once when | ||
328 | * recursive main loops are used and any number of events may have occurred | ||
329 | * between the beginning and the end of recursive main loop. | ||
330 | */ | ||
331 | Ecore_Event *e; | ||
332 | int type; | ||
333 | int ret; | ||
334 | |||
335 | _log_dom = eina_log_domain_register("test", EINA_COLOR_CYAN); | ||
336 | |||
337 | INF("main: begin"); | ||
338 | ret = ecore_init(); | ||
339 | fail_if(ret != 1); | ||
340 | |||
341 | |||
342 | type = ecore_event_type_new(); | ||
343 | ecore_event_handler_add(type, _event_recursive_cb, NULL); | ||
344 | e = ecore_event_add(type, NULL, NULL, NULL); | ||
345 | INF(" add event to trigger cb1: event=%p", e); | ||
346 | INF(" main loop begin"); | ||
347 | ecore_main_loop_begin(); | ||
348 | INF(" main loop end"); | ||
349 | |||
350 | INF("main: end"); | ||
351 | ecore_shutdown(); | ||
352 | } | ||
353 | END_TEST | ||
354 | |||
355 | void ecore_test_ecore(TCase *tc) | ||
356 | { | ||
357 | tcase_add_test(tc, ecore_test_ecore_init); | ||
358 | tcase_add_test(tc, ecore_test_ecore_main_loop); | ||
359 | tcase_add_test(tc, ecore_test_ecore_main_loop_idler); | ||
360 | tcase_add_test(tc, ecore_test_ecore_main_loop_idle_enterer); | ||
361 | tcase_add_test(tc, ecore_test_ecore_main_loop_idle_exiter); | ||
362 | tcase_add_test(tc, ecore_test_ecore_main_loop_timer); | ||
363 | tcase_add_test(tc, ecore_test_ecore_main_loop_fd_handler); | ||
364 | tcase_add_test(tc, ecore_test_ecore_main_loop_event); | ||
365 | tcase_add_test(tc, ecore_test_ecore_main_loop_timer_inner); | ||
366 | tcase_add_test(tc, ecore_test_ecore_main_loop_event_recursive); | ||
367 | } | ||