#!perl
# vim:ts=4:sw=4:expandtab
-# !NO_I3_INSTANCE! will prevent complete-run.pl from starting i3
-#
# Checks if the 'workspace back_and_forth' command and the
# 'workspace_auto_back_and_forth' config directive work correctly.
#
-use i3test;
-use X11::XCB::Connection;
-
-my $x = X11::XCB::Connection->new;
+use i3test i3_autostart => 0;
my $config = <<EOT;
# i3 config file (v4)
cmd qq|workspace "$third_ws"|;
ok(get_ws($second_ws)->{focused}, 'second workspace focused');
+################################################################################
+# 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');
+
exit_gracefully($pid);
done_testing;