From 9c851d0fbb346467bbd92f8b5ba95b9b6eb73052 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Wed, 14 Oct 2026 14:33:43 +0300 Subject: Make the surface test robust on a live desktop On a real compositor, input from the user and focus-stealing prevention reach the test window. Drain real events before checking the order of pushed ones, check only that gaining focus does not reset input, and accept ESTALE for a primary selection offered while the new window lacks keyboard focus. Co-Authored-By: Claude Opus 5.5 --- tests/common/test_surface_integration.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'tests/common') diff --git a/tests/common/test_surface_integration.c b/tests/common/test_surface_integration.c index 1dca7c8..f33e35b 100644 --- a/tests/common/test_surface_integration.c +++ b/tests/common/test_surface_integration.c @@ -181,11 +181,17 @@ int main(int argc, char **argv) assert(yasl_clipboard_set((enum yasl_selection)5, "x") == -EINVAL); assert(yasl_clipboard_set(YASL_CLIPBOARD, NULL) == -EINVAL); assert(yasl_clipboard_set(YASL_CLIPBOARD, "\xff") == -EILSEQ); - assert(yasl_clipboard_set(YASL_PRIMARY, "x") == - ((features & YASL_FEATURE_PRIMARY_SELECTION) ? 0 : -ENOTSUP)); + /* Offering a selection needs input on one of our windows; on a live desktop the new + * window may not have keyboard focus yet. */ + int primary = yasl_clipboard_set(YASL_PRIMARY, "x"); + assert((features & YASL_FEATURE_PRIMARY_SELECTION) ? primary == 0 || primary == -ESTALE + : primary == -ENOTSUP); drain(); - /* Event conversion: positions are logical, text is owned until the next wait. */ + /* Event conversion: positions are logical, text is owned until the next wait. Pushed + * events are returned before the server is read, so draining first keeps a live + * desktop's input out of their way. */ + drain(); uint32_t real_scale = s->scale_120; s->scale_120 = 240; push(s, (struct yasl_private_event){ @@ -216,7 +222,9 @@ int main(int argc, char **argv) push(s, (struct yasl_private_event){.type = YASL_PRIVATE_EVENT_FOCUS, .focus = {.focused = false}}); assert(yasl_wait_event(&e, 0) == 1 && e.type == YASL_EVENT_INPUT_RESET); push(s, (struct yasl_private_event){.type = YASL_PRIVATE_EVENT_FOCUS, .focus = {.focused = true}}); - assert(yasl_wait_event(&e, 0) == 0 && e.type == YASL_EVENT_NONE); + /* Gaining focus reports nothing; an empty queue makes this wait read the server too. */ + while (yasl_wait_event(&e, 0) > 0) + assert(e.type != YASL_EVENT_INPUT_RESET); push(s, (struct yasl_private_event){.type = YASL_PRIVATE_EVENT_DROP_HOVER, .drop = {YASL_PRIVATE_DROP_LEAVE, {0, 0}}}); assert(yasl_wait_event(&e, 0) == 1 && e.type == YASL_EVENT_DROP && e.action == YASL_DROP_LEAVE); -- cgit v1.2.3