]> git.sur5r.net Git - i3/i3/blob - testcases/t/130-close-empty-split.t
Merge "force_focus_wrapping" option into "focus_wrapping force"
[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 # clean up the remaining containers to ensure this workspace will be garbage
57 # collected.
58 cmd 'kill';
59 cmd 'kill';
60
61 ##############################################################
62 # same thing but this time we are moving the cons away instead
63 # of killing them
64 ##############################################################
65
66 $tmp = fresh_workspace;
67
68 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
69
70 $first = open_empty_con($i3);
71 $second = open_empty_con($i3);
72 cmd qq|[con_id="$first"] focus|;
73
74 cmd 'split v';
75
76 ($nodes, $focus) = get_ws_content($tmp);
77
78 is($nodes->[0]->{focused}, 0, 'split container not focused');
79
80 # focus the split container
81 cmd 'focus parent';
82 ($nodes, $focus) = get_ws_content($tmp);
83 $split = $focus->[0];
84 cmd 'focus child';
85
86 $second = open_empty_con($i3);
87
88 isnt($first, $second, 'different container focused');
89
90 ##############################################################
91 # close both windows and see if the split container still exists
92 ##############################################################
93
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');
99
100 done_testing;