2015-10-16 17:17:41 +02:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
|
|
|
#
|
|
|
|
# Please read the following documents before working on tests:
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/testsuite.html
|
2015-10-16 17:17:41 +02:00
|
|
|
# (or docs/testsuite)
|
|
|
|
#
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/lib-i3test.html
|
2015-10-16 17:17:41 +02:00
|
|
|
# (alternatively: perldoc ./testcases/lib/i3test.pm)
|
|
|
|
#
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/ipc.html
|
2015-10-16 17:17:41 +02:00
|
|
|
# (or docs/ipc)
|
|
|
|
#
|
|
|
|
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
|
|
|
|
# (unless you are already familiar with Perl)
|
|
|
|
#
|
|
|
|
# Tests whether 'workspace next' works correctly.
|
|
|
|
#
|
|
|
|
use List::Util qw(first);
|
2017-09-14 12:30:42 +02:00
|
|
|
use i3test i3_config => <<EOT;
|
|
|
|
# i3 config file (v4)
|
|
|
|
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
|
|
|
|
|
|
|
|
fake-outputs 1024x768+0+0,1024x768+1024+0
|
|
|
|
EOT
|
2015-10-16 17:17:41 +02:00
|
|
|
|
|
|
|
sub assert_next {
|
|
|
|
my ($expected) = @_;
|
|
|
|
|
|
|
|
cmd 'workspace next';
|
|
|
|
# We need to sync after changing focus to a different output to wait for the
|
|
|
|
# EnterNotify to be processed, otherwise it will be processed at some point
|
|
|
|
# later in time and mess up our subsequent tests.
|
|
|
|
sync_with_i3;
|
|
|
|
|
|
|
|
is(focused_ws, $expected, "workspace $expected focused");
|
|
|
|
}
|
|
|
|
|
2016-07-31 19:28:04 +02:00
|
|
|
sub assert_prev {
|
|
|
|
my ($expected) = @_;
|
|
|
|
|
|
|
|
cmd 'workspace prev';
|
|
|
|
# We need to sync after changing focus to a different output to wait for the
|
|
|
|
# EnterNotify to be processed, otherwise it will be processed at some point
|
|
|
|
# later in time and mess up our subsequent tests.
|
|
|
|
sync_with_i3;
|
|
|
|
|
|
|
|
is(focused_ws, $expected, "workspace $expected focused");
|
|
|
|
}
|
2015-10-16 17:17:41 +02:00
|
|
|
|
|
|
|
sync_with_i3;
|
|
|
|
$x->root->warp_pointer(0, 0);
|
|
|
|
sync_with_i3;
|
|
|
|
|
2016-07-31 19:28:04 +02:00
|
|
|
################################################################################
|
|
|
|
# Setup workspaces so that they stay open (with an empty container).
|
|
|
|
# open_window ensures, this
|
|
|
|
#
|
|
|
|
# numbered named
|
|
|
|
# output 1 (left) : 1, 2, 3, 6, 7, B, F, C
|
|
|
|
# output 2 (right): 4, 5, A, D, E
|
|
|
|
#
|
|
|
|
################################################################################
|
2015-10-16 17:17:41 +02:00
|
|
|
|
|
|
|
cmd 'focus output right';
|
2016-07-31 19:28:04 +02:00
|
|
|
cmd 'workspace A'; open_window;
|
|
|
|
cmd 'workspace D'; open_window;
|
|
|
|
cmd 'workspace 4'; open_window;
|
|
|
|
cmd 'workspace 5'; open_window;
|
|
|
|
cmd 'workspace E'; open_window;
|
|
|
|
|
|
|
|
cmd 'focus output left';
|
|
|
|
cmd 'workspace 1'; open_window;
|
|
|
|
cmd 'workspace 2'; open_window;
|
|
|
|
cmd 'workspace B'; open_window;
|
|
|
|
cmd 'workspace 3'; open_window;
|
|
|
|
cmd 'workspace F'; open_window;
|
|
|
|
cmd 'workspace 6'; open_window;
|
|
|
|
cmd 'workspace C'; open_window;
|
|
|
|
cmd 'workspace 7'; open_window;
|
2015-10-16 17:17:41 +02:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Use workspace next and verify the correct order.
|
2016-07-31 19:28:04 +02:00
|
|
|
# numbered -> numerical sort
|
|
|
|
# named -> sort by creation time
|
2015-10-16 17:17:41 +02:00
|
|
|
################################################################################
|
2016-07-31 19:28:04 +02:00
|
|
|
cmd 'workspace 1';
|
|
|
|
is(focused_ws, '1', 'back on workspace 1');
|
2015-10-16 17:17:41 +02:00
|
|
|
|
|
|
|
assert_next('2');
|
|
|
|
assert_next('3');
|
|
|
|
assert_next('4');
|
|
|
|
assert_next('5');
|
2016-07-31 19:28:04 +02:00
|
|
|
assert_next('6');
|
|
|
|
assert_next('7');
|
|
|
|
|
2015-10-16 17:17:41 +02:00
|
|
|
assert_next('B');
|
2016-07-31 19:28:04 +02:00
|
|
|
assert_next('F');
|
|
|
|
assert_next('C');
|
|
|
|
assert_next('A');
|
|
|
|
assert_next('D');
|
|
|
|
assert_next('E');
|
|
|
|
assert_next('1');
|
|
|
|
|
|
|
|
cmd 'workspace 1';
|
|
|
|
is(focused_ws, '1', 'back on workspace 1');
|
|
|
|
|
|
|
|
assert_prev('E');
|
|
|
|
assert_prev('D');
|
|
|
|
assert_prev('A');
|
|
|
|
assert_prev('C');
|
|
|
|
assert_prev('F');
|
|
|
|
assert_prev('B');
|
|
|
|
|
|
|
|
assert_prev('7');
|
|
|
|
assert_prev('6');
|
|
|
|
assert_prev('5');
|
|
|
|
assert_prev('4');
|
|
|
|
assert_prev('3');
|
|
|
|
assert_prev('2');
|
|
|
|
assert_prev('1');
|
|
|
|
|
2015-10-16 17:17:41 +02:00
|
|
|
|
|
|
|
done_testing;
|