]> git.sur5r.net Git - i3/i3/blobdiff - testcases/t/122-split.t
added "toggle" option to "split" command
[i3/i3] / testcases / t / 122-split.t
index 01765e1e92a8dbeb9f09081c8812b0c705d041e4..6fd9b0e747313da53d43707c7601960f5c7d2e81 100644 (file)
@@ -48,7 +48,7 @@ sub verify_split_layout {
 
     is(@{$first->{nodes}}, 0, 'first container has no children');
     is(@{$second->{nodes}}, 0, 'second container has no children (yet)');
-    my $old_name = $second->{name};
+    my $old_id = $second->{id};
 
     cmd $args{split_command};
     cmd 'open';
@@ -60,10 +60,10 @@ sub verify_split_layout {
     $second = $content->[1];
 
     is(@{$first->{nodes}}, 0, 'first container has no children');
-    isnt($second->{name}, $old_name, 'second container was replaced');
+    isnt($second->{id}, $old_id, '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($second->{nodes}->[0]->{id}, $old_id, 'found old second container');
 }
 
 verify_split_layout(split_command => 'split h');
@@ -145,7 +145,7 @@ sub get_output_content {
     is(scalar @outputs, 1, 'exactly one output (testcase not multi-monitor capable)');
     my $output = $outputs[0];
     # get the first (and only) CT_CON
-    return first { $_->{type} == 2 } @{$output->{nodes}};
+    return first { $_->{type} eq 'con' } @{$output->{nodes}};
 }
 
 $tmp = fresh_workspace;
@@ -158,4 +158,54 @@ is(get_output_content()->{layout}, 'splith', 'content container layout ok');
 cmd 'layout stacked';
 is(get_output_content()->{layout}, 'splith', 'content container layout still ok');
 
+######################################################################
+# Splitting a workspace that has more than one child
+######################################################################
+
+$tmp = fresh_workspace;
+
+cmd 'open';
+cmd 'open';
+cmd 'focus parent';
+cmd 'split v';
+cmd 'open';
+
+my $content = get_ws_content($tmp);
+my $fst = $content->[0];
+my $snd = $content->[1];
+
+is(@{$content}, 2, 'two containers on workspace');
+is(@{$fst->{nodes}}, 2, 'first child has two children');
+is(@{$snd->{nodes}}, 0, 'second child has no children');
+
+######################################################################
+# Test split toggle
+######################################################################
+
+$tmp = fresh_workspace;
+cmd 'split h';
+cmd 'split toggle';
+$ws = get_ws($tmp);
+is($ws->{layout}, 'splitv', 'toggled workspace split');
+
+$tmp = fresh_workspace;
+cmd 'split h';
+cmd 'split toggle';
+cmd 'split toggle';
+$ws = get_ws($tmp);
+is($ws->{layout}, 'splith', 'toggled workspace back and forth');
+
+cmd 'open';
+cmd 'open';
+cmd 'split toggle';
+
+$content = get_ws_content($tmp);
+my $second = $content->[1];
+is($second->{layout}, 'splitv', 'toggled container orientation to vertical');
+
+cmd 'split toggle';
+$content = get_ws_content($tmp);
+$second = $content->[1];
+is($second->{layout}, 'splith', 'toggled container orientation back to horizontal');
+
 done_testing;