2 # vim:ts=4:sw=4:expandtab
5 use List::Util qw(first);
7 # to not depend on List::MoreUtils
11 return 0 unless $cb->();
24 my $i3 = i3(get_socket_path());
30 my $tree = $i3->get_tree->recv;
37 orientation => ignore(),
41 window_rect => ignore(),
47 focused => JSON::XS::false,
48 urgent => JSON::XS::false,
50 'floating_nodes' => ignore(),
53 is_deeply($tree, $expected, 'root node OK');
55 my @nodes = @{$tree->{nodes}};
57 ok(@nodes > 0, 'root node has at least one leaf');
59 ok((all { $_->{type} == 1 } @nodes), 'all nodes are of type CT_OUTPUT');
60 ok((none { defined($_->{window}) } @nodes), 'no CT_OUTPUT contains a window');
61 ok((all { @{$_->{nodes}} > 0 } @nodes), 'all nodes have at least one leaf (workspace)');
64 my $content = first { $_->{type} == 2 } @{$ws->{nodes}};
65 @workspaces = (@workspaces, @{$content->{nodes}});
68 ok((all { $_->{type} == 4 } @workspaces), 'all workspaces are of type CT_WORKSPACE');
69 #ok((all { @{$_->{nodes}} == 0 } @workspaces), 'all workspaces are empty yet');
70 ok((none { defined($_->{window}) } @workspaces), 'no CT_OUTPUT contains a window');
72 # TODO: get the focused container
74 $i3->command('open')->recv;
76 # TODO: get the focused container, check if it changed.
77 # TODO: get the old focused container, check if there is a new child
79 #diag(Dumper(\@workspaces));