]> git.sur5r.net Git - i3/i3/blob - testcases/t/118-openkill.t
fa4becc43569252b563e6d9c51df34f21791985f
[i3/i3] / testcases / t / 118-openkill.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • http://build.i3wm.org/docs/ipc.html
12 #   (or docs/ipc)
13 #
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 #   (unless you are already familiar with Perl)
16 #
17 # Tests whether opening an empty container and killing it again works
18 #
19 use List::Util qw(first);
20 use i3test;
21
22 my $tmp = fresh_workspace;
23
24 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
25
26 # Open a new container
27 cmd 'open';
28
29 ok(@{get_ws_content($tmp)} == 1, 'container opened');
30
31 cmd 'kill';
32 ok(@{get_ws_content($tmp)} == 0, 'container killed');
33
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 ##############################################################
38
39 cmd 'open';
40 cmd 'open';
41 ok(@{get_ws_content($tmp)} == 2, 'two containers opened');
42
43 my $content = get_ws_content($tmp);
44 my $not_focused = first { !$_->{focused} } @{$content};
45 my $id = $not_focused->{id};
46
47 cmd "[con_id=\"$id\"] kill";
48
49 $content = get_ws_content($tmp);
50 ok(@{$content} == 1, 'one container killed');
51 ok($content->[0]->{id} != $id, 'correct window killed');
52
53 done_testing;