]> git.sur5r.net Git - i3/i3/blob - testcases/t/522-rename-assigned-workspace.t
9897e4ee263860be01b52f8f185496282e3228ed
[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 # • 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 #
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_config => <<EOT;
23 # i3 config file (v4)
24 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
25 fake-outputs 1024x768+0+0,1024x768+1024+0
26
27 workspace 1 output fake-0
28 workspace 2 output fake-1
29 workspace 3:foo output fake-1
30 workspace baz output fake-1
31 workspace 5 output left
32 workspace 6 output doesnotexist fake-0
33 workspace 7 output fake-1 fake-0
34 EOT
35
36 ##########################################################################
37 # Renaming the workspace to an unassigned name does not move the workspace
38 # (regression test)
39 ##########################################################################
40
41 cmd 'focus output fake-0';
42 cmd 'rename workspace to unassigned';
43 is(get_output_for_workspace('unassigned'), 'fake-0',
44     'Unassigned workspace should stay on its output when being renamed');
45
46 ##########################################################################
47 # Renaming a workspace by number only triggers the assignment
48 ##########################################################################
49
50 cmd 'focus output fake-0';
51 cmd 'rename workspace to 2';
52 is(get_output_for_workspace('2'), 'fake-1',
53     'Renaming the workspace to a number should move it to the assigned output');
54
55 ##########################################################################
56 # Renaming a workspace by number and name triggers the assignment
57 ##########################################################################
58
59 cmd 'focus output fake-0';
60 cmd 'rename workspace to "2:foo"';
61 is(get_output_for_workspace('2:foo'), 'fake-1',
62     'Renaming the workspace to a number and name should move it to the assigned output');
63
64 ##########################################################################
65 # Renaming a workspace by name only triggers the assignment
66 ##########################################################################
67
68 cmd 'focus output fake-0';
69 cmd 'rename workspace to baz';
70 is(get_output_for_workspace('baz'), 'fake-1',
71     'Renaming the workspace to a number and name should move it to the assigned output');
72
73 ##########################################################################
74 # Renaming a workspace so that it is assigned a directional output does
75 # not move the workspace or crash
76 ##########################################################################
77
78 cmd 'focus output fake-0';
79 cmd 'workspace bar';
80 cmd 'rename workspace to 5';
81 is(get_output_for_workspace('5'), 'fake-0',
82     'Renaming the workspace to a workspace assigned to a directional output should not move the workspace');
83
84 ##########################################################################
85 # Renaming an unfocused workspace, triggering an assignment to the output
86 # which holds the currently focused empty workspace should result in the
87 # original workspace replacing the empty one.
88 # See issue #3228.
89 ##########################################################################
90
91 cmd 'workspace baz';
92 cmd 'rename workspace 5 to 2';
93 is(get_output_for_workspace('2'), 'fake-1',
94     'Renaming an unfocused workspace, triggering an assignment to the output which holds the currently focused empty workspace should result in the original workspace replacing the empty one');
95
96 ##########################################################################
97 # Renaming an unfocused empty workspace, triggering an assignment to the
98 # output which holds the currently focused non-empty workspace should
99 # close the empty workspace and not crash i3.
100 # See issue #3248.
101 ##########################################################################
102
103 cmd 'workspace 1';
104 cmd 'workspace 2';
105 open_window;
106 cmd 'rename workspace 1 to baz';
107 is(get_output_for_workspace('baz'), '',
108     'Renaming an unfocused empty workspace, triggering an assignment to the output which holds the currently focused non-empty workspace should close the empty workspace and not crash i3');
109 kill_all_windows;
110
111 ##########################################################################
112 # Renaming a workspace with multiple assignments, where the first output
113 # doesn't exist.
114 ##########################################################################
115
116 cmd 'focus output fake-1';
117 cmd 'rename workspace to 6';
118 is(get_output_for_workspace('6'), 'fake-0',
119    'Renaming the workspace while first target output doesn\'t exist moves it to the second assigned output');
120
121 ##########################################################################
122 # Renaming a workspace with multiple assignments, where both outputs exist
123 # moves it to the first output.
124 ##########################################################################
125
126 cmd 'focus output fake-0';
127 cmd 'rename workspace to 7';
128 is(get_output_for_workspace('7'), 'fake-1',
129    'Renaming a workspace with multiple assignments, where both outputs exist moves it to the first output.');
130
131 done_testing;