aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-02-01 15:11:04 -0500
committerDerek Foreman <derek.foreman.samsung@gmail.com>2019-02-01 15:13:36 -0600
commit21bdcf42650a4f4bbe6f634d2133c6a6f50fba3c (patch)
treeef651d44a75f000a1811be5a437c26de6fe24186
parenttests/elm: speed up all main loop timer execution (diff)
downloadefl-21bdcf42650a4f4bbe6f634d2133c6a6f50fba3c.tar.gz
tests: add explicit test for concentric loop usage
having multiple loops which interact is a valid use case that should be tested to ensure functionality Reviewed-by: Derek Foreman <derekf@osg.samsung.com> Differential Revision: https://phab.enlightenment.org/D7868
-rw-r--r--src/tests/ecore/efl_app_test_loop.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/tests/ecore/efl_app_test_loop.c b/src/tests/ecore/efl_app_test_loop.c
index f8e0b5548f..f02af90707 100644
--- a/src/tests/ecore/efl_app_test_loop.c
+++ b/src/tests/ecore/efl_app_test_loop.c
@@ -39,7 +39,52 @@ EFL_START_TEST(efl_app_test_efl_loop_register)
}
EFL_END_TEST
+static void
+efl_app_test_efl_loop_concentric_fail(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
+{
+ ck_abort_msg("test timeout");
+}
+
+static void
+loop_idle(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
+{
+ static int num = 0;
+
+ if (num++ == 5) efl_loop_quit(efl_main_loop_get(), eina_value_int_init(0));
+}
+
+static void
+loop_timer_tick(void *data, const Efl_Event *ev EINA_UNUSED)
+{
+ efl_loop_iterate(data);
+}
+
+EFL_START_TEST(efl_app_test_efl_loop_concentric)
+{
+ Eo *loop, *loop2, *timer, *timer2;
+ int exitcode;
+
+ loop = efl_main_loop_get();
+ efl_event_callback_add(loop, EFL_LOOP_EVENT_IDLE, loop_idle, NULL);
+ loop2 = efl_add(EFL_LOOP_CLASS, loop);
+ timer = efl_add(EFL_LOOP_TIMER_CLASS, loop2,
+ efl_loop_timer_interval_set(efl_added, 0.01),
+ efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK, loop_timer_tick, loop)
+ );
+ timer2 = efl_add(EFL_LOOP_TIMER_CLASS, loop,
+ efl_loop_timer_interval_set(efl_added, 0.5),
+ efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK, efl_app_test_efl_loop_concentric_fail, NULL)
+ );
+ exitcode = efl_loop_exit_code_process(efl_loop_begin(loop));
+ ck_assert_int_eq(exitcode, 0);
+ efl_del(timer2);
+ efl_del(timer);
+ efl_del(loop2);
+}
+EFL_END_TEST
+
void efl_app_test_efl_loop(TCase *tc)
{
tcase_add_test(tc, efl_app_test_efl_loop_register);
+ tcase_add_test(tc, efl_app_test_efl_loop_concentric);
}