2010-05-10 09:33:10 +02:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
|
|
|
#
|
|
|
|
# Tests splitting
|
|
|
|
#
|
2010-06-01 22:29:19 +02:00
|
|
|
use i3test tests => 14;
|
2010-05-10 09:33:10 +02:00
|
|
|
use X11::XCB qw(:all);
|
|
|
|
|
|
|
|
my $i3 = i3("/tmp/nestedcons");
|
|
|
|
|
|
|
|
my $tmp = get_unused_workspace();
|
|
|
|
$i3->command("workspace $tmp")->recv;
|
|
|
|
|
|
|
|
my $ws = get_ws($tmp);
|
2010-06-01 22:29:19 +02:00
|
|
|
is($ws->{orientation}, 1, 'orientation horizontal by default');
|
2010-05-10 09:33:10 +02:00
|
|
|
$i3->command('split v')->recv;
|
|
|
|
$ws = get_ws($tmp);
|
2010-06-01 22:29:19 +02:00
|
|
|
is($ws->{orientation}, 2, 'split v changes workspace orientation');
|
2010-05-10 09:33:10 +02:00
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Open two containers, split, open another container. Then verify
|
|
|
|
# the layout is like we expect it to be
|
|
|
|
######################################################################
|
|
|
|
$i3->command('open')->recv;
|
|
|
|
$i3->command('open')->recv;
|
|
|
|
my $content = get_ws_content($tmp);
|
|
|
|
|
|
|
|
is(@{$content}, 2, 'two containers on workspace level');
|
|
|
|
my $first = $content->[0];
|
|
|
|
my $second = $content->[1];
|
|
|
|
|
|
|
|
is(@{$first->{nodes}}, 0, 'first container has no children');
|
|
|
|
is(@{$second->{nodes}}, 0, 'second container has no children (yet)');
|
|
|
|
my $old_name = $second->{name};
|
|
|
|
|
|
|
|
|
|
|
|
$i3->command('split h')->recv;
|
|
|
|
$i3->command('open')->recv;
|
|
|
|
|
|
|
|
$content = get_ws_content($tmp);
|
|
|
|
|
|
|
|
is(@{$content}, 2, 'two containers on workspace level');
|
|
|
|
$first = $content->[0];
|
|
|
|
$second = $content->[1];
|
|
|
|
|
|
|
|
is(@{$first->{nodes}}, 0, 'first container has no children');
|
|
|
|
isnt($second->{name}, $old_name, 'second container was replaced');
|
2010-06-01 22:29:19 +02:00
|
|
|
is($second->{orientation}, 1, 'orientation is horizontal');
|
2010-05-10 09:33:10 +02:00
|
|
|
is(@{$second->{nodes}}, 2, 'second container has 2 children');
|
|
|
|
is($second->{nodes}->[0]->{name}, $old_name, 'found old second container');
|
|
|
|
|
|
|
|
# TODO: extend this test-case (test next/prev)
|
|
|
|
# - wrapping (no horizontal switch possible, goes level-up)
|
|
|
|
# - going level-up "manually"
|
|
|
|
|
2010-06-01 22:29:19 +02:00
|
|
|
######################################################################
|
|
|
|
# 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)};
|
2010-08-21 18:25:48 +02:00
|
|
|
$old_count = sum_nodes(\@content);
|
2010-06-01 22:29:19 +02:00
|
|
|
|
|
|
|
$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');
|
2010-05-10 09:33:10 +02:00
|
|
|
|
|
|
|
diag( "Testing i3, Perl $], $^X" );
|