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 # Tests that workspace assignment config directives for plain numbers will
18 # assign any workspace of that number to the specified output.
20 # Bug still in: 4.7.2-147-g3760a48
21 use i3test i3_autostart => 0;
25 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
27 workspace 1:override output fake-0
28 workspace 2 output fake-0
29 workspace 1 output fake-1
30 workspace 2:override output fake-1
32 fake-outputs 1024x768+0+0,1024x768+1024+0
35 my $pid = launch_with_config($config);
36 my $i3 = i3(get_socket_path());
39 # Returns the name of the output on which this workspace resides
40 sub get_output_for_workspace {
41 my $ws_name = shift @_;
43 foreach (grep { not $_->{name} =~ /^__/ } @{$i3->get_tree->recv->{nodes}}) {
44 my $output = $_->{name};
45 foreach (grep { $_->{name} =~ "content" } @{$_->{nodes}}) {
46 return $output if $_->{nodes}[0]->{name} =~ $ws_name;
51 ################################################################################
52 # Workspace assignments with bare numbers should be interpreted as `workspace
53 # number` config directives. Any workspace beginning with that number should be
54 # assigned to the specified output.
55 ################################################################################
57 cmd 'focus output fake-1';
58 cmd 'workspace "2:foo"';
59 is(get_output_for_workspace('2:foo'), 'fake-0',
60 'Workspaces should be assigned by number when the assignment is a plain number')
61 or diag 'Since workspace number 2 is assigned to fake-0, 2:foo should open on fake-0';
63 cmd 'focus output fake-0';
64 cmd 'workspace "2:override"';
65 is(get_output_for_workspace('2:override'), 'fake-1',
66 'Workspace assignments by name should override numbered assignments')
67 or diag 'Since workspace "2:override" is assigned by name to fake-1, it should open on fake-1';
69 cmd 'focus output fake-1';
70 cmd 'workspace "1:override"';
71 is(get_output_for_workspace('1:override'), 'fake-0',
72 'Assignment rules should not be affected by the order assignments are declared')
73 or diag 'Since workspace "1:override" is assigned by name to fake-0, it should open on fake-0';
75 exit_gracefully($pid);