summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-10-29 13:08:21 -0400
committerMike Blumenkrantz <zmike@samsung.com>2019-10-31 09:58:59 -0400
commit33dd0b3454549c03b622f520ce4f4e17eb8eadbd (patch)
treed98fb62e9fc0c22343839043a03d18cc16b2740f
parentfb1a055f13c4666b4bb785cf7633fa778c7a74c0 (diff)
tests/efl_app: add port of intensive timer recursion
this is roughly the same as the similarly-named ecore_timer unit test Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D10556
-rw-r--r--src/tests/ecore/efl_app_test_loop_timer.c103
1 files changed, 103 insertions, 0 deletions
diff --git a/src/tests/ecore/efl_app_test_loop_timer.c b/src/tests/ecore/efl_app_test_loop_timer.c
index 790e56768e..fecc6a39cf 100644
--- a/src/tests/ecore/efl_app_test_loop_timer.c
+++ b/src/tests/ecore/efl_app_test_loop_timer.c
@@ -151,6 +151,108 @@ EFL_START_TEST(efl_loop_test_loop_timer_iteration)
151} 151}
152EFL_END_TEST 152EFL_END_TEST
153 153
154#undef TIMER
155#define TIMER(duration) \
156 efl_add(EFL_LOOP_TIMER_CLASS, loop, \
157 efl_loop_timer_interval_set(efl_added, (duration)), \
158 efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TIMER_TICK, _timer_del_cb, NULL) \
159 ); \
160
161static void
162_timer_del_cb(void *data EINA_UNUSED, const Efl_Event *ev)
163{
164 count++;
165 efl_del(ev->object);
166}
167
168
169static void
170_recursion(void *data EINA_UNUSED, const Efl_Event *ev)
171{
172 static unsigned int recurse = 0;
173 static Eo *timer;
174 Eo *loop = efl_main_loop_get();
175
176 switch (recurse++)
177 {
178 case 0:
179 /* verify multiple timer expiration in single mainloop iteration */
180 TIMER(0);
181 TIMER(0);
182 efl_loop_iterate(loop);
183 efl_loop_iterate(loop);
184 ck_assert_int_eq(count, 6);
185 efl_loop_quit(loop, EINA_VALUE_EMPTY);
186 break;
187 case 1:
188 /* timers should not expire for one loop iteration */
189 ck_assert_int_eq(count, 1);
190 TIMER(0);
191 efl_loop_iterate(loop);
192 efl_loop_iterate(loop);
193 break;
194 case 2:
195 /* all pending and instantiated timers should expire after exactly one loop iteration */
196 ck_assert_int_eq(count, 3);
197 efl_loop_iterate(loop);
198 efl_loop_iterate(loop);
199 break;
200 case 3:
201 /* this should not interfere with successive timer processing */
202 ck_assert_int_eq(count, 4);
203
204 /* verify out-of-order timer processing solely based on timer times */
205 timer = TIMER(1);
206 efl_loop_iterate(loop);
207 efl_loop_iterate(loop);
208 break;
209 case 4:
210 ck_assert_int_eq(count, 4);
211 TIMER(0);
212 efl_loop_iterate(loop);
213 efl_loop_iterate(loop);
214 break;
215 case 5:
216 ck_assert_int_eq(count, 4);
217 /* timer should expire after exactly 2 iterations */
218 efl_loop_iterate(loop);
219 efl_loop_iterate(loop);
220 break;
221 case 6:
222 ck_assert_int_eq(count, 5);
223 efl_loop_timer_interval_set(timer, 0);
224 efl_loop_timer_reset(timer);
225 /* timer should expire after exactly 2 iterations since it becomes un-instantiated now */
226 efl_loop_iterate(loop);
227 efl_loop_iterate(loop);
228 break;
229 case 7:
230 efl_loop_iterate(loop);
231 efl_loop_iterate(loop);
232 efl_del(ev->object);
233 break;
234 }
235}
236
237EFL_START_TEST(efl_loop_test_loop_timer_recursion)
238{
239 Eina_Bool crit = eina_log_abort_on_critical_get();
240 int critlevel = eina_log_abort_on_critical_level_get();
241 Eo *loop = efl_main_loop_get();
242 count = 1;
243 eina_log_abort_on_critical_set(1);
244 eina_log_abort_on_critical_level_set(1);
245 efl_add(EFL_LOOP_TIMER_CLASS, loop,
246 efl_loop_timer_interval_set(efl_added, 0),
247 efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TIMER_TICK, _recursion, NULL)
248 );
249 efl_loop_begin(loop);
250 ck_assert_int_eq(count, 6);
251 eina_log_abort_on_critical_set(crit);
252 eina_log_abort_on_critical_level_set(critlevel);
253}
254EFL_END_TEST
255
154void efl_app_test_efl_loop_timer(TCase *tc EINA_UNUSED) 256void efl_app_test_efl_loop_timer(TCase *tc EINA_UNUSED)
155{ 257{
156 /* XXX: this seems a silly test - that we del the loop object? 258 /* XXX: this seems a silly test - that we del the loop object?
@@ -159,4 +261,5 @@ void efl_app_test_efl_loop_timer(TCase *tc EINA_UNUSED)
159 261
160 tcase_add_test(tc, efl_app_test_loop_timer_invalid); 262 tcase_add_test(tc, efl_app_test_loop_timer_invalid);
161 tcase_add_test(tc, efl_loop_test_loop_timer_iteration); 263 tcase_add_test(tc, efl_loop_test_loop_timer_iteration);
264 tcase_add_test(tc, efl_loop_test_loop_timer_recursion);
162} 265}