2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • https://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 # Tests focus switching (next/prev)
21 my $tmp = fresh_workspace;
23 ######################################################################
24 # Open one container, verify that 'focus down' and 'focus right' do nothing
25 ######################################################################
28 my ($nodes, $focus) = get_ws_content($tmp);
29 my $old_focused = $focus->[0];
32 ($nodes, $focus) = get_ws_content($tmp);
33 is($focus->[0], $old_focused, 'focus did not change with only one con');
36 ($nodes, $focus) = get_ws_content($tmp);
37 is($focus->[0], $old_focused, 'focus did not change with only one con');
39 ######################################################################
40 # Open another container, verify that 'focus right' switches
41 ######################################################################
42 my $left = $old_focused;
45 ($nodes, $focus) = get_ws_content($tmp);
46 isnt($old_focused, $focus->[0], 'new container is focused');
47 my $mid = $focus->[0];
50 ($nodes, $focus) = get_ws_content($tmp);
51 isnt($old_focused, $focus->[0], 'new container is focused');
52 my $right = $focus->[0];
55 ($nodes, $focus) = get_ws_content($tmp);
56 isnt($focus->[0], $right, 'focus did change');
57 is($focus->[0], $left, 'left container focused (wrapping)');
60 ($nodes, $focus) = get_ws_content($tmp);
61 is($focus->[0], $mid, 'middle container focused');
64 ($nodes, $focus) = get_ws_content($tmp);
65 is($focus->[0], $right, 'right container focused');
68 ($nodes, $focus) = get_ws_content($tmp);
69 is($focus->[0], $mid, 'middle container focused');
72 ($nodes, $focus) = get_ws_content($tmp);
73 is($focus->[0], $left, 'left container focused');
76 ($nodes, $focus) = get_ws_content($tmp);
77 is($focus->[0], $right, 'right container focused');
80 ######################################################################
82 ######################################################################
84 cmd qq|[con_id="$mid"] focus|;
85 ($nodes, $focus) = get_ws_content($tmp);
86 is($focus->[0], $mid, 'middle container focused');