summaryrefslogtreecommitdiff
path: root/src/tests/eo/suite
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2017-02-16 13:37:16 -0800
committerCedric BAIL <cedric@osg.samsung.com>2017-02-16 13:37:19 -0800
commitae8004033112f0f4f94ad6d0eac2f010b5c009cd (patch)
tree94ef267acd5bbd29bf6ba075c8255140e489b362 /src/tests/eo/suite
parent7760613107f164f14e706deb96c0ae9ac6614417 (diff)
eo: ensure the generation is correctly clamped
Summary: when a few recursive event emissions are happening, and in some deep recursive level a subscription to the same object is happening, the subscription would just be executed when the complete recursion is done. that is wrong. The subscription needs to be executed when the event is called after the subscription is added, undepended from any recursive level. That fixes that and adds a regression test for it. This was discovered in e, since e gives a lot of error messages about a eo object that is already freed. It turned out this object is returned from evas, and exactly the above happened to the EFL_EVENT_DEL subscription of that object. Test Plan: make check Reviewers: tasn, cedric, stefan_schmidt Subscribers: stefan_schmidt, netstar, zmike, raster, jpeg Differential Revision: https://phab.enlightenment.org/D4656 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/tests/eo/suite')
-rw-r--r--src/tests/eo/suite/eo_test_event.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/tests/eo/suite/eo_test_event.c b/src/tests/eo/suite/eo_test_event.c
index ebbeaa859c..66902db233 100644
--- a/src/tests/eo/suite/eo_test_event.c
+++ b/src/tests/eo/suite/eo_test_event.c
@@ -14,8 +14,12 @@
14EWAPI const Efl_Class *efl_test_event_class_get(void); 14EWAPI const Efl_Class *efl_test_event_class_get(void);
15 15
16EWAPI extern const Efl_Event_Description _EFL_TEST_EVENT_EVENT_TESTER; 16EWAPI extern const Efl_Event_Description _EFL_TEST_EVENT_EVENT_TESTER;
17EWAPI extern const Efl_Event_Description _EFL_TEST_EVENT_EVENT_TESTER_SUBSCRIBE;
18EWAPI extern const Efl_Event_Description _EFL_TEST_EVENT_EVENT_TESTER_CLAMP_TEST;
17 19
18#define EFL_TEST_EVENT_EVENT_TESTER (&(_EFL_TEST_EVENT_EVENT_TESTER)) 20#define EFL_TEST_EVENT_EVENT_TESTER (&(_EFL_TEST_EVENT_EVENT_TESTER))
21#define EFL_TEST_EVENT_EVENT_TESTER_SUBSCRIBE (&(_EFL_TEST_EVENT_EVENT_TESTER_SUBSCRIBE))
22#define EFL_TEST_EVENT_EVENT_TESTER_CLAMP_TEST (&(_EFL_TEST_EVENT_EVENT_TESTER_CLAMP_TEST))
19 23
20typedef struct { 24typedef struct {
21 Eina_Bool event1; 25 Eina_Bool event1;
@@ -131,17 +135,84 @@ START_TEST(eo_event_call_in_call)
131 efl_object_shutdown(); 135 efl_object_shutdown();
132} 136}
133END_TEST 137END_TEST
138
139static Eina_Bool emitted = 0;
140
141static void
142_generation_clamp_step3(void *data EINA_UNUSED, const Efl_Event *e EINA_UNUSED)
143{
144 emitted = 1;
145}
146
147static void
148_generation_clamp_subscribe(void *data EINA_UNUSED, const Efl_Event *e)
149{
150 //generation is 2
151 efl_event_callback_add(e->object, EFL_TEST_EVENT_EVENT_TESTER_CLAMP_TEST, _generation_clamp_step3, NULL);
152}
153
154static void
155_generation_clamp_step1(void *data EINA_UNUSED, const Efl_Event *e)
156{
157 //generation is 1
158 efl_event_callback_call(e->object, EFL_TEST_EVENT_EVENT_TESTER_SUBSCRIBE, NULL);
159
160 efl_event_callback_call(e->object, EFL_TEST_EVENT_EVENT_TESTER_CLAMP_TEST, NULL);
161 efl_event_callback_call(e->object, EFL_TEST_EVENT_EVENT_TESTER_CLAMP_TEST, NULL);
162}
163
164
165START_TEST(eo_event_generation_bug)
166{
167 efl_object_init();
168
169 /*
170 * The idea is:
171 *
172 * #1 a event gets emitted (generation is 1)
173 * #2 a event gets emitted as a result of #1 (generation is 2)
174 * in a callback from #2 a new subscription for E is added (S) (generation of it is 2)
175 * in a callback of #1 event E is emitted (generation is 2)
176 * S now MUST get executed (Here is the bug generation of S is 2 and of emission is 2, event gets skipped)
177 * subscription adds a callback to a event
178 */
179
180 Eo *obj;
181
182 obj = efl_add(efl_test_event_class_get(), NULL);
183 emitted = 0;
184 efl_event_callback_priority_add(obj, EFL_TEST_EVENT_EVENT_TESTER, EFL_CALLBACK_PRIORITY_BEFORE, _generation_clamp_step1, NULL);
185 efl_event_callback_priority_add(obj, EFL_TEST_EVENT_EVENT_TESTER_SUBSCRIBE, EFL_CALLBACK_PRIORITY_BEFORE, _generation_clamp_subscribe, NULL);
186 efl_event_callback_call(obj, EFL_TEST_EVENT_EVENT_TESTER, NULL);
187
188 ck_assert_int_ne(emitted, 0);
189
190 efl_object_shutdown();
191}
192END_TEST
193
194
134void eo_test_event(TCase *tc) 195void eo_test_event(TCase *tc)
135{ 196{
136 tcase_add_test(tc, eo_event); 197 tcase_add_test(tc, eo_event);
137 tcase_add_test(tc, eo_event_call_in_call); 198 tcase_add_test(tc, eo_event_call_in_call);
199 tcase_add_test(tc, eo_event_generation_bug);
138} 200}
139 201
202
203
140//class implementation 204//class implementation
141 205
142EWAPI const Efl_Event_Description _EFL_TEST_EVENT_EVENT_TESTER = 206EWAPI const Efl_Event_Description _EFL_TEST_EVENT_EVENT_TESTER =
143 EFL_EVENT_DESCRIPTION("tester"); 207 EFL_EVENT_DESCRIPTION("tester");
144 208
209EWAPI const Efl_Event_Description _EFL_TEST_EVENT_EVENT_TESTER_SUBSCRIBE =
210 EFL_EVENT_DESCRIPTION("tester");
211
212EWAPI const Efl_Event_Description _EFL_TEST_EVENT_EVENT_TESTER_CLAMP_TEST =
213 EFL_EVENT_DESCRIPTION("tester");
214
215
145static const Efl_Class_Description _efl_test_event_class_desc = { 216static const Efl_Class_Description _efl_test_event_class_desc = {
146 EO_VERSION, 217 EO_VERSION,
147 "Efl_Test_Event", 218 "Efl_Test_Event",