diff options
author | Marcel Hollerbach <marcel-hollerbach@t-online.de> | 2016-11-29 20:18:44 +0100 |
---|---|---|
committer | Marcel Hollerbach <marcel-hollerbach@t-online.de> | 2016-11-30 13:07:44 +0100 |
commit | a4e1485f6f6b7f9d6617338147fe1a3cc2bda2d8 (patch) | |
tree | 295f0c2bae600503d279d2658cd8ec2cda11b151 | |
parent | 8a213847596376305d282e1ba26080b548a207f9 (diff) | |
download | efl-a4e1485f6f6b7f9d6617338147fe1a3cc2bda2d8.tar.gz |
eo: add testcase to check emission of events
-rw-r--r-- | src/Makefile_Eo.am | 1 | ||||
-rw-r--r-- | src/tests/eo/suite/eo_suite.c | 1 | ||||
-rw-r--r-- | src/tests/eo/suite/eo_suite.h | 1 | ||||
-rw-r--r-- | src/tests/eo/suite/eo_test_event.c | 98 |
4 files changed, 101 insertions, 0 deletions
diff --git a/src/Makefile_Eo.am b/src/Makefile_Eo.am index eefa6119f8..0bf2453c61 100644 --- a/src/Makefile_Eo.am +++ b/src/Makefile_Eo.am @@ -143,6 +143,7 @@ tests/eo/suite/eo_test_class_behaviour_errors.c \ tests/eo/suite/eo_test_call_errors.c \ tests/eo/suite/eo_test_general.c \ tests/eo/suite/eo_test_value.c \ +tests/eo/suite/eo_test_event.c \ tests/eo/suite/eo_test_threaded_calls.c \ tests/eo/suite/eo_test_init.c 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[] = { { "Eo call errors", eo_test_call_errors }, { "Eo eina value", eo_test_value }, { "Eo threaded eo calls", eo_test_threaded_calls }, + { "Eo event calls", eo_test_event}, { NULL, NULL } }; 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); void eo_test_call_errors(TCase *tc); void eo_test_value(TCase *tc); void eo_test_threaded_calls(TCase *tc); +void eo_test_event(TCase *tc); #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 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <stdio.h> + +#include <Eo.h> + +#include "eo_suite.h" +#include "eo_test_class_simple.h" + +//Class definition with one event + +EWAPI const Efl_Class *efl_test_event_class_get(void); + +EWAPI extern const Efl_Event_Description _EFL_TEST_EVENT_EVENT_TESTER; + +#define EFL_TEST_EVENT_EVENT_TESTER (&(_EFL_TEST_EVENT_EVENT_TESTER)) + +typedef struct { + Eina_Bool event1; + Eina_Bool event2; + Eina_Bool event3; +} Test_Data; + +typedef struct { + int not_empty; +} Efl_Test_Event_Data; + + +static void +_cb3(void *data, const Efl_Event *event) +{ + Test_Data *d = data; + + d->event3 = EINA_TRUE; +} + +static void +_cb2(void *data, const Efl_Event *event) +{ + Test_Data *d = data; + + d->event2 = EINA_TRUE; +} + +static void +_cb1(void *data, const Efl_Event *event) +{ + Test_Data *d = data; + + d->event1 = EINA_TRUE; + + efl_event_callback_add(event->object, EFL_TEST_EVENT_EVENT_TESTER, _cb3, data); +} + +START_TEST(eo_event) +{ + Test_Data data; + efl_object_init(); + Eo *obj; + + memset(&data, 0, sizeof(Test_Data)); + + obj = efl_add(efl_test_event_class_get(), NULL); + efl_event_callback_priority_add(obj, EFL_TEST_EVENT_EVENT_TESTER, EFL_CALLBACK_PRIORITY_BEFORE, _cb2, &data); + efl_event_callback_priority_add(obj, EFL_TEST_EVENT_EVENT_TESTER, EFL_CALLBACK_PRIORITY_BEFORE, _cb1, &data); + efl_event_callback_call(obj, EFL_TEST_EVENT_EVENT_TESTER, NULL); + + ck_assert_int_ne(data.event1, 0); + ck_assert_int_ne(data.event2, 0); + ck_assert_int_ne(data.event3, 0); + + efl_object_shutdown(); +} +END_TEST + +void eo_test_event(TCase *tc) +{ + tcase_add_test(tc, eo_event); +} + +//class implementation + +EWAPI const Efl_Event_Description _EFL_TEST_EVENT_EVENT_TESTER = + EFL_EVENT_DESCRIPTION("tester"); + +static const Efl_Class_Description _efl_test_event_class_desc = { + EO_VERSION, + "Efl_Test_Event", + EFL_CLASS_TYPE_REGULAR, + sizeof(Efl_Test_Event_Data), + NULL, + NULL, + NULL +}; + +EFL_DEFINE_CLASS(efl_test_event_class_get, &_efl_test_event_class_desc, EFL_OBJECT_CLASS, NULL); |