summaryrefslogtreecommitdiff
path: root/tests/common
diff options
context:
space:
mode:
Diffstat (limited to 'tests/common')
-rw-r--r--tests/common/test_app.c2
-rw-r--r--tests/common/test_backends.c29
-rw-r--r--tests/common/test_contracts.c12
-rw-r--r--tests/common/test_keyboard.c5
-rw-r--r--tests/common/test_timers.c2
5 files changed, 38 insertions, 12 deletions
diff --git a/tests/common/test_app.c b/tests/common/test_app.c
index 661620c..23c9a93 100644
--- a/tests/common/test_app.c
+++ b/tests/common/test_app.c
@@ -43,7 +43,7 @@ static int on_init(void *ud, struct yasl_display *d)
state->display = d;
state->init_called = true;
- struct yasl_surface_spec spec = {
+ struct yasl_window_spec spec = {
.title = "App Runner Test",
.size = {320, 240},
};
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);
diff --git a/tests/common/test_contracts.c b/tests/common/test_contracts.c
index 8580dd6..ac0065c 100644
--- a/tests/common/test_contracts.c
+++ b/tests/common/test_contracts.c
@@ -114,7 +114,7 @@ static void copy(struct yasl_display *d, enum yasl_selection sel, const char *te
{ (void)d; (void)sel; (void)text; copies++; }
static void paste(struct yasl_display *d, enum yasl_selection sel, struct yasl_surface *s)
{ (void)d; (void)sel; (void)s; pastes++; }
-static struct yasl_surface *create(struct yasl_display *d, const struct yasl_surface_spec *spec, void *graphics_device)
+static struct yasl_surface *create(struct yasl_display *d, const struct yasl_window_spec *spec, void *graphics_device)
{ (void)d; (void)spec; (void)graphics_device; creates++; return NULL; }
static void *native_device;
@@ -123,7 +123,7 @@ static struct yasl_surface native_surface;
static uint32_t native_caps(const struct yasl_display *d)
{ (void)d; return YASL_CAP_NATIVE_GRAPHICS; }
static struct yasl_surface *native_create(struct yasl_display *d,
- const struct yasl_surface_spec *spec, void *device)
+ const struct yasl_window_spec *spec, void *device)
{
(void)spec;
native_device = device;
@@ -144,7 +144,7 @@ static void test_native(void)
const struct yasl_backend_ops ops = {.display_caps = native_caps,
.surface_create_toplevel = native_create, .surface_get_native_frame = native_frame};
struct yasl_display d = {.ops = &ops};
- struct yasl_surface_spec spec = {.size = {100, 80}};
+ struct yasl_window_spec spec = {.size = {100, 80}};
assert(yasl_surface_create_toplevel(&d, &spec) == &native_surface);
assert(!native_device);
assert(yasl_surface_create_native(&d, &spec, &d) == &native_surface);
@@ -209,7 +209,7 @@ static void test_validation(void)
yasl_display_copy(&d, YASL_CLIPBOARD, "yes");
yasl_display_paste(&d, YASL_CLIPBOARD, &s);
assert(copies == 1 && pastes == 1);
- struct yasl_surface_spec spec = {.size = {100, 80}};
+ struct yasl_window_spec spec = {.size = {100, 80}};
assert(!yasl_surface_create_native(&d, &spec, &d) && errno == ENOTSUP);
assert(!yasl_surface_create_native(&d, &spec, NULL) && errno == EINVAL);
spec.size.x = 0;
@@ -257,7 +257,7 @@ static int dispatch_failure(struct yasl_display *d, int timeout)
{ (void)d; (void)timeout; return -1; }
static struct yasl_surface *create_failure(struct yasl_display *d,
- const struct yasl_surface_spec *spec, void *device)
+ const struct yasl_window_spec *spec, void *device)
{ (void)d; (void)spec; (void)device; return NULL; }
static int drag_starts;
@@ -310,7 +310,7 @@ static void test_errors(void)
d.ops = &ops;
errno = ERANGE;
assert(yasl_display_dispatch(&d, 0) == -1 && errno == EIO);
- struct yasl_surface_spec toplevel = {.size = {120, 80}};
+ struct yasl_window_spec toplevel = {.size = {120, 80}};
errno = ERANGE;
assert(!yasl_surface_create_toplevel(&d, &toplevel) && errno == ENODEV);
assert(yasl_display_drag_start(&d, &s, NULL, NULL, NULL));
diff --git a/tests/common/test_keyboard.c b/tests/common/test_keyboard.c
index 5a7f18e..f2fc8f2 100644
--- a/tests/common/test_keyboard.c
+++ b/tests/common/test_keyboard.c
@@ -1,5 +1,8 @@
#include "common/keyboard.h"
-#include "cocoa/keycodes.h"
+#include "platform/wayland/keymap.h"
+#include "platform/x11/keymap.h"
+#include "platform/cocoa/keymap.h"
+#include "platform/cocoa/keycodes.h"
#include <assert.h>
int main(void)
diff --git a/tests/common/test_timers.c b/tests/common/test_timers.c
index 4e95c5a..f321b2c 100644
--- a/tests/common/test_timers.c
+++ b/tests/common/test_timers.c
@@ -234,7 +234,7 @@ static void test_surface_timers(void)
assert(yasl_display_loop(d) == loop);
- struct yasl_surface_spec sspec = {
+ struct yasl_window_spec sspec = {
.title = "Timer Surface",
.size = { .x = 160, .y = 100 },
};