From 5d55f93eb35d8a0626cef09b8de250b884e06eb8 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 3 Oct 2017 09:58:10 +0200 Subject: [PATCH] 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. --- testcases/lib/i3test.pm.in | 7 +++++++ testcases/t/219-ipc-window-focus.t | 12 ++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/testcases/lib/i3test.pm.in b/testcases/lib/i3test.pm.in index 5b24ab39..1e4eea75 100644 --- a/testcases/lib/i3test.pm.in +++ b/testcases/lib/i3test.pm.in @@ -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, ); } diff --git a/testcases/t/219-ipc-window-focus.t b/testcases/t/219-ipc-window-focus.t index 5baf68a8..b1c8ba18 100644 --- a/testcases/t/219-ipc-window-focus.t +++ b/testcases/t/219-ipc-window-focus.t @@ -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; -- 2.39.5