summaryrefslogtreecommitdiff
path: root/src/tests/eo/suite
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2016-11-29 20:18:44 +0100
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2016-12-02 12:27:37 +0100
commitd81025a66ceab3369c3ed1a5366cb53bdcc31c97 (patch)
tree392d50237f16bdbe0ad80212066a6d54214b69a4 /src/tests/eo/suite
parent299471991c19bde387e96073ccf2bee7deaa9fcd (diff)
eo: add testcase to check emission of events
Diffstat (limited to 'src/tests/eo/suite')
-rw-r--r--src/tests/eo/suite/eo_suite.c1
-rw-r--r--src/tests/eo/suite/eo_suite.h1
-rw-r--r--src/tests/eo/suite/eo_test_event.c98
3 files changed, 100 insertions, 0 deletions
diff --git a/src/tests/eo/suite/eo_suite.c b/src/tests/eo/suite/eo_suite.c
index 2a62f7b2c6..15cf8bc1ec 100644
--- a/src/tests/eo/suite/eo_suite.c
+++ b/src/tests/eo/suite/eo_suite.c
@@ -13,6 +13,7 @@ static const Efl_Test_Case etc[] = {
13 { "Eo call errors", eo_test_call_errors }, 13 { "Eo call errors", eo_test_call_errors },
14 { "Eo eina value", eo_test_value }, 14 { "Eo eina value", eo_test_value },
15 { "Eo threaded eo calls", eo_test_threaded_calls }, 15 { "Eo threaded eo calls", eo_test_threaded_calls },
16 { "Eo event calls", eo_test_event},
16 { NULL, NULL } 17 { NULL, NULL }
17}; 18};
18 19
diff --git a/src/tests/eo/suite/eo_suite.h b/src/tests/eo/suite/eo_suite.h
index ba07799bc9..173965fdf7 100644
--- a/src/tests/eo/suite/eo_suite.h
+++ b/src/tests/eo/suite/eo_suite.h
@@ -10,5 +10,6 @@ void eo_test_class_behaviour_errors(TCase *tc);
10void eo_test_call_errors(TCase *tc); 10void eo_test_call_errors(TCase *tc);
11void eo_test_value(TCase *tc); 11void eo_test_value(TCase *tc);
12void eo_test_threaded_calls(TCase *tc); 12void eo_test_threaded_calls(TCase *tc);
13void eo_test_event(TCase *tc);
13 14
14#endif /* _EO_SUITE_H */ 15#endif /* _EO_SUITE_H */
diff --git a/src/tests/eo/suite/eo_test_event.c b/src/tests/eo/suite/eo_test_event.c
new file mode 100644
index 0000000000..f8727fa022
--- /dev/null
+++ b/src/tests/eo/suite/eo_test_event.c
@@ -0,0 +1,98 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <stdio.h>
6
7#include <Eo.h>
8
9#include "eo_suite.h"
10#include "eo_test_class_simple.h"
11
12//Class definition with one event
13
14EWAPI const Efl_Class *efl_test_event_class_get(void);
15
16EWAPI extern const Efl_Event_Description _EFL_TEST_EVENT_EVENT_TESTER;
17
18#define EFL_TEST_EVENT_EVENT_TESTER (&(_EFL_TEST_EVENT_EVENT_TESTER))
19
20typedef struct {
21 Eina_Bool event1;
22 Eina_Bool event2;
23 Eina_Bool event3;
24} Test_Data;
25
26typedef struct {
27 int not_empty;
28} Efl_Test_Event_Data;
29
30
31static void
32_cb3(void *data, const Efl_Event *event)
33{
34 Test_Data *d = data;
35
36 d->event3 = EINA_TRUE;
37}
38
39static void
40_cb2(void *data, const Efl_Event *event)
41{
42 Test_Data *d = data;
43
44 d->event2 = EINA_TRUE;
45}
46
47static void
48_cb1(void *data, const Efl_Event *event)
49{
50 Test_Data *d = data;
51
52 d->event1 = EINA_TRUE;
53
54 efl_event_callback_add(event->object, EFL_TEST_EVENT_EVENT_TESTER, _cb3, data);
55}
56
57START_TEST(eo_event)
58{
59 Test_Data data;
60 efl_object_init();
61 Eo *obj;
62
63 memset(&data, 0, sizeof(Test_Data));
64
65 obj = efl_add(efl_test_event_class_get(), NULL);
66 efl_event_callback_priority_add(obj, EFL_TEST_EVENT_EVENT_TESTER, EFL_CALLBACK_PRIORITY_BEFORE, _cb2, &data);
67 efl_event_callback_priority_add(obj, EFL_TEST_EVENT_EVENT_TESTER, EFL_CALLBACK_PRIORITY_BEFORE, _cb1, &data);
68 efl_event_callback_call(obj, EFL_TEST_EVENT_EVENT_TESTER, NULL);
69
70 ck_assert_int_ne(data.event1, 0);
71 ck_assert_int_ne(data.event2, 0);
72 ck_assert_int_ne(data.event3, 0);
73
74 efl_object_shutdown();
75}
76END_TEST
77
78void eo_test_event(TCase *tc)
79{
80 tcase_add_test(tc, eo_event);
81}
82
83//class implementation
84
85EWAPI const Efl_Event_Description _EFL_TEST_EVENT_EVENT_TESTER =
86 EFL_EVENT_DESCRIPTION("tester");
87
88static const Efl_Class_Description _efl_test_event_class_desc = {
89 EO_VERSION,
90 "Efl_Test_Event",
91 EFL_CLASS_TYPE_REGULAR,
92 sizeof(Efl_Test_Event_Data),
93 NULL,
94 NULL,
95 NULL
96};
97
98EFL_DEFINE_CLASS(efl_test_event_class_get, &_efl_test_event_class_desc, EFL_OBJECT_CLASS, NULL);