2 # vim:ts=4:sw=4:expandtab
9 my $tmp = fresh_workspace;
11 my $ws = get_ws($tmp);
12 is($ws->{orientation}, 'horizontal', 'orientation horizontal by default');
15 is($ws->{orientation}, 'vertical', 'split v changes workspace orientation');
17 ######################################################################
18 # Open two containers, split, open another container. Then verify
19 # the layout is like we expect it to be
20 ######################################################################
23 my $content = get_ws_content($tmp);
25 is(@{$content}, 2, 'two containers on workspace level');
26 my $first = $content->[0];
27 my $second = $content->[1];
29 is(@{$first->{nodes}}, 0, 'first container has no children');
30 is(@{$second->{nodes}}, 0, 'second container has no children (yet)');
31 my $old_name = $second->{name};
37 $content = get_ws_content($tmp);
39 is(@{$content}, 2, 'two containers on workspace level');
40 $first = $content->[0];
41 $second = $content->[1];
43 is(@{$first->{nodes}}, 0, 'first container has no children');
44 isnt($second->{name}, $old_name, 'second container was replaced');
45 is($second->{orientation}, 'horizontal', 'orientation is horizontal');
46 is(@{$second->{nodes}}, 2, 'second container has 2 children');
47 is($second->{nodes}->[0]->{name}, $old_name, 'found old second container');
49 # TODO: extend this test-case (test next/prev)
50 # - wrapping (no horizontal switch possible, goes level-up)
51 # - going level-up "manually"
53 ######################################################################
54 # Test splitting multiple times without actually creating windows
55 ######################################################################
57 $tmp = fresh_workspace;
60 is($ws->{orientation}, 'horizontal', 'orientation horizontal by default');
63 is($ws->{orientation}, 'vertical', 'split v changes workspace orientation');
66 my @content = @{get_ws_content($tmp)};
68 # recursively sums up all nodes and their children
72 return 0 if !@{$nodes};
74 my @children = (map { @{$_->{nodes}} } @{$nodes},
75 map { @{$_->{'floating_nodes'}} } @{$nodes});
77 return @{$nodes} + sum_nodes(\@children);
80 my $old_count = sum_nodes(\@content);
83 @content = @{get_ws_content($tmp)};
84 $old_count = sum_nodes(\@content);
88 @content = @{get_ws_content($tmp)};
89 my $count = sum_nodes(\@content);
90 is($count, $old_count, 'not more windows after splitting again');