Added --no-auto-back-and-forth to workspace commands.

This patch introduces the --no-auto-back-and-forth flag to both of

    workspace --no-auto-back-and-forth <name>
    workspace --no-auto-back-and-forth number <number>

This flag will only have an effect if the back_and_forth feature is
enabled. If passed, the feature will be ignored for this particular
call only.

fixes #2028
This commit is contained in:
Ingo Bürk
2015-10-23 23:36:37 +02:00
parent 185a2f24ba
commit 7270206e24
6 changed files with 91 additions and 26 deletions

View File

@ -131,11 +131,11 @@ is(parser_calls('[con_mark="yay"] focus'),
# commands being parsed due to the configuration, people might send IPC
# commands with leading or trailing newlines.
is(parser_calls("workspace test\n"),
'cmd_workspace_name(test)',
'cmd_workspace_name(test, (null))',
'trailing whitespace stripped off ok');
is(parser_calls("\nworkspace test"),
'cmd_workspace_name(test)',
'cmd_workspace_name(test, (null))',
'trailing whitespace stripped off ok');
################################################################################
@ -187,27 +187,27 @@ is(parser_calls('move something to somewhere'),
################################################################################
is(parser_calls('workspace "foo"'),
'cmd_workspace_name(foo)',
'cmd_workspace_name(foo, (null))',
'Command with simple double quotes ok');
is(parser_calls('workspace "foo'),
'cmd_workspace_name(foo)',
'cmd_workspace_name(foo, (null))',
'Command without ending double quotes ok');
is(parser_calls('workspace "foo \"bar"'),
'cmd_workspace_name(foo "bar)',
'cmd_workspace_name(foo "bar, (null))',
'Command with escaped double quotes ok');
is(parser_calls('workspace "foo \\'),
'cmd_workspace_name(foo \\)',
'cmd_workspace_name(foo \\, (null))',
'Command with single backslash in the end ok');
is(parser_calls('workspace "foo\\\\bar"'),
'cmd_workspace_name(foo\\bar)',
'cmd_workspace_name(foo\\bar, (null))',
'Command with escaped backslashes ok');
is(parser_calls('workspace "foo\\\\\\"bar"'),
'cmd_workspace_name(foo\\"bar)',
'cmd_workspace_name(foo\\"bar, (null))',
'Command with escaped double quotes after escaped backslashes ok');
################################################################################

View File

@ -0,0 +1,57 @@
#!perl
# vim:ts=4:sw=4:expandtab
#
# 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)
#
# Test for the --no-auto-back-and-forth flag.
# Ticket: #2028
use i3test;
my ($first, $second, $third);
$first = "1:first";
$second = "2:second";
$third = "3:third";
###############################################################################
# Switching to another workspace when passing --no-auto-back-and-forth works
# as if the flag wasn't set.
###############################################################################
cmd qq|workspace "$first"|;
ok(get_ws($first)->{focused}, 'first workspace is focused');
cmd qq|workspace --no-auto-back-and-forth "$second"|;
ok(get_ws($second)->{focused}, 'second workspace is focused');
cmd qq|workspace --no-auto-back-and-forth number "$third"|;
ok(get_ws($third)->{focused}, 'third workspace is focused');
###############################################################################
# Switching to the focused workspace when passing --no-auto-back-and-forth
# is a no-op.
###############################################################################
cmd qq|workspace "$second"|;
cmd qq|workspace "$first"|;
ok(get_ws($first)->{focused}, 'first workspace is focused');
cmd qq|workspace --no-auto-back-and-forth "$first"|;
ok(get_ws($first)->{focused}, 'first workspace is still focused');
cmd qq|workspace --no-auto-back-and-forth number "$first"|;
ok(get_ws($first)->{focused}, 'first workspace is still focused');
###############################################################################
done_testing;