diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 15:43:04 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 15:43:04 +0300 |
| commit | e24b8a8cef001e1c7e50ab12b739486f59b2a850 (patch) | |
| tree | f4678f9c7081c2bfd2dad56c8ca456c01447a116 /tests | |
| parent | 38533c81e7b7ebfc5f281c2523188aeaa38d09c3 (diff) | |
Let yasl_app_desc describe its initial window
A new optional yasl_app_desc.window spec makes yasl_run() create that
toplevel and request its first frame before init(), which is now
optional too. If creation fails, yasl_run() closes the display and
returns an error without calling init().
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/common/test_app.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/common/test_app.c b/tests/common/test_app.c index 6972921..f61a957 100644 --- a/tests/common/test_app.c +++ b/tests/common/test_app.c @@ -109,6 +109,29 @@ static void on_quit(void *ud, struct yasl_display *d) state->quit_called = true; } +static void present_once(void *ud, struct yasl_surface *s, struct yasl_frame_context *ctx) +{ + (*(int *)ud)++; + if (ctx->cpu.pixels) + assert(yasl_frame_present_cpu(ctx, NULL, 0)); + yasl_surface_destroy(s); +} + +/* desc.window replaces init: the runner creates the toplevel and draws it. */ +static void test_window_without_init(void) +{ + int frames = 0; + struct yasl_window_spec window = {.title = "App Runner Window", .size = {160, 120}}; + int res = yasl_run(&(struct yasl_app_desc){ + .app_id = "org.yasl.test.app.window", + .userdata = &frames, + .window = &window, + .frame = present_once, + }); + assert(res == 0); + assert(frames == 1); +} + int main(void) { struct test_state state = {0}; @@ -129,6 +152,7 @@ int main(void) assert(state.user_event_called); assert(state.timer_called); assert(state.quit_called); + test_window_without_init(); printf("App runner tests passed!\n"); return 0; } |
