]> git.sur5r.net Git - i3/i3/blob - testcases/t/531-fullscreen-on-given-output.t
Merge pull request #3435 from vivien/i3-msg/subscribe
[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 # • 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 # Tests that fullscreen windows appear on the output indicated by
18 # their geometry
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 # Helper functions
28 sub fullscreen($) {
29     my ($window) = @_;
30     $window->fullscreen(1);
31 }
32
33 sub find_window {
34     my ($nodes, $id) = @_;
35
36     foreach (@{$nodes}) {
37         return $_ if ($_->{window} // 0) == $id;
38         my $node = find_window($_->{nodes}, $id);
39         return $node if $node;
40     };
41     return undef;
42 }
43
44 # Create two fullscreen windows, each on different output
45 my $orig_rect1 = X11::XCB::Rect->new(x => 0, y => 0, width => 1024, height => 768);
46 my $orig_rect2 = X11::XCB::Rect->new(x => 1024, y => 0, width => 1024, height => 768);
47
48 my $win_on_first_output = open_window(rect => $orig_rect1,
49                                       before_map => \&fullscreen);
50
51 my $win_on_second_output = open_window(rect => $orig_rect2,
52                                        before_map => \&fullscreen);
53
54 sync_with_i3;
55
56 # Check that the windows are on the correct output
57 is_deeply(scalar $win_on_first_output->rect, $orig_rect1, "first window spans the first output");
58 is_deeply(scalar $win_on_second_output->rect, $orig_rect2, "second window spans the sencond output");
59
60 # Check that both windows remained fullscreen
61 my $tree = i3(get_socket_path())->get_tree->recv;
62
63 my $node1 = find_window($tree->{nodes}, $win_on_first_output->{id});
64 my $node2 = find_window($tree->{nodes}, $win_on_second_output->{id});
65
66 is($node1->{fullscreen_mode}, 1, "first window is fullscreen");
67 is($node2->{fullscreen_mode}, 1, "second window is fullscreen");
68
69 done_testing;