]> git.sur5r.net Git - i3/i3/blob - testcases/t/502-focus-output.t
tests: use i3_config arg instead of precisely one launch_with_config
[i3/i3] / testcases / t / 502-focus-output.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 # Verifies the 'focus output' command works properly.
18
19 use i3test i3_config => <<EOT;
20 # i3 config file (v4)
21 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
22
23 fake-outputs 1024x768+0+0,1024x768+1024+0
24 EOT
25 use List::Util qw(first);
26
27 my $tmp = fresh_workspace;
28 my $i3 = i3(get_socket_path());
29
30 ################################################################################
31 # use 'focus output' and verify that focus gets changed appropriately
32 ################################################################################
33
34 sub focused_output {
35     my $tree = $i3->get_tree->recv;
36     my $focused = $tree->{focus}->[0];
37     my $output = first { $_->{id} == $focused } @{$tree->{nodes}};
38     return $output->{name};
39 }
40
41 sync_with_i3;
42 $x->root->warp_pointer(0, 0);
43 sync_with_i3;
44
45 is(focused_output, 'fake-0', 'focus on first output');
46
47 cmd 'focus output right';
48 is(focused_output, 'fake-1', 'focus on second output');
49
50 # focus should wrap when we focus to the right again.
51 cmd 'focus output right';
52 is(focused_output, 'fake-0', 'focus on first output again');
53
54 cmd 'focus output left';
55 is(focused_output, 'fake-1', 'focus back on second output');
56
57 cmd 'focus output left';
58 is(focused_output, 'fake-0', 'focus on first output again');
59
60 cmd 'focus output up';
61 is(focused_output, 'fake-0', 'focus still on first output');
62
63 cmd 'focus output down';
64 is(focused_output, 'fake-0', 'focus still on first output');
65
66 cmd 'focus output fake-1';
67 is(focused_output, 'fake-1', 'focus on second output');
68
69 cmd 'focus output fake-0';
70 is(focused_output, 'fake-0', 'focus on first output');
71
72 ################################################################################
73 # use 'focus output' and verify that i3 does not crash when the currently
74 # focused window is floating and is only partially mapped on an output screen
75 ################################################################################
76
77 is(focused_output, 'fake-0', 'focus on first output');
78
79 my $floating_win = open_window;
80 cmd 'floating toggle';
81 cmd 'move to absolute position -10 -10';
82
83 cmd 'focus output right';
84 is(focused_output, 'fake-1', 'focus on second output');
85
86 cmd 'focus output fake-0';
87 is(focused_output, 'fake-0', 'focus on first output');
88
89 done_testing;