2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • http://build.i3wm.org/docs/ipc.html
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 # (unless you are already familiar with Perl)
17 # Tests whether opening an empty container and killing it again works
19 use List::Util qw(first);
22 my $tmp = fresh_workspace;
24 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
26 # Open a new container
29 ok(@{get_ws_content($tmp)} == 1, 'container opened');
32 ok(@{get_ws_content($tmp)} == 0, 'container killed');
34 ##############################################################
35 # open two containers and kill the one which is not focused
36 # by its ID to test if the parser correctly matches the window
37 ##############################################################
41 ok(@{get_ws_content($tmp)} == 2, 'two containers opened');
43 my $content = get_ws_content($tmp);
44 my $not_focused = first { !$_->{focused} } @{$content};
45 my $id = $not_focused->{id};
47 cmd "[con_id=\"$id\"] kill";
49 $content = get_ws_content($tmp);
50 ok(@{$content} == 1, 'one container killed');
51 ok($content->[0]->{id} != $id, 'correct window killed');