summaryrefslogtreecommitdiff
path: root/tests/common/test_timers.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/common/test_timers.c')
-rw-r--r--tests/common/test_timers.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/tests/common/test_timers.c b/tests/common/test_timers.c
index 9b6499d..d02bfe9 100644
--- a/tests/common/test_timers.c
+++ b/tests/common/test_timers.c
@@ -1,4 +1,5 @@
#define _POSIX_C_SOURCE 200809L
+#include "common/loop.h"
#include "yasl/yasl.h"
#include <assert.h>
@@ -95,18 +96,18 @@ static uint64_t killer_timer_cb(void *ud, yasl_timer_id id, uint64_t interval_ns
return 0;
}
-/* 6. Millisecond variant timer. */
-static uint32_t ms_timer_cb(void *ud, yasl_timer_id id, uint32_t interval_ms)
+/* 6. Millisecond convenience conversion uses the same timer callback. */
+static uint64_t ms_timer_cb(void *ud, yasl_timer_id id, uint64_t interval_ns)
{
struct test_ctx *ctx = ud;
assert(id == ctx->id);
- assert(interval_ms == 5);
+ assert(interval_ns == YASL_MS_TO_NS(5));
ctx->count++;
if (ctx->count >= 3) {
ctx->done = true;
return 0;
}
- return interval_ms;
+ return interval_ns;
}
static void test_loop_timers(void)
@@ -185,9 +186,9 @@ static void test_loop_timers(void)
assert(ctx6.count == 1);
yasl_loop_step(l, 20);
- /* Test 7: Millisecond API */
+ /* Test 7: Millisecond conversion */
struct test_ctx ctx7 = { .loop = l };
- ctx7.id = yasl_loop_add_timer_ms(l, 5, ms_timer_cb, &ctx7);
+ ctx7.id = yasl_loop_add_timer(l, YASL_MS_TO_NS(5), ms_timer_cb, &ctx7);
assert(ctx7.id > 0);
while (!ctx7.done) {
yasl_loop_step(l, 50);
@@ -239,14 +240,14 @@ static void test_surface_timers(void)
};
struct yasl_surface *s = yasl_surface_create_toplevel(d, &sspec);
assert(s);
- assert(yasl_surface_loop(s) == loop);
+ assert(yasl_display_loop(yasl_surface_display(s)) == loop);
- /* Display timers */
+ /* Application timers use the display's loop. */
struct test_ctx dctx = {0};
- dctx.id = yasl_display_add_timer(d, 2000000ull, oneshot_cb, &dctx);
+ dctx.id = yasl_loop_add_timer(yasl_display_loop(d), 2000000ull, oneshot_cb, &dctx);
assert(dctx.id > 0);
while (dctx.count == 0) {
- yasl_display_dispatch_timeout(d, 50);
+ yasl_display_dispatch(d, 50);
}
assert(dctx.count == 1);
@@ -255,12 +256,12 @@ static void test_surface_timers(void)
sctx.id = yasl_surface_add_timer(s, 2000000ull, surface_timer_repeat_cb, &sctx);
assert(sctx.id > 0);
while (sctx.count < 3) {
- yasl_display_dispatch_timeout(d, 50);
+ yasl_display_dispatch(d, 50);
}
assert(sctx.count >= 3);
assert(yasl_surface_del_timer(s, sctx.id));
int count_before = sctx.count;
- yasl_display_dispatch_timeout(d, 10);
+ yasl_display_dispatch(d, 10);
assert(sctx.count == count_before);
/* Surface timer auto-cleanup on surface destruction */
@@ -269,7 +270,7 @@ static void test_surface_timers(void)
assert(sctx2.id > 0);
yasl_surface_destroy(s);
/* Step display/loop; timer must not fire on dead surface */
- yasl_display_dispatch_timeout(d, 10);
+ yasl_display_dispatch(d, 10);
assert(sctx2.count == 0);
/* Surface suicide from timer callback */
@@ -279,7 +280,7 @@ static void test_surface_timers(void)
sctx3.id = yasl_surface_add_timer(s, 2000000ull, surface_suicide_cb, &sctx3);
assert(sctx3.id > 0);
while (sctx3.count == 0) {
- yasl_display_dispatch_timeout(d, 50);
+ yasl_display_dispatch(d, 50);
}
assert(sctx3.count == 1);
assert(sctx3.surface == NULL);