]> git.sur5r.net Git - i3/i3/blob - testcases/t/531-fullscreen-on-given-output.t
Kill windows between tests
[i3/i3] / testcases / t / 531-fullscreen-on-given-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 # Tests that fullscreen windows appear on the output indicated by
18 # their geometry
19 use i3test i3_autostart => 0;
20 use List::Util qw(first);
21
22 my $config = <<EOT;
23 # i3 config file (v4)
24 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
25
26 fake-outputs 1024x768+0+0,1024x768+1024+0
27 EOT
28
29 my $pid = launch_with_config($config);
30
31 # Helper functions
32 sub fullscreen($) {
33     my ($window) = @_;
34     $window->fullscreen(1);
35 }
36
37 sub find_window {
38     my ($nodes, $id) = @_;
39
40     foreach (@{$nodes}) {
41         return $_ if ($_->{window} // 0) == $id;
42         my $node = find_window($_->{nodes}, $id);
43         return $node if $node;
44     };
45     return undef;
46 }
47
48 # Create two fullscreen windows, each on different output
49 my $orig_rect1 = X11::XCB::Rect->new(x => 0, y => 0, width => 1024, height => 768);
50 my $orig_rect2 = X11::XCB::Rect->new(x => 1024, y => 0, width => 1024, height => 768);
51
52 my $win_on_first_output = open_window(rect => $orig_rect1,
53                                       before_map => \&fullscreen);
54
55 my $win_on_second_output = open_window(rect => $orig_rect2,
56                                        before_map => \&fullscreen);
57
58 sync_with_i3;
59
60 # Check that the windows are on the correct output
61 is_deeply(scalar $win_on_first_output->rect, $orig_rect1, "first window spans the first output");
62 is_deeply(scalar $win_on_second_output->rect, $orig_rect2, "second window spans the sencond output");
63
64 # Check that both windows remained fullscreen
65 my $tree = i3(get_socket_path())->get_tree->recv;
66
67 my $node1 = find_window($tree->{nodes}, $win_on_first_output->{id});
68 my $node2 = find_window($tree->{nodes}, $win_on_second_output->{id});
69
70 is($node1->{fullscreen_mode}, 1, "first window is fullscreen");
71 is($node2->{fullscreen_mode}, 1, "second window is fullscreen");
72
73 exit_gracefully($pid);
74
75 done_testing;