]> git.sur5r.net Git - i3/i3/blob - testcases/t/16-nestedcons.t
first step of the big refactoring ("tree" branch).
[i3/i3] / testcases / t / 16-nestedcons.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3
4 use Test::More tests => 8;
5 use Test::Deep;
6 use List::MoreUtils qw(all none);
7 use Data::Dumper;
8 use AnyEvent::I3;
9
10 my $i3 = i3("/tmp/nestedcons");
11
12 ####################
13 # Request tree
14 ####################
15
16 my $tree = $i3->get_workspaces->recv;
17 # $VAR1 = {
18 #           'fullscreen_mode' => 0,
19 #           'nodes' => [
20 #                         {
21 #                           'fullscreen_mode' => 0,
22 #                           'nodes' => [
23 #                                         {
24 #                                           'fullscreen_mode' => 0,
25 #                                           'nodes' => [],
26 #                                           'window' => undef,
27 #                                           'name' => '1',
28 #                                           'orientation' => 0,
29 #                                           'type' => 2
30 #                                         }
31 #                                       ],
32 #                           'window' => undef,
33 #                           'name' => 'LVDS1',
34 #                           'orientation' => 0,
35 #                           'type' => 1
36 #                         }
37 #                       ],
38 #           'window' => undef,
39 #           'name' => 'root',
40 #           'orientation' => 0,
41 #           'type' => 0
42 #         };
43
44 my $expected = {
45     fullscreen_mode => 0,
46     nodes => ignore(),
47     window => undef,
48     name => 'root',
49     orientation => ignore(),
50     type => 0,
51     id => ignore(),
52 };
53
54 cmp_deeply($tree, $expected, 'root node OK');
55
56 my @nodes = @{$tree->{nodes}};
57
58 ok(@nodes > 0, 'root node has at least one leaf');
59
60 ok((all { $_->{type} == 1 } @nodes), 'all nodes are of type CT_OUTPUT');
61 ok((none { defined($_->{window}) } @nodes), 'no CT_OUTPUT contains a window');
62 ok((all { @{$_->{nodes}} > 0 } @nodes), 'all nodes have at least one leaf (workspace)');
63 my @workspaces;
64 for my $ws (map { @{$_->{nodes}} } @nodes) {
65     push @workspaces, $ws;
66 }
67
68 ok((all { $_->{type} == 2 } @workspaces), 'all workspaces are of type CT_CON');
69 ok((all { @{$_->{nodes}} == 0 } @workspaces), 'all workspaces are empty yet');
70 ok((none { defined($_->{window}) } @workspaces), 'no CT_OUTPUT contains a window');
71
72 # TODO: get the focused container
73
74 $i3->command('open')->recv;
75
76 # TODO: get the focused container, check if it changed.
77 # TODO: get the old focused container, check if there is a new child
78
79 diag(Dumper(\@workspaces));
80
81 diag(Dumper($tree));
82
83
84 diag( "Testing i3, Perl $], $^X" );