]> git.sur5r.net Git - i3/i3/blob - testcases/t/297-assign-workspace-to-output.t
a7b75be9fdfa5a49987c63cb22b6448a547d82a5
[i3/i3] / testcases / t / 297-assign-workspace-to-output.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • https://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 # Test assignments of workspaces to outputs.
18 use i3test i3_autostart => 0;
19
20 ################################################################################
21 # Test initial workspaces.
22 ################################################################################
23
24 my $config = <<EOT;
25 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
26
27 fake-outputs 1024x768+0+0,1024x768+1024+0,1024x768+1024+768,1024x768+0+768
28
29 bindsym Mod1+x workspace bindingname
30
31 workspace 9 output doesnotexist
32 workspace special output fake-0
33 workspace 1 output doesnotexist
34 workspace dontusethisname output doesnotexist
35 workspace donotoverride output fake-0
36 workspace 2 output fake-0
37 workspace 3 output fake-0
38 EOT
39
40 my $pid = launch_with_config($config);
41
42 sub check_output {
43     my ($workspace, $output, $msg) = @_;
44     is(get_output_for_workspace($workspace), $output, $msg);
45 }
46
47 check_output('9', '', 'Numbered workspace with a big number that is assigned to output that does not exist is not used');
48 check_output('special', 'fake-0', 'Output gets special workspace because of assignment');
49 check_output('bindingname', 'fake-1', 'Bindings give workspace names');
50 check_output('1', 'fake-2', 'Numbered workspace that is assigned to output that does not exist is used');
51 check_output('2', '', 'Numbered workspace assigned to output with existing workspace is not used');
52 check_output('3', '', 'Numbered workspace assigned to output with existing workspace is not used');
53 check_output('4', 'fake-3', 'First available number that is not assigned to existing output is used');
54 check_output('dontusethisname', '', 'Named workspace that is assigned to output that does not exist is not used');
55 check_output('donotoverride', '', 'Named workspace assigned to already occupied output is not used');
56
57 exit_gracefully($pid);
58
59 ################################################################################
60 # Test multiple assignments
61 ################################################################################
62
63 sub do_test {
64     my ($workspace, $output, $msg) = @_;
65     cmd 'focus output ' . ($output eq 'fake-3' ? 'fake-0' : 'fake-3');
66
67     cmd "workspace $workspace";
68     check_output($workspace, $output, $msg)
69 }
70
71 $config = <<EOT;
72 # i3 config file (v4)
73 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
74
75 fake-outputs 1024x768+0+0P,1024x768+1024+0,1024x768+1024+768,1024x768+0+768
76
77 workspace 1 output fake-0
78 workspace 1 output fake-1 fake-2
79 workspace 2 output fake-3 fake-4 fake-0 fake-1
80 workspace 3 output these outputs do not exist but these do: fake-0 fake-3
81 workspace 4 output whitespace                    fake-0
82 workspace special output doesnotexist1 doesnotexist2 doesnotexist3
83 EOT
84
85 $pid = launch_with_config($config);
86
87 do_test('1', 'fake-0', 'Multiple assignments do not override a single one');
88 do_test('2', 'fake-3', 'First output out of multiple assignments is used');
89 do_test('3', 'fake-0', 'First existing output is used');
90 do_test('4', 'fake-0', 'Excessive whitespace is ok');
91 do_test('5', 'fake-1', 'Numbered initialization for fake-1');
92 do_test('6', 'fake-2', 'Numbered initialization for fake-2');
93
94 cmd 'focus output fake-0, workspace special';
95 check_output('special', 'fake-0', 'Workspace with only non-existing assigned outputs opened in current output.');
96
97 # Moving assigned workspaces.
98 cmd 'workspace 2, move workspace to output left';
99 check_output('2', 'fake-2', 'Moved assigned workspace up');
100
101 exit_gracefully($pid);
102 done_testing;