summaryrefslogtreecommitdiff
path: root/src/tests/eeze
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-03 20:37:42 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-03 20:37:42 +0000
commit68188ac0c89407cb35a0f04f86ad44b0deb95bdb (patch)
tree0ddf76421ab114f162c5a113f65119a6662d6a54 /src/tests/eeze
parentf7cc32f78bf86c804a3f3ae7b8428a408092fbdf (diff)
efl: merge eeze.
Changes also in this commit: * fix missing EAPI in symbols used by modules * removed old libudev and libmount support as agreed by discomfitor/zmike * replaced __UNUSED__ with EINA_UNUSED * fixed docs hierarchy SVN revision: 82100
Diffstat (limited to 'src/tests/eeze')
-rw-r--r--src/tests/eeze/eeze_suite.c679
1 files changed, 679 insertions, 0 deletions
diff --git a/src/tests/eeze/eeze_suite.c b/src/tests/eeze/eeze_suite.c
new file mode 100644
index 0000000000..360d34ccd4
--- /dev/null
+++ b/src/tests/eeze/eeze_suite.c
@@ -0,0 +1,679 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include <stdlib.h>
6#include <stdio.h>
7
8#include <Eina.h>
9
10#include <check.h>
11
12#include <Eeze.h>
13#include <Eeze_Sensor.h>
14#include <Eeze_Net.h>
15
16#include "eeze_udev_private.h"
17
18START_TEST(eeze_test_init)
19{
20 int ret;
21
22 ret = eeze_init();
23 fail_if(ret != 1);
24
25 ret = eeze_shutdown();
26 fail_if(ret != 0);
27}
28END_TEST
29
30static void
31catch_events(const char *device EINA_UNUSED, Eeze_Udev_Event event EINA_UNUSED,
32 void *data EINA_UNUSED, Eeze_Udev_Watch *watch EINA_UNUSED)
33{
34}
35
36// FIXME split udev tests into pieces here
37START_TEST(eeze_test_udev_types)
38{
39 Eina_List *type;
40
41 eeze_init();
42
43 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_NONE, NULL);
44 type = eeze_udev_find_unlisted_similar(type);
45 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_KEYBOARD, NULL);
46 type = eeze_udev_find_unlisted_similar(type);
47 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_MOUSE, NULL);
48 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_TOUCHPAD, NULL);
49 type = eeze_udev_find_unlisted_similar(type);
50 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_MOUNTABLE, NULL);
51 type = eeze_udev_find_unlisted_similar(type);
52 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_INTERNAL, NULL);
53 type = eeze_udev_find_unlisted_similar(type);
54 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_REMOVABLE, NULL);
55 type = eeze_udev_find_unlisted_similar(type);
56 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_CDROM, NULL);
57 type = eeze_udev_find_unlisted_similar(type);
58 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_POWER_AC, NULL);
59 type = eeze_udev_find_unlisted_similar(type);
60 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_POWER_BAT, NULL);
61 type = eeze_udev_find_unlisted_similar(type);
62 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_IS_IT_HOT_OR_IS_IT_COLD_SENSOR, NULL);
63 type = eeze_udev_find_unlisted_similar(type);
64 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_NET, NULL);
65 type = eeze_udev_find_unlisted_similar(type);
66 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_V4L, NULL);
67 type = eeze_udev_find_unlisted_similar(type);
68 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_BLUETOOTH, NULL);
69 type = eeze_udev_find_unlisted_similar(type);
70 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_JOYSTICK, NULL);
71 type = eeze_udev_find_unlisted_similar(type);
72 type = eeze_udev_find_by_type(0, NULL);
73 type = eeze_udev_find_unlisted_similar(type);
74
75 eeze_shutdown();
76}
77END_TEST
78
79START_TEST(eeze_test_udev_watch)
80{
81 Eeze_Udev_Watch *watch;
82
83 ecore_init();
84 eeze_init();
85
86 /* watch never gets triggered as this is run without user interaction */
87 watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_KEYBOARD, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
88 watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_DRIVE_INTERNAL, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
89 watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_POWER_AC, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
90 watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_NET, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
91 watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_IS_IT_HOT_OR_IS_IT_COLD_SENSOR, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
92 watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_V4L, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
93 watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_BLUETOOTH, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
94 watch = eeze_udev_watch_add(EEZE_UDEV_TYPE_NONE, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), catch_events, NULL);
95 eeze_udev_watch_del(watch);
96
97 eeze_shutdown();
98 ecore_shutdown();
99}
100END_TEST
101
102START_TEST(eeze_test_udev_syspath)
103{
104 Eina_List *type, *l;
105 const char *name, *check;
106
107 eeze_init();
108
109 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_KEYBOARD, NULL);
110 type = eeze_udev_find_unlisted_similar(type);
111 EINA_LIST_FOREACH(type, l, name)
112 {
113 check = eeze_udev_syspath_get_devpath(name);
114 eeze_udev_find_similar_from_syspath(name);
115 eeze_udev_find_similar_from_syspath(NULL);
116 eeze_udev_syspath_get_parent(name);
117 eeze_udev_syspath_get_parent(NULL);
118 eeze_udev_syspath_get_parents(name);
119 eeze_udev_syspath_get_parents(NULL);
120 eeze_udev_syspath_get_devname(name);
121 eeze_udev_syspath_get_devname(NULL);
122 eeze_udev_syspath_get_subsystem(name);
123 eeze_udev_syspath_get_sysattr(name, "manufacturer");
124 eeze_udev_syspath_is_mouse(name);
125 eeze_udev_syspath_is_kbd(name);
126 eeze_udev_syspath_is_touchpad(name);
127 eeze_udev_syspath_is_joystick(name);
128 eeze_udev_walk_get_sysattr(name, "manufacturer");
129 eeze_udev_find_by_sysattr("manufacturer", NULL);
130 eeze_udev_find_by_sysattr(NULL, NULL);
131 eeze_udev_walk_check_sysattr(name, "manufacturer", NULL);
132 eeze_udev_walk_check_sysattr(name, "manufacturer", "foo");
133 eeze_udev_walk_get_sysattr(NULL, "manufacturer");
134 eeze_udev_walk_get_sysattr(name, NULL);
135 }
136
137 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_MOUSE, NULL);
138 type = eeze_udev_find_unlisted_similar(type);
139 EINA_LIST_FOREACH(type, l, name)
140 {
141 eeze_udev_syspath_is_mouse(name);
142 eeze_udev_syspath_is_touchpad(name);
143 eeze_udev_syspath_is_joystick(name);
144 }
145
146 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_TOUCHPAD, NULL);
147 type = eeze_udev_find_unlisted_similar(type);
148 EINA_LIST_FOREACH(type, l, name)
149 {
150 eeze_udev_syspath_is_touchpad(name);
151 }
152
153 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_JOYSTICK, NULL);
154 type = eeze_udev_find_unlisted_similar(type);
155 EINA_LIST_FOREACH(type, l, name)
156 {
157 eeze_udev_syspath_is_joystick(name);
158 }
159
160 eeze_udev_devpath_get_syspath("/dev/null");
161
162 eeze_shutdown();
163}
164END_TEST
165
166START_TEST(eeze_test_udev_attr)
167{
168 Eina_List *type;
169 const char *name, *check, *check2;
170
171 eeze_init();
172
173 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_INTERNAL, NULL);
174 type = eeze_udev_find_unlisted_similar(type);
175 eeze_udev_find_by_filter("backlight", NULL, NULL);
176
177 eeze_udev_find_by_filter(NULL, NULL, NULL);
178
179 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_NET, NULL);
180 type = eeze_udev_find_unlisted_similar(type);
181 EINA_LIST_FREE(type, name)
182 {
183 check = eeze_udev_syspath_get_property(name, "INTERFACE");
184 }
185
186 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_INTERNAL, NULL);
187 type = eeze_udev_find_unlisted_similar(type);
188 EINA_LIST_FREE(type, name)
189 {
190 check = eeze_udev_syspath_get_property(name, "ID_SERIAL");
191 }
192
193 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_REMOVABLE, NULL);
194 type = eeze_udev_find_unlisted_similar(type);
195 EINA_LIST_FREE(type, name)
196 {
197 if ((check = eeze_udev_syspath_get_sysattr(name, "model")))
198 {
199 check2 = eeze_udev_syspath_get_subsystem(name);
200 }
201 }
202
203 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_V4L, NULL);
204 type = eeze_udev_find_unlisted_similar(type);
205 EINA_LIST_FREE(type, name)
206 {
207 if ((check = eeze_udev_syspath_get_property(name, "DEVNAME")))
208 {
209 if ((check2 = eeze_udev_syspath_get_sysattr(name, "name")))
210 {
211 eina_stringshare_del(check2);
212 }
213 eina_stringshare_del(check);
214 }
215 eina_stringshare_del(name);
216 }
217
218 eeze_shutdown();
219}
220END_TEST
221
222/*
223START_TEST(eeze_test_udev_device)
224{
225 Eina_List *type, *l;
226 _udev_device *device, *device2;
227 const char *name;
228
229 eeze_init();
230
231 type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_INTERNAL, NULL);
232 fail_if(type == NULL);
233 type = eeze_udev_find_unlisted_similar(type);
234 fail_if(type == NULL);
235 EINA_LIST_FOREACH(type, l, name)
236 {
237 device = _new_device(name);
238 fail_if(device == NULL);
239 _walk_parents_get_attr(device, "FOO", EINA_FALSE);
240 _walk_parents_get_attr(device, "FOO", EINA_TRUE);
241 _walk_children_get_attr(name, "FOO", "BAR", EINA_FALSE);
242 _walk_children_get_attr(name, "FOO", "BAR", EINA_TRUE);
243 }
244
245 device = _new_device("Wrong path");
246 fail_if(device != NULL);
247
248 device2 = _copy_device(device);
249 fail_if(device2 != NULL);
250
251 eeze_shutdown();
252}
253END_TEST
254*/
255
256START_TEST(eeze_test_net_list)
257{
258 int ret;
259 Eina_List *list = NULL;
260
261 ret = eeze_init();
262 fail_if(ret != 1);
263
264 list = eeze_net_list();
265 fail_if(list == NULL);
266
267 ret = eeze_shutdown();
268 fail_if(ret != 0);
269}
270END_TEST
271
272START_TEST(eeze_test_net_attr)
273{
274 int ret;
275 int idx = 0;
276 Eeze_Net *net = NULL;
277 const char *tmp = NULL;
278
279 ret = eeze_init();
280 fail_if(ret != 1);
281
282 net = eeze_net_new("lo");
283 fail_if(net == NULL);
284
285 tmp = eeze_net_mac_get(net);
286 fail_if(tmp == NULL);
287 tmp = NULL;
288
289 idx = eeze_net_idx_get(net);
290 fail_if(!idx);
291
292 eeze_net_scan(net);
293
294 tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_IP);
295 fail_if(tmp == NULL);
296 tmp = NULL;
297
298 tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_BROADCAST);
299 fail_if(tmp == NULL);
300 tmp = NULL;
301
302 tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_NETMASK);
303 fail_if(tmp == NULL);
304 tmp = NULL;
305
306 tmp = eeze_net_attribute_get(net, "carrier");
307 fail_if(tmp == NULL);
308 tmp = NULL;
309
310 tmp = eeze_net_syspath_get(net);
311 fail_if(tmp == NULL);
312
313 eeze_net_free(net);
314
315 ret = eeze_shutdown();
316 fail_if(ret != 0);
317}
318END_TEST
319
320/*
321#ifdef HAVE_IPV6
322START_TEST(eeze_test_net_attr_ipv6)
323{
324 int ret;
325 Eeze_Net *net = NULL;
326 const char *tmp = NULL;
327
328 ret = eeze_init();
329 fail_if(ret != 1);
330
331 net = eeze_net_new("lo");
332 fail_if(net == NULL);
333
334 tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_IP6);
335 fail_if(tmp == NULL);
336 tmp = NULL;
337
338 tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_BROADCAST6);
339 fail_if(tmp == NULL);
340 tmp = NULL;
341
342 tmp = eeze_net_addr_get(net, EEZE_NET_ADDR_TYPE_NETMASK6);
343 fail_if(tmp == NULL);
344
345 eeze_net_free(net);
346
347 ret = eeze_shutdown();
348 fail_if(ret != 0);
349}
350END_TEST
351#endif
352*/
353
354START_TEST(eeze_test_sensor_read)
355{
356 Eeze_Sensor_Obj *sens = NULL;
357 int ret = 0;
358 float x, y, z;
359 int acc;
360 unsigned long long timestamp;
361 Eina_Bool rc = EINA_FALSE;
362
363 ecore_init();
364 ret = eeze_init();
365 fail_if(ret != 1);
366
367 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_ACCELEROMETER);
368 fail_if(sens == NULL);
369 rc = eeze_sensor_read(sens);
370 fail_if(rc == EINA_FALSE);
371 rc = eeze_sensor_accuracy_get(sens, &acc);
372 fail_if(rc == EINA_FALSE);
373 rc = eeze_sensor_timestamp_get(sens, &timestamp);
374 fail_if(rc == EINA_FALSE);
375 rc = eeze_sensor_xyz_get(sens, &x, &y, &z);
376 fail_if(rc == EINA_FALSE);
377
378 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_MAGNETIC);
379 fail_if(sens == NULL);
380 rc = eeze_sensor_read(sens);
381 fail_if(rc == EINA_FALSE);
382 rc = eeze_sensor_accuracy_get(sens, &acc);
383 fail_if(rc == EINA_FALSE);
384 rc = eeze_sensor_timestamp_get(sens, &timestamp);
385 fail_if(rc == EINA_FALSE);
386 rc = eeze_sensor_xyz_get(sens, &x, &y, &z);
387 fail_if(rc == EINA_FALSE);
388
389 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_ORIENTATION);
390 fail_if(sens == NULL);
391 rc = eeze_sensor_read(sens);
392 fail_if(rc == EINA_FALSE);
393 rc = eeze_sensor_accuracy_get(sens, &acc);
394 fail_if(rc == EINA_FALSE);
395 rc = eeze_sensor_timestamp_get(sens, &timestamp);
396 fail_if(rc == EINA_FALSE);
397 rc = eeze_sensor_xyz_get(sens, &x, &y, &z);
398 fail_if(rc == EINA_FALSE);
399
400 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_GYROSCOPE);
401 fail_if(sens == NULL);
402 rc = eeze_sensor_read(sens);
403 fail_if(rc == EINA_FALSE);
404 rc = eeze_sensor_accuracy_get(sens, &acc);
405 fail_if(rc == EINA_FALSE);
406 rc = eeze_sensor_timestamp_get(sens, &timestamp);
407 fail_if(rc == EINA_FALSE);
408 rc = eeze_sensor_xyz_get(sens, &x, &y, &z);
409 fail_if(rc == EINA_FALSE);
410
411 /* Use gyro with xy here even if it offers xzy */
412 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_GYROSCOPE);
413 fail_if(sens == NULL);
414 rc = eeze_sensor_read(sens);
415 fail_if(rc == EINA_FALSE);
416 rc = eeze_sensor_accuracy_get(sens, &acc);
417 fail_if(rc == EINA_FALSE);
418 rc = eeze_sensor_timestamp_get(sens, &timestamp);
419 fail_if(rc == EINA_FALSE);
420 rc = eeze_sensor_xy_get(sens, &x, &y);
421 fail_if(rc == EINA_FALSE);
422
423 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_PROXIMITY);
424 fail_if(sens == NULL);
425 rc = eeze_sensor_read(sens);
426 fail_if(rc == EINA_FALSE);
427 rc = eeze_sensor_accuracy_get(sens, &acc);
428 fail_if(rc == EINA_FALSE);
429 rc = eeze_sensor_timestamp_get(sens, &timestamp);
430 fail_if(rc == EINA_FALSE);
431 rc = eeze_sensor_x_get(sens, &x);
432 fail_if(rc == EINA_FALSE);
433
434 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LIGHT);
435 fail_if(sens == NULL);
436 rc = eeze_sensor_read(sens);
437 fail_if(rc == EINA_FALSE);
438 rc = eeze_sensor_accuracy_get(sens, &acc);
439 fail_if(rc == EINA_FALSE);
440 rc = eeze_sensor_timestamp_get(sens, &timestamp);
441 fail_if(rc == EINA_FALSE);
442 rc = eeze_sensor_x_get(sens, &x);
443 fail_if(rc == EINA_FALSE);
444
445 /* Call non existing type */
446 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LAST + 1);
447 fail_if(sens != NULL);
448
449 /* Give NULL as sensor object */
450 rc = eeze_sensor_read(NULL);
451 fail_if(rc != EINA_FALSE);
452
453 /* Change sensor type after creation but before read */
454 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LIGHT);
455 fail_if(sens == NULL);
456 sens->type = EEZE_SENSOR_TYPE_LAST + 1;
457 rc = eeze_sensor_read(sens);
458 fail_if(rc != EINA_FALSE);
459
460 /* Try to read from a type you can't read from */
461 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LIGHT);
462 fail_if(sens == NULL);
463 sens->type = EEZE_SENSOR_TYPE_LAST;
464 rc = eeze_sensor_read(sens);
465 fail_if(rc != EINA_FALSE);
466
467 /* Try all getter functions with a NULL sensor object */
468 rc = eeze_sensor_xyz_get(NULL, &x, &y, &z);
469 fail_if(rc != EINA_FALSE);
470 rc = eeze_sensor_xy_get(NULL, &x, &y);
471 fail_if(rc != EINA_FALSE);
472 rc = eeze_sensor_x_get(NULL, &x);
473 fail_if(rc != EINA_FALSE);
474 rc = eeze_sensor_accuracy_get(NULL, &acc);
475 fail_if(rc != EINA_FALSE);
476 rc = eeze_sensor_timestamp_get(NULL, &timestamp);
477 fail_if(rc != EINA_FALSE);
478
479 eeze_sensor_free(sens);
480
481 /* Try free on NULL */
482 eeze_sensor_free(NULL);
483
484 ret = eeze_shutdown();
485 fail_if(ret != 0);
486}
487END_TEST
488
489static Eina_Bool
490event_cb(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *event)
491{
492 Eeze_Sensor_Obj *sens = NULL;
493 int acc;
494 unsigned long long timestamp;
495 Eina_Bool rc = EINA_FALSE;
496
497 sens = event;
498 fail_if(sens == NULL);
499 rc = eeze_sensor_accuracy_get(sens, &acc);
500 fail_if(rc == EINA_FALSE);
501 rc = eeze_sensor_timestamp_get(sens, &timestamp);
502 fail_if(rc == EINA_FALSE);
503
504 eeze_sensor_free(sens);
505
506 ecore_main_loop_quit();
507
508 return EINA_FALSE;
509}
510
511START_TEST(eeze_test_sensor_async_read)
512{
513 Ecore_Event_Handler *handler;
514 Ecore_Event *event;
515
516 Eeze_Sensor_Obj *sens = NULL;
517 int ret = 0;
518 Eina_Bool rc = EINA_FALSE;
519
520 ecore_init();
521 ret = eeze_init();
522 fail_if(ret != 1);
523
524 EEZE_SENSOR_EVENT_ACCELEROMETER = ecore_event_type_new();
525 fail_if(EEZE_SENSOR_EVENT_ACCELEROMETER < 1);
526
527 handler = ecore_event_handler_add(EEZE_SENSOR_EVENT_ACCELEROMETER, event_cb, NULL);
528 fail_if(handler == NULL);
529 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_ACCELEROMETER);
530 fail_if(sens == NULL);
531 rc = eeze_sensor_async_read(sens, NULL);
532 fail_if(rc == EINA_FALSE);
533
534 ecore_event_handler_add(EEZE_SENSOR_EVENT_MAGNETIC, event_cb, NULL);
535 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_MAGNETIC);
536 fail_if(sens == NULL);
537 rc = eeze_sensor_async_read(sens, NULL);
538 fail_if(rc == EINA_FALSE);
539
540 ecore_event_handler_add(EEZE_SENSOR_EVENT_ORIENTATION, event_cb, NULL);
541 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_ORIENTATION);
542 fail_if(sens == NULL);
543 rc = eeze_sensor_async_read(sens, NULL);
544 fail_if(rc == EINA_FALSE);
545
546 ecore_event_handler_add(EEZE_SENSOR_EVENT_GYROSCOPE, event_cb, NULL);
547 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_GYROSCOPE);
548 fail_if(sens == NULL);
549 rc = eeze_sensor_async_read(sens, NULL);
550 fail_if(rc == EINA_FALSE);
551
552 ecore_event_handler_add(EEZE_SENSOR_EVENT_PROXIMITY, event_cb, NULL);
553 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_PROXIMITY);
554 fail_if(sens == NULL);
555 rc = eeze_sensor_async_read(sens, NULL);
556 fail_if(rc == EINA_FALSE);
557
558 ecore_event_handler_add(EEZE_SENSOR_EVENT_LIGHT, event_cb, NULL);
559 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LIGHT);
560 fail_if(sens == NULL);
561 rc = eeze_sensor_async_read(sens, NULL);
562 fail_if(rc == EINA_FALSE);
563
564 event = ecore_event_add(EEZE_SENSOR_EVENT_ACCELEROMETER, sens, NULL, NULL);
565 fail_if(event == NULL);
566
567 /* Error case */
568 event = ecore_event_add(42, sens, NULL, NULL);
569 fail_if(event != NULL);
570 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LAST + 1);
571 fail_if(sens != NULL);
572 rc = eeze_sensor_async_read(NULL, NULL);
573 fail_if(rc != EINA_FALSE);
574
575 /* Change sensor type after creation but before read */
576 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LIGHT);
577 fail_if(sens == NULL);
578 sens->type = EEZE_SENSOR_TYPE_LAST + 1;
579 rc = eeze_sensor_async_read(sens, NULL);
580 fail_if(rc != EINA_FALSE);
581
582 /* Try to read from a type you can't read from */
583 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LIGHT);
584 fail_if(sens == NULL);
585 sens->type = EEZE_SENSOR_TYPE_LAST;
586 rc = eeze_sensor_async_read(sens, NULL);
587 fail_if(rc != EINA_FALSE);
588
589 ecore_main_loop_begin();
590
591 ret = eeze_shutdown();
592 fail_if(ret != 0);
593}
594END_TEST
595
596START_TEST(eeze_test_sensor_obj_get)
597{
598 Eeze_Sensor_Obj *obj = NULL, *obj_tmp = NULL;
599 int ret = 0;
600
601 ecore_init();
602 ret = eeze_init();
603 fail_if(ret != 1);
604
605 obj = calloc(1, sizeof(Eeze_Sensor_Obj));
606 fail_if(obj == NULL);
607
608 obj_tmp = obj;
609
610 obj = eeze_sensor_obj_get(EEZE_SENSOR_TYPE_ACCELEROMETER);
611 fail_if(obj == obj_tmp);
612
613 free(obj);
614
615 /* Try to get non existing obj */
616 obj_tmp = eeze_sensor_obj_get(EEZE_SENSOR_TYPE_LAST + 1);
617 fail_if(obj_tmp != NULL);
618
619 ret = eeze_shutdown();
620 fail_if(ret != 0);
621}
622END_TEST
623
624Suite *
625eeze_suite(void)
626{
627 Suite *s;
628 TCase *tc;
629
630 s = suite_create("Eeze");
631#if 0
632 tc = tcase_create("Eeze_Init");
633 tcase_add_test(tc, eeze_test_init);
634 suite_add_tcase(s, tc);
635
636 tc = tcase_create("Eeze_Udev");
637 tcase_add_test(tc, eeze_test_udev_types);
638 tcase_add_test(tc, eeze_test_udev_watch);
639 tcase_add_test(tc, eeze_test_udev_syspath);
640 tcase_add_test(tc, eeze_test_udev_attr);
641 //FIXME Tested functions here are hidden (not EAPI) and thus can not be tested like this with
642 //-fvisibility=hidden turned on.
643 //tcase_add_test(tc, eeze_test_udev_device);
644 suite_add_tcase(s, tc);
645
646 tc = tcase_create("Eeze_Net");
647 tcase_add_test(tc, eeze_test_net_list);
648 tcase_add_test(tc, eeze_test_net_attr);
649#ifdef HAVE_IPV6
650 //FIXME Figure out why we fail for the ipv6 tests here (code or test)
651 //tcase_add_test(tc, eeze_test_net_attr_ipv6);
652#endif
653 suite_add_tcase(s, tc);
654#endif
655 tc = tcase_create("Eeze Sensor");
656 tcase_add_test(tc, eeze_test_sensor_read);
657 tcase_add_test(tc, eeze_test_sensor_async_read);
658 tcase_add_test(tc, eeze_test_sensor_obj_get);
659 suite_add_tcase(s, tc);
660
661 return s;
662}
663
664int
665main(void)
666{
667 Suite *s;
668 SRunner *sr;
669 int failed_count;
670
671 s = eeze_suite();
672 sr = srunner_create(s);
673 srunner_run_all(sr, CK_ENV);
674 failed_count = srunner_ntests_failed(sr);
675 srunner_free(sr);
676
677 return (failed_count == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
678}
679