2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • http://build.i3wm.org/docs/ipc.html
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 # (unless you are already familiar with Perl)
17 # Checks that the bar config is parsed correctly.
20 use i3test i3_autostart => 0;
22 #####################################################################
23 # test a config without any bars
24 #####################################################################
28 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
31 my $pid = launch_with_config($config);
33 my $i3 = i3(get_socket_path(0));
34 my $bars = $i3->get_bar_config()->recv;
35 is(@$bars, 0, 'no bars configured');
37 exit_gracefully($pid);
39 #####################################################################
40 # now provide a simple bar configuration
41 #####################################################################
45 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
48 # Start a default instance of i3bar which provides workspace buttons.
49 # Additionally, i3status will provide a statusline.
50 status_command i3status --foo
54 $pid = launch_with_config($config);
56 $i3 = i3(get_socket_path(0));
57 $bars = $i3->get_bar_config()->recv;
58 is(@$bars, 1, 'one bar configured');
60 my $bar_id = shift @$bars;
62 my $bar_config = $i3->get_bar_config($bar_id)->recv;
63 is($bar_config->{status_command}, 'i3status --foo', 'status_command correct');
64 ok(!$bar_config->{verbose}, 'verbose off by default');
65 ok($bar_config->{workspace_buttons}, 'workspace buttons enabled per default');
66 ok($bar_config->{binding_mode_indicator}, 'mode indicator enabled per default');
67 is($bar_config->{mode}, 'dock', 'dock mode by default');
68 is($bar_config->{position}, 'bottom', 'position bottom by default');
70 #####################################################################
71 # ensure that reloading cleans up the old bar configs
72 #####################################################################
75 $bars = $i3->get_bar_config()->recv;
76 is(@$bars, 1, 'still one bar configured');
78 exit_gracefully($pid);
80 #####################################################################
81 # validate a more complex configuration
82 #####################################################################
86 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
89 # Start a default instance of i3bar which does not provide
91 # Additionally, i3status will provide a statusline.
92 status_command i3status --bar
103 binding_mode_indicator no
105 socket_path /tmp/foobar
111 focused_workspace #4c7899 #285577 #ffffff
112 active_workspace #333333 #222222 #888888
113 inactive_workspace #333333 #222222 #888888
114 urgent_workspace #2f343a #900000 #ffffff
119 $pid = launch_with_config($config);
121 $i3 = i3(get_socket_path(0));
122 $bars = $i3->get_bar_config()->recv;
123 is(@$bars, 1, 'one bar configured');
125 $bar_id = shift @$bars;
127 $bar_config = $i3->get_bar_config($bar_id)->recv;
128 is($bar_config->{status_command}, 'i3status --bar', 'status_command correct');
129 ok($bar_config->{verbose}, 'verbose on');
130 ok(!$bar_config->{workspace_buttons}, 'workspace buttons disabled');
131 ok(!$bar_config->{binding_mode_indicator}, 'mode indicator disabled');
132 is($bar_config->{mode}, 'dock', 'dock mode');
133 is($bar_config->{position}, 'top', 'position top');
134 is_deeply($bar_config->{outputs}, [ 'HDMI1', 'HDMI2' ], 'outputs ok');
135 is($bar_config->{tray_output}, 'HDMI2', 'tray_output ok');
136 is($bar_config->{font}, 'Terminus', 'font ok');
137 is($bar_config->{socket_path}, '/tmp/foobar', 'socket_path ok');
138 is_deeply($bar_config->{colors},
140 background => '#ff0000',
141 statusline => '#00ff00',
142 focused_workspace_border => '#4c7899',
143 focused_workspace_text => '#ffffff',
144 focused_workspace_bg => '#285577',
145 active_workspace_border => '#333333',
146 active_workspace_text => '#888888',
147 active_workspace_bg => '#222222',
148 inactive_workspace_border => '#333333',
149 inactive_workspace_text => '#888888',
150 inactive_workspace_bg => '#222222',
151 urgent_workspace_border => '#2f343a',
152 urgent_workspace_text => '#ffffff',
153 urgent_workspace_bg => '#900000',
156 exit_gracefully($pid);
158 #####################################################################
159 # ensure that multiple bars get different IDs
160 #####################################################################
163 # i3 config file (v4)
164 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
167 # Start a default instance of i3bar which provides workspace buttons.
168 # Additionally, i3status will provide a statusline.
169 status_command i3status --bar
179 $pid = launch_with_config($config);
181 $i3 = i3(get_socket_path(0));
182 $bars = $i3->get_bar_config()->recv;
183 is(@$bars, 2, 'two bars configured');
184 isnt($bars->[0], $bars->[1], 'bar IDs are different');
186 my $bar1_config = $i3->get_bar_config($bars->[0])->recv;
187 my $bar2_config = $i3->get_bar_config($bars->[1])->recv;
189 isnt($bar1_config->{outputs}, $bar2_config->{outputs}, 'outputs different');
191 exit_gracefully($pid);
193 #####################################################################
194 # make sure comments work properly
195 #####################################################################
198 # i3 config file (v4)
199 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
202 # Start a default instance of i3bar which provides workspace buttons.
203 # Additionally, i3status will provide a statusline.
204 status_command i3status --bar
205 #status_command i3status --qux
206 #status_command i3status --qux
216 $pid = launch_with_config($config);
218 $i3 = i3(get_socket_path(0));
219 $bars = $i3->get_bar_config()->recv;
220 $bar_id = shift @$bars;
222 $bar_config = $i3->get_bar_config($bar_id)->recv;
223 is($bar_config->{status_command}, 'i3status --bar', 'status_command correct');
224 is($bar_config->{colors}->{background}, '#000000', 'background color ok');
226 exit_gracefully($pid);
228 #####################################################################
229 # verify that the old syntax still works
230 #####################################################################
233 # i3 config file (v4)
234 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
237 # Start a default instance of i3bar which does not provide
239 # Additionally, i3status will provide a statusline.
240 status_command i3status --bar
251 binding_mode_indicator yes
253 socket_path /tmp/foobar
259 focused_workspace #ffffff #285577
260 active_workspace #888888 #222222
261 inactive_workspace #888888 #222222
262 urgent_workspace #ffffff #900000
267 $pid = launch_with_config($config);
269 $i3 = i3(get_socket_path(0));
270 $bars = $i3->get_bar_config()->recv;
271 is(@$bars, 1, 'one bar configured');
273 $bar_id = shift @$bars;
276 $bar_config = $i3->get_bar_config($bar_id)->recv;
277 is($bar_config->{status_command}, 'i3status --bar', 'status_command correct');
278 ok($bar_config->{verbose}, 'verbose on');
279 ok(!$bar_config->{workspace_buttons}, 'workspace buttons disabled');
280 ok($bar_config->{binding_mode_indicator}, 'mode indicator enabled');
281 is($bar_config->{mode}, 'dock', 'dock mode');
282 is($bar_config->{position}, 'top', 'position top');
283 is_deeply($bar_config->{outputs}, [ 'HDMI1', 'HDMI2' ], 'outputs ok');
284 is($bar_config->{tray_output}, 'HDMI2', 'tray_output ok');
285 is($bar_config->{font}, 'Terminus', 'font ok');
286 is($bar_config->{socket_path}, '/tmp/foobar', 'socket_path ok');
287 is_deeply($bar_config->{colors},
289 background => '#ff0000',
290 statusline => '#00ff00',
291 focused_workspace_text => '#ffffff',
292 focused_workspace_bg => '#285577',
293 active_workspace_text => '#888888',
294 active_workspace_bg => '#222222',
295 inactive_workspace_text => '#888888',
296 inactive_workspace_bg => '#222222',
297 urgent_workspace_text => '#ffffff',
298 urgent_workspace_bg => '#900000',
299 }, '(old) colors ok');
301 exit_gracefully($pid);