summaryrefslogtreecommitdiff
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
parent421b29dcb8d7e6434b6bd031ab7b168c9b8fcb67 (diff)
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);
30 30
31void efl_ui_model(TCase *tc); 31void efl_ui_model(TCase *tc);
32 32
33void loop_timer_interval_set(Eo *obj, double in);
34
35#define efl_loop_timer_interval_set loop_timer_interval_set
36
33Eo *win_add(); 37Eo *win_add();
34Eo *win_add_focused(); 38Eo *win_add_focused();
35#endif 39#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 @@
16 } 16 }
17 17
18#include <Evas.h> 18#include <Evas.h>
19#include <Ecore.h>
19 20
20void elm_test_config(TCase *tc); 21void elm_test_config(TCase *tc);
21void elm_test_check(TCase *tc); 22void elm_test_check(TCase *tc);
@@ -99,4 +100,8 @@ void elm_code_test_widget_undo(TCase *tc);
99Evas_Object *win_add(); 100Evas_Object *win_add();
100Evas_Object *win_add_focused(); 101Evas_Object *win_add_focused();
101 102
103Eo *timer_add(double in, Ecore_Task_Cb cb, void *data);
104
105#define ecore_timer_add timer_add
106
102#endif /* _ELM_SUITE_H */ 107#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[] = {
107 { NULL, NULL } 107 { NULL, NULL }
108}; 108};
109 109
110#define BUFFER_RENDER_INTERVAL 0.002 110#undef ecore_timer_add
111#define BUFFER_RENDER_INTERVAL 0.005
112#define LOOP_INCREMENT 0.1
113#define TIMER_SCALE ((1.0 / BUFFER_RENDER_INTERVAL) * LOOP_INCREMENT)
111 114
112static void 115void
113_ui_win_manual_render(void *data, const Efl_Event *ev EINA_UNUSED) 116loop_timer_interval_set(Eo *obj, double in)
114{ 117{
115 ecore_animator_custom_tick(); 118 efl_loop_timer_interval_set(obj, in * TIMER_SCALE);
116 evas_norender(evas_object_evas_get(data));
117} 119}
118 120
119static Eina_Bool 121Eo *
120_win_manual_render(void *data) 122timer_add(double in, Ecore_Task_Cb cb, void *data)
121{ 123{
124 return ecore_timer_add(in * TIMER_SCALE, cb, data);
125}
126
127static void
128_win_manual_render(void *data, const Efl_Event *event EINA_UNUSED)
129 {
130 double t = ecore_loop_time_get();
131
132 ecore_loop_time_set(t + LOOP_INCREMENT);
122 ecore_animator_custom_tick(); 133 ecore_animator_custom_tick();
123 evas_norender(evas_object_evas_get(data)); 134 evas_norender(evas_object_evas_get(data));
124 return EINA_TRUE;
125} 135}
126 136
127static void 137static void
128_ui_win_show(void *data EINA_UNUSED, const Efl_Event *ev) 138_loop_iterate(void *data, const Efl_Event *event EINA_UNUSED)
129{ 139{
130 Eo *timer = efl_add(EFL_LOOP_TIMER_CLASS, ev->object, 140 efl_loop_iterate(data);
131 efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK, _ui_win_manual_render, ev->object),
132 efl_loop_timer_interval_set(efl_added, BUFFER_RENDER_INTERVAL)
133 );
134 efl_key_data_set(ev->object, "timer", timer);
135} 141}
136 142
137static void 143static void
138_ui_win_hide(void *data EINA_UNUSED, const Efl_Event *ev) 144_win_show(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
139{ 145{
140 efl_del(efl_key_data_get(ev->object, "timer")); 146 Eo *timer = evas_object_data_get(obj, "timer");
141 efl_key_data_set(ev->object, "timer", NULL); 147 efl_event_thaw(timer);
148 efl_event_callback_add(efl_loop_get(obj), EFL_LOOP_EVENT_IDLE, _loop_iterate, efl_parent_get(timer));
142} 149}
143 150
144static void 151static void
145_win_show(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) 152_win_hide(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
146{ 153{
147 evas_object_data_set(obj, "timer", ecore_timer_add(BUFFER_RENDER_INTERVAL, _win_manual_render, obj)); 154 Eo *timer = evas_object_data_get(obj, "timer");
155 efl_event_freeze(timer);
156 efl_loop_timer_reset(timer);
157 efl_event_callback_del(efl_loop_get(obj), EFL_LOOP_EVENT_IDLE, _loop_iterate, efl_parent_get(timer));
148} 158}
149 159
150static void 160static void
151_win_hide(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) 161_ui_win_show(void *data EINA_UNUSED, const Efl_Event *ev)
162{
163 _win_show(NULL, NULL, ev->object, NULL);
164}
165
166static void
167_ui_win_hide(void *data EINA_UNUSED, const Efl_Event *ev)
152{ 168{
153 ecore_timer_del(evas_object_data_del(obj, "timer")); 169 _win_hide(NULL, NULL, ev->object, NULL);
170 efl_key_data_set(ev->object, "timer", NULL);
154} 171}
155 172
156static Evas_Object * 173static Evas_Object *
157_elm_suite_win_create() 174_elm_suite_win_create()
158{ 175{
159 Evas_Object *win; 176 Evas_Object *win;
177 Eo *loop, *timer;
160 178
161 if (legacy_mode) 179 if (legacy_mode)
162 win = elm_win_add(NULL, "elm_suite", ELM_WIN_BASIC); 180 win = elm_win_add(NULL, "elm_suite", ELM_WIN_BASIC);
163 else 181 else
164 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(), efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC)); 182 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(), efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC));
165 if (!buffer) return win; 183 if (!buffer) return win;
184 loop = efl_add(EFL_LOOP_CLASS, win);
185 timer = efl_add(EFL_LOOP_TIMER_CLASS, loop,
186 efl_loop_timer_interval_set(efl_added, BUFFER_RENDER_INTERVAL),
187 efl_event_freeze(efl_added),
188 efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK, _win_manual_render, win)
189 );
190 evas_object_data_set(win, "timer", timer);
166 ecore_evas_manual_render_set(ecore_evas_ecore_evas_get(evas_object_evas_get(win)), EINA_TRUE); 191 ecore_evas_manual_render_set(ecore_evas_ecore_evas_get(evas_object_evas_get(win)), EINA_TRUE);
167 edje_frametime_set(BUFFER_RENDER_INTERVAL); 192 edje_frametime_set(BUFFER_RENDER_INTERVAL);
168 ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM); 193 ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM);