Kill windows between tests

This commit is contained in:
Michael Stapelberg 2017-09-10 11:31:10 +02:00
parent 94c76d9e30
commit f7565b5f32
3 changed files with 61 additions and 19 deletions

View File

@ -112,6 +112,8 @@ wait_for_unmap $window;
@content = @{get_ws_content($tmp)}; @content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 0, 'no more nodes'); cmp_ok(@content, '==', 0, 'no more nodes');
kill_all_windows;
############################################################## ##############################################################
# 2: match on the title, check if for_window is really executed # 2: match on the title, check if for_window is really executed
# only once # only once
@ -151,6 +153,8 @@ wait_for_unmap $window;
@content = @{get_ws_content($tmp)}; @content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 0, 'no more nodes'); cmp_ok(@content, '==', 0, 'no more nodes');
kill_all_windows;
############################################################## ##############################################################
# 3: match on the title, set border style *and* a mark # 3: match on the title, set border style *and* a mark
############################################################## ##############################################################
@ -176,6 +180,8 @@ cmd qq|[con_mark="bleh"] focus|;
@content = @{get_ws_content($tmp)}; @content = @{get_ws_content($tmp)};
ok($content[0]->{focused}, 'first node focused'); ok($content[0]->{focused}, 'first node focused');
kill_all_windows;
############################################################## ##############################################################
# 4: multiple criteria for the for_window command # 4: multiple criteria for the for_window command
############################################################## ##############################################################
@ -211,6 +217,8 @@ wait_for_map $window;
cmp_ok(@content, '==', 1, 'one node on this workspace now'); cmp_ok(@content, '==', 1, 'one node on this workspace now');
is($content[0]->{border}, 'normal', 'no border'); is($content[0]->{border}, 'normal', 'no border');
kill_all_windows;
############################################################## ##############################################################
# 5: check that a class criterion does not match the instance # 5: check that a class criterion does not match the instance
############################################################## ##############################################################
@ -227,6 +235,8 @@ $window = open_window(
cmp_ok(@content, '==', 1, 'one node on this workspace now'); cmp_ok(@content, '==', 1, 'one node on this workspace now');
is($content[0]->{border}, 'normal', 'normal border, not matched'); is($content[0]->{border}, 'normal', 'normal border, not matched');
kill_all_windows;
############################################################## ##############################################################
# 6: check that the 'instance' criterion works # 6: check that the 'instance' criterion works
############################################################## ##############################################################
@ -243,6 +253,8 @@ $window = open_window(
cmp_ok(@content, '==', 1, 'one node on this workspace now'); cmp_ok(@content, '==', 1, 'one node on this workspace now');
is($content[0]->{border}, 'none', 'no border'); is($content[0]->{border}, 'none', 'no border');
kill_all_windows;
############################################################## ##############################################################
# 7: check that invalid criteria dont end up matching all windows # 7: check that invalid criteria dont end up matching all windows
############################################################## ##############################################################
@ -259,6 +271,8 @@ $window = open_window(
cmp_ok(@content, '==', 1, 'one node on this workspace now'); cmp_ok(@content, '==', 1, 'one node on this workspace now');
is($content[0]->{border}, 'normal', 'normal border'); is($content[0]->{border}, 'normal', 'normal border');
kill_all_windows;
############################################################## ##############################################################
# 8: check that the role criterion works properly # 8: check that the role criterion works properly
############################################################## ##############################################################
@ -287,6 +301,8 @@ $window = open_window(
cmp_ok(@content, '==', 1, 'one node on this workspace now'); cmp_ok(@content, '==', 1, 'one node on this workspace now');
is($content[0]->{border}, 'none', 'no border (window_role)'); is($content[0]->{border}, 'none', 'no border (window_role)');
kill_all_windows;
############################################################## ##############################################################
# 9: another test for the window_role, but this time it changes # 9: another test for the window_role, but this time it changes
# *after* the window has been mapped # *after* the window has been mapped
@ -320,6 +336,8 @@ sync_with_i3;
cmp_ok(@content, '==', 1, 'one node on this workspace now'); cmp_ok(@content, '==', 1, 'one node on this workspace now');
is($content[0]->{border}, 'none', 'no border (window_role 2)'); is($content[0]->{border}, 'none', 'no border (window_role 2)');
kill_all_windows;
############################################################## ##############################################################
# 10: check that the criterion 'window_type' works # 10: check that the criterion 'window_type' works
############################################################## ##############################################################
@ -332,6 +350,8 @@ while (my ($window_type, $atom) = each %window_types) {
my @nodes = @{get_ws($tmp)->{floating_nodes}}; my @nodes = @{get_ws($tmp)->{floating_nodes}};
cmp_ok(@nodes, '==', 1, 'one floating container on this workspace'); cmp_ok(@nodes, '==', 1, 'one floating container on this workspace');
is_deeply($nodes[0]->{nodes}[0]->{marks}, [ "branded-$window_type" ], "mark set (window_type = $atom)"); is_deeply($nodes[0]->{nodes}[0]->{marks}, [ "branded-$window_type" ], "mark set (window_type = $atom)");
kill_all_windows;
} }
############################################################## ##############################################################
@ -354,6 +374,8 @@ while (my ($window_type, $atom) = each %window_types) {
my @nodes = @{get_ws($tmp)->{floating_nodes}}; my @nodes = @{get_ws($tmp)->{floating_nodes}};
cmp_ok(@nodes, '==', 1, 'one floating container on this workspace'); cmp_ok(@nodes, '==', 1, 'one floating container on this workspace');
is_deeply($nodes[0]->{nodes}[0]->{marks}, [ "branded-$window_type" ], "mark set (window_type = $atom)"); is_deeply($nodes[0]->{nodes}[0]->{marks}, [ "branded-$window_type" ], "mark set (window_type = $atom)");
kill_all_windows;
} }
############################################################## ##############################################################
@ -367,6 +389,8 @@ $window = open_window;
cmp_ok(@nodes, '==', 1, 'one floating container on this workspace'); cmp_ok(@nodes, '==', 1, 'one floating container on this workspace');
is_deeply($nodes[0]->{nodes}[0]->{marks}, [ 'triggered' ], "mark set for workspace criterion"); is_deeply($nodes[0]->{nodes}[0]->{marks}, [ 'triggered' ], "mark set for workspace criterion");
kill_all_windows;
############################################################## ##############################################################
exit_gracefully($pid); exit_gracefully($pid);

View File

@ -45,6 +45,7 @@ open_window;
cmd "swap container with con_id 1"; cmd "swap container with con_id 1";
does_i3_live; does_i3_live;
kill_all_windows;
############################################################################### ###############################################################################
# Swap 2 windows in different workspaces using con_id # Swap 2 windows in different workspaces using con_id
@ -60,6 +61,8 @@ open_window;
cmd "swap container with con_id $A"; cmd "swap container with con_id $A";
is(get_focused($ws), $A, 'A is now focused'); is(get_focused($ws), $A, 'A is now focused');
kill_all_windows;
############################################################################### ###############################################################################
# Swap two containers next to each other. # Swap two containers next to each other.
# Focus should stay on B because both windows are on the focused workspace. # Focus should stay on B because both windows are on the focused workspace.
@ -82,6 +85,8 @@ is($nodes->[0]->{window}, $B->{id}, 'B is on the left');
is($nodes->[1]->{window}, $A->{id}, 'A is on the right'); is($nodes->[1]->{window}, $A->{id}, 'A is on the right');
is(get_focused($ws), $expected_focus, 'B is still focused'); is(get_focused($ws), $expected_focus, 'B is still focused');
kill_all_windows;
############################################################################### ###############################################################################
# Swap two containers with different parents. # Swap two containers with different parents.
# In this test, the focus head of the left v-split container is A. # In this test, the focus head of the left v-split container is A.
@ -112,6 +117,8 @@ is($nodes->[0]->{nodes}->[0]->{window}, $B->{id}, 'B is on the top left');
is($nodes->[1]->{nodes}->[1]->{window}, $A->{id}, 'A is on the bottom right'); is($nodes->[1]->{nodes}->[1]->{window}, $A->{id}, 'A is on the bottom right');
is(get_focused($ws), $expected_focus, 'B is still focused'); is(get_focused($ws), $expected_focus, 'B is still focused');
kill_all_windows;
############################################################################### ###############################################################################
# Swap two containers with different parents. # Swap two containers with different parents.
# In this test, the focus head of the left v-split container is _not_ A. # In this test, the focus head of the left v-split container is _not_ A.
@ -142,6 +149,8 @@ is($nodes->[0]->{nodes}->[0]->{window}, $B->{id}, 'B is on the top left');
is($nodes->[1]->{nodes}->[1]->{window}, $A->{id}, 'A is on the bottom right'); is($nodes->[1]->{nodes}->[1]->{window}, $A->{id}, 'A is on the bottom right');
is(get_focused($ws), $expected_focus, 'B is still focused'); is(get_focused($ws), $expected_focus, 'B is still focused');
kill_all_windows;
############################################################################### ###############################################################################
# Swap two containers with one being on a different workspace. # Swap two containers with one being on a different workspace.
# The focused container is B. # The focused container is B.
@ -177,6 +186,8 @@ $nodes = get_ws_content($ws2);
is($nodes->[1]->{window}, $A->{id}, 'A is on ws2:right'); is($nodes->[1]->{window}, $A->{id}, 'A is on ws2:right');
is(get_focused($ws2), $expected_focus, 'A is focused'); is(get_focused($ws2), $expected_focus, 'A is focused');
kill_all_windows;
############################################################################### ###############################################################################
# Swap two non-focused containers within the same workspace. # Swap two non-focused containers within the same workspace.
# #
@ -205,6 +216,8 @@ is($nodes->[0]->{nodes}->[0]->{window}, $B->{id}, 'B is on the top left');
is($nodes->[1]->{nodes}->[1]->{window}, $A->{id}, 'A is on the bottom right'); is($nodes->[1]->{nodes}->[1]->{window}, $A->{id}, 'A is on the bottom right');
is(get_focused($ws), $expected_focus, 'F is still focused'); is(get_focused($ws), $expected_focus, 'F is still focused');
kill_all_windows;
############################################################################### ###############################################################################
# Swap two non-focused containers which are both on different workspaces. # Swap two non-focused containers which are both on different workspaces.
# #
@ -244,6 +257,8 @@ is($nodes->[0]->{window}, $A->{id}, 'A is on the second workspace');
is(get_focused($ws3), $expected_focus, 'F is still focused'); is(get_focused($ws3), $expected_focus, 'F is still focused');
kill_all_windows;
############################################################################### ###############################################################################
# Swap two non-focused containers with one being on a different workspace. # Swap two non-focused containers with one being on a different workspace.
# #
@ -277,6 +292,8 @@ $nodes = get_ws_content($ws2);
is($nodes->[0]->{window}, $A->{id}, 'A is on the left of the second workspace'); is($nodes->[0]->{window}, $A->{id}, 'A is on the left of the second workspace');
is(get_focused($ws2), $expected_focus, 'F is still focused'); is(get_focused($ws2), $expected_focus, 'F is still focused');
kill_all_windows;
############################################################################### ###############################################################################
# 1. A container cannot be swapped with its parent. # 1. A container cannot be swapped with its parent.
# 2. A container cannot be swapped with one of its children. # 2. A container cannot be swapped with one of its children.
@ -301,6 +318,8 @@ is($result->[0]->{success}, 0, 'B cannot be swappd with its parent');
$result = cmd '[con_mark=A] swap container with mark B'; $result = cmd '[con_mark=A] swap container with mark B';
is($result->[0]->{success}, 0, 'A cannot be swappd with one of its children'); is($result->[0]->{success}, 0, 'A cannot be swappd with one of its children');
kill_all_windows;
############################################################################### ###############################################################################
# Swapping two containers preserves the geometry of the container they are # Swapping two containers preserves the geometry of the container they are
# being swapped with. # being swapped with.
@ -331,6 +350,8 @@ $nodes = get_ws_content($ws);
cmp_float($nodes->[0]->{percent}, 0.25, 'B has 25% width'); cmp_float($nodes->[0]->{percent}, 0.25, 'B has 25% width');
cmp_float($nodes->[1]->{percent}, 0.75, 'A has 75% width'); cmp_float($nodes->[1]->{percent}, 0.75, 'A has 75% width');
kill_all_windows;
############################################################################### ###############################################################################
# Swapping containers not sharing the same parent preserves the geometry of # Swapping containers not sharing the same parent preserves the geometry of
# the container they are swapped with. # the container they are swapped with.
@ -375,6 +396,8 @@ $nodes = get_ws_content($ws);
cmp_float($nodes->[0]->{nodes}->[0]->{percent}, 0.25, 'B has 25% height'); cmp_float($nodes->[0]->{nodes}->[0]->{percent}, 0.25, 'B has 25% height');
cmp_float($nodes->[1]->{nodes}->[0]->{percent}, 0.75, 'A has 75% height'); cmp_float($nodes->[1]->{nodes}->[0]->{percent}, 0.75, 'A has 75% height');
kill_all_windows;
############################################################################### ###############################################################################
# Swapping containers moves the urgency hint correctly. # Swapping containers moves the urgency hint correctly.
############################################################################### ###############################################################################
@ -398,6 +421,8 @@ is(get_ws($ws1)->{urgent}, 1, 'the first workspace is marked urgent');
is(@urgent, 0, 'A is not marked urgent'); is(@urgent, 0, 'A is not marked urgent');
is(get_ws($ws2)->{urgent}, 0, 'the second workspace is not marked urgent'); is(get_ws($ws2)->{urgent}, 0, 'the second workspace is not marked urgent');
kill_all_windows;
############################################################################### ###############################################################################
exit_gracefully($pid); exit_gracefully($pid);

View File

@ -78,13 +78,6 @@ sub open_window_with_net_wm_desktop {
return $window; return $window;
} }
# We need to kill all windows in between tests since they survive the i3 restart
# and will interfere with the following tests.
sub kill_windows {
sync_with_i3;
cmd '[title="Window.*"] kill';
}
############################################################################### ###############################################################################
my $config = <<EOT; my $config = <<EOT;
@ -108,7 +101,7 @@ my $con = open_window;
is(get_net_wm_desktop($con), 0, '_NET_WM_DESKTOP is set upon managing a window'); is(get_net_wm_desktop($con), 0, '_NET_WM_DESKTOP is set upon managing a window');
kill_windows; kill_all_windows;
############################################################################### ###############################################################################
# Upon managing a window which sets _NET_WM_DESKTOP, the window is moved to # Upon managing a window which sets _NET_WM_DESKTOP, the window is moved to
@ -127,7 +120,7 @@ $con = open_window_with_net_wm_desktop(1);
is(get_net_wm_desktop($con), 1, '_NET_WM_DESKTOP still has the correct value'); is(get_net_wm_desktop($con), 1, '_NET_WM_DESKTOP still has the correct value');
is_num_children('1', 2, 'The window was moved to workspace 1'); is_num_children('1', 2, 'The window was moved to workspace 1');
kill_windows; kill_all_windows;
############################################################################### ###############################################################################
# Upon managing a window which sets _NET_WM_DESKTOP to the appropriate value, # Upon managing a window which sets _NET_WM_DESKTOP to the appropriate value,
@ -141,7 +134,7 @@ is(get_net_wm_desktop($con), 0xFFFFFFFF, '_NET_WM_DESKTOP still has the correct
is(@{get_ws('0')->{floating_nodes}}, 1, 'The window is floating'); is(@{get_ws('0')->{floating_nodes}}, 1, 'The window is floating');
ok(get_ws('0')->{floating_nodes}->[0]->{nodes}->[0]->{sticky}, 'The window is sticky'); ok(get_ws('0')->{floating_nodes}->[0]->{nodes}->[0]->{sticky}, 'The window is sticky');
kill_windows; kill_all_windows;
############################################################################### ###############################################################################
# _NET_WM_DESKTOP is updated when the window is moved to another workspace # _NET_WM_DESKTOP is updated when the window is moved to another workspace
@ -159,7 +152,7 @@ cmd 'move window to workspace 1';
is(get_net_wm_desktop($con), 1, '_NET_WM_DESKTOP is updated when moving the window'); is(get_net_wm_desktop($con), 1, '_NET_WM_DESKTOP is updated when moving the window');
kill_windows; kill_all_windows;
############################################################################### ###############################################################################
# _NET_WM_DESKTOP is updated when the floating window is moved to another # _NET_WM_DESKTOP is updated when the floating window is moved to another
@ -178,7 +171,7 @@ cmd 'move window to workspace 1';
is(get_net_wm_desktop($con), 1, '_NET_WM_DESKTOP is updated when moving the window'); is(get_net_wm_desktop($con), 1, '_NET_WM_DESKTOP is updated when moving the window');
kill_windows; kill_all_windows;
############################################################################### ###############################################################################
# _NET_WM_DESKTOP is removed when the window is withdrawn. # _NET_WM_DESKTOP is removed when the window is withdrawn.
@ -192,7 +185,7 @@ wait_for_unmap($con);
is(get_net_wm_desktop($con), undef, '_NET_WM_DESKTOP is removed'); is(get_net_wm_desktop($con), undef, '_NET_WM_DESKTOP is removed');
kill_windows; kill_all_windows;
############################################################################### ###############################################################################
# A _NET_WM_DESKTOP client message sent to the root window moves a window # A _NET_WM_DESKTOP client message sent to the root window moves a window
@ -214,7 +207,7 @@ is_num_children('0', 1, 'The window is no longer on workspace 0');
is_num_children('1', 2, 'The window is now on workspace 1'); is_num_children('1', 2, 'The window is now on workspace 1');
is(get_net_wm_desktop($con), 1, '_NET_WM_DESKTOP is updated'); is(get_net_wm_desktop($con), 1, '_NET_WM_DESKTOP is updated');
kill_windows; kill_all_windows;
############################################################################### ###############################################################################
# A _NET_WM_DESKTOP client message sent to the root window can make a window # A _NET_WM_DESKTOP client message sent to the root window can make a window
@ -230,7 +223,7 @@ is(get_net_wm_desktop($con), 0xFFFFFFFF, '_NET_WM_DESKTOP is updated');
is(@{get_ws('0')->{floating_nodes}}, 1, 'The window is floating'); is(@{get_ws('0')->{floating_nodes}}, 1, 'The window is floating');
ok(get_ws('0')->{floating_nodes}->[0]->{nodes}->[0]->{sticky}, 'The window is sticky'); ok(get_ws('0')->{floating_nodes}->[0]->{nodes}->[0]->{sticky}, 'The window is sticky');
kill_windows; kill_all_windows;
############################################################################### ###############################################################################
# _NET_WM_DESKTOP is updated when a new workspace with a lower number is # _NET_WM_DESKTOP is updated when a new workspace with a lower number is
@ -244,7 +237,7 @@ is(get_net_wm_desktop($con), 0, '_NET_WM_DESKTOP is set sanity check)');
cmd 'workspace 0'; cmd 'workspace 0';
is(get_net_wm_desktop($con), 1, '_NET_WM_DESKTOP is updated'); is(get_net_wm_desktop($con), 1, '_NET_WM_DESKTOP is updated');
kill_windows; kill_all_windows;
############################################################################### ###############################################################################
# _NET_WM_DESKTOP is updated when a window is made sticky by command. # _NET_WM_DESKTOP is updated when a window is made sticky by command.
@ -258,7 +251,7 @@ is(get_net_wm_desktop($con), 0, '_NET_WM_DESKTOP is set sanity check)');
cmd 'sticky enable'; cmd 'sticky enable';
is(get_net_wm_desktop($con), 0xFFFFFFFF, '_NET_WM_DESKTOP is updated'); is(get_net_wm_desktop($con), 0xFFFFFFFF, '_NET_WM_DESKTOP is updated');
kill_windows; kill_all_windows;
############################################################################### ###############################################################################
# _NET_WM_DESKTOP is updated when a window is made sticky by client message. # _NET_WM_DESKTOP is updated when a window is made sticky by client message.
@ -282,7 +275,7 @@ sync_with_i3;
is(get_net_wm_desktop($con), 0xFFFFFFFF, '_NET_WM_DESKTOP is updated'); is(get_net_wm_desktop($con), 0xFFFFFFFF, '_NET_WM_DESKTOP is updated');
kill_windows; kill_all_windows;
############################################################################### ###############################################################################
# _NET_WM_DESKTOP is updated when a window is moved to the scratchpad. # _NET_WM_DESKTOP is updated when a window is moved to the scratchpad.
@ -299,7 +292,7 @@ is(get_net_wm_desktop($con), 0xFFFFFFFF, '_NET_WM_DESKTOP is updated');
cmd 'scratchpad show'; cmd 'scratchpad show';
is(get_net_wm_desktop($con), 0, '_NET_WM_DESKTOP is set sanity check)'); is(get_net_wm_desktop($con), 0, '_NET_WM_DESKTOP is set sanity check)');
kill_windows; kill_all_windows;
############################################################################### ###############################################################################