]> git.sur5r.net Git - i3/i3/blob - testcases/t/167-workspace_layout.t
testcases: correctly enable lexical pragmata
[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 use X11::XCB qw(:all);
10 use X11::XCB::Connection;
11
12 my $x = X11::XCB::Connection->new;
13
14 #####################################################################
15 # 1: check that with an empty config, cons are place next to each
16 # other and no split containers are created
17 #####################################################################
18
19 my $config = <<EOT;
20 # i3 config file (v4)
21 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
22 EOT
23
24 my $pid = launch_with_config($config);
25
26 my $tmp = fresh_workspace;
27
28 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
29
30 my $first = open_window($x);
31 my $second = open_window($x);
32
33 sync_with_i3($x);
34
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');
40
41 exit_gracefully($pid);
42
43 #####################################################################
44 # 2: set workspace_layout stacked, check that when opening two cons,
45 # they end up in a stacked con
46 #####################################################################
47
48 $config = <<EOT;
49 # i3 config file (v4)
50 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
51 workspace_layout stacked
52 EOT
53
54 $pid = launch_with_config($config);
55
56 $tmp = fresh_workspace;
57
58 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
59
60 $first = open_window($x);
61 $second = open_window($x);
62
63 sync_with_i3($x);
64
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');
69
70 #####################################################################
71 # 3: focus parent, open two new cons, check that they end up in a stacked
72 # con
73 #####################################################################
74
75 cmd 'focus parent';
76 my $right_top = open_window($x);
77 my $right_bot = open_window($x);
78
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');
83
84 #####################################################################
85 # 4: move one of the cons to the right, check that it will end up in
86 # a stacked con
87 #####################################################################
88
89 cmd 'move right';
90
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');
96
97 #####################################################################
98 # 5: move it to the left again, check that the stacked con is deleted
99 #####################################################################
100
101 cmd 'move left';
102
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');
107
108 #####################################################################
109 # 6: move it to a different workspace, check that it ends up in a
110 # stacked con
111 #####################################################################
112
113 my $otmp = get_unused_workspace;
114
115 cmd "move workspace $otmp";
116
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');
121
122 @content = @{get_ws_content($otmp)};
123 is(@content, 1, 'one con on target workspace');
124 is($content[0]->{layout}, 'stacked', 'layout stacked');
125
126 exit_gracefully($pid);
127
128 done_testing;