]> git.sur5r.net Git - i3/i3/blob - testcases/t/18-openkill.t
Merge branch 'tree' into next
[i3/i3] / testcases / t / 18-openkill.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Tests whether opening an empty container and killing it again works
5 #
6 use List::Util qw(first);
7 use i3test;
8
9 my $tmp = fresh_workspace;
10
11 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
12
13 # Open a new container
14 cmd 'open';
15
16 ok(@{get_ws_content($tmp)} == 1, 'container opened');
17
18 cmd 'kill';
19 ok(@{get_ws_content($tmp)} == 0, 'container killed');
20
21 ##############################################################
22 # open two containers and kill the one which is not focused
23 # by its ID to test if the parser correctly matches the window
24 ##############################################################
25
26 cmd 'open';
27 cmd 'open';
28 ok(@{get_ws_content($tmp)} == 2, 'two containers opened');
29
30 my $content = get_ws_content($tmp);
31 my $not_focused = first { !$_->{focused} } @{$content};
32 my $id = $not_focused->{id};
33
34 cmd "[con_id=\"$id\"] kill";
35
36 $content = get_ws_content($tmp);
37 ok(@{$content} == 1, 'one container killed');
38 ok($content->[0]->{id} != $id, 'correct window killed');
39
40 done_testing;