From 18f7e1ffd1b89aedcea164be93d54e22cb93e2f0 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 1 Jun 2010 22:29:19 +0200 Subject: [PATCH] t/22: extend to verify that splitting in the same direction multiple times does not create new containers --- testcases/t/22-split.t | 47 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/testcases/t/22-split.t b/testcases/t/22-split.t index 95e387d1..fdfe0abc 100644 --- a/testcases/t/22-split.t +++ b/testcases/t/22-split.t @@ -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" );