]> git.sur5r.net Git - i3/i3/blob - testcases/t/121-next-prev.t
3228b259a46492e257471c2cc13af95a4aa6d568
[i3/i3] / testcases / t / 121-next-prev.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 # Tests focus switching (next/prev)
18 #
19 use i3test;
20
21 my $tmp = fresh_workspace;
22
23 ######################################################################
24 # Open one container, verify that 'focus down' and 'focus right' do nothing
25 ######################################################################
26 cmd 'open';
27
28 my ($nodes, $focus) = get_ws_content($tmp);
29 my $old_focused = $focus->[0];
30
31 cmd 'focus down';
32 ($nodes, $focus) = get_ws_content($tmp);
33 is($focus->[0], $old_focused, 'focus did not change with only one con');
34
35 cmd 'focus right';
36 ($nodes, $focus) = get_ws_content($tmp);
37 is($focus->[0], $old_focused, 'focus did not change with only one con');
38
39 ######################################################################
40 # Open another container, verify that 'focus right' switches
41 ######################################################################
42 my $left = $old_focused;
43
44 cmd 'open';
45 ($nodes, $focus) = get_ws_content($tmp);
46 isnt($old_focused, $focus->[0], 'new container is focused');
47 my $mid = $focus->[0];
48
49 cmd 'open';
50 ($nodes, $focus) = get_ws_content($tmp);
51 isnt($old_focused, $focus->[0], 'new container is focused');
52 my $right = $focus->[0];
53
54 cmd 'focus right';
55 ($nodes, $focus) = get_ws_content($tmp);
56 isnt($focus->[0], $right, 'focus did change');
57 is($focus->[0], $left, 'left container focused (wrapping)');
58
59 cmd 'focus right';
60 ($nodes, $focus) = get_ws_content($tmp);
61 is($focus->[0], $mid, 'middle container focused');
62
63 cmd 'focus right';
64 ($nodes, $focus) = get_ws_content($tmp);
65 is($focus->[0], $right, 'right container focused');
66
67 cmd 'focus left';
68 ($nodes, $focus) = get_ws_content($tmp);
69 is($focus->[0], $mid, 'middle container focused');
70
71 cmd 'focus left';
72 ($nodes, $focus) = get_ws_content($tmp);
73 is($focus->[0], $left, 'left container focused');
74
75 cmd 'focus left';
76 ($nodes, $focus) = get_ws_content($tmp);
77 is($focus->[0], $right, 'right container focused');
78
79
80 ######################################################################
81 # Test focus command
82 ######################################################################
83
84 cmd qq|[con_id="$mid"] focus|;
85 ($nodes, $focus) = get_ws_content($tmp);
86 is($focus->[0], $mid, 'middle container focused');
87
88
89 done_testing;