From 07d07719f047de0aed545036bba1dba4b1076481 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sun, 8 Jan 2012 11:59:24 +0000 Subject: [PATCH] add testcase for 'focus output' --- testcases/t/502-focus-output.t | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 testcases/t/502-focus-output.t diff --git a/testcases/t/502-focus-output.t b/testcases/t/502-focus-output.t new file mode 100644 index 00000000..139b670a --- /dev/null +++ b/testcases/t/502-focus-output.t @@ -0,0 +1,50 @@ +#!perl +# vim:ts=4:sw=4:expandtab +# +# Verifies the 'focus output' command works properly. + +use i3test; +use List::Util qw(first); + +my $tmp = fresh_workspace; +my $i3 = i3(get_socket_path()); + +################################################################################ +# use 'focus output' and verify that focus gets changed appropriately +################################################################################ + +sub focused_output { + my $tree = $i3->get_tree->recv; + my $focused = $tree->{focus}->[0]; + my $output = first { $_->{id} == $focused } @{$tree->{nodes}}; + return $output->{name}; +} + +is(focused_output, 'xinerama-0', 'focus on first output'); + +cmd 'focus output right'; +is(focused_output, 'xinerama-1', 'focus on second output'); + +# focus should wrap when we focus to the right again. +cmd 'focus output right'; +is(focused_output, 'xinerama-0', 'focus on first output again'); + +cmd 'focus output left'; +is(focused_output, 'xinerama-1', 'focus back on second output'); + +cmd 'focus output left'; +is(focused_output, 'xinerama-0', 'focus on first output again'); + +cmd 'focus output up'; +is(focused_output, 'xinerama-0', 'focus still on first output'); + +cmd 'focus output down'; +is(focused_output, 'xinerama-0', 'focus still on first output'); + +cmd 'focus output xinerama-1'; +is(focused_output, 'xinerama-1', 'focus on second output'); + +cmd 'focus output xinerama-0'; +is(focused_output, 'xinerama-0', 'focus on first output'); + +done_testing; -- 2.39.5