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