diff options
Diffstat (limited to 'tests/common/test_backends.c')
| -rw-r--r-- | tests/common/test_backends.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/tests/common/test_backends.c b/tests/common/test_backends.c index cf5b1f9..28f2f52 100644 --- a/tests/common/test_backends.c +++ b/tests/common/test_backends.c @@ -121,13 +121,13 @@ static void close_window(struct yasl_surface *s, void *ud) w->surface = NULL; } -static const struct yasl_surface_cbs callbacks = { +static const struct yasl_window_cbs callbacks = { .draw = draw, .configure = configure, .close = close_window, }; static void attach(struct window *w) { - struct yasl_surface_cbs temporary = callbacks; + struct yasl_window_cbs temporary = callbacks; yasl_surface_set_callbacks(w->surface, &temporary, w); temporary.draw = NULL; temporary.configure = NULL; @@ -136,7 +136,7 @@ static void attach(struct window *w) static struct window create(struct yasl_display *d) { - struct yasl_surface_spec spec = {.title = "Backend test", .size = {160, 100}}; + struct yasl_window_spec spec = {.title = "Backend test", .size = {160, 100}}; struct yasl_surface *s = yasl_surface_create_toplevel(d, &spec); assert(s); assert(yasl_display_get_native_handle(d)); @@ -146,6 +146,27 @@ static struct window create(struct yasl_display *d) return (struct window){.surface = s, .display = d}; } +static void test_window_spec(struct yasl_loop *loop, struct yasl_display *d) +{ + struct window w = {.display = d, .destroy_on_draw = true}; + { + struct yasl_window_cbs temporary = callbacks; + struct yasl_window_spec spec = { + .title = "Callbacks at creation", .size = {160, 100}, + .cbs = &temporary, .ud = &w, + }; + w.surface = yasl_surface_create_toplevel(d, &spec); + assert(w.surface); + assert(!w.draws && !w.configures && !w.closes); + /* Neither the spec nor its callback table needs to outlive creation. */ + memset(&temporary, 0, sizeof(temporary)); + memset(&spec, 0, sizeof(spec)); + } + yasl_surface_schedule_redraw(w.surface); + pump(loop, d, NULL); + assert(w.draws == 1 && !w.surface); +} + static void x11_behavior(struct yasl_loop *loop, struct yasl_display *d, struct window *w) { Display *native = yasl_display_get_native_handle(d); @@ -371,6 +392,8 @@ int main(int argc, char **argv) spec.backend = YASL_BACKEND_X11; struct yasl_display *b = yasl_display_open(loop, &spec); assert(a && b); + test_window_spec(loop, a); + test_window_spec(loop, b); struct window wa = create(a), wb = create(b); #if YASL_HAS_WAYLAND assert(yasl_wayland_display_get_wl_display(a) != NULL); |
