]> git.sur5r.net Git - i3/i3/blobdiff - testcases/t/145-flattening.t
Merge pull request #2953 from CyberShadow/focus_wrapping
[i3/i3] / testcases / t / 145-flattening.t
index 9d22afc3d0f955c49e58096a0d7187bf39ca7932..3f84cdc13676771c56f23d6b4092d4fa6f5911b0 100644 (file)
@@ -1,6 +1,19 @@
 #!perl
 # vim:ts=4:sw=4:expandtab
 #
+# Please read the following documents before working on tests:
+# • https://build.i3wm.org/docs/testsuite.html
+#   (or docs/testsuite)
+#
+# • https://build.i3wm.org/docs/lib-i3test.html
+#   (alternatively: perldoc ./testcases/lib/i3test.pm)
+#
+# • https://build.i3wm.org/docs/ipc.html
+#   (or docs/ipc)
+#
+# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
+#   (unless you are already familiar with Perl)
+#
 # by moving the window in the opposite orientation that its parent has, we
 # force i3 to create a new split container with the appropriate orientation.
 # However, when doing that two times in a row, we end up with two split
@@ -22,7 +35,41 @@ cmd 'move up';
 cmd 'move right';
 my $ws = get_ws($tmp);
 
-is($ws->{orientation}, 'horizontal', 'workspace orientation is horizontal');
+is($ws->{layout}, 'splith', 'workspace layout is splith');
 is(@{$ws->{nodes}}, 3, 'all three windows on workspace level');
 
+################################################################################
+# Ticket #1053 provides a sequence of operations where the flattening does not
+# work correctly:
+################################################################################
+
+$tmp = fresh_workspace;
+
+my $tab1 = open_window;
+my $tab2 = open_window;
+$mid = open_window;
+$right = open_window;
+cmd 'focus right';
+cmd 'split v';
+cmd 'focus right';
+cmd 'move left';
+cmd 'layout tabbed';
+cmd 'focus parent';
+cmd 'split v';
+
+$ws = get_ws($tmp);
+my @nodes = @{$ws->{nodes}};
+is(@nodes, 3, 'all three windows on workspace level');
+is($nodes[0]->{layout}, 'splitv', 'first node is splitv');
+is(@{$nodes[0]->{nodes}}, 1, 'one node in the first node');
+is($nodes[0]->{nodes}->[0]->{layout}, 'tabbed', 'tabbed layout');
+is(@{$nodes[0]->{nodes}->[0]->{nodes}}, 2, 'two nodes in that node');
+
+cmd 'focus right';
+cmd 'move left';
+
+$ws = get_ws($tmp);
+@nodes = @{$ws->{nodes}};
+is(@nodes, 2, 'all three windows on workspace level');
+
 done_testing;