summaryrefslogtreecommitdiff
path: root/tests/common/test_backends.c
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-13 15:41:39 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-13 15:41:39 +0300
commit482f799d356a8fbb8f585c4de7cc0992b8dc6fd3 (patch)
tree85551a69e3c356da7b9b514224e25a6c2f8d29b9 /tests/common/test_backends.c
parent537b2d768b31deb0f95c5122e0d562e4406ae9a0 (diff)
Migrate tests to the unified event API
Port backend, input, tablet and app tests from yasl_input_event and YASL_INPUT_* to struct yasl_event and YASL_EVENT_*. The input allocation test links input.c on its own, so it stubs yasl_loop_now_ns() for the new event timestamps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/common/test_backends.c')
-rw-r--r--tests/common/test_backends.c86
1 files changed, 43 insertions, 43 deletions
diff --git a/tests/common/test_backends.c b/tests/common/test_backends.c
index 28f2f52..74860c8 100644
--- a/tests/common/test_backends.c
+++ b/tests/common/test_backends.c
@@ -191,17 +191,17 @@ static void x11_behavior(struct yasl_loop *loop, struct yasl_display *d, struct
assert(size.x == 200 && size.y == 120);
/* A server-generated motion verifies the XI2 subscription and cookie
* dispatch path, including source-device lookup, rather than SendEvent. */
- struct yasl_input_event pointer_event;
- while (yasl_surface_input_poll(w->surface, &pointer_event)) {}
+ struct yasl_event pointer_event;
+ while (yasl_surface_poll_event(w->surface, &pointer_event)) {}
XWarpPointer(native, None, window, 0, 0, 0, 0, 80, 50);
XFlush(native);
pump(loop, d, NULL);
bool saw_motion = false;
- while (yasl_surface_input_poll(w->surface, &pointer_event)) {
- if (pointer_event.kind == YASL_INPUT_MOUSE && pointer_event.mouse.kind == YASL_PTR_MOTION) {
- assert(pointer_event.mouse.device == YASL_PTR_DEV_MOUSE);
- assert(!pointer_event.mouse.pen.pressure);
- if (pointer_event.mouse.pos.x == 80 && pointer_event.mouse.pos.y == 50)
+ while (yasl_surface_poll_event(w->surface, &pointer_event)) {
+ if (pointer_event.type == YASL_EVENT_POINTER_MOTION) {
+ assert(pointer_event.pointer.device == YASL_PTR_DEV_MOUSE);
+ assert(!pointer_event.pointer.pen.pressure);
+ if (pointer_event.pointer.pos.x == 80 && pointer_event.pointer.pos.y == 50)
saw_motion = true;
}
}
@@ -216,22 +216,22 @@ static void x11_behavior(struct yasl_loop *loop, struct yasl_display *d, struct
yasl_display_paste(d, YASL_CLIPBOARD, w->surface);
pump(loop, d, NULL);
bool saw_key = false, saw_paste = false, saw_text = false;
- struct yasl_input_event event;
- while (yasl_surface_input_poll(w->surface, &event)) {
+ struct yasl_event event;
+ while (yasl_surface_poll_event(w->surface, &event)) {
assert(event.surface == w->surface);
- if (event.kind == YASL_INPUT_KEY) {
+ if (event.type == YASL_EVENT_KEY) {
assert(event.key.codepoint == 'a');
assert(event.key.shifted == 'A');
assert(event.key.native_code == key.xkey.keycode);
saw_key = event.key.key == YASL_KEY_A;
}
- if (event.kind == YASL_INPUT_PASTE) {
- assert(event.paste.len == strlen("clipboard text"));
- assert(memcmp(event.paste.text, "clipboard text", event.paste.len) == 0);
+ if (event.type == YASL_EVENT_PASTE) {
+ assert(event.text.len == strlen("clipboard text"));
+ assert(memcmp(event.text.data, "clipboard text", event.text.len) == 0);
saw_paste = true;
}
- if (event.kind == YASL_INPUT_TEXT) {
- assert(event.text.len == 1 && event.text.text[0] == 'a');
+ if (event.type == YASL_EVENT_TEXT) {
+ assert(event.text.len == 1 && event.text.data[0] == 'a');
saw_text = true;
}
}
@@ -246,13 +246,13 @@ static void x11_behavior(struct yasl_loop *loop, struct yasl_display *d, struct
XFlush(native);
pump(loop, d, NULL);
int key_count = 0, text_count = 0;
- while (yasl_surface_input_poll(w->surface, &event)) {
- if (event.kind == YASL_INPUT_KEY) {
+ while (yasl_surface_poll_event(w->surface, &event)) {
+ if (event.type == YASL_EVENT_KEY) {
assert(event.key.key == YASL_KEY_A);
assert(event.key.action == (key_count ? YASL_KEY_RELEASE : YASL_KEY_PRESS));
key_count++;
- } else if (event.kind == YASL_INPUT_TEXT) {
- assert(event.text.len == 1 && event.text.text[0] == 'A');
+ } else if (event.type == YASL_EVENT_TEXT) {
+ assert(event.text.len == 1 && event.text.data[0] == 'A');
text_count++;
}
}
@@ -262,10 +262,10 @@ static void x11_behavior(struct yasl_loop *loop, struct yasl_display *d, struct
XSendEvent(native, window, False, KeyPressMask, &key);
XFlush(native);
pump(loop, d, NULL);
- assert(yasl_surface_input_poll(w->surface, &event));
- assert(event.kind == YASL_INPUT_KEY && event.key.key == YASL_KEY_A);
+ assert(yasl_surface_poll_event(w->surface, &event));
+ assert(event.type == YASL_EVENT_KEY && event.key.key == YASL_KEY_A);
assert(event.key.mods & YASL_MOD_CTRL);
- assert(!yasl_surface_input_poll(w->surface, &event));
+ assert(!yasl_surface_poll_event(w->surface, &event));
int symbols_per_key = 0;
KeySym *saved_symbols = XGetKeyboardMapping(native, key.xkey.keycode, 1, &symbols_per_key);
@@ -282,12 +282,12 @@ static void x11_behavior(struct yasl_loop *loop, struct yasl_display *d, struct
XFlush(native);
pump(loop, d, NULL);
saw_key = saw_text = false;
- while (yasl_surface_input_poll(w->surface, &event)) {
- if (event.kind == YASL_INPUT_KEY) {
+ while (yasl_surface_poll_event(w->surface, &event)) {
+ if (event.type == YASL_EVENT_KEY) {
assert(event.key.key == YASL_KEY_A && event.key.codepoint == 'q');
saw_key = true;
- } else if (event.kind == YASL_INPUT_TEXT) {
- assert(event.text.len == 1 && event.text.text[0] == 'q');
+ } else if (event.type == YASL_EVENT_TEXT) {
+ assert(event.text.len == 1 && event.text.data[0] == 'q');
saw_text = true;
}
}
@@ -308,11 +308,11 @@ static void x11_behavior(struct yasl_loop *loop, struct yasl_display *d, struct
XSendEvent(native, window, False, NoEventMask, &wheel);
XFlush(native);
pump(loop, d, NULL);
- assert(yasl_surface_input_poll(w->surface, &event));
- assert(event.kind == YASL_INPUT_MOUSE && event.mouse.kind == YASL_PTR_SCROLL);
- assert(event.mouse.scroll.x == (button == 6 ? -1 : button == 7 ? 1 : 0));
- assert(event.mouse.scroll.y == (button == 4 ? -1 : button == 5 ? 1 : 0));
- assert(!yasl_surface_input_poll(w->surface, &event));
+ assert(yasl_surface_poll_event(w->surface, &event));
+ assert(event.type == YASL_EVENT_POINTER_SCROLL);
+ assert(event.pointer.scroll.x == (button == 6 ? -1 : button == 7 ? 1 : 0));
+ assert(event.pointer.scroll.y == (button == 4 ? -1 : button == 5 ? 1 : 0));
+ assert(!yasl_surface_poll_event(w->surface, &event));
}
assert(yasl_surface_timing(w->surface).source == YASL_TIMING_SUBMISSION);
assert(!(yasl_display_caps(d) & YASL_CAP_FRAME_PACING));
@@ -329,18 +329,18 @@ static void x11_behavior(struct yasl_loop *loop, struct yasl_display *d, struct
for (int i = 0; i < 300; i++) {
char text[32];
snprintf(text, sizeof(text), "owned-%d", i);
- assert(yasl_surface_input_poll(w->surface, &event));
- assert(event.kind == YASL_INPUT_PASTE && strcmp(event.paste.text, text) == 0);
+ assert(yasl_surface_poll_event(w->surface, &event));
+ assert(event.type == YASL_EVENT_PASTE && strcmp(event.text.data, text) == 0);
}
- const char *last = event.paste.text;
- assert(!yasl_surface_input_poll(w->surface, &event));
+ const char *last = event.text.data;
+ assert(!yasl_surface_poll_event(w->surface, &event));
yasl_display_copy(d, YASL_CLIPBOARD, "changed");
pump(loop, d, NULL);
assert(strcmp(last, "owned-299") == 0);
yasl_display_copy(d, YASL_CLIPBOARD, "");
yasl_display_paste(d, YASL_CLIPBOARD, w->surface);
- assert(yasl_surface_input_poll(w->surface, &event));
- assert(event.kind == YASL_INPUT_PASTE && !event.paste.len && !event.paste.text[0]);
+ assert(yasl_surface_poll_event(w->surface, &event));
+ assert(event.type == YASL_EVENT_PASTE && !event.text.len && !event.text.data[0]);
/* Concurrent external conversions must not share a mutable target slot. */
struct yasl_display_spec ds = {.backend = YASL_BACKEND_X11};
@@ -354,15 +354,15 @@ static void x11_behavior(struct yasl_loop *loop, struct yasl_display *d, struct
yasl_surface_destroy(cancelled.surface);
pump(loop, d, owner);
int first_pastes = 0, second_pastes = 0;
- while (yasl_surface_input_poll(w->surface, &event)) {
- if (event.kind == YASL_INPUT_PASTE) {
- assert(strcmp(event.paste.text, "external") == 0);
+ while (yasl_surface_poll_event(w->surface, &event)) {
+ if (event.type == YASL_EVENT_PASTE) {
+ assert(strcmp(event.text.data, "external") == 0);
first_pastes++;
}
}
- while (yasl_surface_input_poll(other.surface, &event)) {
- if (event.kind == YASL_INPUT_PASTE) {
- assert(strcmp(event.paste.text, "external") == 0);
+ while (yasl_surface_poll_event(other.surface, &event)) {
+ if (event.type == YASL_EVENT_PASTE) {
+ assert(strcmp(event.text.data, "external") == 0);
second_pastes++;
}
}