summaryrefslogtreecommitdiff
path: root/tests/wayland/test_input.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/wayland/test_input.c')
-rw-r--r--tests/wayland/test_input.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/wayland/test_input.c b/tests/wayland/test_input.c
new file mode 100644
index 0000000..f421e6c
--- /dev/null
+++ b/tests/wayland/test_input.c
@@ -0,0 +1,26 @@
+#include "wayland/internal.h"
+#include <assert.h>
+
+int main(void)
+{
+ struct wayland_surface w = {0};
+ struct seat seat = {.ime_focus = &w};
+ wayland_surface_set_callbacks(&w, NULL, NULL);
+ for (int i = 0; i < 600; i++) {
+ char text[32];
+ snprintf(text, sizeof(text), "commit-%d", i);
+ text_input_listener.commit_string(&seat, NULL, text);
+ text_input_listener.done(&seat, NULL, (uint32_t)i);
+ assert(!w.ime_commit);
+ }
+ for (int i = 0; i < 600; i++) {
+ char text[32];
+ snprintf(text, sizeof(text), "commit-%d", i);
+ struct yasl_input_event event;
+ assert(wayland_surface_input_poll(&w, &event));
+ assert(event.kind == YASL_INPUT_TEXT && event.surface == &w.base);
+ assert(strcmp(event.text.text, text) == 0);
+ }
+ input_queue_clear(&w.input);
+ return 0;
+}