2010-03-27 10:25:51 -04:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
|
|
|
|
2011-03-09 14:25:17 -05:00
|
|
|
use i3test;
|
2011-02-20 17:43:03 -05:00
|
|
|
use List::Util qw(first);
|
2010-03-27 10:25:51 -04:00
|
|
|
|
2011-10-05 18:21:36 -04:00
|
|
|
# to not depend on List::MoreUtils
|
|
|
|
sub all (&@) {
|
|
|
|
my $cb = shift;
|
|
|
|
for (@_) {
|
|
|
|
return 0 unless $cb->();
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub none (&@) {
|
|
|
|
my $cb = shift;
|
|
|
|
for (@_) {
|
|
|
|
return 0 if $cb->();
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-07-25 07:35:56 -04:00
|
|
|
my $i3 = i3(get_socket_path());
|
2010-03-27 10:25:51 -04:00
|
|
|
|
|
|
|
####################
|
|
|
|
# Request tree
|
|
|
|
####################
|
|
|
|
|
2010-11-21 15:42:28 -05:00
|
|
|
my $tree = $i3->get_tree->recv;
|
2010-03-27 10:25:51 -04:00
|
|
|
|
|
|
|
my $expected = {
|
|
|
|
fullscreen_mode => 0,
|
|
|
|
nodes => ignore(),
|
|
|
|
window => undef,
|
|
|
|
name => 'root',
|
|
|
|
orientation => ignore(),
|
|
|
|
type => 0,
|
|
|
|
id => ignore(),
|
2010-04-16 15:01:08 -04:00
|
|
|
rect => ignore(),
|
2010-11-28 11:29:44 -05:00
|
|
|
window_rect => ignore(),
|
2011-02-21 06:20:55 -05:00
|
|
|
geometry => ignore(),
|
|
|
|
swallows => ignore(),
|
2011-07-24 08:47:28 -04:00
|
|
|
percent => undef,
|
2011-06-02 11:12:18 -04:00
|
|
|
layout => 'default',
|
2010-04-16 15:01:08 -04:00
|
|
|
focus => ignore(),
|
2011-07-24 09:00:09 -04:00
|
|
|
focused => JSON::XS::false,
|
2011-07-24 08:54:30 -04:00
|
|
|
urgent => JSON::XS::false,
|
2011-05-11 14:39:18 -04:00
|
|
|
border => 'normal',
|
2010-11-21 10:34:45 -05:00
|
|
|
'floating_nodes' => ignore(),
|
2010-03-27 10:25:51 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
cmp_deeply($tree, $expected, 'root node OK');
|
|
|
|
|
|
|
|
my @nodes = @{$tree->{nodes}};
|
|
|
|
|
|
|
|
ok(@nodes > 0, 'root node has at least one leaf');
|
|
|
|
|
|
|
|
ok((all { $_->{type} == 1 } @nodes), 'all nodes are of type CT_OUTPUT');
|
|
|
|
ok((none { defined($_->{window}) } @nodes), 'no CT_OUTPUT contains a window');
|
|
|
|
ok((all { @{$_->{nodes}} > 0 } @nodes), 'all nodes have at least one leaf (workspace)');
|
|
|
|
my @workspaces;
|
2011-02-20 17:43:03 -05:00
|
|
|
for my $ws (@nodes) {
|
|
|
|
my $content = first { $_->{type} == 2 } @{$ws->{nodes}};
|
|
|
|
@workspaces = (@workspaces, @{$content->{nodes}});
|
2010-03-27 10:25:51 -04:00
|
|
|
}
|
|
|
|
|
2010-06-02 17:53:22 -04:00
|
|
|
ok((all { $_->{type} == 4 } @workspaces), 'all workspaces are of type CT_WORKSPACE');
|
|
|
|
#ok((all { @{$_->{nodes}} == 0 } @workspaces), 'all workspaces are empty yet');
|
2010-03-27 10:25:51 -04:00
|
|
|
ok((none { defined($_->{window}) } @workspaces), 'no CT_OUTPUT contains a window');
|
|
|
|
|
|
|
|
# TODO: get the focused container
|
|
|
|
|
|
|
|
$i3->command('open')->recv;
|
|
|
|
|
|
|
|
# TODO: get the focused container, check if it changed.
|
|
|
|
# TODO: get the old focused container, check if there is a new child
|
|
|
|
|
2010-06-02 17:53:22 -04:00
|
|
|
#diag(Dumper(\@workspaces));
|
2010-03-27 10:25:51 -04:00
|
|
|
|
2010-06-02 17:53:22 -04:00
|
|
|
#diag(Dumper($tree));
|
2010-03-27 10:25:51 -04:00
|
|
|
|
|
|
|
|
2011-03-09 14:25:17 -05:00
|
|
|
done_testing;
|