2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • https://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 # Test behavior of "resize <width> <height>" command.
19 # Bug still in: 4.10.2-1-gc0dbc5d
20 use i3test i3_config => <<EOT;
22 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
24 fake-outputs 1333x999+0+0
25 workspace ws output fake-0
28 ################################################################################
29 # Check that setting floating windows size works
30 ################################################################################
32 my $tmp = fresh_workspace;
36 my @content = @{get_ws($tmp)->{floating_nodes}};
37 is(@content, 1, 'one floating node on this ws');
39 my $oldrect = $content[0]->{rect};
41 cmd 'resize set 100 px 250 px';
43 @content = @{get_ws($tmp)->{floating_nodes}};
44 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x untouched');
45 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y untouched');
46 cmp_ok($content[0]->{rect}->{width}, '!=', $oldrect->{width}, 'width changed');
47 cmp_ok($content[0]->{rect}->{height}, '!=', $oldrect->{width}, 'height changed');
48 cmp_ok($content[0]->{rect}->{width}, '==', 100, 'width changed to 100 px');
49 cmp_ok($content[0]->{rect}->{height}, '==', 250, 'height changed to 250 px');
51 ################################################################################
52 # Same but with ppt instead of px
53 ################################################################################
60 @content = @{get_ws($tmp)->{floating_nodes}};
61 is(@content, 1, 'one floating node on this ws');
63 $oldrect = $content[0]->{rect};
65 cmd 'resize set 33 ppt 20 ppt';
66 my $expected_width = int(0.33 * 1333);
67 my $expected_height = int(0.2 * 999);
69 @content = @{get_ws($tmp)->{floating_nodes}};
70 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x untouched');
71 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y untouched');
72 cmp_ok($content[0]->{rect}->{width}, '!=', $oldrect->{width}, 'width changed');
73 cmp_ok($content[0]->{rect}->{height}, '!=', $oldrect->{width}, 'height changed');
74 cmp_ok($content[0]->{rect}->{width}, '==', $expected_width, "width changed to $expected_width px");
75 cmp_ok($content[0]->{rect}->{height}, '==', $expected_height, "height changed to $expected_height px");
77 ################################################################################
78 # Mix ppt and px in a single resize set command
79 ################################################################################
81 cmd 'resize set 44 ppt 111 px';
82 my $expected_width = int(0.44 * 1333);
83 my $expected_height = 111;
85 @content = @{get_ws($tmp)->{floating_nodes}};
86 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x untouched');
87 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y untouched');
88 cmp_ok($content[0]->{rect}->{width}, '==', $expected_width, "width changed to $expected_width px");
89 cmp_ok($content[0]->{rect}->{height}, '==', $expected_height, "height changed to $expected_height px");
91 cmd 'resize set 222 px 100 ppt';
92 my $expected_width = 222;
93 my $expected_height = 999;
95 @content = @{get_ws($tmp)->{floating_nodes}};
96 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x untouched');
97 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y untouched');
98 cmp_ok($content[0]->{rect}->{width}, '==', $expected_width, "width changed to $expected_width px");
99 cmp_ok($content[0]->{rect}->{height}, '==', $expected_height, "height changed to $expected_height px");