From 03693bf0cce0fe01c38466e2c6ce7016c2d95712 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Wed, 30 Jan 2013 13:31:20 +0100 Subject: [PATCH] add testcase for "move workspace " --- testcases/t/513-move-workspace.t | 94 ++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 testcases/t/513-move-workspace.t diff --git a/testcases/t/513-move-workspace.t b/testcases/t/513-move-workspace.t new file mode 100644 index 00000000..96ddfba9 --- /dev/null +++ b/testcases/t/513-move-workspace.t @@ -0,0 +1,94 @@ +#!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 whether moving workspaces between outputs works correctly. +use i3test i3_autostart => 0; +use List::Util qw(first); + +# Ensure the pointer is at (0, 0) so that we really start on the first +# (the left) workspace. +$x->root->warp_pointer(0, 0); + +my $config = <get_tree->recv; + my @outputs = @{$tree->{nodes}}; + + my $fake0 = first { $_->{name} eq 'fake-0' } @outputs; + my $fake0_content = first { $_->{type} == 2 } @{$fake0->{nodes}}; + + my $fake1 = first { $_->{name} eq 'fake-1' } @outputs; + my $fake1_content = first { $_->{type} == 2 } @{$fake1->{nodes}}; + + my @fake0_workspaces = map { $_->{name} } @{$fake0_content->{nodes}}; + my @fake1_workspaces = map { $_->{name} } @{$fake1_content->{nodes}}; + + return \@fake0_workspaces, \@fake1_workspaces; +} + +# Switch to temporary workspaces on both outputs so the numbers are free. +my $tmp_right = fresh_workspace(output => 1); +my $tmp_left = fresh_workspace(output => 0); + +cmd 'workspace 1'; +# Keep that workspace open. +my $win1 = open_window; + +cmd 'workspace 5'; +# Keep that workspace open. +open_window; + +cmd "workspace $tmp_right"; +cmd 'workspace 2'; +# Keep that workspace open. +open_window; + +my ($x0, $x1) = workspaces_per_screen(); +is_deeply($x0, [ '1', '5' ], 'workspace 1 and 5 on fake-0'); +is_deeply($x1, [ '2' ], 'workspace 2 on fake-1'); + +cmd 'workspace 1'; + +my ($nodes, $focus) = get_ws_content('1'); +is($nodes->[0]->{window}, $win1->id, 'window 1 on workspace 1'); + +cmd 'move workspace next'; + +($nodes, $focus) = get_ws_content('2'); +is($nodes->[1]->{window}, $win1->id, 'window 1 on workspace 2 after moving'); + +cmd 'move workspace prev'; + +($nodes, $focus) = get_ws_content('1'); +is($nodes->[0]->{window}, $win1->id, 'window 1 on workspace 1'); + +cmd 'move workspace next_on_output'; + +($nodes, $focus) = get_ws_content('5'); +is($nodes->[1]->{window}, $win1->id, 'window 1 on workspace 5 after moving'); + +exit_gracefully($pid); + +done_testing; -- 2.39.5