summaryrefslogtreecommitdiff
path: root/src/tests/ecore/ecore_test_timer.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2017-02-07 16:32:44 -0800
committerCedric BAIL <cedric@osg.samsung.com>2017-02-07 16:39:02 -0800
commitd70bcb94cba2180c0175fd864427b193dfc2f8eb (patch)
treef806e328e59cc1d5b86bc5e70995f491b7ea9a78 /src/tests/ecore/ecore_test_timer.c
parent4f2af2475551bcddb8b48a6c832563277635af92 (diff)
ecore: add test to make sure that the timer reset during callback work as expected.
Diffstat (limited to '')
-rw-r--r--src/tests/ecore/ecore_test_timer.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/tests/ecore/ecore_test_timer.c b/src/tests/ecore/ecore_test_timer.c
index 6efe5a2554..7447aad2cf 100644
--- a/src/tests/ecore/ecore_test_timer.c
+++ b/src/tests/ecore/ecore_test_timer.c
@@ -191,6 +191,45 @@ START_TEST(ecore_test_timers)
191} 191}
192END_TEST 192END_TEST
193 193
194typedef struct _Test_Inside_Call
195{
196 Ecore_Timer *t;
197 double start;
198} Test_Inside_Call;
199
200static Eina_Bool
201_timeri_cb(void *data)
202{
203 static int it = 5;
204 Test_Inside_Call *c = data;
205
206 fail_if(fabs(((ecore_time_get() - c->start) / (6 - it)) - 0.011) > 0.01);
207 ecore_timer_reset(c->t);
208
209 it--;
210
211 if (it == 0) ecore_main_loop_quit();
212 return it != 0;
213}
214
215START_TEST(ecore_test_timer_inside_call)
216{
217 Test_Inside_Call c;
218
219 fail_if(!ecore_init(), "ERROR: Cannot init Ecore!\n");
220
221 c.start = ecore_time_get();
222 c.t = ecore_timer_add(0.01, _timeri_cb, &c);
223
224 fail_if(!c.t, "Error add timer\n");
225
226 ecore_main_loop_begin();
227
228 ecore_shutdown();
229
230}
231END_TEST
232
194static void 233static void
195_ecore_promise_quit(void *data, const Efl_Event *ev) 234_ecore_promise_quit(void *data, const Efl_Event *ev)
196{ 235{
@@ -326,4 +365,5 @@ void ecore_test_timer(TCase *tc)
326 tcase_add_test(tc, ecore_test_timeout); 365 tcase_add_test(tc, ecore_test_timeout);
327 tcase_add_test(tc, ecore_test_timeout_cancel); 366 tcase_add_test(tc, ecore_test_timeout_cancel);
328 tcase_add_test(tc, ecore_test_timer_lifecycle); 367 tcase_add_test(tc, ecore_test_timer_lifecycle);
368 tcase_add_test(tc, ecore_test_timer_inside_call);
329} 369}