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 # Verifies that entire outputs can be saved and restored properly by i3.
19 # Bug still in: 4.8-26-gf96ec19
21 use File::Temp qw(tempfile);
24 my $ws = fresh_workspace;
26 ################################################################################
27 # Append a new workspace with a name.
28 ################################################################################
30 ok(!workspace_exists('ws_new'), 'workspace "ws_new" does not exist yet');
32 my ($fh, $filename) = tempfile(UNLINK => 1);
36 // workspace with 1 children
38 "floating": "auto_off",
46 "floating": "auto_off",
53 "name": "vals@w00t: ~",
57 // "class": "^URxvt$",
58 // "instance": "^urxvt$",
59 // "title": "^vals\\@w00t\\:\\ \\~$"
68 cmd "append_layout $filename";
70 ok(workspace_exists('ws_new'), 'workspace "ws_new" exists now');
76 ################################################################################
77 # Append a new workspace with a name that clashes with an existing workspace.
78 ################################################################################
80 my @old_workspaces = @{get_workspace_names()};
82 cmd "append_layout $filename";
84 my @new_workspaces = @{get_workspace_names()};
85 cmp_ok(scalar @new_workspaces, '>', scalar @old_workspaces, 'more workspaces than before');
87 my %created_workspaces = map { ($_, 1) } @new_workspaces;
88 delete $created_workspaces{$_} for @old_workspaces;
89 diag('created workspaces = ' . Dumper(keys %created_workspaces));
90 cmp_ok(scalar keys %created_workspaces, '>', 0, 'new workspaces appeared');
92 ################################################################################
93 # Append a new workspace without a name.
94 ################################################################################
96 ok(!workspace_exists('unnamed'), 'workspace "unnamed" does not exist yet');
98 ($fh, $filename) = tempfile(UNLINK => 1);
102 // workspace with 1 children
104 "floating": "auto_off",
111 "floating": "auto_off",
118 "name": "vals@w00t: ~",
122 // "class": "^URxvt$",
123 // "instance": "^urxvt$",
124 // "title": "^vals\\@w00t\\:\\ \\~$"
133 cmd "append_layout $filename";
135 ok(workspace_exists('unnamed'), 'workspace "unnamed" exists now');
137 ################################################################################
138 # Append a workspace with a numeric name, ensure it has ->num set.
139 ################################################################################
141 ok(!workspace_exists('4'), 'workspace "4" does not exist yet');
143 ($fh, $filename) = tempfile(UNLINK => 1);
147 // workspace with 1 children
149 "floating": "auto_off",
157 "floating": "auto_off",
164 "name": "vals@w00t: ~",
168 // "class": "^URxvt$",
169 // "instance": "^urxvt$",
170 // "title": "^vals\\@w00t\\:\\ \\~$"
179 cmd "append_layout $filename";
181 ok(workspace_exists('4'), 'workspace "4" exists now');
183 is($ws->{num}, 4, 'workspace number is 4');
185 ################################################################################
186 # Append a workspace with a numeric name, with the “type” property at the end
187 # of the JSON blurb (which is valid and sometimes happens).
188 ################################################################################
190 ok(!workspace_exists('5'), 'workspace "5" does not exist yet');
192 ($fh, $filename) = tempfile(UNLINK => 1);
196 // workspace with 1 children
198 "floating": "auto_off",
205 "floating": "auto_off",
212 "name": "vals@w00t: ~",
216 // "class": "^URxvt$",
217 // "instance": "^urxvt$",
218 // "title": "^vals\\@w00t\\:\\ \\~$"
228 cmd "append_layout $filename";
230 ok(workspace_exists('5'), 'workspace "5" exists now');
232 is($ws->{num}, 5, 'workspace number is 5');