]> git.sur5r.net Git - i3/i3/blobdiff - testcases/t/176-workspace-baf.t
Merge branch 'master' into next
[i3/i3] / testcases / t / 176-workspace-baf.t
index 31c4f2484f3eb673753785c88a55c560945bb478..bad76ec8987938476bde92f25071a4e78a3e9dce 100644 (file)
@@ -1,12 +1,24 @@
 #!perl
 # vim:ts=4:sw=4:expandtab
-# !NO_I3_INSTANCE! will prevent complete-run.pl from starting i3
+#
+# 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)
 #
 # Checks if the 'workspace back_and_forth' command and the
 # 'workspace_auto_back_and_forth' config directive work correctly.
 #
 
-use i3test;
+use i3test i3_autostart => 0;
 
 my $config = <<EOT;
 # i3 config file (v4)
@@ -35,6 +47,33 @@ ok(get_ws($second_ws)->{focused}, 'second workspace focused');
 cmd qq|workspace "$second_ws"|;
 ok(get_ws($second_ws)->{focused}, 'second workspace still focused');
 
+################################################################################
+# verify that 'move workspace back_and_forth' works as expected
+################################################################################
+
+cmd qq|workspace "$first_ws"|;
+my $first_win = open_window;
+
+cmd qq|workspace "$second_ws"|;
+my $second_win = open_window;
+
+is(@{get_ws_content($first_ws)}, 1, 'one container on ws 1 before moving');
+cmd 'move workspace back_and_forth';
+is(@{get_ws_content($first_ws)}, 2, 'two containers on ws 1 before moving');
+
+my $third_win = open_window;
+
+################################################################################
+# verify that moving to the current ws is a no-op without
+# workspace_auto_back_and_forth.
+################################################################################
+
+cmd qq|workspace "$first_ws"|;
+
+is(@{get_ws_content($second_ws)}, 1, 'one container on ws 2 before moving');
+cmd qq|move workspace "$first_ws"|;
+is(@{get_ws_content($second_ws)}, 1, 'still one container');
+
 exit_gracefully($pid);
 
 #####################################################################
@@ -60,6 +99,69 @@ ok(get_ws($third_ws)->{focused}, 'third workspace focused');
 
 cmd qq|workspace "$third_ws"|;
 ok(get_ws($second_ws)->{focused}, 'second workspace focused');
+$first_win = open_window;
+
+################################################################################
+# verify that moving to the current ws moves to the previous one with
+# workspace_auto_back_and_forth.
+################################################################################
+
+cmd qq|workspace "$first_ws"|;
+$second_win = open_window;
+
+is(@{get_ws_content($second_ws)}, 1, 'one container on ws 2 before moving');
+cmd qq|move workspace "$first_ws"|;
+is(@{get_ws_content($second_ws)}, 2, 'two containers on ws 2');
+
+################################################################################
+# Now see if "workspace number <number>" also works as expected with
+# workspace_auto_back_and_forth enabled.
+################################################################################
+
+cmd 'workspace number 5';
+ok(get_ws('5')->{focused}, 'workspace 5 focused');
+# ensure it stays open
+cmd 'open';
+
+cmd 'workspace number 6';
+ok(get_ws('6')->{focused}, 'workspace 6 focused');
+# ensure it stays open
+cmd 'open';
+
+cmd 'workspace number 6';
+is(focused_ws, '5', 'workspace 5 focused again');
+
+################################################################################
+# Rename the workspaces and see if workspace number still works with BAF.
+################################################################################
+
+cmd 'rename workspace 5 to 5: foo';
+cmd 'rename workspace 6 to 6: baz';
+
+is(focused_ws, '5: foo', 'workspace 5 still focused');
+
+cmd 'workspace number 6';
+is(focused_ws, '6: baz', 'workspace 6 now focused');
+
+cmd 'workspace number 6';
+is(focused_ws, '5: foo', 'workspace 5 focused again');
+
+################################################################################
+# Place a window in the scratchpad, see if BAF works after showing the
+# scratchpad window.
+################################################################################
+
+my $scratchwin = open_window;
+cmd 'move scratchpad';
+
+# show scratchpad window
+cmd 'scratchpad show';
+
+# hide scratchpad window
+cmd 'scratchpad show';
+
+cmd 'workspace back_and_forth';
+is(focused_ws, '6: baz', 'workspace 6 now focused');
 
 exit_gracefully($pid);