]> git.sur5r.net Git - i3/i3/blob - testcases/t/167-workspace_layout.t
Merge branch 'master' into next
[i3/i3] / testcases / t / 167-workspace_layout.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Tests the workspace_layout config option.
5 #
6
7 use i3test i3_autostart => 0;
8
9 #####################################################################
10 # 1: check that with an empty config, cons are place next to each
11 # other and no split containers are created
12 #####################################################################
13
14 my $config = <<EOT;
15 # i3 config file (v4)
16 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
17 EOT
18
19 my $pid = launch_with_config($config);
20
21 my $tmp = fresh_workspace;
22
23 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
24
25 my $first = open_window;
26 my $second = open_window;
27
28 is($x->input_focus, $second->id, 'second window focused');
29 my @content = @{get_ws_content($tmp)};
30 ok(@content == 2, 'two containers opened');
31 isnt($content[0]->{layout}, 'stacked', 'layout not stacked');
32 isnt($content[1]->{layout}, 'stacked', 'layout not stacked');
33
34 exit_gracefully($pid);
35
36 #####################################################################
37 # 2: set workspace_layout stacked, check that when opening two cons,
38 # they end up in a stacked con
39 #####################################################################
40
41 $config = <<EOT;
42 # i3 config file (v4)
43 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
44 workspace_layout stacked
45 EOT
46
47 $pid = launch_with_config($config);
48
49 $tmp = fresh_workspace;
50
51 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
52
53 $first = open_window;
54 $second = open_window;
55
56 is($x->input_focus, $second->id, 'second window focused');
57 @content = @{get_ws_content($tmp)};
58 ok(@content == 1, 'one con at workspace level');
59 is($content[0]->{layout}, 'stacked', 'layout stacked');
60
61 #####################################################################
62 # 3: focus parent, open two new cons, check that they end up in a stacked
63 # con
64 #####################################################################
65
66 cmd 'focus parent';
67 my $right_top = open_window;
68 my $right_bot = open_window;
69
70 @content = @{get_ws_content($tmp)};
71 is(@content, 2, 'two cons at workspace level after focus parent');
72 is($content[0]->{layout}, 'stacked', 'layout stacked');
73 is($content[1]->{layout}, 'stacked', 'layout stacked');
74
75 #####################################################################
76 # 4: move one of the cons to the right, check that it will end up in
77 # a stacked con
78 #####################################################################
79
80 cmd 'move right';
81
82 @content = @{get_ws_content($tmp)};
83 is(@content, 3, 'three cons at workspace level after move');
84 is($content[0]->{layout}, 'stacked', 'layout stacked');
85 is($content[1]->{layout}, 'stacked', 'layout stacked');
86 is($content[2]->{layout}, 'stacked', 'layout stacked');
87
88 #####################################################################
89 # 5: move it to the left again, check that the stacked con is deleted
90 #####################################################################
91
92 cmd 'move left';
93
94 @content = @{get_ws_content($tmp)};
95 is(@content, 2, 'two cons at workspace level after moving back');
96 is($content[0]->{layout}, 'stacked', 'layout stacked');
97 is($content[1]->{layout}, 'stacked', 'layout stacked');
98
99 #####################################################################
100 # 6: move it to a different workspace, check that it ends up in a
101 # stacked con
102 #####################################################################
103
104 my $otmp = get_unused_workspace;
105
106 cmd "move workspace $otmp";
107
108 @content = @{get_ws_content($tmp)};
109 is(@content, 2, 'still two cons on this workspace');
110 is($content[0]->{layout}, 'stacked', 'layout stacked');
111 is($content[1]->{layout}, 'stacked', 'layout stacked');
112
113 @content = @{get_ws_content($otmp)};
114 is(@content, 1, 'one con on target workspace');
115 is($content[0]->{layout}, 'stacked', 'layout stacked');
116
117 exit_gracefully($pid);
118
119 done_testing;