2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • https://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 # Restores a simple layout from a JSON file.
19 use File::Temp qw(tempfile);
22 ################################################################################
24 ################################################################################
26 my ($fh, $filename) = tempfile(UNLINK => 1);
27 cmd "append_layout $filename";
33 ################################################################################
34 # simple vsplit layout
35 ################################################################################
37 my $ws = fresh_workspace;
39 my @content = @{get_ws_content($ws)};
40 is(@content, 0, 'no nodes on the new workspace yet');
42 ($fh, $filename) = tempfile(UNLINK => 1);
55 cmd "append_layout $filename";
59 @content = @{get_ws_content($ws)};
60 is(@content, 1, 'one node on the workspace now');
61 is($content[0]->{layout}, 'splitv', 'node has splitv layout');
62 is(@{$content[0]->{nodes}}, 2, 'node has two children');
66 ################################################################################
67 # two simple vsplit containers in the same file
68 ################################################################################
70 $ws = fresh_workspace;
72 @content = @{get_ws_content($ws)};
73 is(@content, 0, 'no nodes on the new workspace yet');
75 ($fh, $filename) = tempfile(UNLINK => 1);
92 cmd "append_layout $filename";
96 @content = @{get_ws_content($ws)};
97 is(@content, 2, 'one node on the workspace now');
98 is($content[0]->{layout}, 'splitv', 'first node has splitv layout');
99 is(@{$content[0]->{nodes}}, 2, 'first node has two children');
100 is($content[1]->{layout}, 'splitv', 'second node has splitv layout');
101 is(@{$content[1]->{nodes}}, 0, 'first node has no children');
105 ################################################################################
106 # simple vsplit layout with swallow specifications
107 ################################################################################
109 $ws = fresh_workspace;
111 @content = @{get_ws_content($ws)};
112 is(@content, 0, 'no nodes on the new workspace yet');
114 ($fh, $filename) = tempfile(UNLINK => 1);
137 cmd "append_layout $filename";
141 @content = @{get_ws_content($ws)};
142 is(@content, 1, 'one node on the workspace now');
144 my $top = open_window(
145 name => 'top window',
150 my $bottom = open_window(
151 name => 'bottom window',
152 wm_class => 'bottom',
153 instance => 'bottom',
156 @content = @{get_ws_content($ws)};
157 is(@content, 1, 'still one node on the workspace now');
158 my @nodes = @{$content[0]->{nodes}};
159 is($nodes[0]->{name}, 'top window', 'top window on top');