]> git.sur5r.net Git - i3/i3/blob - testcases/t/522-rename-assigned-workspace.t
Merge pull request #1549 from shdown/y-offset-fix
[i3/i3] / testcases / t / 522-rename-assigned-workspace.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 #
18 # Tests that workspaces are moved to the assigned output if they
19 # are renamed to an assigned name.
20 # Ticket: #1473
21
22 use i3test i3_autostart => 0;
23
24 my $config = <<EOT;
25 # i3 config file (v4)
26 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
27 fake-outputs 1024x768+0+0,1024x768+1024+0
28
29 workspace 1 output fake-0
30 workspace 2 output fake-1
31 workspace 3:foo output fake-1
32 workspace baz output fake-1
33 EOT
34
35 my $pid = launch_with_config($config);
36 my $i3 = i3(get_socket_path());
37 $i3->connect->recv;
38
39 # Returns the name of the output on which this workspace resides
40 sub get_output_for_workspace {
41     my $ws_name = shift @_;
42
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;
47         }
48     }
49 }
50
51 ##########################################################################
52 # Renaming the workspace to an unassigned name does not move the workspace
53 # (regression test)
54 ##########################################################################
55
56 cmd 'focus output fake-0';
57 cmd 'rename workspace to unassigned';
58 is(get_output_for_workspace('unassigned'), 'fake-0',
59     'Unassigned workspace should stay on its output when being renamed');
60
61 ##########################################################################
62 # Renaming a workspace by number only triggers the assignment
63 ##########################################################################
64
65 cmd 'focus output fake-0';
66 cmd 'rename workspace to 2';
67 is(get_output_for_workspace('2'), 'fake-1',
68     'Renaming the workspace to a number should move it to the assigned output');
69
70 ##########################################################################
71 # Renaming a workspace by number and name triggers the assignment
72 ##########################################################################
73
74 cmd 'focus output fake-0';
75 cmd 'rename workspace to "2:foo"';
76 is(get_output_for_workspace('2:foo'), 'fake-1',
77     'Renaming the workspace to a number and name should move it to the assigned output');
78
79 ##########################################################################
80 # Renaming a workspace by name only triggers the assignment
81 ##########################################################################
82
83 cmd 'focus output fake-0';
84 cmd 'rename workspace to baz';
85 is(get_output_for_workspace('baz'), 'fake-1',
86     'Renaming the workspace to a number and name should move it to the assigned output');
87
88
89 exit_gracefully($pid);
90 done_testing;