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
|
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#define EO_BASE_BETA
#include "Eo.h"
#include "composite_objects_simple.h"
#include "composite_objects_comp.h"
#include "../eunit_tests.h"
static int cb_called = EINA_FALSE;
static Eina_Bool
_a_changed_cb(void *data, const Eo_Event *event)
{
int new_a = *((int *) event->event_info);
printf("%s event_info:'%d' data:'%s'\n", __func__, new_a, (const char *) data);
cb_called = EINA_TRUE;
return EO_CALLBACK_CONTINUE;
}
int
main(int argc, char *argv[])
{
Eina_Bool tmp;
(void) argc;
(void) argv;
eo_init();
Eo *obj = eo_add(COMP_CLASS, NULL);
eo_do(obj, eo_event_callback_add(EV_A_CHANGED, _a_changed_cb, NULL));
fail_if(!eo_isa(obj, COMP_CLASS));
fail_if(!eo_isa(obj, SIMPLE_CLASS));
int a = 0;
cb_called = EINA_FALSE;
eo_do(obj, simple_a_set(1));
fail_if(!cb_called);
/* Test functions from all across the chain. */
cb_called = EINA_FALSE;
eo_do(obj, simple_a_set1(1));
fail_if(!cb_called);
cb_called = EINA_FALSE;
eo_do(obj, simple_a_set15(1));
fail_if(!cb_called);
cb_called = EINA_FALSE;
eo_do(obj, simple_a_set32(1));
fail_if(!cb_called);
eo_do(obj, a = simple_a_get());
fail_if(a != 1);
/* disable the callback forwarder, and fail if it's still called. */
Eo *simple = NULL;
eo_do(obj, simple = eo_key_data_get("simple-obj"));
eo_ref(simple);
eo_do(simple, eo_event_callback_forwarder_del(EV_A_CHANGED, obj));
cb_called = EINA_FALSE;
eo_do(obj, simple_a_set(2));
fail_if(cb_called);
fail_if(!eo_do_ret(simple, tmp,eo_composite_part_is()));
fail_if(!eo_do_ret(obj, tmp,eo_composite_detach(simple)));
fail_if(eo_do_ret(obj, tmp,eo_composite_detach(simple)));
fail_if(eo_do_ret(simple, tmp,eo_composite_part_is()));
fail_if(!eo_do_ret(obj, tmp,eo_composite_attach(simple)));
fail_if(!eo_do_ret(simple, tmp,eo_composite_part_is()));
fail_if(eo_do_ret(obj, tmp,eo_composite_attach(simple)));
fail_if(eo_do_ret(simple, tmp,eo_composite_attach(obj)));
eo_unref(simple);
eo_unref(obj);
eo_shutdown();
return 0;
}
|