2 # vim:ts=4:sw=4:expandtab
8 my $tmp = fresh_workspace;
10 my $ws = get_ws($tmp);
11 is($ws->{orientation}, 'horizontal', 'orientation horizontal by default');
14 is($ws->{orientation}, 'vertical', 'split v changes workspace orientation');
16 ######################################################################
17 # Open two containers, split, open another container. Then verify
18 # the layout is like we expect it to be
19 ######################################################################
22 my $content = get_ws_content($tmp);
24 is(@{$content}, 2, 'two containers on workspace level');
25 my $first = $content->[0];
26 my $second = $content->[1];
28 is(@{$first->{nodes}}, 0, 'first container has no children');
29 is(@{$second->{nodes}}, 0, 'second container has no children (yet)');
30 my $old_name = $second->{name};
36 $content = get_ws_content($tmp);
38 is(@{$content}, 2, 'two containers on workspace level');
39 $first = $content->[0];
40 $second = $content->[1];
42 is(@{$first->{nodes}}, 0, 'first container has no children');
43 isnt($second->{name}, $old_name, 'second container was replaced');
44 is($second->{orientation}, 'horizontal', 'orientation is horizontal');
45 is(@{$second->{nodes}}, 2, 'second container has 2 children');
46 is($second->{nodes}->[0]->{name}, $old_name, 'found old second container');
48 # TODO: extend this test-case (test next/prev)
49 # - wrapping (no horizontal switch possible, goes level-up)
50 # - going level-up "manually"
52 ######################################################################
53 # Test splitting multiple times without actually creating windows
54 ######################################################################
56 $tmp = fresh_workspace;
59 is($ws->{orientation}, 'horizontal', 'orientation horizontal by default');
62 is($ws->{orientation}, 'vertical', 'split v changes workspace orientation');
65 my @content = @{get_ws_content($tmp)};
67 # recursively sums up all nodes and their children
71 return 0 if !@{$nodes};
73 my @children = (map { @{$_->{nodes}} } @{$nodes},
74 map { @{$_->{'floating_nodes'}} } @{$nodes});
76 return @{$nodes} + sum_nodes(\@children);
79 my $old_count = sum_nodes(\@content);
82 @content = @{get_ws_content($tmp)};
83 $old_count = sum_nodes(\@content);
87 @content = @{get_ws_content($tmp)};
88 my $count = sum_nodes(\@content);
89 is($count, $old_count, 'not more windows after splitting again');