2015-09-05 08:31:45 +02:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
|
|
|
#
|
|
|
|
# Please read the following documents before working on tests:
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/testsuite.html
|
2015-09-05 08:31:45 +02:00
|
|
|
# (or docs/testsuite)
|
|
|
|
#
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/lib-i3test.html
|
2015-09-05 08:31:45 +02:00
|
|
|
# (alternatively: perldoc ./testcases/lib/i3test.pm)
|
|
|
|
#
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/ipc.html
|
2015-09-05 08:31:45 +02:00
|
|
|
# (or docs/ipc)
|
|
|
|
#
|
|
|
|
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
|
|
|
|
# (unless you are already familiar with Perl)
|
|
|
|
#
|
|
|
|
# Test behavior of "resize <width> <height>" command.
|
|
|
|
# Ticket: #1727
|
|
|
|
# Bug still in: 4.10.2-1-gc0dbc5d
|
2017-10-18 01:04:42 +02:00
|
|
|
use i3test i3_config => <<EOT;
|
|
|
|
# i3 config file (v4)
|
|
|
|
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
|
|
|
|
|
|
|
|
fake-outputs 1333x999+0+0
|
|
|
|
workspace ws output fake-0
|
|
|
|
EOT
|
2015-09-05 08:31:45 +02:00
|
|
|
|
|
|
|
################################################################################
|
2018-05-02 17:06:48 +02:00
|
|
|
# Init variables used for all tests.
|
2015-09-05 08:31:45 +02:00
|
|
|
################################################################################
|
|
|
|
|
|
|
|
my $tmp = fresh_workspace;
|
|
|
|
open_floating_window;
|
|
|
|
my @content = @{get_ws($tmp)->{floating_nodes}};
|
|
|
|
is(@content, 1, 'one floating node on this ws');
|
|
|
|
my $oldrect = $content[0]->{rect};
|
|
|
|
|
2018-05-02 17:06:48 +02:00
|
|
|
sub do_test {
|
|
|
|
my ($width, $height) = @_;
|
|
|
|
|
|
|
|
cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x unchanged');
|
|
|
|
cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y unchanged');
|
|
|
|
|
|
|
|
@content = @{get_ws($tmp)->{floating_nodes}};
|
|
|
|
if ($width) {
|
|
|
|
cmp_ok($content[0]->{rect}->{width}, '==', $width, "width changed to $width px");
|
|
|
|
} else {
|
|
|
|
cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'width unchanged');
|
|
|
|
}
|
|
|
|
if ($height) {
|
|
|
|
cmp_ok($content[0]->{rect}->{height}, '==', $height, "height changed to $height px");
|
|
|
|
} else {
|
|
|
|
cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height}, 'height unchanged');
|
|
|
|
}
|
|
|
|
$oldrect = $content[0]->{rect};
|
|
|
|
}
|
2015-09-05 08:31:45 +02:00
|
|
|
|
2017-10-18 01:04:42 +02:00
|
|
|
################################################################################
|
2018-05-02 17:06:48 +02:00
|
|
|
# Check that setting floating windows size works
|
2017-10-18 01:04:42 +02:00
|
|
|
################################################################################
|
|
|
|
|
2018-05-02 17:06:48 +02:00
|
|
|
cmd 'resize set 100 px 250 px';
|
|
|
|
do_test(100, 250);
|
2017-10-18 01:04:42 +02:00
|
|
|
|
2018-05-02 17:06:48 +02:00
|
|
|
################################################################################
|
|
|
|
# Same but with ppt instead of px
|
|
|
|
################################################################################
|
2017-10-18 01:04:42 +02:00
|
|
|
|
|
|
|
cmd 'resize set 33 ppt 20 ppt';
|
2018-05-02 17:06:48 +02:00
|
|
|
do_test(int(0.33 * 1333), int(0.2 * 999));
|
2017-10-18 01:04:42 +02:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Mix ppt and px in a single resize set command
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
cmd 'resize set 44 ppt 111 px';
|
2018-05-02 17:06:48 +02:00
|
|
|
do_test(int(0.44 * 1333), 111);
|
2017-10-18 01:04:42 +02:00
|
|
|
|
|
|
|
cmd 'resize set 222 px 100 ppt';
|
2018-05-02 17:06:48 +02:00
|
|
|
do_test(222, 999);
|
2017-10-18 01:04:42 +02:00
|
|
|
|
2018-05-02 16:43:43 +02:00
|
|
|
################################################################################
|
|
|
|
# Zero is interpreted as no change.
|
|
|
|
# See issue: #3276.
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
cmd 'resize set 0 px 333 px';
|
|
|
|
do_test(0, 333);
|
|
|
|
|
|
|
|
cmd 'resize set 333 px 0 ppt';
|
|
|
|
do_test(333, 0);
|
|
|
|
|
|
|
|
cmd 'resize set 0 px 0 ppt';
|
|
|
|
do_test(0, 0);
|
|
|
|
|
|
|
|
cmd 'resize set 100 ppt 0 px';
|
|
|
|
do_test(1333, 0);
|
|
|
|
|
2018-05-02 17:59:17 +02:00
|
|
|
################################################################################
|
|
|
|
# Use 'width' and 'height' keywords.
|
|
|
|
# See issue: #3275.
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
cmd 'resize set width 200 px';
|
|
|
|
do_test(200, 0);
|
|
|
|
|
|
|
|
cmd 'resize set height 200 px';
|
|
|
|
do_test(0, 200);
|
|
|
|
|
|
|
|
cmd 'resize set width 300 px height 300 px';
|
|
|
|
do_test(300, 300);
|
|
|
|
|
|
|
|
# ppt + keyword used only for height
|
|
|
|
cmd 'resize set 100 ppt height 100 px';
|
|
|
|
do_test(1333, 100);
|
|
|
|
|
2015-09-05 08:31:45 +02:00
|
|
|
done_testing;
|