forked from enlightenment/efl
ecore: add timeout promise test.
This commit is contained in:
parent
950701b738
commit
a1bd7a7499
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
#include <Ecore.h>
|
#include <Ecore.h>
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include "ecore_suite.h"
|
#include "ecore_suite.h"
|
||||||
|
|
||||||
#define TIMEOUT_1 0.01 // interval for timer1
|
#define TIMEOUT_1 0.01 // interval for timer1
|
||||||
|
@ -173,7 +175,41 @@ START_TEST(ecore_test_timers)
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
static void
|
||||||
|
_ecore_promise_quit(void *data, void *value)
|
||||||
|
{
|
||||||
|
Eina_Bool *bob = data;
|
||||||
|
double *start = *(double**)value;
|
||||||
|
double delta = fabs(ecore_loop_time_get() - *start);
|
||||||
|
|
||||||
|
fail_if(fabs(delta - 0.2) > 0.01);
|
||||||
|
|
||||||
|
*bob = EINA_TRUE;
|
||||||
|
ecore_main_loop_quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(ecore_test_timeout)
|
||||||
|
{
|
||||||
|
Eina_Promise *timeout = NULL;
|
||||||
|
Eina_Bool bob = EINA_FALSE;
|
||||||
|
double start;
|
||||||
|
|
||||||
|
ecore_init();
|
||||||
|
|
||||||
|
start = ecore_time_get();
|
||||||
|
efl_loop_timeout(ecore_main_loop_get(), &timeout, 0.2, &start);
|
||||||
|
eina_promise_then(timeout, &_ecore_promise_quit, NULL, &bob);
|
||||||
|
|
||||||
|
ecore_main_loop_begin();
|
||||||
|
|
||||||
|
fail_if(bob != EINA_TRUE);
|
||||||
|
|
||||||
|
ecore_shutdown();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
void ecore_test_timer(TCase *tc)
|
void ecore_test_timer(TCase *tc)
|
||||||
{
|
{
|
||||||
tcase_add_test(tc, ecore_test_timers);
|
tcase_add_test(tc, ecore_test_timers);
|
||||||
|
tcase_add_test(tc, ecore_test_timeout);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue