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 # Check if empty split containers are automatically closed.
21 my $i3 = i3(get_socket_path());
23 my $tmp = fresh_workspace;
25 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
27 my $first = open_empty_con($i3);
28 my $second = open_empty_con($i3);
29 cmd qq|[con_id="$first"] focus|;
33 my ($nodes, $focus) = get_ws_content($tmp);
35 is($nodes->[0]->{focused}, 0, 'split container not focused');
37 # focus the split container
39 ($nodes, $focus) = get_ws_content($tmp);
40 my $split = $focus->[0];
43 $second = open_empty_con($i3);
45 isnt($first, $second, 'different container focused');
47 ##############################################################
48 # close both windows and see if the split container still exists
49 ##############################################################
53 ($nodes, $focus) = get_ws_content($tmp);
54 isnt($nodes->[0]->{id}, $split, 'split container closed');
56 # clean up the remaining containers to ensure this workspace will be garbage
61 ##############################################################
62 # same thing but this time we are moving the cons away instead
64 ##############################################################
66 $tmp = fresh_workspace;
68 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
70 $first = open_empty_con($i3);
71 $second = open_empty_con($i3);
72 cmd qq|[con_id="$first"] focus|;
76 ($nodes, $focus) = get_ws_content($tmp);
78 is($nodes->[0]->{focused}, 0, 'split container not focused');
80 # focus the split container
82 ($nodes, $focus) = get_ws_content($tmp);
86 $second = open_empty_con($i3);
88 isnt($first, $second, 'different container focused');
90 ##############################################################
91 # close both windows and see if the split container still exists
92 ##############################################################
94 my $otmp = get_unused_workspace();
95 cmd "move workspace $otmp";
96 cmd "move workspace $otmp";
97 ($nodes, $focus) = get_ws_content($tmp);
98 isnt($nodes->[0]->{id}, $split, 'split container closed');