X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=testcases%2Ft%2F129-focus-after-close.t;h=2ebfd61022012c5a913b53a53f614ba260f91d68;hb=1dbdd4fece86c5f85bde54e40f58fa1a91810933;hp=3913f4c6d1eb1221ae664c2f849af03a42976d0b;hpb=f7f1ec5dab85e934de8220fb48dee861e1097e35;p=i3%2Fi3 diff --git a/testcases/t/129-focus-after-close.t b/testcases/t/129-focus-after-close.t index 3913f4c6..2ebfd610 100644 --- a/testcases/t/129-focus-after-close.t +++ b/testcases/t/129-focus-after-close.t @@ -1,6 +1,19 @@ #!perl # vim:ts=4:sw=4:expandtab # +# Please read the following documents before working on tests: +# • http://build.i3wm.org/docs/testsuite.html +# (or docs/testsuite) +# +# • http://build.i3wm.org/docs/lib-i3test.html +# (alternatively: perldoc ./testcases/lib/i3test.pm) +# +# • http://build.i3wm.org/docs/ipc.html +# (or docs/ipc) +# +# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf +# (unless you are already familiar with Perl) +# # Check if the focus is correctly restored after closing windows. # use i3test; @@ -42,9 +55,8 @@ isnt(get_focused($tmp), $second, 'different container focused'); ############################################################## cmd 'kill'; -# TODO: this testcase sometimes has different outcomes when the -# sleep is missing. why? -sleep 0.25; +sync_with_i3; + ($nodes, $focus) = get_ws_content($tmp); is($nodes->[1]->{nodes}->[0]->{id}, $second, 'second container found'); ok($nodes->[1]->{nodes}->[0]->{focused}, 'second container focused'); @@ -103,11 +115,59 @@ my $win = open_window({ background_color => '#00ff00' }); cmd qq|[con_id="$middle"] focus|; $win->destroy; - -sleep 0.25; +sync_with_i3; is(get_focused($tmp), $middle, 'middle container focused'); +############################################################## +# check if the workspace container can be closed +############################################################## + +$tmp = fresh_workspace; + +my $window = open_window(); + +# one window opened on the current workspace +($nodes, $focus) = get_ws_content($tmp); +is(scalar @$nodes, 1, 'workspace contains one node'); + +# focus the workspace +cmd "focus parent"; +cmd "focus parent"; + +# try to kill the workspace +cmd "kill"; +sync_with_i3; + +# the workspace should now be empty +($nodes, $focus) = get_ws_content($tmp); +is(scalar @$nodes, 0, 'workspace is empty'); + +################################################################################ +# check if killing a workspace also closes floating windows. +################################################################################ + +$tmp = fresh_workspace; + +$window = open_window; +my $floating_window = open_floating_window; + +# one window opened on the current workspace +($nodes, $focus) = get_ws_content($tmp); +is(scalar @$focus, 2, 'workspace contains two nodes'); + +# focus the workspace +cmd "focus parent"; +cmd "focus parent"; + +# try to kill the workspace +cmd "kill"; +sync_with_i3; + +# the workspace should now be empty +($nodes, $focus) = get_ws_content($tmp); +is(scalar @$focus, 0, 'workspace is empty'); + ############################################################## # and now for something completely different: # check if the pointer position is relevant when restoring focus