aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2019-02-01 19:42:40 +0000
committerDerek Foreman <derek.foreman.samsung@gmail.com>2019-02-01 14:10:52 -0600
commit08b7974fa19170bbba862fbe1f217e1988e8ebfa (patch)
tree11663994bf9e0b749bcb5a736493895d1d4d43de
parentefl_interfaces: missing interfaces prefix (diff)
downloadefl-08b7974fa19170bbba862fbe1f217e1988e8ebfa.tar.gz
tests/elm: speed up all main loop timer execution
this spins a second loop which manages a timer to trigger the canvas tick and increase the loop timer by a fixed interval on every timer call by increasing the loop time manually, timers such as edje animation timers which would usually take a very long time (e.g., 0.5s) to run will instead complete almost instantly, making tests run much faster the second loop is necessary in this case in order to accurately provide ticks at a consistent interval without any modifications to timing Reviewed-by: Derek Foreman <derekf@osg.samsung.com> Differential Revision: https://phab.enlightenment.org/D6791
-rw-r--r--src/tests/elementary/efl_ui_suite.h4
-rw-r--r--src/tests/elementary/elm_suite.h5
-rw-r--r--src/tests/elementary/suite_helpers.c67
3 files changed, 55 insertions, 21 deletions
diff --git a/src/tests/elementary/efl_ui_suite.h b/src/tests/elementary/efl_ui_suite.h
index b131f01476..5c91331fc5 100644
--- a/src/tests/elementary/efl_ui_suite.h
+++ b/src/tests/elementary/efl_ui_suite.h
@@ -30,6 +30,10 @@ void efl_ui_test_focus_sub(TCase *tc);
void efl_ui_model(TCase *tc);
+void loop_timer_interval_set(Eo *obj, double in);
+
+#define efl_loop_timer_interval_set loop_timer_interval_set
+
Eo *win_add();
Eo *win_add_focused();
#endif
diff --git a/src/tests/elementary/elm_suite.h b/src/tests/elementary/elm_suite.h
index ba3c8a6789..bf169e32e9 100644
--- a/src/tests/elementary/elm_suite.h
+++ b/src/tests/elementary/elm_suite.h
@@ -16,6 +16,7 @@
}
#include <Evas.h>
+#include <Ecore.h>
void elm_test_config(TCase *tc);
void elm_test_check(TCase *tc);
@@ -99,4 +100,8 @@ void elm_code_test_widget_undo(TCase *tc);
Evas_Object *win_add();
Evas_Object *win_add_focused();
+Eo *timer_add(double in, Ecore_Task_Cb cb, void *data);
+
+#define ecore_timer_add timer_add
+
#endif /* _ELM_SUITE_H */
diff --git a/src/tests/elementary/suite_helpers.c b/src/tests/elementary/suite_helpers.c
index e6a8cfee24..de175fc420 100644
--- a/src/tests/elementary/suite_helpers.c
+++ b/src/tests/elementary/suite_helpers.c
@@ -107,62 +107,87 @@ static const Efl_Test_Case ui_init[] = {
{ NULL, NULL }
};
-#define BUFFER_RENDER_INTERVAL 0.002
+#undef ecore_timer_add
+#define BUFFER_RENDER_INTERVAL 0.005
+#define LOOP_INCREMENT 0.1
+#define TIMER_SCALE ((1.0 / BUFFER_RENDER_INTERVAL) * LOOP_INCREMENT)
-static void
-_ui_win_manual_render(void *data, const Efl_Event *ev EINA_UNUSED)
+void
+loop_timer_interval_set(Eo *obj, double in)
{
- ecore_animator_custom_tick();
- evas_norender(evas_object_evas_get(data));
+ efl_loop_timer_interval_set(obj, in * TIMER_SCALE);
}
-static Eina_Bool
-_win_manual_render(void *data)
+Eo *
+timer_add(double in, Ecore_Task_Cb cb, void *data)
{
+ return ecore_timer_add(in * TIMER_SCALE, cb, data);
+}
+
+static void
+_win_manual_render(void *data, const Efl_Event *event EINA_UNUSED)
+ {
+ double t = ecore_loop_time_get();
+
+ ecore_loop_time_set(t + LOOP_INCREMENT);
ecore_animator_custom_tick();
evas_norender(evas_object_evas_get(data));
- return EINA_TRUE;
}
static void
-_ui_win_show(void *data EINA_UNUSED, const Efl_Event *ev)
+_loop_iterate(void *data, const Efl_Event *event EINA_UNUSED)
{
- Eo *timer = efl_add(EFL_LOOP_TIMER_CLASS, ev->object,
- efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK, _ui_win_manual_render, ev->object),
- efl_loop_timer_interval_set(efl_added, BUFFER_RENDER_INTERVAL)
- );
- efl_key_data_set(ev->object, "timer", timer);
+ efl_loop_iterate(data);
}
static void
-_ui_win_hide(void *data EINA_UNUSED, const Efl_Event *ev)
+_win_show(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
- efl_del(efl_key_data_get(ev->object, "timer"));
- efl_key_data_set(ev->object, "timer", NULL);
+ Eo *timer = evas_object_data_get(obj, "timer");
+ efl_event_thaw(timer);
+ efl_event_callback_add(efl_loop_get(obj), EFL_LOOP_EVENT_IDLE, _loop_iterate, efl_parent_get(timer));
}
static void
-_win_show(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
+_win_hide(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
- evas_object_data_set(obj, "timer", ecore_timer_add(BUFFER_RENDER_INTERVAL, _win_manual_render, obj));
+ Eo *timer = evas_object_data_get(obj, "timer");
+ efl_event_freeze(timer);
+ efl_loop_timer_reset(timer);
+ efl_event_callback_del(efl_loop_get(obj), EFL_LOOP_EVENT_IDLE, _loop_iterate, efl_parent_get(timer));
}
static void
-_win_hide(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
+_ui_win_show(void *data EINA_UNUSED, const Efl_Event *ev)
+{
+ _win_show(NULL, NULL, ev->object, NULL);
+}
+
+static void
+_ui_win_hide(void *data EINA_UNUSED, const Efl_Event *ev)
{
- ecore_timer_del(evas_object_data_del(obj, "timer"));
+ _win_hide(NULL, NULL, ev->object, NULL);
+ efl_key_data_set(ev->object, "timer", NULL);
}
static Evas_Object *
_elm_suite_win_create()
{
Evas_Object *win;
+ Eo *loop, *timer;
if (legacy_mode)
win = elm_win_add(NULL, "elm_suite", ELM_WIN_BASIC);
else
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(), efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC));
if (!buffer) return win;
+ loop = efl_add(EFL_LOOP_CLASS, win);
+ timer = efl_add(EFL_LOOP_TIMER_CLASS, loop,
+ efl_loop_timer_interval_set(efl_added, BUFFER_RENDER_INTERVAL),
+ efl_event_freeze(efl_added),
+ efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK, _win_manual_render, win)
+ );
+ evas_object_data_set(win, "timer", timer);
ecore_evas_manual_render_set(ecore_evas_ecore_evas_get(evas_object_evas_get(win)), EINA_TRUE);
edje_frametime_set(BUFFER_RENDER_INTERVAL);
ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM);