From 25ec389ecba8aef71bb6e729c438e1b0f3192258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20B=C3=BCrk?= Date: Wed, 4 Mar 2015 09:45:47 +0100 Subject: [PATCH] Added tests for #1473 --- testcases/t/522-rename-assigned-workspace.t | 90 +++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 testcases/t/522-rename-assigned-workspace.t diff --git a/testcases/t/522-rename-assigned-workspace.t b/testcases/t/522-rename-assigned-workspace.t new file mode 100644 index 00000000..aa69d66d --- /dev/null +++ b/testcases/t/522-rename-assigned-workspace.t @@ -0,0 +1,90 @@ +#!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) +# +# +# Tests that workspaces are moved to the assigned output if they +# are renamed to an assigned name. +# Ticket: #1473 + +use i3test i3_autostart => 0; + +my $config = <connect->recv; + +# Returns the name of the output on which this workspace resides +sub get_output_for_workspace { + my $ws_name = shift @_; + + foreach (grep { not $_->{name} =~ /^__/ } @{$i3->get_tree->recv->{nodes}}) { + my $output = $_->{name}; + foreach (grep { $_->{name} =~ "content" } @{$_->{nodes}}) { + return $output if $_->{nodes}[0]->{name} =~ $ws_name; + } + } +} + +########################################################################## +# Renaming the workspace to an unassigned name does not move the workspace +# (regression test) +########################################################################## + +cmd 'focus output fake-0'; +cmd 'rename workspace to unassigned'; +is(get_output_for_workspace('unassigned'), 'fake-0', + 'Unassigned workspace should stay on its output when being renamed'); + +########################################################################## +# Renaming a workspace by number only triggers the assignment +########################################################################## + +cmd 'focus output fake-0'; +cmd 'rename workspace to 2'; +is(get_output_for_workspace('2'), 'fake-1', + 'Renaming the workspace to a number should move it to the assigned output'); + +########################################################################## +# Renaming a workspace by number and name triggers the assignment +########################################################################## + +cmd 'focus output fake-0'; +cmd 'rename workspace to "2:foo"'; +is(get_output_for_workspace('2:foo'), 'fake-1', + 'Renaming the workspace to a number and name should move it to the assigned output'); + +########################################################################## +# Renaming a workspace by name only triggers the assignment +########################################################################## + +cmd 'focus output fake-0'; +cmd 'rename workspace to baz'; +is(get_output_for_workspace('baz'), 'fake-1', + 'Renaming the workspace to a number and name should move it to the assigned output'); + + +exit_gracefully($pid); +done_testing;