]> git.sur5r.net Git - i3/i3/blobdiff - testcases/t/503-workspace.t
Add "focus_wrapping" option
[i3/i3] / testcases / t / 503-workspace.t
index 94ba34349295d1a4e62b58c65250bf70ce8e4593..62f15394343d8adbdc47f74ea21d360e14c2386b 100644 (file)
@@ -1,23 +1,34 @@
 #!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 'workspace next_on_output' and the like work correctly.
 #
 use List::Util qw(first);
-use i3test i3_autostart => 0;
-
-my $config = <<EOT;
+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
-my $pid = launch_with_config($config);
 
 ################################################################################
 # Setup workspaces so that they stay open (with an empty container).
 ################################################################################
 
+sync_with_i3;
 $x->root->warp_pointer(0, 0);
 sync_with_i3;
 
@@ -48,8 +59,18 @@ open_window;
 # output 2: 2
 cmd 'workspace 1';
 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, '2', 'workspace 2 focused');
 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, '5', 'workspace 5 focused');
 
 ################################################################################
@@ -68,16 +89,12 @@ cmd 'workspace prev_on_output';
 is(focused_ws, '1', 'workspace 1 focused');
 
 cmd 'workspace 2';
-
-# XXX: This is to avoid EnterNotifies changing the focus. Not sure why they
-# appear sometimes in the first place. Only happens when running the full
-# testsuite.
-$x->root->warp_pointer(1025, 0);
+# 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;
 
 cmd 'workspace prev_on_output';
 is(focused_ws, '2', 'workspace 2 focused');
 
-exit_gracefully($pid);
-
 done_testing;