]> git.sur5r.net Git - i3/i3/blob - testcases/t/130-close-empty-split.t
Merge branch 'master' into next
[i3/i3] / testcases / t / 130-close-empty-split.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 # Check if empty split containers are automatically closed.
18 #
19 use i3test;
20
21 my $i3 = i3(get_socket_path());
22
23 my $tmp = fresh_workspace;
24
25 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
26
27 my $first = open_empty_con($i3);
28 my $second = open_empty_con($i3);
29 cmd qq|[con_id="$first"] focus|;
30
31 cmd 'split v';
32
33 my ($nodes, $focus) = get_ws_content($tmp);
34
35 is($nodes->[0]->{focused}, 0, 'split container not focused');
36
37 # focus the split container
38 cmd 'focus parent';
39 ($nodes, $focus) = get_ws_content($tmp);
40 my $split = $focus->[0];
41 cmd 'focus child';
42
43 $second = open_empty_con($i3);
44
45 isnt($first, $second, 'different container focused');
46
47 ##############################################################
48 # close both windows and see if the split container still exists
49 ##############################################################
50
51 cmd 'kill';
52 cmd 'kill';
53 ($nodes, $focus) = get_ws_content($tmp);
54 isnt($nodes->[0]->{id}, $split, 'split container closed');
55
56 ##############################################################
57 # same thing but this time we are moving the cons away instead
58 # of killing them
59 ##############################################################
60
61 $tmp = fresh_workspace;
62
63 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
64
65 $first = open_empty_con($i3);
66 $second = open_empty_con($i3);
67 cmd qq|[con_id="$first"] focus|;
68
69 cmd 'split v';
70
71 ($nodes, $focus) = get_ws_content($tmp);
72
73 is($nodes->[0]->{focused}, 0, 'split container not focused');
74
75 # focus the split container
76 cmd 'focus parent';
77 ($nodes, $focus) = get_ws_content($tmp);
78 $split = $focus->[0];
79 cmd 'focus child';
80
81 $second = open_empty_con($i3);
82
83 isnt($first, $second, 'different container focused');
84
85 ##############################################################
86 # close both windows and see if the split container still exists
87 ##############################################################
88
89 my $otmp = get_unused_workspace();
90 cmd "move workspace $otmp";
91 cmd "move workspace $otmp";
92 ($nodes, $focus) = get_ws_content($tmp);
93 isnt($nodes->[0]->{id}, $split, 'split container closed');
94
95 done_testing;