From 4add185025612103a599f1d6f8a0f55675b245b2 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 14 Dec 2013 10:42:01 +0100 Subject: [PATCH] tests: add simple layout restore test --- testcases/t/213-layout-restore-simple.t | 124 ++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 testcases/t/213-layout-restore-simple.t diff --git a/testcases/t/213-layout-restore-simple.t b/testcases/t/213-layout-restore-simple.t new file mode 100644 index 00000000..b10dfdf6 --- /dev/null +++ b/testcases/t/213-layout-restore-simple.t @@ -0,0 +1,124 @@ +#!perl +# vim:ts=4:sw=4:expandtab +# +# Please read the following documents before working on tests: +# • http://build.i3wm.org/docs/testsuite.html +# (or docs/testsuite) +# +# • http://build.i3wm.org/docs/lib-i3test.html +# (alternatively: perldoc ./testcases/lib/i3test.pm) +# +# • http://build.i3wm.org/docs/ipc.html +# (or docs/ipc) +# +# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf +# (unless you are already familiar with Perl) +# +# Restores a simple layout from a JSON file. +use i3test; +use File::Temp qw(tempfile); +use IO::Handle; + +################################################################################ +# empty layout file. +################################################################################ + +my ($fh, $filename) = tempfile(UNLINK => 1); +cmd "append_layout $filename"; + +does_i3_live; + +close($fh); + +################################################################################ +# simple vsplit layout +################################################################################ + +my $ws = fresh_workspace; + +my @content = @{get_ws_content($ws)}; +is(@content, 0, 'no nodes on the new workspace yet'); + +($fh, $filename) = tempfile(UNLINK => 1); +print $fh <flush; +cmd "append_layout $filename"; + +does_i3_live; + +@content = @{get_ws_content($ws)}; +is(@content, 1, 'one node on the workspace now'); +is($content[0]->{layout}, 'splitv', 'node has splitv layout'); +is(@{$content[0]->{nodes}}, 2, 'node has two children'); + +close($fh); + +################################################################################ +# simple vsplit layout with swallow specifications +################################################################################ + +$ws = fresh_workspace; + +@content = @{get_ws_content($ws)}; +is(@content, 0, 'no nodes on the new workspace yet'); + +($fh, $filename) = tempfile(UNLINK => 1); +print $fh <flush; +cmd "append_layout $filename"; + +does_i3_live; + +@content = @{get_ws_content($ws)}; +is(@content, 1, 'one node on the workspace now'); + +my $top = open_window( + name => 'top window', + wm_class => 'top', + instance => 'top', +); + +my $bottom = open_window( + name => 'bottom window', + wm_class => 'bottom', + instance => 'bottom', +); + +@content = @{get_ws_content($ws)}; +is(@content, 1, 'still one node on the workspace now'); +my @nodes = @{$content[0]->{nodes}}; +is($nodes[0]->{name}, 'top window', 'top window on top'); + +close($fh); + +done_testing;