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