2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • https://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 # Test assignments of workspaces to outputs.
18 use i3test i3_autostart => 0;
20 ################################################################################
21 # Test initial workspaces.
22 ################################################################################
25 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
27 fake-outputs 1024x768+0+0,1024x768+1024+0,1024x768+1024+768,1024x768+0+768
29 bindsym Mod1+x workspace bindingname
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
40 my $pid = launch_with_config($config);
43 my ($workspace, $output, $msg) = @_;
44 is(get_output_for_workspace($workspace), $output, $msg);
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');
57 exit_gracefully($pid);
59 ################################################################################
60 # Test multiple assignments
61 ################################################################################
64 my ($workspace, $output, $msg) = @_;
65 cmd 'focus output ' . ($output eq 'fake-3' ? 'fake-0' : 'fake-3');
67 cmd "workspace $workspace";
68 check_output($workspace, $output, $msg)
73 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
75 fake-outputs 1024x768+0+0P,1024x768+1024+0,1024x768+1024+768,1024x768+0+768
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
85 $pid = launch_with_config($config);
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');
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.');
97 # Moving assigned workspaces.
98 cmd 'workspace 2, move workspace to output left';
99 check_output('2', 'fake-2', 'Moved assigned workspace up');
101 exit_gracefully($pid);