summaryrefslogtreecommitdiff
path: root/tests/wayland/test_input.c
blob: f421e6cab872de047ed1755935b89c53ddca52fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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;
}