t/22: extend to verify that splitting in the same direction multiple times does not create new containers

This commit is contained in:
Michael Stapelberg 2010-06-01 22:29:19 +02:00
parent 249c3f58ab
commit 18f7e1ffd1

View File

@ -3,7 +3,7 @@
#
# Tests splitting
#
use i3test tests => 11;
use i3test tests => 14;
use X11::XCB qw(:all);
use v5.10;
@ -13,10 +13,10 @@ my $tmp = get_unused_workspace();
$i3->command("workspace $tmp")->recv;
my $ws = get_ws($tmp);
is($ws->{orientation}, 0, 'orientation horizontal by default');
is($ws->{orientation}, 1, 'orientation horizontal by default');
$i3->command('split v')->recv;
$ws = get_ws($tmp);
is($ws->{orientation}, 1, 'split v changes workspace orientation');
is($ws->{orientation}, 2, 'split v changes workspace orientation');
######################################################################
# Open two containers, split, open another container. Then verify
@ -46,7 +46,7 @@ $second = $content->[1];
is(@{$first->{nodes}}, 0, 'first container has no children');
isnt($second->{name}, $old_name, 'second container was replaced');
is($second->{orientation}, 0, 'orientation is horizontal');
is($second->{orientation}, 1, 'orientation is horizontal');
is(@{$second->{nodes}}, 2, 'second container has 2 children');
is($second->{nodes}->[0]->{name}, $old_name, 'found old second container');
@ -54,5 +54,44 @@ is($second->{nodes}->[0]->{name}, $old_name, 'found old second container');
# - wrapping (no horizontal switch possible, goes level-up)
# - going level-up "manually"
######################################################################
# Test splitting multiple times without actually creating windows
######################################################################
$tmp = get_unused_workspace();
$i3->command("workspace $tmp")->recv;
$ws = get_ws($tmp);
is($ws->{orientation}, 1, 'orientation horizontal by default');
$i3->command('split v')->recv;
$ws = get_ws($tmp);
is($ws->{orientation}, 2, 'split v changes workspace orientation');
$i3->command('open')->recv;
my @content = @{get_ws_content($tmp)};
# recursively sums up all nodes and their children
sub sum_nodes {
my ($nodes) = @_;
return 0 if !@{$nodes};
my @children = (map { @{$_->{nodes}} } @{$nodes},
map { @{$_->{'floating-nodes'}} } @{$nodes});
return @{$nodes} + sum_nodes(\@children);
}
my $old_count = sum_nodes(\@content);
$i3->command('split v')->recv;
@content = @{get_ws_content($tmp)};
my $old_count = sum_nodes(\@content);
$i3->command('split v')->recv;
@content = @{get_ws_content($tmp)};
my $count = sum_nodes(\@content);
is($count, $old_count, 'not more windows after splitting again');
diag( "Testing i3, Perl $], $^X" );