summaryrefslogtreecommitdiff
path: root/src/tests/ecore/ecore_test_args.c
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-05-31 17:16:14 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-05-31 17:16:14 +0900
commit47e3b171a3902f9dd5b81af093989d8e1c425235 (patch)
tree56d8f3656567c063b18eb1b83b3680722b2eea9a /src/tests/ecore/ecore_test_args.c
parentcdd59921c6613de766ae088574dfbd86b2750206 (diff)
efl test suite - test args event and args values
Diffstat (limited to '')
-rw-r--r--src/tests/ecore/ecore_test_args.c135
1 files changed, 135 insertions, 0 deletions
diff --git a/src/tests/ecore/ecore_test_args.c b/src/tests/ecore/ecore_test_args.c
new file mode 100644
index 0000000000..84ff61aeee
--- /dev/null
+++ b/src/tests/ecore/ecore_test_args.c
@@ -0,0 +1,135 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <Ecore.h>
6#include "ecore_suite.h"
7
8static Eina_Bool
9_cb_args1(void *data EINA_UNUSED, const Eo_Event *event)
10{
11 Efl_Loop_Args *args = event->info;
12 int n;
13
14 n = efl_loop_args_arg_num_get(args);
15 fail_if(n != 8);
16 fail_if(!!strcmp(efl_loop_args_arg_get(args, 0), "a"));
17 fail_if(!!strcmp(efl_loop_args_arg_get(args, 1), "b"));
18 fail_if(!!strcmp(efl_loop_args_arg_get(args, 2), "c"));
19 fail_if(!!strcmp(efl_loop_args_arg_get(args, 3), "d"));
20 fail_if(!!strcmp(efl_loop_args_arg_get(args, 4), "e"));
21 fail_if(!!strcmp(efl_loop_args_arg_get(args, 5), "f"));
22 fail_if(!!strcmp(efl_loop_args_arg_get(args, 6), "g"));
23 fail_if(!!strcmp(efl_loop_args_arg_get(args, 7), "h"));
24 ecore_main_loop_quit();
25 return EO_CALLBACK_CONTINUE;
26}
27
28START_TEST(ecore_test_args1)
29{
30 const char *args[] =
31 {
32 "a", "b", "c", "d", "e", "f", "g", "h"
33 };
34
35 ecore_init();
36 eo_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGS,
37 _cb_args1, NULL);
38 efl_loop_args_add(ecore_main_loop_get(), 8, args);
39 ecore_main_loop_begin();
40 ecore_shutdown();
41}
42END_TEST
43
44static Eina_Bool
45_cb_args2(void *data EINA_UNUSED, const Eo_Event *event)
46{
47 Efl_Loop_Args *args = event->info;
48 int n;
49
50 n = efl_loop_args_arg_num_get(args);
51 fail_if(n != 1);
52 fail_if(!!strcmp(efl_loop_args_arg_get(args, 0), "hello world"));
53 ecore_main_loop_quit();
54 return EO_CALLBACK_CONTINUE;
55}
56
57START_TEST(ecore_test_args2)
58{
59 const char *args[] =
60 {
61 "hello world"
62 };
63
64 ecore_init();
65 eo_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGS,
66 _cb_args2, NULL);
67 efl_loop_args_add(ecore_main_loop_get(), 1, args);
68 ecore_main_loop_begin();
69 ecore_shutdown();
70}
71END_TEST
72
73static Eina_Bool
74_cb_args3(void *data EINA_UNUSED, const Eo_Event *event)
75{
76 Efl_Loop_Args *args = event->info;
77 int n;
78
79 n = efl_loop_args_arg_num_get(args);
80 fail_if(n != 0);
81 ecore_main_loop_quit();
82 return EO_CALLBACK_CONTINUE;
83}
84
85START_TEST(ecore_test_args3)
86{
87 ecore_init();
88 eo_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGS,
89 _cb_args3, NULL);
90 efl_loop_args_add(ecore_main_loop_get(), 0, NULL);
91 ecore_main_loop_begin();
92 ecore_shutdown();
93}
94END_TEST
95
96static Eina_Bool
97_cb_args4(void *data EINA_UNUSED, const Eo_Event *event)
98{
99 Efl_Loop_Args *args = event->info;
100 int n;
101
102 n = efl_loop_args_arg_num_get(args);
103 fail_if(n != 3);
104 fail_if(!!strcmp(efl_loop_args_arg_get(args, 0), "some really long string with lots more to it than is needed for an argument blah"));
105 fail_if(!!strcmp(efl_loop_args_arg_get(args, 1), "xxxxx"));
106 fail_if(!!strcmp(efl_loop_args_arg_get(args, 2), "y"));
107 ecore_main_loop_quit();
108 return EO_CALLBACK_CONTINUE;
109}
110
111START_TEST(ecore_test_args4)
112{
113 const char *args[] =
114 {
115 "some really long string with lots more to it than is needed for an argument blah",
116 "xxxxx",
117 "y"
118 };
119
120 ecore_init();
121 eo_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGS,
122 _cb_args4, NULL);
123 efl_loop_args_add(ecore_main_loop_get(), 3, args);
124 ecore_main_loop_begin();
125 ecore_shutdown();
126}
127END_TEST
128
129void ecore_test_ecore_args(TCase *tc)
130{
131 tcase_add_test(tc, ecore_test_args1);
132 tcase_add_test(tc, ecore_test_args2);
133 tcase_add_test(tc, ecore_test_args3);
134 tcase_add_test(tc, ecore_test_args4);
135}