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