2 # vim:ts=4:sw=4:expandtab
4 # Check if the focus is correctly restored after closing windows.
7 use Time::HiRes qw(sleep);
9 my $i3 = i3("/tmp/nestedcons");
11 my $tmp = get_unused_workspace();
12 $i3->command("workspace $tmp")->recv;
14 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
16 $i3->command('open')->recv;
17 my ($nodes, $focus) = get_ws_content($tmp);
18 my $first = $focus->[0];
20 $i3->command('split v')->recv;
22 ($nodes, $focus) = get_ws_content($tmp);
24 is($nodes->[0]->{focused}, 0, 'split container not focused');
25 $i3->command('level up')->recv;
26 ($nodes, $focus) = get_ws_content($tmp);
27 is($nodes->[0]->{focused}, 1, 'split container focused after level up');
29 $i3->command('open')->recv;
31 ($nodes, $focus) = get_ws_content($tmp);
32 my $second = $focus->[0];
34 isnt($first, $second, 'different container focused');
36 # We have the following layout now (con is focused):
44 ##############################################################
45 # see if the focus goes down to $first (not to its split parent)
46 # when closing $second
47 ##############################################################
49 $i3->command('kill')->recv;
50 # TODO: this testcase sometimes has different outcomes when the
51 # sleep is missing. why?
53 ($nodes, $focus) = get_ws_content($tmp);
54 is($nodes->[0]->{nodes}->[0]->{id}, $first, 'first container found');
55 is($nodes->[0]->{nodes}->[0]->{focused}, 1, 'first container focused');
57 diag( "Testing i3, Perl $], $^X" );