2 # vim:ts=4:sw=4:expandtab
3 # !NO_I3_INSTANCE! will prevent complete-run.pl from starting i3
5 # Tests the workspace_layout config option.
10 use X11::XCB::Connection;
12 my $x = X11::XCB::Connection->new;
14 #####################################################################
15 # 1: check that with an empty config, cons are place next to each
16 # other and no split containers are created
17 #####################################################################
21 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
24 my $pid = launch_with_config($config);
26 my $tmp = fresh_workspace;
28 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
30 my $first = open_window($x);
31 my $second = open_window($x);
35 is($x->input_focus, $second->id, 'second window focused');
36 my @content = @{get_ws_content($tmp)};
37 ok(@content == 2, 'two containers opened');
38 isnt($content[0]->{layout}, 'stacked', 'layout not stacked');
39 isnt($content[1]->{layout}, 'stacked', 'layout not stacked');
41 exit_gracefully($pid);
43 #####################################################################
44 # 2: set workspace_layout stacked, check that when opening two cons,
45 # they end up in a stacked con
46 #####################################################################
50 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
51 workspace_layout stacked
54 $pid = launch_with_config($config);
56 $tmp = fresh_workspace;
58 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
60 $first = open_window($x);
61 $second = open_window($x);
65 is($x->input_focus, $second->id, 'second window focused');
66 @content = @{get_ws_content($tmp)};
67 ok(@content == 1, 'one con at workspace level');
68 is($content[0]->{layout}, 'stacked', 'layout stacked');
70 #####################################################################
71 # 3: focus parent, open two new cons, check that they end up in a stacked
73 #####################################################################
76 my $right_top = open_window($x);
77 my $right_bot = open_window($x);
79 @content = @{get_ws_content($tmp)};
80 is(@content, 2, 'two cons at workspace level after focus parent');
81 is($content[0]->{layout}, 'stacked', 'layout stacked');
82 is($content[1]->{layout}, 'stacked', 'layout stacked');
84 #####################################################################
85 # 4: move one of the cons to the right, check that it will end up in
87 #####################################################################
91 @content = @{get_ws_content($tmp)};
92 is(@content, 3, 'three cons at workspace level after move');
93 is($content[0]->{layout}, 'stacked', 'layout stacked');
94 is($content[1]->{layout}, 'stacked', 'layout stacked');
95 is($content[2]->{layout}, 'stacked', 'layout stacked');
97 #####################################################################
98 # 5: move it to the left again, check that the stacked con is deleted
99 #####################################################################
103 @content = @{get_ws_content($tmp)};
104 is(@content, 2, 'two cons at workspace level after moving back');
105 is($content[0]->{layout}, 'stacked', 'layout stacked');
106 is($content[1]->{layout}, 'stacked', 'layout stacked');
108 #####################################################################
109 # 6: move it to a different workspace, check that it ends up in a
111 #####################################################################
113 my $otmp = get_unused_workspace;
115 cmd "move workspace $otmp";
117 @content = @{get_ws_content($tmp)};
118 is(@content, 2, 'still two cons on this workspace');
119 is($content[0]->{layout}, 'stacked', 'layout stacked');
120 is($content[1]->{layout}, 'stacked', 'layout stacked');
122 @content = @{get_ws_content($otmp)};
123 is(@content, 1, 'one con on target workspace');
124 is($content[0]->{layout}, 'stacked', 'layout stacked');
126 exit_gracefully($pid);