]> git.sur5r.net Git - i3/i3/blob - testcases/t/170-force_focus_wrapping.t
fd0865058c14e352770cf3f5cf531e6c99a5eac5
[i3/i3] / testcases / t / 170-force_focus_wrapping.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 if the 'force_focus_wrapping' config directive works correctly.
18 #
19 use i3test i3_autostart => 0;
20
21 #####################################################################
22 # 1: test the wrapping behaviour without force_focus_wrapping
23 #####################################################################
24
25 my $config = <<EOT;
26 # i3 config file (v4)
27 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
28 EOT
29
30 my $pid = launch_with_config($config);
31
32 my $tmp = fresh_workspace;
33
34 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
35
36 my $first = open_window;
37 my $second = open_window;
38
39 cmd 'layout tabbed';
40 cmd 'focus parent';
41
42 my $third = open_window;
43 is($x->input_focus, $third->id, 'third window focused');
44
45 cmd 'focus left';
46 is($x->input_focus, $second->id, 'second window focused');
47
48 cmd 'focus left';
49 is($x->input_focus, $first->id, 'first window focused');
50
51 # now test the wrapping
52 cmd 'focus left';
53 is($x->input_focus, $second->id, 'second window focused');
54
55 # but focusing right should not wrap now, but instead focus the third window
56 cmd 'focus right';
57 is($x->input_focus, $third->id, 'third window focused');
58
59 exit_gracefully($pid);
60
61 #####################################################################
62 # 2: test the wrapping behaviour with force_focus_wrapping
63 #####################################################################
64
65 $config = <<EOT;
66 # i3 config file (v4)
67 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
68 force_focus_wrapping true
69 EOT
70
71 $pid = launch_with_config($config);
72
73 $tmp = fresh_workspace;
74
75 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
76
77 $first = open_window;
78 $second = open_window;
79
80 cmd 'layout tabbed';
81 cmd 'focus parent';
82
83 $third = open_window;
84
85 is($x->input_focus, $third->id, 'third window focused');
86
87 cmd 'focus left';
88 is($x->input_focus, $second->id, 'second window focused');
89
90 cmd 'focus left';
91 is($x->input_focus, $first->id, 'first window focused');
92
93 # now test the wrapping
94 cmd 'focus left';
95 is($x->input_focus, $second->id, 'second window focused');
96
97 # focusing right should now be forced to wrap
98 cmd 'focus right';
99 is($x->input_focus, $first->id, 'first window focused');
100
101 exit_gracefully($pid);
102
103 done_testing;