summaryrefslogtreecommitdiff
path: root/src/tests/ecore/ecore_test_args.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-06-22 14:36:39 -0700
committerCedric BAIL <cedric@osg.samsung.com>2016-06-22 14:36:39 -0700
commit068f57a79d4cc51b7140f67fa2dcae2191c57c2d (patch)
treee5cfff38acaca1ecbdfadbd1d5ead4dd1cba3648 /src/tests/ecore/ecore_test_args.c
parentb047bf7f641d297a5613e889e83aa5466ec3a575 (diff)
ecore: fix arguments to use Eo native array type.
Diffstat (limited to '')
-rw-r--r--src/tests/ecore/ecore_test_args.c96
1 files changed, 27 insertions, 69 deletions
diff --git a/src/tests/ecore/ecore_test_args.c b/src/tests/ecore/ecore_test_args.c
index eb6d13c3e2..367640c4bf 100644
--- a/src/tests/ecore/ecore_test_args.c
+++ b/src/tests/ecore/ecore_test_args.c
@@ -5,36 +5,32 @@
5#include <Ecore.h> 5#include <Ecore.h>
6#include "ecore_suite.h" 6#include "ecore_suite.h"
7 7
8EAPI void ecore_loop_arguments_send(int argc, const char **argv);
9
10static const char *args[] = {
11 "a", "b", "c", "d", "e", "f", "g", "h"
12};
13
8static void 14static void
9_cb_args1(void *data EINA_UNUSED, const Eo_Event *event) 15_cb_args1(void *data EINA_UNUSED, const Eo_Event *event)
10{ 16{
11 Efl_Loop_Args *args = event->info; 17 Efl_Loop_Arguments *arge = event->info;
12 int n; 18 unsigned int i;
13 19
14 n = efl_loop_args_arg_num_get(args); 20 fail_if(eina_array_count(arge->argv) != (sizeof (args) / sizeof (args[0])));
15 fail_if(n != 8); 21 for (i = 0; i < eina_array_count(arge->argv); i++)
16 fail_if(!!strcmp(efl_loop_args_arg_get(args, 0), "a")); 22 {
17 fail_if(!!strcmp(efl_loop_args_arg_get(args, 1), "b")); 23 fail_if(!!strcmp(eina_array_data_get(arge->argv, i), args[i]));
18 fail_if(!!strcmp(efl_loop_args_arg_get(args, 2), "c")); 24 }
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 ecore_main_loop_quit();
25} 26}
26 27
27START_TEST(ecore_test_args1) 28START_TEST(ecore_test_args1)
28{ 29{
29 const char *args[] =
30 {
31 "a", "b", "c", "d", "e", "f", "g", "h"
32 };
33
34 ecore_init(); 30 ecore_init();
35 eo_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGS, 31 eo_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGUMENTS,
36 _cb_args1, NULL); 32 _cb_args1, NULL);
37 efl_loop_args_add(ecore_main_loop_get(), 8, args); 33 ecore_loop_arguments_send(8, args);
38 ecore_main_loop_begin(); 34 ecore_main_loop_begin();
39 ecore_shutdown(); 35 ecore_shutdown();
40} 36}
@@ -43,26 +39,23 @@ END_TEST
43static void 39static void
44_cb_args2(void *data EINA_UNUSED, const Eo_Event *event) 40_cb_args2(void *data EINA_UNUSED, const Eo_Event *event)
45{ 41{
46 Efl_Loop_Args *args = event->info; 42 Efl_Loop_Arguments *arge = event->info;
47 int n;
48 43
49 n = efl_loop_args_arg_num_get(args); 44 fail_if(eina_array_count(arge->argv) != 1);
50 fail_if(n != 1); 45 fail_if(!!strcmp(eina_array_data_get(arge->argv, 0), "hello world"));
51 fail_if(!!strcmp(efl_loop_args_arg_get(args, 0), "hello world"));
52 ecore_main_loop_quit(); 46 ecore_main_loop_quit();
53} 47}
54 48
55START_TEST(ecore_test_args2) 49START_TEST(ecore_test_args2)
56{ 50{
57 const char *args[] = 51 const char *simple_args[] = {
58 { 52 "hello world"
59 "hello world" 53 };
60 };
61 54
62 ecore_init(); 55 ecore_init();
63 eo_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGS, 56 eo_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGUMENTS,
64 _cb_args2, NULL); 57 _cb_args2, NULL);
65 efl_loop_args_add(ecore_main_loop_get(), 1, args); 58 ecore_loop_arguments_send(1, simple_args);
66 ecore_main_loop_begin(); 59 ecore_main_loop_begin();
67 ecore_shutdown(); 60 ecore_shutdown();
68} 61}
@@ -71,52 +64,18 @@ END_TEST
71static void 64static void
72_cb_args3(void *data EINA_UNUSED, const Eo_Event *event) 65_cb_args3(void *data EINA_UNUSED, const Eo_Event *event)
73{ 66{
74 Efl_Loop_Args *args = event->info; 67 Efl_Loop_Arguments *arge = event->info;
75 int n;
76 68
77 n = efl_loop_args_arg_num_get(args); 69 fail_if(eina_array_count(arge->argv) != 0);
78 fail_if(n != 0);
79 ecore_main_loop_quit(); 70 ecore_main_loop_quit();
80} 71}
81 72
82START_TEST(ecore_test_args3) 73START_TEST(ecore_test_args3)
83{ 74{
84 ecore_init(); 75 ecore_init();
85 eo_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGS, 76 eo_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGUMENTS,
86 _cb_args3, NULL); 77 _cb_args3, NULL);
87 efl_loop_args_add(ecore_main_loop_get(), 0, NULL); 78 ecore_loop_arguments_send(0, NULL);
88 ecore_main_loop_begin();
89 ecore_shutdown();
90}
91END_TEST
92
93static void
94_cb_args4(void *data EINA_UNUSED, const Eo_Event *event)
95{
96 Efl_Loop_Args *args = event->info;
97 int n;
98
99 n = efl_loop_args_arg_num_get(args);
100 fail_if(n != 3);
101 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"));
102 fail_if(!!strcmp(efl_loop_args_arg_get(args, 1), "xxxxx"));
103 fail_if(!!strcmp(efl_loop_args_arg_get(args, 2), "y"));
104 ecore_main_loop_quit();
105}
106
107START_TEST(ecore_test_args4)
108{
109 const char *args[] =
110 {
111 "some really long string with lots more to it than is needed for an argument blah",
112 "xxxxx",
113 "y"
114 };
115
116 ecore_init();
117 eo_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGS,
118 _cb_args4, NULL);
119 efl_loop_args_add(ecore_main_loop_get(), 3, args);
120 ecore_main_loop_begin(); 79 ecore_main_loop_begin();
121 ecore_shutdown(); 80 ecore_shutdown();
122} 81}
@@ -127,5 +86,4 @@ void ecore_test_ecore_args(TCase *tc)
127 tcase_add_test(tc, ecore_test_args1); 86 tcase_add_test(tc, ecore_test_args1);
128 tcase_add_test(tc, ecore_test_args2); 87 tcase_add_test(tc, ecore_test_args2);
129 tcase_add_test(tc, ecore_test_args3); 88 tcase_add_test(tc, ecore_test_args3);
130 tcase_add_test(tc, ecore_test_args4);
131} 89}