]> git.sur5r.net Git - i3/i3/blob - testcases/t/70-force_focus_wrapping.t
Merge branch 'tree' into next
[i3/i3] / testcases / t / 70-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 use Cwd qw(abs_path);
9 use Proc::Background;
10 use File::Temp qw(tempfile tempdir);
11 use X11::XCB qw(:all);
12 use X11::XCB::Connection;
13
14 my $x = X11::XCB::Connection->new;
15
16 # assuming we are run by complete-run.pl
17 my $i3_path = abs_path("../i3");
18 my $socketpath = File::Temp::tempnam('/tmp', 'i3-test-socket-');
19
20 #####################################################################
21 # 1: test the wrapping behaviour without force_focus_wrapping
22 #####################################################################
23
24 my ($fh, $tmpfile) = tempfile();
25 say $fh "# i3 config file (v4)";
26 say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1";
27 say $fh "ipc-socket $socketpath";
28 close($fh);
29
30 diag("Starting i3");
31 my $i3cmd = "exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >/dev/null 2>/dev/null";
32 my $process = Proc::Background->new($i3cmd);
33 sleep 1;
34
35 # force update of the cached socket path in lib/i3test
36 get_socket_path(0);
37
38 diag("pid = " . $process->pid);
39
40 my $tmp = fresh_workspace;
41
42 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
43
44 my $first = open_standard_window($x);
45 my $second = open_standard_window($x);
46
47 cmd 'layout tabbed';
48 cmd 'focus parent';
49
50 my $third = open_standard_window($x);
51 is($x->input_focus, $third->id, 'third window focused');
52
53 cmd 'focus left';
54 is($x->input_focus, $second->id, 'second window focused');
55
56 cmd 'focus left';
57 is($x->input_focus, $first->id, 'first window focused');
58
59 # now test the wrapping
60 cmd 'focus left';
61 is($x->input_focus, $second->id, 'second window focused');
62
63 # but focusing right should not wrap now, but instead focus the third window
64 cmd 'focus right';
65 is($x->input_focus, $third->id, 'third window focused');
66
67 exit_gracefully($process->pid);
68
69 #####################################################################
70 # 2: test the wrapping behaviour with force_focus_wrapping
71 #####################################################################
72
73 ($fh, $tmpfile) = tempfile();
74 say $fh "# i3 config file (v4)";
75 say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1";
76 say $fh "ipc-socket $socketpath";
77 say $fh "force_focus_wrapping true";
78 close($fh);
79
80 diag("Starting i3");
81 $i3cmd = "exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >/dev/null 2>/dev/null";
82 $process = Proc::Background->new($i3cmd);
83 sleep 1;
84
85 # force update of the cached socket path in lib/i3test
86 get_socket_path(0);
87
88 diag("pid = " . $process->pid);
89
90 $tmp = fresh_workspace;
91
92 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
93
94 $first = open_standard_window($x);
95 $second = open_standard_window($x);
96
97 cmd 'layout tabbed';
98 cmd 'focus parent';
99
100 $third = open_standard_window($x);
101 is($x->input_focus, $third->id, 'third window focused');
102
103 cmd 'focus left';
104 is($x->input_focus, $second->id, 'second window focused');
105
106 cmd 'focus left';
107 is($x->input_focus, $first->id, 'first window focused');
108
109 # now test the wrapping
110 cmd 'focus left';
111 is($x->input_focus, $second->id, 'second window focused');
112
113 # focusing right should now be forced to wrap
114 cmd 'focus right';
115 is($x->input_focus, $first->id, 'first window focused');
116
117 exit_gracefully($process->pid);
118
119 done_testing;