summaryrefslogtreecommitdiff
path: root/src/tests/ecore/ecore_test_args.c
blob: 84ff61aeeeb6d6b111095701ed8c9b966fb482a2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <Ecore.h>
#include "ecore_suite.h"

static Eina_Bool
_cb_args1(void *data EINA_UNUSED, const Eo_Event *event)
{
   Efl_Loop_Args *args = event->info;
   int n;

   n = efl_loop_args_arg_num_get(args);
   fail_if(n != 8);
   fail_if(!!strcmp(efl_loop_args_arg_get(args, 0), "a"));
   fail_if(!!strcmp(efl_loop_args_arg_get(args, 1), "b"));
   fail_if(!!strcmp(efl_loop_args_arg_get(args, 2), "c"));
   fail_if(!!strcmp(efl_loop_args_arg_get(args, 3), "d"));
   fail_if(!!strcmp(efl_loop_args_arg_get(args, 4), "e"));
   fail_if(!!strcmp(efl_loop_args_arg_get(args, 5), "f"));
   fail_if(!!strcmp(efl_loop_args_arg_get(args, 6), "g"));
   fail_if(!!strcmp(efl_loop_args_arg_get(args, 7), "h"));
   ecore_main_loop_quit();
   return EO_CALLBACK_CONTINUE;
}

START_TEST(ecore_test_args1)
{
   const char *args[] =
     {
        "a", "b", "c", "d", "e", "f", "g", "h"
     };

   ecore_init();
   eo_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGS,
                        _cb_args1, NULL);
   efl_loop_args_add(ecore_main_loop_get(), 8, args);
   ecore_main_loop_begin();
   ecore_shutdown();
}
END_TEST

static Eina_Bool
_cb_args2(void *data EINA_UNUSED, const Eo_Event *event)
{
   Efl_Loop_Args *args = event->info;
   int n;

   n = efl_loop_args_arg_num_get(args);
   fail_if(n != 1);
   fail_if(!!strcmp(efl_loop_args_arg_get(args, 0), "hello world"));
   ecore_main_loop_quit();
   return EO_CALLBACK_CONTINUE;
}

START_TEST(ecore_test_args2)
{
   const char *args[] =
     {
        "hello world"
     };

   ecore_init();
   eo_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGS,
                        _cb_args2, NULL);
   efl_loop_args_add(ecore_main_loop_get(), 1, args);
   ecore_main_loop_begin();
   ecore_shutdown();
}
END_TEST

static Eina_Bool
_cb_args3(void *data EINA_UNUSED, const Eo_Event *event)
{
   Efl_Loop_Args *args = event->info;
   int n;

   n = efl_loop_args_arg_num_get(args);
   fail_if(n != 0);
   ecore_main_loop_quit();
   return EO_CALLBACK_CONTINUE;
}

START_TEST(ecore_test_args3)
{
   ecore_init();
   eo_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGS,
                        _cb_args3, NULL);
   efl_loop_args_add(ecore_main_loop_get(), 0, NULL);
   ecore_main_loop_begin();
   ecore_shutdown();
}
END_TEST

static Eina_Bool
_cb_args4(void *data EINA_UNUSED, const Eo_Event *event)
{
   Efl_Loop_Args *args = event->info;
   int n;

   n = efl_loop_args_arg_num_get(args);
   fail_if(n != 3);
   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"));
   fail_if(!!strcmp(efl_loop_args_arg_get(args, 1), "xxxxx"));
   fail_if(!!strcmp(efl_loop_args_arg_get(args, 2), "y"));
   ecore_main_loop_quit();
   return EO_CALLBACK_CONTINUE;
}

START_TEST(ecore_test_args4)
{
   const char *args[] =
     {
        "some really long string with lots more to it than is needed for an argument blah",
        "xxxxx",
        "y"
     };

   ecore_init();
   eo_event_callback_add(ecore_main_loop_get(), EFL_LOOP_EVENT_ARGS,
                        _cb_args4, NULL);
   efl_loop_args_add(ecore_main_loop_get(), 3, args);
   ecore_main_loop_begin();
   ecore_shutdown();
}
END_TEST

void ecore_test_ecore_args(TCase *tc)
{
   tcase_add_test(tc, ecore_test_args1);
   tcase_add_test(tc, ecore_test_args2);
   tcase_add_test(tc, ecore_test_args3);
   tcase_add_test(tc, ecore_test_args4);
}