From d9f3a31cb7bc1de1c5b1d684e0a34ed4a6de00b6 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 18 Oct 2011 22:15:48 +0100 Subject: [PATCH] tests: add a test to check that bar configs are parsed correctly --- testcases/t/177-bar-config.t | 130 +++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 testcases/t/177-bar-config.t diff --git a/testcases/t/177-bar-config.t b/testcases/t/177-bar-config.t new file mode 100644 index 00000000..98eb4edd --- /dev/null +++ b/testcases/t/177-bar-config.t @@ -0,0 +1,130 @@ +#!perl +# vim:ts=4:sw=4:expandtab +# !NO_I3_INSTANCE! will prevent complete-run.pl from starting i3 +# +# Checks that the bar config is parsed correctly. +# + +use i3test; + +##################################################################### +# 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'); +is($bar_config->{mode}, 'hide', 'hide mode by default'); +is($bar_config->{position}, 'bottom', 'position bottom by default'); + +exit_gracefully($pid); + +##################################################################### +# validate a more complex 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 --bar', 'status_command correct'); +ok($bar_config->{verbose}, 'verbose on'); +ok(!$bar_config->{workspace_buttons}, 'workspace buttons 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->{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', + }, 'colors ok'); + +exit_gracefully($pid); + +done_testing;