#include "platform/wayland/internal.h" #include static void test_popup_bounds(void) { struct seat seat = {.input_serial = 1}; struct wayland_display d = {.base.ops = &yasl_wayland_backend, .seats = &seat}; struct wayland_surface w = {.base.display = &d.base, .conn = &d}; w.parent = &w; w.content.x = w.content.y = 1; /* Invalid bounds must be rejected before accessing any protocol object. */ w.xdg_surface = (struct xdg_surface *)&w; w.popup = (struct xdg_popup *)&w; struct yasl_popup_spec specs[] = { {.size = {100, 100}, .content_offset = {INT_MAX, 0}, .content_size = {1, 0}}, {.size = {100, 100}, .content_offset = {0, INT_MAX}, .content_size = {0, 1}}, {.size = {100, 100}, .content_offset = {1, 0}, .content_size = {INT_MAX, 0}}, {.size = {100, 100}, .content_offset = {0, 1}, .content_size = {0, INT_MAX}}, {.size = {100, 100}, .anchor = {INT_MIN, 0, 1, 1}}, {.size = {100, 100}, .anchor = {0, INT_MIN, 1, 1}}, }; for (size_t i = 0; i < sizeof(specs) / sizeof(specs[0]); i++) { assert(!yasl_surface_create_popup(&w.base, &specs[i])); assert(!yasl_surface_popup_reposition(&w.base, &specs[i])); } } int main(void) { test_popup_bounds(); 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_event event; assert(wayland_surface_poll_event(&w, &event)); assert(event.type == YASL_EVENT_TEXT && event.surface == &w.base); assert(strcmp(event.text.data, text) == 0); } input_queue_clear(&w.input); return 0; }