]> git.sur5r.net Git - i3/i3/blob - testcases/t/176-workspace-baf.t
add boilerplate to all testcases with documentation references
[i3/i3] / testcases / t / 176-workspace-baf.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • http://build.i3wm.org/docs/ipc.html
12 #   (or docs/ipc)
13 #
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 #   (unless you are already familiar with Perl)
16 #
17 # Checks if the 'workspace back_and_forth' command and the
18 # 'workspace_auto_back_and_forth' config directive work correctly.
19 #
20
21 use i3test i3_autostart => 0;
22
23 my $config = <<EOT;
24 # i3 config file (v4)
25 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
26 EOT
27
28 my $pid = launch_with_config($config);
29
30 my $first_ws = fresh_workspace;
31 ok(get_ws($first_ws)->{focused}, 'first workspace focused');
32
33 my $second_ws = fresh_workspace;
34 ok(get_ws($second_ws)->{focused}, 'second workspace focused');
35
36 my $third_ws = fresh_workspace;
37 ok(get_ws($third_ws)->{focused}, 'third workspace focused');
38
39 cmd 'workspace back_and_forth';
40 ok(get_ws($second_ws)->{focused}, 'second workspace focused');
41
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 #####################################################################
46
47 cmd qq|workspace "$second_ws"|;
48 ok(get_ws($second_ws)->{focused}, 'second workspace still focused');
49
50 exit_gracefully($pid);
51
52 #####################################################################
53 # the same test, but with workspace_auto_back_and_forth
54 #####################################################################
55
56 $config = <<EOT;
57 # i3 config file (v4)
58 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
59 workspace_auto_back_and_forth yes
60 EOT
61
62 $pid = launch_with_config($config);
63
64 $first_ws = fresh_workspace;
65 ok(get_ws($first_ws)->{focused}, 'first workspace focused');
66
67 $second_ws = fresh_workspace;
68 ok(get_ws($second_ws)->{focused}, 'second workspace focused');
69
70 $third_ws = fresh_workspace;
71 ok(get_ws($third_ws)->{focused}, 'third workspace focused');
72
73 cmd qq|workspace "$third_ws"|;
74 ok(get_ws($second_ws)->{focused}, 'second workspace focused');
75
76 ################################################################################
77 # Now see if "workspace number <number>" also works as expected with
78 # workspace_auto_back_and_forth enabled.
79 ################################################################################
80
81 cmd 'workspace number 5';
82 ok(get_ws('5')->{focused}, 'workspace 5 focused');
83 # ensure it stays open
84 cmd 'open';
85
86 cmd 'workspace number 6';
87 ok(get_ws('6')->{focused}, 'workspace 6 focused');
88 # ensure it stays open
89 cmd 'open';
90
91 cmd 'workspace number 6';
92 is(focused_ws, '5', 'workspace 5 focused again');
93
94 ################################################################################
95 # Rename the workspaces and see if workspace number still works with BAF.
96 ################################################################################
97
98 cmd 'rename workspace 5 to 5: foo';
99 cmd 'rename workspace 6 to 6: baz';
100
101 is(focused_ws, '5: foo', 'workspace 5 still focused');
102
103 cmd 'workspace number 6';
104 is(focused_ws, '6: baz', 'workspace 6 now focused');
105
106 cmd 'workspace number 6';
107 is(focused_ws, '5: foo', 'workspace 5 focused again');
108
109 exit_gracefully($pid);
110
111 done_testing;