diff options
author | Mike Blumenkrantz <zmike@osg.samsung.com> | 2018-04-09 13:37:01 +0200 |
---|---|---|
committer | Stefan Schmidt <stefan@osg.samsung.com> | 2018-04-10 11:28:01 +0200 |
commit | 3b22dbc5af3a4759b375a8cc7fa9a414914302b5 (patch) | |
tree | bb4551e17ca66830202258c4775a4a10e2fb4dd9 /src | |
parent | f83dfb21736071efbad43b17525f24ab4a93957a (diff) |
tests: move efl_loop_fd tests into efl_app_suite
Summary:
ref T6815
Depends on D5898
Reviewers: stefan_schmidt
Subscribers: cedric
Maniphest Tasks: T6815
Differential Revision: https://phab.enlightenment.org/D5899
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile_Ecore.am | 1 | ||||
-rw-r--r-- | src/tests/ecore/ecore_test_ecore.c | 88 | ||||
-rw-r--r-- | src/tests/ecore/efl_app_suite.c | 1 | ||||
-rw-r--r-- | src/tests/ecore/efl_app_suite.h | 1 | ||||
-rw-r--r-- | src/tests/ecore/efl_app_test_loop_fd.c | 97 |
5 files changed, 100 insertions, 88 deletions
diff --git a/src/Makefile_Ecore.am b/src/Makefile_Ecore.am index 1915225..b000957 100644 --- a/src/Makefile_Ecore.am +++ b/src/Makefile_Ecore.am | |||
@@ -330,6 +330,7 @@ tests_ecore_ecore_suite_DEPENDENCIES = \ | |||
330 | 330 | ||
331 | tests_ecore_efl_app_suite_SOURCES = \ | 331 | tests_ecore_efl_app_suite_SOURCES = \ |
332 | tests/ecore/efl_app_test_loop.c \ | 332 | tests/ecore/efl_app_test_loop.c \ |
333 | tests/ecore/efl_app_test_loop_fd.c \ | ||
333 | tests/ecore/efl_app_test_loop_timer.c \ | 334 | tests/ecore/efl_app_test_loop_timer.c \ |
334 | tests/ecore/efl_app_suite.c \ | 335 | tests/ecore/efl_app_suite.c \ |
335 | tests/ecore/efl_app_suite.h | 336 | tests/ecore/efl_app_suite.h |
diff --git a/src/tests/ecore/ecore_test_ecore.c b/src/tests/ecore/ecore_test_ecore.c index 3f68225..7297b66 100644 --- a/src/tests/ecore/ecore_test_ecore.c +++ b/src/tests/ecore/ecore_test_ecore.c | |||
@@ -224,92 +224,6 @@ EFL_START_TEST(ecore_test_ecore_main_loop_fd_handler_valid_flags) | |||
224 | } | 224 | } |
225 | EFL_END_TEST | 225 | EFL_END_TEST |
226 | 226 | ||
227 | static void | ||
228 | _eo_read_cb(void *data, const Efl_Event *info EINA_UNUSED) | ||
229 | { | ||
230 | Eina_Bool *did = data; | ||
231 | |||
232 | *did = EINA_TRUE; | ||
233 | ecore_main_loop_quit(); | ||
234 | } | ||
235 | |||
236 | EFL_START_TEST(ecore_test_efl_loop_fd) | ||
237 | { | ||
238 | Eina_Bool did = EINA_FALSE; | ||
239 | Eo *fd; | ||
240 | int comm[2]; | ||
241 | int ret; | ||
242 | |||
243 | ret = pipe(comm); | ||
244 | fail_if(ret != 0); | ||
245 | |||
246 | fd = efl_add(EFL_LOOP_FD_CLASS, efl_main_loop_get(), | ||
247 | efl_loop_fd_set(efl_added, comm[0]), | ||
248 | efl_event_callback_add(efl_added, EFL_LOOP_FD_EVENT_READ, _eo_read_cb, &did)); | ||
249 | fail_if(fd == NULL); | ||
250 | |||
251 | ret = write(comm[1], &did, 1); | ||
252 | fail_if(ret != 1); | ||
253 | |||
254 | ecore_main_loop_begin(); | ||
255 | |||
256 | close(comm[0]); | ||
257 | close(comm[1]); | ||
258 | |||
259 | fail_if(did == EINA_FALSE); | ||
260 | |||
261 | } | ||
262 | EFL_END_TEST | ||
263 | |||
264 | static void | ||
265 | _efl_del_cb(void *data, const Efl_Event *ev EINA_UNUSED) | ||
266 | { | ||
267 | Eina_Bool *dead = data; | ||
268 | |||
269 | *dead = EINA_TRUE; | ||
270 | } | ||
271 | |||
272 | EFL_START_TEST(ecore_test_efl_loop_fd_lifecycle) | ||
273 | { | ||
274 | Eina_Bool did = EINA_FALSE; | ||
275 | Eina_Bool dead = EINA_FALSE; | ||
276 | Eo *fd; | ||
277 | int comm[2]; | ||
278 | int ret; | ||
279 | |||
280 | efl_object_init(); | ||
281 | |||
282 | ret = pipe(comm); | ||
283 | fail_if(ret != 0); | ||
284 | |||
285 | fd = efl_add(EFL_LOOP_FD_CLASS, efl_main_loop_get(), | ||
286 | efl_loop_fd_set(efl_added, comm[0]), | ||
287 | efl_event_callback_add(efl_added, EFL_LOOP_FD_EVENT_READ, _eo_read_cb, &did), | ||
288 | efl_event_callback_add(efl_added, EFL_EVENT_DEL, _efl_del_cb, &dead)); | ||
289 | efl_ref(fd); | ||
290 | fail_if(fd == NULL); | ||
291 | |||
292 | ret = write(comm[1], &did, 1); | ||
293 | fail_if(ret != 1); | ||
294 | |||
295 | ecore_main_loop_begin(); | ||
296 | |||
297 | close(comm[0]); | ||
298 | close(comm[1]); | ||
299 | |||
300 | fail_if(did == EINA_FALSE); | ||
301 | fail_if(dead == EINA_TRUE); | ||
302 | |||
303 | ecore_shutdown(); | ||
304 | ecore_init(); | ||
305 | |||
306 | efl_del(fd); | ||
307 | fail_if(dead == EINA_FALSE); | ||
308 | |||
309 | efl_object_shutdown(); | ||
310 | } | ||
311 | EFL_END_TEST | ||
312 | |||
313 | EFL_START_TEST(ecore_test_ecore_main_loop_fd_handler_activate_modify) | 227 | EFL_START_TEST(ecore_test_ecore_main_loop_fd_handler_activate_modify) |
314 | { | 228 | { |
315 | Eina_Bool did = EINA_FALSE; | 229 | Eina_Bool did = EINA_FALSE; |
@@ -788,6 +702,4 @@ void ecore_test_ecore(TCase *tc) | |||
788 | tcase_add_test(tc, ecore_test_ecore_main_loop_poller_add); | 702 | tcase_add_test(tc, ecore_test_ecore_main_loop_poller_add); |
789 | tcase_add_test(tc, ecore_test_ecore_main_loop_poller_del); | 703 | tcase_add_test(tc, ecore_test_ecore_main_loop_poller_del); |
790 | tcase_add_test(tc, ecore_test_ecore_main_loop_poller_modify); | 704 | tcase_add_test(tc, ecore_test_ecore_main_loop_poller_modify); |
791 | tcase_add_test(tc, ecore_test_efl_loop_fd); | ||
792 | tcase_add_test(tc, ecore_test_efl_loop_fd_lifecycle); | ||
793 | } | 705 | } |
diff --git a/src/tests/ecore/efl_app_suite.c b/src/tests/ecore/efl_app_suite.c index f79e5f8..c92aa3a 100644 --- a/src/tests/ecore/efl_app_suite.c +++ b/src/tests/ecore/efl_app_suite.c | |||
@@ -49,6 +49,7 @@ static const Efl_Test_Case etc[] = { | |||
49 | { "App", efl_test_efl_app }, | 49 | { "App", efl_test_efl_app }, |
50 | { "Loop", efl_app_test_efl_loop }, | 50 | { "Loop", efl_app_test_efl_loop }, |
51 | { "Loop_Timer", efl_app_test_efl_loop_timer }, | 51 | { "Loop_Timer", efl_app_test_efl_loop_timer }, |
52 | { "Loop_FD", efl_app_test_efl_loop_fd }, | ||
52 | { NULL, NULL } | 53 | { NULL, NULL } |
53 | }; | 54 | }; |
54 | 55 | ||
diff --git a/src/tests/ecore/efl_app_suite.h b/src/tests/ecore/efl_app_suite.h index 391231d..b4fce48 100644 --- a/src/tests/ecore/efl_app_suite.h +++ b/src/tests/ecore/efl_app_suite.h | |||
@@ -5,6 +5,7 @@ | |||
5 | #include "../efl_check.h" | 5 | #include "../efl_check.h" |
6 | void efl_app_test_efl_app(TCase *tc); | 6 | void efl_app_test_efl_app(TCase *tc); |
7 | void efl_app_test_efl_loop(TCase *tc); | 7 | void efl_app_test_efl_loop(TCase *tc); |
8 | void efl_app_test_efl_loop_fd(TCase *tc); | ||
8 | void efl_app_test_efl_loop_timer(TCase *tc); | 9 | void efl_app_test_efl_loop_timer(TCase *tc); |
9 | 10 | ||
10 | #endif /* _EFL_APP_SUITE_H */ | 11 | #endif /* _EFL_APP_SUITE_H */ |
diff --git a/src/tests/ecore/efl_app_test_loop_fd.c b/src/tests/ecore/efl_app_test_loop_fd.c new file mode 100644 index 0000000..4403933 --- /dev/null +++ b/src/tests/ecore/efl_app_test_loop_fd.c | |||
@@ -0,0 +1,97 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif | ||
4 | |||
5 | #include <stdio.h> | ||
6 | #include <unistd.h> | ||
7 | #define EFL_NOLEGACY_API_SUPPORT | ||
8 | #include <Efl_Core.h> | ||
9 | #include <Efl_Net.h> | ||
10 | #include "efl_app_suite.h" | ||
11 | #include "../efl_check.h" | ||
12 | |||
13 | |||
14 | static void | ||
15 | _eo_read_cb(void *data, const Efl_Event *info EINA_UNUSED) | ||
16 | { | ||
17 | Eina_Bool *did = data; | ||
18 | |||
19 | *did = EINA_TRUE; | ||
20 | ecore_main_loop_quit(); | ||
21 | } | ||
22 | |||
23 | EFL_START_TEST(ecore_test_efl_loop_fd) | ||
24 | { | ||
25 | Eina_Bool did = EINA_FALSE; | ||
26 | Eo *fd; | ||
27 | int comm[2]; | ||
28 | int ret; | ||
29 | |||
30 | ret = pipe(comm); | ||
31 | fail_if(ret != 0); | ||
32 | |||
33 | fd = efl_add(EFL_LOOP_FD_CLASS, efl_main_loop_get(), | ||
34 | efl_loop_fd_set(efl_added, comm[0]), | ||
35 | efl_event_callback_add(efl_added, EFL_LOOP_FD_EVENT_READ, _eo_read_cb, &did)); | ||
36 | fail_if(fd == NULL); | ||
37 | |||
38 | ret = write(comm[1], &did, 1); | ||
39 | fail_if(ret != 1); | ||
40 | |||
41 | efl_loop_begin(efl_main_loop_get()); | ||
42 | |||
43 | close(comm[0]); | ||
44 | close(comm[1]); | ||
45 | |||
46 | fail_if(did == EINA_FALSE); | ||
47 | |||
48 | } | ||
49 | EFL_END_TEST | ||
50 | |||
51 | static void | ||
52 | _efl_del_cb(void *data, const Efl_Event *ev EINA_UNUSED) | ||
53 | { | ||
54 | Eina_Bool *dead = data; | ||
55 | |||
56 | *dead = EINA_TRUE; | ||
57 | } | ||
58 | |||
59 | EFL_START_TEST(ecore_test_efl_loop_fd_lifecycle) | ||
60 | { | ||
61 | Eina_Bool did = EINA_FALSE; | ||
62 | Eina_Bool dead = EINA_FALSE; | ||
63 | Eo *fd; | ||
64 | int comm[2]; | ||
65 | int ret; | ||
66 | |||
67 | ret = pipe(comm); | ||
68 | fail_if(ret != 0); | ||
69 | |||
70 | fd = efl_add(EFL_LOOP_FD_CLASS, efl_main_loop_get(), | ||
71 | efl_loop_fd_set(efl_added, comm[0]), | ||
72 | efl_event_callback_add(efl_added, EFL_LOOP_FD_EVENT_READ, _eo_read_cb, &did), | ||
73 | efl_event_callback_add(efl_added, EFL_EVENT_DEL, _efl_del_cb, &dead)); | ||
74 | fail_if(fd == NULL); | ||
75 | |||
76 | ret = write(comm[1], &did, 1); | ||
77 | fail_if(ret != 1); | ||
78 | |||
79 | efl_loop_begin(efl_main_loop_get()); | ||
80 | |||
81 | close(comm[0]); | ||
82 | close(comm[1]); | ||
83 | |||
84 | fail_if(did == EINA_FALSE); | ||
85 | fail_if(dead == EINA_TRUE); | ||
86 | |||
87 | efl_del(fd); | ||
88 | fail_if(dead == EINA_FALSE); | ||
89 | } | ||
90 | EFL_END_TEST | ||
91 | |||
92 | |||
93 | void efl_app_test_efl_loop_fd(TCase *tc) | ||
94 | { | ||
95 | tcase_add_test(tc, ecore_test_efl_loop_fd); | ||
96 | tcase_add_test(tc, ecore_test_efl_loop_fd_lifecycle); | ||
97 | } | ||