]> git.sur5r.net Git - i3/i3/blob - testcases/t/170-force_focus_wrapping.t
testcases: let i3test.pm export $x, adapt testcases
[i3/i3] / testcases / t / 170-force_focus_wrapping.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 # !NO_I3_INSTANCE! will prevent complete-run.pl from starting i3
4 #
5 # Tests if the 'force_focus_wrapping' config directive works correctly.
6 #
7 use i3test;
8
9 #####################################################################
10 # 1: test the wrapping behaviour without force_focus_wrapping
11 #####################################################################
12
13 my $config = <<EOT;
14 # i3 config file (v4)
15 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
16 EOT
17
18 my $pid = launch_with_config($config);
19
20 my $tmp = fresh_workspace;
21
22 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
23
24 my $first = open_window($x);
25 my $second = open_window($x);
26
27 cmd 'layout tabbed';
28 cmd 'focus parent';
29
30 my $third = open_window($x);
31 is($x->input_focus, $third->id, 'third window focused');
32
33 cmd 'focus left';
34 is($x->input_focus, $second->id, 'second window focused');
35
36 cmd 'focus left';
37 is($x->input_focus, $first->id, 'first window focused');
38
39 # now test the wrapping
40 cmd 'focus left';
41 is($x->input_focus, $second->id, 'second window focused');
42
43 # but focusing right should not wrap now, but instead focus the third window
44 cmd 'focus right';
45 is($x->input_focus, $third->id, 'third window focused');
46
47 exit_gracefully($pid);
48
49 #####################################################################
50 # 2: test the wrapping behaviour with force_focus_wrapping
51 #####################################################################
52
53 $config = <<EOT;
54 # i3 config file (v4)
55 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
56 force_focus_wrapping true
57 EOT
58
59 $pid = launch_with_config($config);
60
61 $tmp = fresh_workspace;
62
63 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
64
65 $first = open_window($x);
66 $second = open_window($x);
67
68 cmd 'layout tabbed';
69 cmd 'focus parent';
70
71 $third = open_window($x);
72
73 sync_with_i3($x);
74
75 is($x->input_focus, $third->id, 'third window focused');
76
77 cmd 'focus left';
78 is($x->input_focus, $second->id, 'second window focused');
79
80 cmd 'focus left';
81 is($x->input_focus, $first->id, 'first window focused');
82
83 # now test the wrapping
84 cmd 'focus left';
85 is($x->input_focus, $second->id, 'second window focused');
86
87 # focusing right should now be forced to wrap
88 cmd 'focus right';
89 is($x->input_focus, $first->id, 'first window focused');
90
91 exit_gracefully($pid);
92
93 done_testing;