]> git.sur5r.net Git - i3/i3/blob - testcases/t/16-nestedcons.t
bugfix: don’t clean up workspace when switching to the same workspace
[i3/i3] / testcases / t / 16-nestedcons.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3
4 use i3test tests => 8;
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_workspaces->recv;
14 # $VAR1 = {
15 #           'fullscreen_mode' => 0,
16 #           'nodes' => [
17 #                         {
18 #                           'fullscreen_mode' => 0,
19 #                           'nodes' => [
20 #                                         {
21 #                                           'fullscreen_mode' => 0,
22 #                                           'nodes' => [],
23 #                                           'window' => undef,
24 #                                           'name' => '1',
25 #                                           'orientation' => 0,
26 #                                           'type' => 2
27 #                                         }
28 #                                       ],
29 #                           'window' => undef,
30 #                           'name' => 'LVDS1',
31 #                           'orientation' => 0,
32 #                           'type' => 1
33 #                         }
34 #                       ],
35 #           'window' => undef,
36 #           'name' => 'root',
37 #           'orientation' => 0,
38 #           'type' => 0
39 #         };
40
41 my $expected = {
42     fullscreen_mode => 0,
43     nodes => ignore(),
44     window => undef,
45     name => 'root',
46     orientation => ignore(),
47     type => 0,
48     id => ignore(),
49     rect => ignore(),
50     layout => 0,
51     focus => 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" );