]> git.sur5r.net Git - i3/i3/blobdiff - testcases/t/122-split.t
Merge branch 'master' into next
[i3/i3] / testcases / t / 122-split.t
index 702679ac41e734880fc2a951231b2d853c81dcfd..d491c37a47451057132eca9acf6ab47e773fd5d4 100644 (file)
@@ -5,45 +5,55 @@
 #
 use i3test;
 
-my $tmp = fresh_workspace;
+my $tmp;
+my $ws;
 
-my $ws = get_ws($tmp);
-is($ws->{orientation}, 'horizontal', 'orientation horizontal by default');
-cmd 'split v';
-$ws = get_ws($tmp);
-is($ws->{orientation}, 'vertical', 'split v changes workspace orientation');
-
-######################################################################
+################################################################################
 # Open two containers, split, open another container. Then verify
 # the layout is like we expect it to be
-######################################################################
-cmd 'open';
-cmd 'open';
-my $content = get_ws_content($tmp);
+################################################################################
 
-is(@{$content}, 2, 'two containers on workspace level');
-my $first = $content->[0];
-my $second = $content->[1];
+sub verify_split_layout {
+    my (%args) = @_;
 
-is(@{$first->{nodes}}, 0, 'first container has no children');
-is(@{$second->{nodes}}, 0, 'second container has no children (yet)');
-my $old_name = $second->{name};
+    $tmp = fresh_workspace;
 
+    $ws = get_ws($tmp);
+    is($ws->{layout}, 'splith', 'orientation horizontal by default');
+    cmd 'split v';
+    $ws = get_ws($tmp);
+    is($ws->{layout}, 'splitv', 'split v changes workspace orientation');
 
-cmd 'split h';
-cmd 'open';
+    cmd 'open';
+    cmd 'open';
+    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};
 
-$content = get_ws_content($tmp);
+    cmd $args{split_command};
+    cmd 'open';
 
-is(@{$content}, 2, 'two containers on workspace level');
-$first = $content->[0];
-$second = $content->[1];
+    $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');
+    is($second->{layout}, 'splith', 'orientation is horizontal');
+    is(@{$second->{nodes}}, 2, 'second container has 2 children');
+    is($second->{nodes}->[0]->{name}, $old_name, 'found old second container');
+}
 
-is(@{$first->{nodes}}, 0, 'first container has no children');
-isnt($second->{name}, $old_name, 'second container was replaced');
-is($second->{orientation}, 'horizontal', 'orientation is horizontal');
-is(@{$second->{nodes}}, 2, 'second container has 2 children');
-is($second->{nodes}->[0]->{name}, $old_name, 'found old second container');
+verify_split_layout(split_command => 'split h');
+verify_split_layout(split_command => 'split horizontal');
 
 # TODO: extend this test-case (test next/prev)
 # - wrapping (no horizontal switch possible, goes level-up)
@@ -56,10 +66,10 @@ is($second->{nodes}->[0]->{name}, $old_name, 'found old second container');
 $tmp = fresh_workspace;
 
 $ws = get_ws($tmp);
-is($ws->{orientation}, 'horizontal', 'orientation horizontal by default');
+is($ws->{layout}, 'splith', 'orientation horizontal by default');
 cmd 'split v';
 $ws = get_ws($tmp);
-is($ws->{orientation}, 'vertical', 'split v changes workspace orientation');
+is($ws->{layout}, 'splitv', 'split v changes workspace orientation');
 
 cmd 'open';
 my @content = @{get_ws_content($tmp)};