2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • https://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');
69 is($bar_config->{tray_padding}, 2, 'tray_padding ok');
71 #####################################################################
72 # ensure that reloading cleans up the old bar configs
73 #####################################################################
76 $bars = $i3->get_bar_config()->recv;
77 is(@$bars, 1, 'still one bar configured');
79 exit_gracefully($pid);
81 #####################################################################
82 # validate a more complex configuration
83 #####################################################################
87 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
90 # Start a default instance of i3bar which does not provide
92 # Additionally, i3status will provide a statusline.
93 status_command i3status --bar
105 binding_mode_indicator no
107 socket_path /tmp/foobar
112 focused_background #cc0000
113 focused_statusline #cccc00
114 focused_separator #0000cc
116 focused_workspace #4c7899 #285577 #ffffff
117 active_workspace #333333 #222222 #888888
118 inactive_workspace #333333 #222222 #888888
119 urgent_workspace #2f343a #900000 #ffffff
120 binding_mode #abc123 #123abc #ababab
125 $pid = launch_with_config($config);
127 $i3 = i3(get_socket_path(0));
128 $bars = $i3->get_bar_config()->recv;
129 is(@$bars, 1, 'one bar configured');
131 $bar_id = shift @$bars;
133 $bar_config = $i3->get_bar_config($bar_id)->recv;
134 is($bar_config->{status_command}, 'i3status --bar', 'status_command correct');
135 ok($bar_config->{verbose}, 'verbose on');
136 ok(!$bar_config->{workspace_buttons}, 'workspace buttons disabled');
137 ok(!$bar_config->{binding_mode_indicator}, 'mode indicator disabled');
138 is($bar_config->{mode}, 'dock', 'dock mode');
139 is($bar_config->{position}, 'top', 'position top');
140 is_deeply($bar_config->{outputs}, [ 'HDMI1', 'HDMI2' ], 'outputs ok');
141 is_deeply($bar_config->{tray_outputs}, [ 'LVDS1', 'HDMI2' ], 'tray_output ok');
142 is($bar_config->{tray_padding}, 0, 'tray_padding ok');
143 is($bar_config->{font}, 'Terminus', 'font ok');
144 is($bar_config->{socket_path}, '/tmp/foobar', 'socket_path ok');
145 is_deeply($bar_config->{colors},
147 background => '#ff0000',
148 statusline => '#00ff00',
149 focused_background => '#cc0000',
150 focused_statusline=> '#cccc00',
151 focused_separator => '#0000cc',
152 focused_workspace_border => '#4c7899',
153 focused_workspace_text => '#ffffff',
154 focused_workspace_bg => '#285577',
155 active_workspace_border => '#333333',
156 active_workspace_text => '#888888',
157 active_workspace_bg => '#222222',
158 inactive_workspace_border => '#333333',
159 inactive_workspace_text => '#888888',
160 inactive_workspace_bg => '#222222',
161 urgent_workspace_border => '#2f343a',
162 urgent_workspace_text => '#ffffff',
163 urgent_workspace_bg => '#900000',
164 binding_mode_border => '#abc123',
165 binding_mode_text => '#ababab',
166 binding_mode_bg => '#123abc',
169 exit_gracefully($pid);
171 #####################################################################
172 # ensure that multiple bars get different IDs
173 #####################################################################
176 # i3 config file (v4)
177 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
180 # Start a default instance of i3bar which provides workspace buttons.
181 # Additionally, i3status will provide a statusline.
182 status_command i3status --bar
192 $pid = launch_with_config($config);
194 $i3 = i3(get_socket_path(0));
195 $bars = $i3->get_bar_config()->recv;
196 is(@$bars, 2, 'two bars configured');
197 isnt($bars->[0], $bars->[1], 'bar IDs are different');
199 my $bar1_config = $i3->get_bar_config($bars->[0])->recv;
200 my $bar2_config = $i3->get_bar_config($bars->[1])->recv;
202 isnt($bar1_config->{outputs}, $bar2_config->{outputs}, 'outputs different');
204 exit_gracefully($pid);
206 #####################################################################
207 # make sure comments work properly
208 #####################################################################
211 # i3 config file (v4)
212 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
215 # Start a default instance of i3bar which provides workspace buttons.
216 # Additionally, i3status will provide a statusline.
217 status_command i3status --bar
218 #status_command i3status --qux
219 #status_command i3status --qux
229 $pid = launch_with_config($config);
231 $i3 = i3(get_socket_path(0));
232 $bars = $i3->get_bar_config()->recv;
233 $bar_id = shift @$bars;
235 $bar_config = $i3->get_bar_config($bar_id)->recv;
236 is($bar_config->{status_command}, 'i3status --bar', 'status_command correct');
237 is($bar_config->{colors}->{background}, '#000000', 'background color ok');
239 exit_gracefully($pid);
241 #####################################################################
242 # verify that the old syntax still works
243 #####################################################################
246 # i3 config file (v4)
247 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
250 # Start a default instance of i3bar which does not provide
252 # Additionally, i3status will provide a statusline.
253 status_command i3status --bar
264 binding_mode_indicator yes
266 socket_path /tmp/foobar
272 focused_workspace #ffffff #285577
273 active_workspace #888888 #222222
274 inactive_workspace #888888 #222222
275 urgent_workspace #ffffff #900000
280 $pid = launch_with_config($config);
282 $i3 = i3(get_socket_path(0));
283 $bars = $i3->get_bar_config()->recv;
284 is(@$bars, 1, 'one bar configured');
286 $bar_id = shift @$bars;
289 $bar_config = $i3->get_bar_config($bar_id)->recv;
290 is($bar_config->{status_command}, 'i3status --bar', 'status_command correct');
291 ok($bar_config->{verbose}, 'verbose on');
292 ok(!$bar_config->{workspace_buttons}, 'workspace buttons disabled');
293 ok($bar_config->{binding_mode_indicator}, 'mode indicator enabled');
294 is($bar_config->{mode}, 'dock', 'dock mode');
295 is($bar_config->{position}, 'top', 'position top');
296 is_deeply($bar_config->{outputs}, [ 'HDMI1', 'HDMI2' ], 'outputs ok');
297 is_deeply($bar_config->{tray_outputs}, [ 'LVDS1', 'HDMI2' ], 'tray_output ok');
298 is($bar_config->{font}, 'Terminus', 'font ok');
299 is($bar_config->{socket_path}, '/tmp/foobar', 'socket_path ok');
300 is_deeply($bar_config->{colors},
302 background => '#ff0000',
303 statusline => '#00ff00',
304 focused_workspace_text => '#ffffff',
305 focused_workspace_bg => '#285577',
306 active_workspace_text => '#888888',
307 active_workspace_bg => '#222222',
308 inactive_workspace_text => '#888888',
309 inactive_workspace_bg => '#222222',
310 urgent_workspace_text => '#ffffff',
311 urgent_workspace_bg => '#900000',
312 }, '(old) colors ok');
314 exit_gracefully($pid);