]> git.sur5r.net Git - i3/i3/blob - testcases/t/145-flattening.t
Merge "force_focus_wrapping" option into "focus_wrapping force"
[i3/i3] / testcases / t / 145-flattening.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • http://build.i3wm.org/docs/ipc.html
12 #   (or docs/ipc)
13 #
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 #   (unless you are already familiar with Perl)
16 #
17 # by moving the window in the opposite orientation that its parent has, we
18 # force i3 to create a new split container with the appropriate orientation.
19 # However, when doing that two times in a row, we end up with two split
20 # containers which are then redundant (workspace is horizontal, then v-split,
21 # then h-split – we could just append the children of the latest h-split to the
22 # workspace itself).
23 #
24 # This testcase checks that the tree is properly flattened after moving.
25 #
26 use i3test;
27
28 my $tmp = fresh_workspace;
29
30 my $left = open_window;
31 my $mid = open_window;
32 my $right = open_window;
33
34 cmd 'move up';
35 cmd 'move right';
36 my $ws = get_ws($tmp);
37
38 is($ws->{layout}, 'splith', 'workspace layout is splith');
39 is(@{$ws->{nodes}}, 3, 'all three windows on workspace level');
40
41 ################################################################################
42 # Ticket #1053 provides a sequence of operations where the flattening does not
43 # work correctly:
44 ################################################################################
45
46 $tmp = fresh_workspace;
47
48 my $tab1 = open_window;
49 my $tab2 = open_window;
50 $mid = open_window;
51 $right = open_window;
52 cmd 'focus right';
53 cmd 'split v';
54 cmd 'focus right';
55 cmd 'move left';
56 cmd 'layout tabbed';
57 cmd 'focus parent';
58 cmd 'split v';
59
60 $ws = get_ws($tmp);
61 my @nodes = @{$ws->{nodes}};
62 is(@nodes, 3, 'all three windows on workspace level');
63 is($nodes[0]->{layout}, 'splitv', 'first node is splitv');
64 is(@{$nodes[0]->{nodes}}, 1, 'one node in the first node');
65 is($nodes[0]->{nodes}->[0]->{layout}, 'tabbed', 'tabbed layout');
66 is(@{$nodes[0]->{nodes}->[0]->{nodes}}, 2, 'two nodes in that node');
67
68 cmd 'focus right';
69 cmd 'move left';
70
71 $ws = get_ws($tmp);
72 @nodes = @{$ws->{nodes}};
73 is(@nodes, 2, 'all three windows on workspace level');
74
75 done_testing;