#!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 for the scratchpad functionality.
#
use i3test;
# 11: focus a workspace and move all of its children to the scratchpad area
################################################################################
-$tmp = fresh_workspace;
+sub verify_scratchpad_move_multiple_win {
+ my $floating = shift;
-my $first = open_window;
-my $second = open_window;
+ my $first = open_window;
+ my $second = open_window;
-cmd 'focus parent';
-cmd 'move scratchpad';
+ if ($floating) {
+ cmd 'floating toggle';
+ cmd 'focus tiling';
+ }
-does_i3_live;
+ cmd 'focus parent';
+ cmd 'move scratchpad';
-$ws = get_ws($tmp);
-is(scalar @{$ws->{nodes}}, 0, 'no windows on ws');
-is(scalar @{$ws->{floating_nodes}}, 0, 'no floating windows on ws');
+ does_i3_live;
-# show the first window.
-cmd 'scratchpad show';
+ $ws = get_ws($tmp);
+ is(scalar @{$ws->{nodes}}, 0, 'no windows on ws');
+ is(scalar @{$ws->{floating_nodes}}, 0, 'no floating windows on ws');
-$ws = get_ws($tmp);
-is(scalar @{$ws->{nodes}}, 0, 'no windows on ws');
-is(scalar @{$ws->{floating_nodes}}, 1, 'one floating windows on ws');
+ # show the first window.
+ cmd 'scratchpad show';
-$old_focus = get_focused($tmp);
+ $ws = get_ws($tmp);
+ is(scalar @{$ws->{nodes}}, 0, 'no windows on ws');
+ is(scalar @{$ws->{floating_nodes}}, 1, 'one floating windows on ws');
-cmd 'scratchpad show';
+ $old_focus = get_focused($tmp);
-# show the second window.
-cmd 'scratchpad show';
+ cmd 'scratchpad show';
-$ws = get_ws($tmp);
-is(scalar @{$ws->{nodes}}, 0, 'no windows on ws');
-is(scalar @{$ws->{floating_nodes}}, 1, 'one floating windows on ws');
+ # show the second window.
+ cmd 'scratchpad show';
-isnt(get_focused($tmp), $old_focus, 'focus changed');
+ $ws = get_ws($tmp);
+ is(scalar @{$ws->{nodes}}, 0, 'no windows on ws');
+ is(scalar @{$ws->{floating_nodes}}, 1, 'one floating windows on ws');
+
+ isnt(get_focused($tmp), $old_focus, 'focus changed');
+}
+
+$tmp = fresh_workspace;
+verify_scratchpad_move_multiple_win(0);
+$tmp = fresh_workspace;
+verify_scratchpad_move_multiple_win(1);
# TODO: make i3bar display *something* when a window on the scratchpad has the urgency hint