summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-12-11 10:23:33 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-12-11 10:36:17 +0100
commit5cb8e4a3e77c306922c2daa25e254a4d63d208b5 (patch)
treee005632fa5f1c771d95332113fe8f5f4d522c6cd
parent330b72bc6a2506f74703040ec21b680e2d6c86b2 (diff)
eo: add a tcase for testing forwarders
this just adds the newly introduced semantics from cedric.
-rw-r--r--src/tests/eo/suite/eo_test_event.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/tests/eo/suite/eo_test_event.c b/src/tests/eo/suite/eo_test_event.c
index 9694ba3..f7a2670 100644
--- a/src/tests/eo/suite/eo_test_event.c
+++ b/src/tests/eo/suite/eo_test_event.c
@@ -185,12 +185,47 @@ EFL_START_TEST(eo_event_generation_bug)
185} 185}
186EFL_END_TEST 186EFL_END_TEST
187 187
188static void
189_inc_when_called(void *data, const Efl_Event *ev EINA_UNUSED)
190{
191 int *called = (int*)data;
192 *called += 1;
193}
194
195EFL_START_TEST(eo_event_fowarder_test)
196{
197 Eo *obj1, *obj2;
198 int called = 0;
199
200 obj1 = efl_add_ref(efl_test_event_class_get(), NULL);
201 obj2 = efl_add_ref(efl_test_event_class_get(), NULL);
202 efl_event_callback_add(obj2, EFL_TEST_EVENT_EVENT_TESTER, _inc_when_called, &called);
203
204 efl_event_callback_forwarder_priority_add(obj1, EFL_TEST_EVENT_EVENT_TESTER, EFL_CALLBACK_PRIORITY_BEFORE, obj2);
205 efl_event_callback_call(obj1, EFL_TEST_EVENT_EVENT_TESTER, NULL);
206 ck_assert_int_eq(called, 1);
207 called = 0;
208
209 //call it a second time with another forwarder
210 efl_event_callback_forwarder_priority_add(obj1, EFL_TEST_EVENT_EVENT_TESTER, EFL_CALLBACK_PRIORITY_BEFORE, obj2);
211 efl_event_callback_call(obj1, EFL_TEST_EVENT_EVENT_TESTER, NULL);
212 ck_assert_int_eq(called, 1); //we still should only emit it once
213 called = 0;
214
215 //delete it, nothing should happen now
216 efl_event_callback_forwarder_del(obj1, EFL_TEST_EVENT_EVENT_TESTER, obj2);
217 efl_event_callback_call(obj1, EFL_TEST_EVENT_EVENT_TESTER, NULL);
218 ck_assert_int_eq(called, 0);
219
220}
221EFL_END_TEST
188 222
189void eo_test_event(TCase *tc) 223void eo_test_event(TCase *tc)
190{ 224{
191 tcase_add_test(tc, eo_event); 225 tcase_add_test(tc, eo_event);
192 tcase_add_test(tc, eo_event_call_in_call); 226 tcase_add_test(tc, eo_event_call_in_call);
193 tcase_add_test(tc, eo_event_generation_bug); 227 tcase_add_test(tc, eo_event_generation_bug);
228 tcase_add_test(tc, eo_event_fowarder_test);
194} 229}
195 230
196 231