2010-05-10 00:06:24 +02:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
|
|
|
#
|
2012-09-10 14:09:01 +02:00
|
|
|
# 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)
|
|
|
|
#
|
2010-05-10 00:06:24 +02:00
|
|
|
# Tests focus switching (next/prev)
|
|
|
|
#
|
2011-03-09 20:25:17 +01:00
|
|
|
use i3test;
|
2010-05-10 00:06:24 +02:00
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
my $tmp = fresh_workspace;
|
2010-05-10 00:06:24 +02:00
|
|
|
|
|
|
|
######################################################################
|
2011-06-08 20:49:49 +02:00
|
|
|
# Open one container, verify that 'focus down' and 'focus right' do nothing
|
2010-05-10 00:06:24 +02:00
|
|
|
######################################################################
|
2011-03-09 20:25:17 +01:00
|
|
|
cmd 'open';
|
2010-05-10 00:06:24 +02:00
|
|
|
|
|
|
|
my ($nodes, $focus) = get_ws_content($tmp);
|
|
|
|
my $old_focused = $focus->[0];
|
|
|
|
|
2011-06-08 20:49:49 +02:00
|
|
|
cmd 'focus down';
|
2010-05-10 00:06:24 +02:00
|
|
|
($nodes, $focus) = get_ws_content($tmp);
|
|
|
|
is($focus->[0], $old_focused, 'focus did not change with only one con');
|
|
|
|
|
2011-06-08 20:49:49 +02:00
|
|
|
cmd 'focus right';
|
2010-05-10 00:06:24 +02:00
|
|
|
($nodes, $focus) = get_ws_content($tmp);
|
|
|
|
is($focus->[0], $old_focused, 'focus did not change with only one con');
|
|
|
|
|
|
|
|
######################################################################
|
2011-06-08 20:49:49 +02:00
|
|
|
# Open another container, verify that 'focus right' switches
|
2010-05-10 00:06:24 +02:00
|
|
|
######################################################################
|
2010-05-10 09:08:31 +02:00
|
|
|
my $left = $old_focused;
|
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
cmd 'open';
|
2010-05-10 09:08:31 +02:00
|
|
|
($nodes, $focus) = get_ws_content($tmp);
|
|
|
|
isnt($old_focused, $focus->[0], 'new container is focused');
|
|
|
|
my $mid = $focus->[0];
|
2010-05-10 00:06:24 +02:00
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
cmd 'open';
|
2010-05-10 00:06:24 +02:00
|
|
|
($nodes, $focus) = get_ws_content($tmp);
|
|
|
|
isnt($old_focused, $focus->[0], 'new container is focused');
|
2010-05-10 09:08:31 +02:00
|
|
|
my $right = $focus->[0];
|
|
|
|
|
2011-06-08 20:49:49 +02:00
|
|
|
cmd 'focus right';
|
2010-05-10 09:08:31 +02:00
|
|
|
($nodes, $focus) = get_ws_content($tmp);
|
|
|
|
isnt($focus->[0], $right, 'focus did change');
|
|
|
|
is($focus->[0], $left, 'left container focused (wrapping)');
|
|
|
|
|
2011-06-08 20:49:49 +02:00
|
|
|
cmd 'focus right';
|
2010-05-10 09:08:31 +02:00
|
|
|
($nodes, $focus) = get_ws_content($tmp);
|
|
|
|
is($focus->[0], $mid, 'middle container focused');
|
2010-05-10 00:06:24 +02:00
|
|
|
|
2011-06-08 20:49:49 +02:00
|
|
|
cmd 'focus right';
|
2010-05-10 09:08:31 +02:00
|
|
|
($nodes, $focus) = get_ws_content($tmp);
|
|
|
|
is($focus->[0], $right, 'right container focused');
|
|
|
|
|
2011-06-08 20:49:49 +02:00
|
|
|
cmd 'focus left';
|
2010-05-10 09:08:31 +02:00
|
|
|
($nodes, $focus) = get_ws_content($tmp);
|
|
|
|
is($focus->[0], $mid, 'middle container focused');
|
|
|
|
|
2011-06-08 20:49:49 +02:00
|
|
|
cmd 'focus left';
|
2010-05-10 09:08:31 +02:00
|
|
|
($nodes, $focus) = get_ws_content($tmp);
|
|
|
|
is($focus->[0], $left, 'left container focused');
|
|
|
|
|
2011-06-08 20:49:49 +02:00
|
|
|
cmd 'focus left';
|
2010-05-10 09:08:31 +02:00
|
|
|
($nodes, $focus) = get_ws_content($tmp);
|
|
|
|
is($focus->[0], $right, 'right container focused');
|
|
|
|
|
2010-05-10 00:06:24 +02:00
|
|
|
|
2010-06-01 22:29:09 +02:00
|
|
|
######################################################################
|
2010-06-01 18:49:43 +02:00
|
|
|
# Test focus command
|
2010-06-01 22:29:09 +02:00
|
|
|
######################################################################
|
2010-06-01 18:49:43 +02:00
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
cmd qq|[con_id="$mid"] focus|;
|
2010-06-01 18:49:43 +02:00
|
|
|
($nodes, $focus) = get_ws_content($tmp);
|
|
|
|
is($focus->[0], $mid, 'middle container focused');
|
|
|
|
|
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
done_testing;
|