2 # vim:ts=4:sw=4:expandtab
5 use List::MoreUtils qw(all none);
6 use List::Util qw(first);
8 my $i3 = i3(get_socket_path());
14 my $tree = $i3->get_tree->recv;
21 orientation => ignore(),
25 window_rect => ignore(),
31 focused => JSON::XS::false,
32 urgent => JSON::XS::false,
34 'floating_nodes' => ignore(),
37 cmp_deeply($tree, $expected, 'root node OK');
39 my @nodes = @{$tree->{nodes}};
41 ok(@nodes > 0, 'root node has at least one leaf');
43 ok((all { $_->{type} == 1 } @nodes), 'all nodes are of type CT_OUTPUT');
44 ok((none { defined($_->{window}) } @nodes), 'no CT_OUTPUT contains a window');
45 ok((all { @{$_->{nodes}} > 0 } @nodes), 'all nodes have at least one leaf (workspace)');
48 my $content = first { $_->{type} == 2 } @{$ws->{nodes}};
49 @workspaces = (@workspaces, @{$content->{nodes}});
52 ok((all { $_->{type} == 4 } @workspaces), 'all workspaces are of type CT_WORKSPACE');
53 #ok((all { @{$_->{nodes}} == 0 } @workspaces), 'all workspaces are empty yet');
54 ok((none { defined($_->{window}) } @workspaces), 'no CT_OUTPUT contains a window');
56 # TODO: get the focused container
58 $i3->command('open')->recv;
60 # TODO: get the focused container, check if it changed.
61 # TODO: get the old focused container, check if there is a new child
63 #diag(Dumper(\@workspaces));