2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • http://build.i3wm.org/docs/ipc.html
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 # (unless you are already familiar with Perl)
17 # Checks if the 'workspace back_and_forth' command and the
18 # 'workspace_auto_back_and_forth' config directive work correctly.
21 use i3test i3_autostart => 0;
25 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
28 my $pid = launch_with_config($config);
30 my $first_ws = fresh_workspace;
31 ok(get_ws($first_ws)->{focused}, 'first workspace focused');
33 my $second_ws = fresh_workspace;
34 ok(get_ws($second_ws)->{focused}, 'second workspace focused');
36 my $third_ws = fresh_workspace;
37 ok(get_ws($third_ws)->{focused}, 'third workspace focused');
39 cmd 'workspace back_and_forth';
40 ok(get_ws($second_ws)->{focused}, 'second workspace focused');
42 #####################################################################
43 # test that without workspace_auto_back_and_forth switching to the same
44 # workspace that is currently focused is a no-op
45 #####################################################################
47 cmd qq|workspace "$second_ws"|;
48 ok(get_ws($second_ws)->{focused}, 'second workspace still focused');
50 exit_gracefully($pid);
52 #####################################################################
53 # the same test, but with workspace_auto_back_and_forth
54 #####################################################################
58 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
59 workspace_auto_back_and_forth yes
62 $pid = launch_with_config($config);
64 $first_ws = fresh_workspace;
65 ok(get_ws($first_ws)->{focused}, 'first workspace focused');
67 $second_ws = fresh_workspace;
68 ok(get_ws($second_ws)->{focused}, 'second workspace focused');
70 $third_ws = fresh_workspace;
71 ok(get_ws($third_ws)->{focused}, 'third workspace focused');
73 cmd qq|workspace "$third_ws"|;
74 ok(get_ws($second_ws)->{focused}, 'second workspace focused');
76 ################################################################################
77 # Now see if "workspace number <number>" also works as expected with
78 # workspace_auto_back_and_forth enabled.
79 ################################################################################
81 cmd 'workspace number 5';
82 ok(get_ws('5')->{focused}, 'workspace 5 focused');
83 # ensure it stays open
86 cmd 'workspace number 6';
87 ok(get_ws('6')->{focused}, 'workspace 6 focused');
88 # ensure it stays open
91 cmd 'workspace number 6';
92 is(focused_ws, '5', 'workspace 5 focused again');
94 ################################################################################
95 # Rename the workspaces and see if workspace number still works with BAF.
96 ################################################################################
98 cmd 'rename workspace 5 to 5: foo';
99 cmd 'rename workspace 6 to 6: baz';
101 is(focused_ws, '5: foo', 'workspace 5 still focused');
103 cmd 'workspace number 6';
104 is(focused_ws, '6: baz', 'workspace 6 now focused');
106 cmd 'workspace number 6';
107 is(focused_ws, '5: foo', 'workspace 5 focused again');
109 exit_gracefully($pid);