]> git.sur5r.net Git - i3/i3/blob - testcases/t/16-nestedcons.t
365b0054cdb190a60e217ac009431db6054a9f32
[i3/i3] / testcases / t / 16-nestedcons.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3
4 use i3test tests => 7;
5 use List::MoreUtils qw(all none);
6
7 my $i3 = i3("/tmp/nestedcons");
8
9 ####################
10 # Request tree
11 ####################
12
13 my $tree = $i3->get_tree->recv;
14
15 my $expected = {
16     fullscreen_mode => 0,
17     nodes => ignore(),
18     window => undef,
19     name => 'root',
20     orientation => ignore(),
21     type => 0,
22     id => ignore(),
23     rect => ignore(),
24     window_rect => ignore(),
25     percent => 0,
26     layout => 0,
27     focus => ignore(),
28     focused => 0,
29     urgent => 0,
30     border => 0,
31     'floating_nodes' => ignore(),
32 };
33
34 cmp_deeply($tree, $expected, 'root node OK');
35
36 my @nodes = @{$tree->{nodes}};
37
38 ok(@nodes > 0, 'root node has at least one leaf');
39
40 ok((all { $_->{type} == 1 } @nodes), 'all nodes are of type CT_OUTPUT');
41 ok((none { defined($_->{window}) } @nodes), 'no CT_OUTPUT contains a window');
42 ok((all { @{$_->{nodes}} > 0 } @nodes), 'all nodes have at least one leaf (workspace)');
43 my @workspaces;
44 for my $ws (map { @{$_->{nodes}} } @nodes) {
45     push @workspaces, $ws;
46 }
47
48 ok((all { $_->{type} == 4 } @workspaces), 'all workspaces are of type CT_WORKSPACE');
49 #ok((all { @{$_->{nodes}} == 0 } @workspaces), 'all workspaces are empty yet');
50 ok((none { defined($_->{window}) } @workspaces), 'no CT_OUTPUT contains a window');
51
52 # TODO: get the focused container
53
54 $i3->command('open')->recv;
55
56 # TODO: get the focused container, check if it changed.
57 # TODO: get the old focused container, check if there is a new child
58
59 #diag(Dumper(\@workspaces));
60
61 #diag(Dumper($tree));
62
63
64 diag( "Testing i3, Perl $], $^X" );