summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile_Ecore.am35
-rw-r--r--src/tests/ecore/ecore_suite.c103
-rw-r--r--src/tests/ecore/ecore_suite.h11
-rw-r--r--src/tests/ecore/ecore_test_ecore.c366
-rw-r--r--src/tests/ecore/ecore_test_ecore_con.c258
-rw-r--r--src/tests/ecore/ecore_test_ecore_x.c60
6 files changed, 833 insertions, 0 deletions
diff --git a/src/Makefile_Ecore.am b/src/Makefile_Ecore.am
index eabe603558..384a234458 100644
--- a/src/Makefile_Ecore.am
+++ b/src/Makefile_Ecore.am
@@ -86,3 +86,38 @@ endif
86lib_ecore_libecore_la_LIBADD += @ECORE_LIBS@ @EFL_COV_LIBS@ -lm 86lib_ecore_libecore_la_LIBADD += @ECORE_LIBS@ @EFL_COV_LIBS@ -lm
87 87
88lib_ecore_libecore_la_LDFLAGS = -no-undefined -version-info @version_info@ @release_info@ 88lib_ecore_libecore_la_LDFLAGS = -no-undefined -version-info @version_info@ @release_info@
89
90### Unit tests
91
92if EFL_ENABLE_TESTS
93
94check_PROGRAMS += tests/ecore/ecore_suite
95
96tests_ecore_ecore_suite_SOURCES = \
97tests/ecore/ecore_suite.c \
98tests/ecore/ecore_test_ecore.c \
99tests/ecore/ecore_test_ecore_con.c \
100tests/ecore/ecore_test_ecore_x.c \
101tests/ecore/ecore_suite.h
102
103tests_ecore_ecore_suite_CPPFLAGS = \
104-I$(top_srcdir)/src/lib/eina \
105-I$(top_srcdir)/src/lib/eo \
106-I$(top_srcdir)/src/lib/ecore \
107-I$(top_srcdir)/src/lib/ecore_con \
108-I$(top_srcdir)/src/lib/ecore_x \
109-I$(top_builddir)/src/lib/eina \
110-I$(top_builddir)/src/lib/eo \
111-I$(top_builddir)/src/lib/ecore \
112-I$(top_builddir)/src/lib/ecore_con \
113-I$(top_builddir)/src/lib/ecore_x \
114-DTESTS_SRC_DIR=\"$(top_srcdir)\" \
115@CHECK_CFLAGS@
116
117tests_ecore_ecore_suite_LDADD = \
118lib/ecore_con/libecore_con.la \
119lib/ecore/libecore.la \
120lib/eina/libeina.la \
121@CHECK_LIBS@
122
123endif
diff --git a/src/tests/ecore/ecore_suite.c b/src/tests/ecore/ecore_suite.c
new file mode 100644
index 0000000000..fd517506b3
--- /dev/null
+++ b/src/tests/ecore/ecore_suite.c
@@ -0,0 +1,103 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <stdlib.h>
6#include <stdio.h>
7
8#include <Ecore.h>
9
10#include "ecore_suite.h"
11
12typedef struct _Ecore_Test_Case Ecore_Test_Case;
13
14struct _Ecore_Test_Case
15{
16 const char *test_case;
17 void (*build)(TCase *tc);
18};
19
20static const Ecore_Test_Case etc[] = {
21 { "Ecore", ecore_test_ecore },
22 { "Ecore_Con", ecore_test_ecore_con },
23 { "Ecore_X", ecore_test_ecore_x },
24 { NULL, NULL }
25};
26
27static void
28_list_tests(void)
29{
30 const Ecore_Test_Case *itr;
31
32 itr = etc;
33 fputs("Available Test Cases:\n", stderr);
34 for (; itr->test_case; itr++)
35 fprintf(stderr, "\t%s\n", itr->test_case);
36}
37static Eina_Bool
38_use_test(int argc, const char **argv, const char *test_case)
39{
40 if (argc < 1)
41 return 1;
42
43 for (; argc > 0; argc--, argv++)
44 if (strcmp(test_case, *argv) == 0)
45 return 1;
46 return 0;
47}
48
49static Suite *
50ecore_suite_build(int argc, const char **argv)
51{
52 TCase *tc;
53 Suite *s;
54 int i;
55
56 s = suite_create("Ecore");
57
58 for (i = 0; etc[i].test_case; ++i)
59 {
60 if (!_use_test(argc, argv, etc[i].test_case)) continue;
61 tc = tcase_create(etc[i].test_case);
62
63 etc[i].build(tc);
64
65 suite_add_tcase(s, tc);
66 tcase_set_timeout(tc, 0);
67 }
68
69 return s;
70}
71
72int
73main(int argc, char **argv)
74{
75 Suite *s;
76 SRunner *sr;
77 int i, failed_count;
78
79 for (i = 1; i < argc; i++)
80 if ((strcmp(argv[i], "-h") == 0) ||
81 (strcmp(argv[i], "--help") == 0))
82 {
83 fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
84 argv[0]);
85 _list_tests();
86 return 0;
87 }
88 else if ((strcmp(argv[i], "-l") == 0) ||
89 (strcmp(argv[i], "--list") == 0))
90 {
91 _list_tests();
92 return 0;
93 }
94
95 s = ecore_suite_build(argc - 1, (const char **)argv + 1);
96 sr = srunner_create(s);
97
98 srunner_run_all(sr, CK_ENV);
99 failed_count = srunner_ntests_failed(sr);
100 srunner_free(sr);
101
102 return (failed_count == 0) ? 0 : 255;
103}
diff --git a/src/tests/ecore/ecore_suite.h b/src/tests/ecore/ecore_suite.h
new file mode 100644
index 0000000000..0c7dfef8d5
--- /dev/null
+++ b/src/tests/ecore/ecore_suite.h
@@ -0,0 +1,11 @@
1#ifndef _ECORE_SUITE_H
2#define _ECORE_SUITE_H
3
4#include <check.h>
5
6void ecore_test_ecore(TCase *tc);
7void ecore_test_ecore_con(TCase *tc);
8void ecore_test_ecore_x(TCase *tc);
9
10
11#endif /* _ECORE_SUITE_H */
diff --git a/src/tests/ecore/ecore_test_ecore.c b/src/tests/ecore/ecore_test_ecore.c
new file mode 100644
index 0000000000..357ad007bb
--- /dev/null
+++ b/src/tests/ecore/ecore_test_ecore.c
@@ -0,0 +1,366 @@
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
13static int _log_dom;
14#define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__)
15
16static 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
25static Eina_Bool
26_dummy_cb(void *data)
27{
28 return !!data;
29}
30
31START_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}
41END_TEST
42
43START_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}
62END_TEST
63
64START_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}
83END_TEST
84
85START_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}
104END_TEST
105
106START_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}
130END_TEST
131
132START_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}
157END_TEST
158
159static Eina_Bool _timer3(void *data EINA_UNUSED)
160{
161 /* timer 3, do nothing */
162 return EINA_FALSE;
163}
164
165static Eina_Bool _timer2(void *data EINA_UNUSED)
166{
167 /* timer 2, quit inner mainloop */
168 ecore_main_loop_quit();
169 return EINA_FALSE;
170}
171
172static 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
187START_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, &times);
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}
205END_TEST
206
207static Eina_Bool
208_fd_handler_cb(void *data, Ecore_Fd_Handler *handler EINA_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
218START_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}
248END_TEST
249
250static Eina_Bool
251_event_handler_cb(void *data, int type EINA_UNUSED, void *event EINA_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
261START_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}
287END_TEST
288
289static Eina_Bool
290_timer_quit_recursive(void *data EINA_UNUSED)
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
298static Eina_Bool
299_event_recursive_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
300{
301 static int guard = 0;
302
303 /* If we enter this callback more than once, it's wrong! */
304 fail_if(guard != 0);
305 guard++;
306
307 INF(" event_recursive_cb: begin");
308
309 ecore_timer_add(1.0, _timer_quit_recursive, NULL);
310 INF(" add 1.0s timer (once) to trigger _timer_quit_recursive");
311
312 INF(" inner main loop begin (recurse)");
313 ecore_main_loop_begin();
314 INF(" inner main loop end (recurse)");
315
316 ecore_main_loop_quit(); /* quits outer main loop */
317
318 INF(" guard = %d", guard);
319 INF(" event_recursive_cb: end");
320 return EINA_FALSE;
321}
322
323
324START_TEST(ecore_test_ecore_main_loop_event_recursive)
325{
326 /* This test tests if the event handlers are really called only once when
327 * recursive main loops are used and any number of events may have occurred
328 * between the beginning and the end of recursive main loop.
329 */
330 Ecore_Event *e;
331 int type;
332 int ret;
333
334 _log_dom = eina_log_domain_register("test", EINA_COLOR_CYAN);
335
336 INF("main: begin");
337 ret = ecore_init();
338 fail_if(ret != 1);
339
340
341 type = ecore_event_type_new();
342 ecore_event_handler_add(type, _event_recursive_cb, NULL);
343 e = ecore_event_add(type, NULL, NULL, NULL);
344 INF(" add event to trigger cb1: event=%p", e);
345 INF(" main loop begin");
346 ecore_main_loop_begin();
347 INF(" main loop end");
348
349 INF("main: end");
350 ecore_shutdown();
351}
352END_TEST
353
354void ecore_test_ecore(TCase *tc)
355{
356 tcase_add_test(tc, ecore_test_ecore_init);
357 tcase_add_test(tc, ecore_test_ecore_main_loop);
358 tcase_add_test(tc, ecore_test_ecore_main_loop_idler);
359 tcase_add_test(tc, ecore_test_ecore_main_loop_idle_enterer);
360 tcase_add_test(tc, ecore_test_ecore_main_loop_idle_exiter);
361 tcase_add_test(tc, ecore_test_ecore_main_loop_timer);
362 tcase_add_test(tc, ecore_test_ecore_main_loop_fd_handler);
363 tcase_add_test(tc, ecore_test_ecore_main_loop_event);
364 tcase_add_test(tc, ecore_test_ecore_main_loop_timer_inner);
365 tcase_add_test(tc, ecore_test_ecore_main_loop_event_recursive);
366}
diff --git a/src/tests/ecore/ecore_test_ecore_con.c b/src/tests/ecore/ecore_test_ecore_con.c
new file mode 100644
index 0000000000..b4513c2d4e
--- /dev/null
+++ b/src/tests/ecore/ecore_test_ecore_con.c
@@ -0,0 +1,258 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <Ecore_Con.h>
6
7#include "ecore_suite.h"
8
9#include <stdio.h>
10#include <Ecore.h>
11#include <Ecore_Con.h>
12
13Eina_Bool
14_add(void *data, int type EINA_UNUSED, void *ev)
15{
16 fail_if (type != ECORE_CON_EVENT_CLIENT_ADD &&
17 type != ECORE_CON_EVENT_SERVER_ADD);
18
19 /* Server */
20 if (type == ECORE_CON_EVENT_CLIENT_ADD)
21 {
22 Ecore_Con_Event_Client_Add *event = ev;
23
24 fail_if (data != (void *) 1);
25 fail_if (!event->client);
26
27 printf("Client with ip %s, port %d, connected = %d!\n",
28 ecore_con_client_ip_get(event->client),
29 ecore_con_client_port_get(event->client),
30 ecore_con_client_connected_get(event->client));
31
32 ecore_con_client_timeout_set(event->client, 10);
33
34 }
35 else if (type == ECORE_CON_EVENT_SERVER_ADD)
36 {
37 Ecore_Con_Event_Server_Add *event = ev;
38 const char ping[] = "PING";
39 int ret;
40
41 fail_if (data != (void *) 2);
42 fail_if (!event->server);
43 printf("Server with ip %s, name %s, port %d, connected = %d!\n",
44 ecore_con_server_ip_get(event->server),
45 ecore_con_server_name_get(event->server),
46 ecore_con_server_port_get(event->server),
47 ecore_con_server_connected_get(event->server));
48 ret = ecore_con_server_send(event->server, ping, sizeof(ping));
49 fail_if (ret != sizeof(ping));
50 ecore_con_server_flush(event->server);
51 }
52
53 return ECORE_CALLBACK_RENEW;
54}
55
56Eina_Bool
57_del(void *data , int type EINA_UNUSED, void *ev)
58{
59 fail_if (type != ECORE_CON_EVENT_CLIENT_DEL &&
60 type != ECORE_CON_EVENT_SERVER_DEL);
61
62 /* Server */
63 if (type == ECORE_CON_EVENT_CLIENT_DEL)
64 {
65 Ecore_Con_Event_Client_Del *event = ev;
66
67 fail_if (data != (void *) 1);
68 fail_if (!event->client);
69
70 printf("Lost client with ip %s!\n", ecore_con_client_ip_get(event->client));
71 printf("Client was connected for %0.3f seconds.\n",
72 ecore_con_client_uptime_get(event->client));
73
74 ecore_con_client_del(event->client);
75 }
76 else if (type == ECORE_CON_EVENT_SERVER_DEL)
77 {
78 Ecore_Con_Event_Server_Del *event = ev;
79
80 fail_if (!event->server);
81
82 fail_if (data != (void *) 2);
83
84 printf("Lost server with ip %s!\n", ecore_con_server_ip_get(event->server));
85
86 ecore_con_server_del(event->server);
87 }
88 fail ();
89
90 return ECORE_CALLBACK_RENEW;
91}
92
93Eina_Bool
94_data(void *data, int type EINA_UNUSED, void *ev)
95{
96
97 fail_if (type != ECORE_CON_EVENT_CLIENT_DATA &&
98 type != ECORE_CON_EVENT_SERVER_DATA);
99
100 /* Server */
101 if (type == ECORE_CON_EVENT_CLIENT_DATA)
102 {
103 Ecore_Con_Event_Client_Data *event = ev;
104 const char pong[] = "PONG";
105 int ret;
106
107 char fmt[128];
108 fail_if (data != (void *) 1);
109
110 snprintf(fmt, sizeof(fmt),
111 "Received %i bytes from client %s port %d:\n"
112 ">>>>>\n"
113 "%%.%is\n"
114 ">>>>>\n",
115 event->size, ecore_con_client_ip_get(event->client),
116 ecore_con_client_port_get(event->client), event->size);
117
118 printf(fmt, event->data);
119 fail_if (event->size != sizeof("PING"));
120 fail_if (memcmp (event->data, "PING", sizeof("PING")) != 0);
121
122 ret = ecore_con_client_send(event->client, pong, sizeof(pong));
123 fail_if (ret != sizeof(pong));
124 ecore_con_client_flush(event->client);
125 }
126 else if (type == ECORE_CON_EVENT_SERVER_DATA)
127 {
128 Ecore_Con_Event_Server_Data *event = ev;
129 char fmt[128];
130
131 fail_if (data != (void *) 2);
132
133 snprintf(fmt, sizeof(fmt),
134 "Received %i bytes from server:\n"
135 ">>>>>\n"
136 "%%.%is\n"
137 ">>>>>\n",
138 event->size, event->size);
139
140 printf(fmt, event->data);
141 fail_if (event->size != sizeof("PONG"));
142 fail_if (memcmp (event->data, "PONG", sizeof("PONG")) != 0);
143 ecore_main_loop_quit();
144 }
145
146 return ECORE_CALLBACK_RENEW;
147}
148
149START_TEST(ecore_test_ecore_con_server)
150{
151 Ecore_Con_Server *server;
152 Ecore_Con_Server *client;
153 Ecore_Con_Client *cl;
154 const Eina_List *clients, *l;
155 Ecore_Event_Handler *handlers[6];
156 void *server_data = malloc (1);
157 void *client_data = malloc (1);
158 int ret;
159 void *del_ret;
160
161 ret = eina_init();
162 fail_if(ret != 1);
163 ret = ecore_init();
164 fail_if(ret != 1);
165 ret = ecore_con_init();
166 fail_if(ret != 1);
167
168 handlers[0] = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD,
169 _add, (void *) 1);
170 fail_if(handlers[0] == NULL);
171 handlers[1] = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL,
172 _del, (void *) 1);
173 fail_if(handlers[1] == NULL);
174 handlers[2] = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA,
175 _data, (void *) 1);
176 fail_if(handlers[2] == NULL);
177
178 handlers[3] = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD,
179 _add, (void *) 2);
180 fail_if(handlers[3] == NULL);
181 handlers[4] = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL,
182 _del, (void *) 2);
183 fail_if(handlers[4] == NULL);
184 handlers[5] = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA,
185 _data, (void *) 2);
186 fail_if(handlers[5] == NULL);
187
188 server = ecore_con_server_add(ECORE_CON_REMOTE_TCP, "::1", 8080,
189 server_data);
190 fail_if (server == NULL);
191
192 ecore_con_server_timeout_set(server, 10);
193 ecore_con_server_client_limit_set(server, 1, 0);
194
195 client = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, "::1", 8080,
196 client_data);
197 fail_if (client == NULL);
198
199 ecore_main_loop_begin();
200
201 clients = ecore_con_server_clients_get(server);
202 printf("Clients connected to this server when exiting: %d\n",
203 eina_list_count(clients));
204 EINA_LIST_FOREACH(clients, l, cl)
205 {
206 printf("%s\n", ecore_con_client_ip_get(cl));
207 }
208
209 printf("Server was up for %0.3f seconds\n",
210 ecore_con_server_uptime_get(server));
211
212 del_ret = ecore_con_server_del(server);
213 fail_if (del_ret != server_data);
214 free (server_data);
215 del_ret = ecore_con_server_del(client);
216 fail_if (del_ret != client_data);
217 free (client_data);
218
219 del_ret = ecore_event_handler_del (handlers[0]);
220 fail_if (del_ret != (void *) 1);
221 del_ret = ecore_event_handler_del (handlers[1]);
222 fail_if (del_ret != (void *) 1);
223 del_ret = ecore_event_handler_del (handlers[2]);
224 fail_if (del_ret != (void *) 1);
225
226 del_ret = ecore_event_handler_del (handlers[3]);
227 fail_if (del_ret != (void *) 2);
228 del_ret = ecore_event_handler_del (handlers[4]);
229 fail_if (del_ret != (void *) 2);
230 del_ret = ecore_event_handler_del (handlers[5]);
231 fail_if (del_ret != (void *) 2);
232
233 ret = ecore_con_shutdown();
234 fail_if(ret != 0);
235 ret = ecore_shutdown();
236 fail_if(ret != 0);
237 ret = eina_shutdown();
238 fail_if(ret != 0);
239}
240END_TEST
241
242START_TEST(ecore_test_ecore_con_init)
243{
244 int ret;
245
246 ret = ecore_con_init();
247 fail_if(ret != 1);
248
249 ret = ecore_con_shutdown();
250 fail_if(ret != 0);
251}
252END_TEST
253
254void ecore_test_ecore_con(TCase *tc)
255{
256 tcase_add_test(tc, ecore_test_ecore_con_init);
257 tcase_add_test(tc, ecore_test_ecore_con_server);
258}
diff --git a/src/tests/ecore/ecore_test_ecore_x.c b/src/tests/ecore/ecore_test_ecore_x.c
new file mode 100644
index 0000000000..18471fa962
--- /dev/null
+++ b/src/tests/ecore/ecore_test_ecore_x.c
@@ -0,0 +1,60 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <Ecore_X.h>
6
7#include "ecore_suite.h"
8
9/* FIXME: Currently disable these tests. They are useless ATM and they just
10 * make buildbot complain. Once we add useful tests here we'll also bother
11 * with getting X on the server. */
12#undef HAVE_ECORE_X_XLIB
13
14/* TODO: change to HAVE_ECORE_X when xcb implementation is done */
15#ifdef HAVE_ECORE_X_XLIB
16
17START_TEST(ecore_test_ecore_x_init)
18{
19 int ret;
20
21 ret = ecore_x_init(NULL);
22 fail_if(ret != 1);
23
24 ret = ecore_x_shutdown();
25 fail_if(ret != 0);
26}
27END_TEST
28
29START_TEST(ecore_test_ecore_x_bell)
30{
31 int i;
32 int ret;
33
34 ret = ecore_x_init(NULL);
35 fail_if(ret != 1);
36
37 printf("You should hear 3 beeps now.\n");
38 for (i = 0; i < 3; i++)
39 {
40 ret = ecore_x_bell(0);
41 fail_if(ret != EINA_TRUE);
42 ecore_x_sync();
43 sleep(1);
44 }
45
46 ecore_x_shutdown();
47}
48END_TEST
49
50#endif
51
52void ecore_test_ecore_x(TCase *tc EINA_UNUSED)
53{
54
55/* TODO: change to HAVE_ECORE_X when xcb implementation is done */
56#ifdef HAVE_ECORE_X_XLIB
57 tcase_add_test(tc, ecore_test_ecore_x_init);
58 tcase_add_test(tc, ecore_test_ecore_x_bell);
59#endif
60}