#!perl # vim:ts=4:sw=4:expandtab # # Please read the following documents before working on tests: # • http://build.i3wm.org/docs/testsuite.html # (or docs/testsuite) # # • http://build.i3wm.org/docs/lib-i3test.html # (alternatively: perldoc ./testcases/lib/i3test.pm) # # • http://build.i3wm.org/docs/ipc.html # (or docs/ipc) # # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf # (unless you are already familiar with Perl) # # Checks that the bar config is parsed correctly. # use i3test i3_autostart => 0; ##################################################################### # test a config without any bars ##################################################################### my $config = <get_bar_config()->recv; is(@$bars, 0, 'no bars configured'); exit_gracefully($pid); ##################################################################### # now provide a simple bar configuration ##################################################################### $config = <get_bar_config()->recv; is(@$bars, 1, 'one bar configured'); my $bar_id = shift @$bars; my $bar_config = $i3->get_bar_config($bar_id)->recv; is($bar_config->{status_command}, 'i3status --foo', 'status_command correct'); ok(!$bar_config->{verbose}, 'verbose off by default'); ok($bar_config->{workspace_buttons}, 'workspace buttons enabled per default'); ok($bar_config->{binding_mode_indicator}, 'mode indicator enabled per default'); is($bar_config->{mode}, 'dock', 'dock mode by default'); is($bar_config->{position}, 'bottom', 'position bottom by default'); is($bar_config->{tray_padding}, 2, 'tray_padding ok'); ##################################################################### # ensure that reloading cleans up the old bar configs ##################################################################### cmd 'reload'; $bars = $i3->get_bar_config()->recv; is(@$bars, 1, 'still one bar configured'); exit_gracefully($pid); ##################################################################### # validate a more complex configuration ##################################################################### $config = <get_bar_config()->recv; is(@$bars, 1, 'one bar configured'); $bar_id = shift @$bars; $bar_config = $i3->get_bar_config($bar_id)->recv; is($bar_config->{status_command}, 'i3status --bar', 'status_command correct'); ok($bar_config->{verbose}, 'verbose on'); ok(!$bar_config->{workspace_buttons}, 'workspace buttons disabled'); ok(!$bar_config->{binding_mode_indicator}, 'mode indicator disabled'); is($bar_config->{mode}, 'dock', 'dock mode'); is($bar_config->{position}, 'top', 'position top'); is_deeply($bar_config->{outputs}, [ 'HDMI1', 'HDMI2' ], 'outputs ok'); is($bar_config->{tray_output}, 'HDMI2', 'tray_output ok'); is($bar_config->{tray_padding}, 0, 'tray_padding ok'); is($bar_config->{font}, 'Terminus', 'font ok'); is($bar_config->{socket_path}, '/tmp/foobar', 'socket_path ok'); is_deeply($bar_config->{colors}, { background => '#ff0000', statusline => '#00ff00', focused_background => '#cc0000', focused_statusline=> '#cccc00', focused_separator => '#0000cc', focused_workspace_border => '#4c7899', focused_workspace_text => '#ffffff', focused_workspace_bg => '#285577', active_workspace_border => '#333333', active_workspace_text => '#888888', active_workspace_bg => '#222222', inactive_workspace_border => '#333333', inactive_workspace_text => '#888888', inactive_workspace_bg => '#222222', urgent_workspace_border => '#2f343a', urgent_workspace_text => '#ffffff', urgent_workspace_bg => '#900000', binding_mode_border => '#abc123', binding_mode_text => '#ababab', binding_mode_bg => '#123abc', }, 'colors ok'); exit_gracefully($pid); ##################################################################### # ensure that multiple bars get different IDs ##################################################################### $config = <get_bar_config()->recv; is(@$bars, 2, 'two bars configured'); isnt($bars->[0], $bars->[1], 'bar IDs are different'); my $bar1_config = $i3->get_bar_config($bars->[0])->recv; my $bar2_config = $i3->get_bar_config($bars->[1])->recv; isnt($bar1_config->{outputs}, $bar2_config->{outputs}, 'outputs different'); exit_gracefully($pid); ##################################################################### # make sure comments work properly ##################################################################### $config = <get_bar_config()->recv; $bar_id = shift @$bars; $bar_config = $i3->get_bar_config($bar_id)->recv; is($bar_config->{status_command}, 'i3status --bar', 'status_command correct'); is($bar_config->{colors}->{background}, '#000000', 'background color ok'); exit_gracefully($pid); ##################################################################### # verify that the old syntax still works ##################################################################### $config = <get_bar_config()->recv; is(@$bars, 1, 'one bar configured'); $bar_id = shift @$bars; cmd 'nop yeah'; $bar_config = $i3->get_bar_config($bar_id)->recv; is($bar_config->{status_command}, 'i3status --bar', 'status_command correct'); ok($bar_config->{verbose}, 'verbose on'); ok(!$bar_config->{workspace_buttons}, 'workspace buttons disabled'); ok($bar_config->{binding_mode_indicator}, 'mode indicator enabled'); is($bar_config->{mode}, 'dock', 'dock mode'); is($bar_config->{position}, 'top', 'position top'); is_deeply($bar_config->{outputs}, [ 'HDMI1', 'HDMI2' ], 'outputs ok'); is($bar_config->{tray_output}, 'HDMI2', 'tray_output ok'); is($bar_config->{font}, 'Terminus', 'font ok'); is($bar_config->{socket_path}, '/tmp/foobar', 'socket_path ok'); is_deeply($bar_config->{colors}, { background => '#ff0000', statusline => '#00ff00', focused_workspace_text => '#ffffff', focused_workspace_bg => '#285577', active_workspace_text => '#888888', active_workspace_bg => '#222222', inactive_workspace_text => '#888888', inactive_workspace_bg => '#222222', urgent_workspace_text => '#ffffff', urgent_workspace_bg => '#900000', }, '(old) colors ok'); exit_gracefully($pid); done_testing;