]> git.sur5r.net Git - i3/i3/blob - testcases/t/33-size-hints.t
Implement support for size hints (including test case)
[i3/i3] / testcases / t / 33-size-hints.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Checks if size hints are interpreted correctly.
5 #
6 use i3test tests => 2;
7 use Time::HiRes qw(sleep);
8
9 my $i3 = i3("/tmp/nestedcons");
10
11 my $x = X11::XCB::Connection->new;
12
13 my $tmp = get_unused_workspace();
14 $i3->command("workspace $tmp")->recv;
15
16 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
17
18 my $win = $x->root->create_child(
19     class => WINDOW_CLASS_INPUT_OUTPUT,
20     rect => X11::XCB::Rect->new(x => 0, y => 0, width => 30, height => 30),
21     background_color => '#C0C0C0',
22 );
23
24 # XXX: we should check screen size. in screens with an AR of 2.0,
25 # this is not a good idea.
26 my $aspect = X11::XCB::Sizehints::Aspect->new;
27 $aspect->min_num(600);
28 $aspect->min_den(300);
29 $aspect->max_num(600);
30 $aspect->max_den(300);
31 $win->_create;
32 $win->map;
33 sleep 0.25;
34 $win->hints->aspect($aspect);
35 $x->flush;
36
37 sleep 0.25;
38
39 my $rect = $win->rect;
40 my $ar = $rect->width / $rect->height;
41 diag("Aspect ratio = $ar");
42 ok(($ar > 1.90) && ($ar < 2.10), 'Aspect ratio about 2.0');
43
44 diag( "Testing i3, Perl $], $^X" );