]> git.sur5r.net Git - i3/i3/blob - testcases/t/140-focus-lost.t
Merge pull request #2953 from CyberShadow/focus_wrapping
[i3/i3] / testcases / t / 140-focus-lost.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • https://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 # Regression: Check if the focus stays the same when switching the layout
18 # bug introduced by 77d0d42ed2d7ac8cafe267c92b35a81c1b9491eb
19 use i3test;
20
21 my $i3 = i3(get_socket_path());
22
23 sub check_order {
24     my ($msg) = @_;
25
26     my @ws = @{$i3->get_workspaces->recv};
27     my @nums = map { $_->{num} } grep { defined($_->{num}) } @ws;
28     my @sorted = sort @nums;
29
30     is_deeply(\@nums, \@sorted, $msg);
31 }
32
33 my $tmp = fresh_workspace;
34
35 my $left = open_window;
36 my $mid = open_window;
37 my $right = open_window;
38
39 diag("left = " . $left->id . ", mid = " . $mid->id . ", right = " . $right->id);
40
41 is($x->input_focus, $right->id, 'Right window focused');
42
43 cmd 'focus left';
44
45 is($x->input_focus, $mid->id, 'Mid window focused');
46
47 cmd 'layout stacked';
48
49 is($x->input_focus, $mid->id, 'Mid window focused');
50
51 done_testing;