2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • http://build.i3wm.org/docs/ipc.html
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 # (unless you are already familiar with Perl)
17 # Verifies the 'focus output' command works properly.
19 use i3test i3_autostart => 0;
20 use List::Util qw(first);
24 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
26 fake-outputs 1024x768+0+0,1024x768+1024+0
28 my $pid = launch_with_config($config);
30 my $tmp = fresh_workspace;
31 my $i3 = i3(get_socket_path());
33 ################################################################################
34 # use 'focus output' and verify that focus gets changed appropriately
35 ################################################################################
38 my $tree = $i3->get_tree->recv;
39 my $focused = $tree->{focus}->[0];
40 my $output = first { $_->{id} == $focused } @{$tree->{nodes}};
41 return $output->{name};
45 $x->root->warp_pointer(0, 0);
48 is(focused_output, 'fake-0', 'focus on first output');
50 cmd 'focus output right';
51 is(focused_output, 'fake-1', 'focus on second output');
53 # focus should wrap when we focus to the right again.
54 cmd 'focus output right';
55 is(focused_output, 'fake-0', 'focus on first output again');
57 cmd 'focus output left';
58 is(focused_output, 'fake-1', 'focus back on second output');
60 cmd 'focus output left';
61 is(focused_output, 'fake-0', 'focus on first output again');
63 cmd 'focus output up';
64 is(focused_output, 'fake-0', 'focus still on first output');
66 cmd 'focus output down';
67 is(focused_output, 'fake-0', 'focus still on first output');
69 cmd 'focus output fake-1';
70 is(focused_output, 'fake-1', 'focus on second output');
72 cmd 'focus output fake-0';
73 is(focused_output, 'fake-0', 'focus on first output');
75 ################################################################################
76 # use 'focus output' and verify that i3 does not crash when the currently
77 # focused window is floating and is only partially mapped on an output screen
78 ################################################################################
80 is(focused_output, 'fake-0', 'focus on first output');
82 my $floating_win = open_window;
83 cmd 'floating toggle';
84 cmd 'move to absolute position -10 -10';
86 cmd 'focus output right';
87 is(focused_output, 'fake-1', 'focus on second output');
89 cmd 'focus output fake-0';
90 is(focused_output, 'fake-0', 'focus on first output');
92 exit_gracefully($pid);