summaryrefslogtreecommitdiff
path: root/src/tests/ecore/ecore_test_timer.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-05-04 15:42:23 -0700
committerCedric BAIL <cedric@osg.samsung.com>2016-05-04 15:42:59 -0700
commita1bd7a74991fc5a618077df6f28494cb8453d6f5 (patch)
tree66188ca88144a53675e5c3ca501d78169b8138c4 /src/tests/ecore/ecore_test_timer.c
parent950701b7383150ac0f999e6215c0db84f003f720 (diff)
ecore: add timeout promise test.
Diffstat (limited to '')
-rw-r--r--src/tests/ecore/ecore_test_timer.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/tests/ecore/ecore_test_timer.c b/src/tests/ecore/ecore_test_timer.c
index ab858931a7..bb76968dcc 100644
--- a/src/tests/ecore/ecore_test_timer.c
+++ b/src/tests/ecore/ecore_test_timer.c
@@ -4,6 +4,8 @@
4 4
5#include <Ecore.h> 5#include <Ecore.h>
6 6
7#include <math.h>
8
7#include "ecore_suite.h" 9#include "ecore_suite.h"
8 10
9#define TIMEOUT_1 0.01 // interval for timer1 11#define TIMEOUT_1 0.01 // interval for timer1
@@ -173,7 +175,41 @@ START_TEST(ecore_test_timers)
173} 175}
174END_TEST 176END_TEST
175 177
178static void
179_ecore_promise_quit(void *data, void *value)
180{
181 Eina_Bool *bob = data;
182 double *start = *(double**)value;
183 double delta = fabs(ecore_loop_time_get() - *start);
184
185 fail_if(fabs(delta - 0.2) > 0.01);
186
187 *bob = EINA_TRUE;
188 ecore_main_loop_quit();
189}
190
191START_TEST(ecore_test_timeout)
192{
193 Eina_Promise *timeout = NULL;
194 Eina_Bool bob = EINA_FALSE;
195 double start;
196
197 ecore_init();
198
199 start = ecore_time_get();
200 efl_loop_timeout(ecore_main_loop_get(), &timeout, 0.2, &start);
201 eina_promise_then(timeout, &_ecore_promise_quit, NULL, &bob);
202
203 ecore_main_loop_begin();
204
205 fail_if(bob != EINA_TRUE);
206
207 ecore_shutdown();
208}
209END_TEST
210
176void ecore_test_timer(TCase *tc) 211void ecore_test_timer(TCase *tc)
177{ 212{
178 tcase_add_test(tc, ecore_test_timers); 213 tcase_add_test(tc, ecore_test_timers);
214 tcase_add_test(tc, ecore_test_timeout);
179} 215}