]> 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 # Check if empty split containers are automatically closed.
5 #
6 use i3test;
7
8 my $i3 = i3(get_socket_path());
9
10 my $tmp = fresh_workspace;
11
12 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
13
14 my $first = open_empty_con($i3);
15 my $second = open_empty_con($i3);
16 cmd qq|[con_id="$first"] focus|;
17
18 cmd 'split v';
19
20 my ($nodes, $focus) = get_ws_content($tmp);
21
22 is($nodes->[0]->{focused}, 0, 'split container not focused');
23
24 # focus the split container
25 cmd 'level up';
26 ($nodes, $focus) = get_ws_content($tmp);
27 my $split = $focus->[0];
28 cmd 'level down';
29
30 $second = open_empty_con($i3);
31
32 isnt($first, $second, 'different container focused');
33
34 ##############################################################
35 # close both windows and see if the split container still exists
36 ##############################################################
37
38 cmd 'kill';
39 cmd 'kill';
40 ($nodes, $focus) = get_ws_content($tmp);
41 isnt($nodes->[0]->{id}, $split, 'split container closed');
42
43 ##############################################################
44 # same thing but this time we are moving the cons away instead
45 # of killing them
46 ##############################################################
47
48 $tmp = fresh_workspace;
49
50 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
51
52 $first = open_empty_con($i3);
53 $second = open_empty_con($i3);
54 cmd qq|[con_id="$first"] focus|;
55
56 cmd 'split v';
57
58 ($nodes, $focus) = get_ws_content($tmp);
59
60 is($nodes->[0]->{focused}, 0, 'split container not focused');
61
62 # focus the split container
63 cmd 'level up';
64 ($nodes, $focus) = get_ws_content($tmp);
65 $split = $focus->[0];
66 cmd 'level down';
67
68 $second = open_empty_con($i3);
69
70 isnt($first, $second, 'different container focused');
71
72 ##############################################################
73 # close both windows and see if the split container still exists
74 ##############################################################
75
76 my $otmp = get_unused_workspace();
77 cmd "move workspace $otmp";
78 cmd "move workspace $otmp";
79 ($nodes, $focus) = get_ws_content($tmp);
80 isnt($nodes->[0]->{id}, $split, 'split container closed');
81
82 done_testing;