summaryrefslogtreecommitdiff
path: root/tests/common/test_surface_integration.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/common/test_surface_integration.c')
-rw-r--r--tests/common/test_surface_integration.c16
1 files changed, 12 insertions, 4 deletions
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);