tests: add sync_with_i3 after open_window

We need to set dont_map => 1 on the sync window to prevent an endless loop.

Further, t/219-ipc-window-focus.t made assumptions about windows being named
incrementally, and that assumption is broken by the sync window opened by the
first sync_with_i3 call from open_window, so use the more reliable ->name.
This commit is contained in:
Michael Stapelberg 2017-10-03 09:58:10 +02:00
parent 4f751610c2
commit 5d55f93eb3
2 changed files with 13 additions and 6 deletions

View File

@ -350,6 +350,12 @@ sub open_window {
$window->map;
wait_for_map($window);
# MapWindow is sent before i3 even starts rendering: the window is placed at
# temporary off-screen coordinates first, and x_push_changes() sends further
# X11 requests to set focus etc. Hence, we sync with i3 before continuing.
sync_with_i3();
return $window;
}
@ -688,6 +694,7 @@ sub sync_with_i3 {
$_sync_window = open_window(
rect => [ -15, -15, 10, 10 ],
override_redirect => 1,
dont_map => 1,
);
}

View File

@ -44,11 +44,11 @@ sub focus_subtest {
is($events[0]->{container}->{name}, $name, "$name focused");
}
subtest 'focus left (1)', \&focus_subtest, 'focus left', 'Window 1';
subtest 'focus left (2)', \&focus_subtest, 'focus left', 'Window 0';
subtest 'focus right (1)', \&focus_subtest, 'focus right', 'Window 1';
subtest 'focus right (2)', \&focus_subtest, 'focus right', 'Window 2';
subtest 'focus right (3)', \&focus_subtest, 'focus right', 'Window 0';
subtest 'focus left', \&focus_subtest, 'focus left', 'Window 2';
subtest 'focus left (1)', \&focus_subtest, 'focus left', $win1->name;
subtest 'focus left (2)', \&focus_subtest, 'focus left', $win0->name;
subtest 'focus right (1)', \&focus_subtest, 'focus right', $win1->name;
subtest 'focus right (2)', \&focus_subtest, 'focus right', $win2->name;
subtest 'focus right (3)', \&focus_subtest, 'focus right', $win0->name;
subtest 'focus left', \&focus_subtest, 'focus left', $win2->name;
done_testing;