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);
22 use List::MoreUtils qw(uniq);
25 my $ws = fresh_workspace;
27 ################################################################################
28 # Append a new workspace with a name.
29 ################################################################################
31 ok(!workspace_exists('ws_new'), 'workspace "ws_new" does not exist yet');
33 my ($fh, $filename) = tempfile(UNLINK => 1);
37 // workspace with 1 children
39 "floating": "auto_off",
47 "floating": "auto_off",
54 "name": "vals@w00t: ~",
58 // "class": "^URxvt$",
59 // "instance": "^urxvt$",
60 // "title": "^vals\\@w00t\\:\\ \\~$"
69 cmd "append_layout $filename";
71 ok(workspace_exists('ws_new'), 'workspace "ws_new" exists now');
77 ################################################################################
78 # Append a new workspace with a name that clashes with an existing workspace.
79 ################################################################################
81 my @old_workspaces = @{get_workspace_names()};
83 cmd "append_layout $filename";
85 my @new_workspaces = @{get_workspace_names()};
86 cmp_ok(scalar @new_workspaces, '>', scalar @old_workspaces, 'more workspaces than before');
88 my %created_workspaces = map { ($_, 1) } @new_workspaces;
89 delete $created_workspaces{$_} for @old_workspaces;
90 diag('created workspaces = ' . Dumper(keys %created_workspaces));
91 cmp_ok(scalar keys %created_workspaces, '>', 0, 'new workspaces appeared');
93 ################################################################################
94 # Append a new workspace without a name.
95 ################################################################################
97 ok(!workspace_exists('unnamed'), 'workspace "unnamed" does not exist yet');
99 ($fh, $filename) = tempfile(UNLINK => 1);
103 // workspace with 1 children
105 "floating": "auto_off",
112 "floating": "auto_off",
119 "name": "vals@w00t: ~",
123 // "class": "^URxvt$",
124 // "instance": "^urxvt$",
125 // "title": "^vals\\@w00t\\:\\ \\~$"
134 cmd "append_layout $filename";
136 ok(workspace_exists('unnamed'), 'workspace "unnamed" exists now');
138 ################################################################################
139 # Append a workspace with a numeric name, ensure it has ->num set.
140 ################################################################################
142 ok(!workspace_exists('4'), 'workspace "4" does not exist yet');
144 ($fh, $filename) = tempfile(UNLINK => 1);
148 // workspace with 1 children
150 "floating": "auto_off",
158 "floating": "auto_off",
165 "name": "vals@w00t: ~",
169 // "class": "^URxvt$",
170 // "instance": "^urxvt$",
171 // "title": "^vals\\@w00t\\:\\ \\~$"
180 cmd "append_layout $filename";
182 ok(workspace_exists('4'), 'workspace "4" exists now');
183 my $ws = get_ws("4");
184 is($ws->{num}, 4, 'workspace number is 4');