2011-10-17 18:34:29 -04:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
2012-09-10 08:09:01 -04: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)
|
|
|
|
#
|
2011-10-17 18:34:29 -04:00
|
|
|
# Checks if the 'workspace back_and_forth' command and the
|
|
|
|
# 'workspace_auto_back_and_forth' config directive work correctly.
|
|
|
|
#
|
|
|
|
|
2011-11-25 11:39:19 -05:00
|
|
|
use i3test i3_autostart => 0;
|
2011-10-17 18:34:29 -04:00
|
|
|
|
|
|
|
my $config = <<EOT;
|
|
|
|
# i3 config file (v4)
|
|
|
|
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
|
|
|
|
EOT
|
|
|
|
|
|
|
|
my $pid = launch_with_config($config);
|
|
|
|
|
|
|
|
my $first_ws = fresh_workspace;
|
|
|
|
ok(get_ws($first_ws)->{focused}, 'first workspace focused');
|
|
|
|
|
|
|
|
my $second_ws = fresh_workspace;
|
|
|
|
ok(get_ws($second_ws)->{focused}, 'second workspace focused');
|
|
|
|
|
|
|
|
my $third_ws = fresh_workspace;
|
|
|
|
ok(get_ws($third_ws)->{focused}, 'third workspace focused');
|
|
|
|
|
|
|
|
cmd 'workspace back_and_forth';
|
|
|
|
ok(get_ws($second_ws)->{focused}, 'second workspace focused');
|
|
|
|
|
|
|
|
#####################################################################
|
|
|
|
# test that without workspace_auto_back_and_forth switching to the same
|
|
|
|
# workspace that is currently focused is a no-op
|
|
|
|
#####################################################################
|
|
|
|
|
|
|
|
cmd qq|workspace "$second_ws"|;
|
|
|
|
ok(get_ws($second_ws)->{focused}, 'second workspace still focused');
|
|
|
|
|
|
|
|
exit_gracefully($pid);
|
|
|
|
|
|
|
|
#####################################################################
|
|
|
|
# the same test, but with workspace_auto_back_and_forth
|
|
|
|
#####################################################################
|
|
|
|
|
|
|
|
$config = <<EOT;
|
|
|
|
# i3 config file (v4)
|
|
|
|
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
|
|
|
|
workspace_auto_back_and_forth yes
|
|
|
|
EOT
|
|
|
|
|
|
|
|
$pid = launch_with_config($config);
|
|
|
|
|
|
|
|
$first_ws = fresh_workspace;
|
|
|
|
ok(get_ws($first_ws)->{focused}, 'first workspace focused');
|
|
|
|
|
|
|
|
$second_ws = fresh_workspace;
|
|
|
|
ok(get_ws($second_ws)->{focused}, 'second workspace focused');
|
|
|
|
|
|
|
|
$third_ws = fresh_workspace;
|
|
|
|
ok(get_ws($third_ws)->{focused}, 'third workspace focused');
|
|
|
|
|
|
|
|
cmd qq|workspace "$third_ws"|;
|
|
|
|
ok(get_ws($second_ws)->{focused}, 'second workspace focused');
|
|
|
|
|
2012-05-09 14:33:41 -04:00
|
|
|
################################################################################
|
|
|
|
# Now see if "workspace number <number>" also works as expected with
|
|
|
|
# workspace_auto_back_and_forth enabled.
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
cmd 'workspace number 5';
|
|
|
|
ok(get_ws('5')->{focused}, 'workspace 5 focused');
|
2012-08-22 11:57:58 -04:00
|
|
|
# ensure it stays open
|
|
|
|
cmd 'open';
|
2012-05-09 14:33:41 -04:00
|
|
|
|
|
|
|
cmd 'workspace number 6';
|
|
|
|
ok(get_ws('6')->{focused}, 'workspace 6 focused');
|
2012-08-22 11:57:58 -04:00
|
|
|
# ensure it stays open
|
|
|
|
cmd 'open';
|
2012-05-09 14:33:41 -04:00
|
|
|
|
|
|
|
cmd 'workspace number 6';
|
2012-08-22 11:57:58 -04:00
|
|
|
is(focused_ws, '5', 'workspace 5 focused again');
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Rename the workspaces and see if workspace number still works with BAF.
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
cmd 'rename workspace 5 to 5: foo';
|
|
|
|
cmd 'rename workspace 6 to 6: baz';
|
|
|
|
|
|
|
|
is(focused_ws, '5: foo', 'workspace 5 still focused');
|
|
|
|
|
|
|
|
cmd 'workspace number 6';
|
|
|
|
is(focused_ws, '6: baz', 'workspace 6 now focused');
|
|
|
|
|
|
|
|
cmd 'workspace number 6';
|
|
|
|
is(focused_ws, '5: foo', 'workspace 5 focused again');
|
2012-05-09 14:33:41 -04:00
|
|
|
|
2011-10-17 18:34:29 -04:00
|
|
|
exit_gracefully($pid);
|
|
|
|
|
|
|
|
done_testing;
|