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