2010-03-27 10:25:51 -04:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
2012-09-10 08:09:01 -04:00
|
|
|
#
|
|
|
|
# Please read the following documents before working on tests:
|
|
|
|
# • http://build.i3wm.org/docs/testsuite.html
|
|
|
|
# (or docs/testsuite)
|
|
|
|
#
|
|
|
|
# • http://build.i3wm.org/docs/lib-i3test.html
|
|
|
|
# (alternatively: perldoc ./testcases/lib/i3test.pm)
|
|
|
|
#
|
|
|
|
# • http://build.i3wm.org/docs/ipc.html
|
|
|
|
# (or docs/ipc)
|
|
|
|
#
|
|
|
|
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
|
|
|
|
# (unless you are already familiar with Perl)
|
2010-03-27 10:25:51 -04:00
|
|
|
|
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
|
|
|
|
2011-11-22 18:10:47 -05:00
|
|
|
# a unique value
|
|
|
|
my $ignore = \"";
|
|
|
|
|
2010-03-27 10:25:51 -04:00
|
|
|
my $expected = {
|
|
|
|
fullscreen_mode => 0,
|
2011-11-22 18:10:47 -05:00
|
|
|
nodes => $ignore,
|
2010-03-27 10:25:51 -04:00
|
|
|
window => undef,
|
|
|
|
name => 'root',
|
2011-11-22 18:10:47 -05:00
|
|
|
orientation => $ignore,
|
2013-12-14 08:50:44 -05:00
|
|
|
type => 'root',
|
2011-11-22 18:10:47 -05:00
|
|
|
id => $ignore,
|
|
|
|
rect => $ignore,
|
2014-11-16 16:05:51 -05:00
|
|
|
deco_rect => $ignore,
|
2011-11-22 18:10:47 -05:00
|
|
|
window_rect => $ignore,
|
|
|
|
geometry => $ignore,
|
|
|
|
swallows => $ignore,
|
2011-07-24 08:47:28 -04:00
|
|
|
percent => undef,
|
Introduce splith/splitv layouts, remove orientation
With this commit, the "default" layout is replaced by the splith and
splitv layouts. splith is equivalent to default with orientation
horizontal and splitv is equivalent to default with orientation
vertical.
The "split h" and "split v" commands continue to work as before, they
split the current container and you will end up in a split container
with layout splith (after "split h") or splitv (after "split v").
To change a splith container into a splitv container, use either "layout
splitv" or "layout toggle split". The latter command is used in the
default config as mod+l (previously "layout default"). In case you have
"layout default" in your config file, it is recommended to just replace
it by "layout toggle split", which will work as "layout default" did
before when pressing it once, but toggle between horizontal/vertical
when pressing it repeatedly.
The rationale behind this commit is that it’s cleaner to have all
parameters that influence how windows are rendered in the layout itself
rather than having a special parameter in combination with only one
layout. This enables us to change existing split containers in all cases
without breaking existing features (see ticket #464). Also, users should
feel more confident about whether they are actually splitting or just
changing an existing split container now.
As a nice side-effect, this commit brings back the "layout toggle"
feature we once had in i3 version 3 (see the userguide).
AFAIK, it is safe to use in-place restart to upgrade into versions
after this commit (switching to an older version will break your layout,
though).
Fixes #464
2012-08-03 21:04:00 -04:00
|
|
|
layout => 'splith',
|
2012-01-05 16:39:18 -05:00
|
|
|
floating => 'auto_off',
|
Introduce splith/splitv layouts, remove orientation
With this commit, the "default" layout is replaced by the splith and
splitv layouts. splith is equivalent to default with orientation
horizontal and splitv is equivalent to default with orientation
vertical.
The "split h" and "split v" commands continue to work as before, they
split the current container and you will end up in a split container
with layout splith (after "split h") or splitv (after "split v").
To change a splith container into a splitv container, use either "layout
splitv" or "layout toggle split". The latter command is used in the
default config as mod+l (previously "layout default"). In case you have
"layout default" in your config file, it is recommended to just replace
it by "layout toggle split", which will work as "layout default" did
before when pressing it once, but toggle between horizontal/vertical
when pressing it repeatedly.
The rationale behind this commit is that it’s cleaner to have all
parameters that influence how windows are rendered in the layout itself
rather than having a special parameter in combination with only one
layout. This enables us to change existing split containers in all cases
without breaking existing features (see ticket #464). Also, users should
feel more confident about whether they are actually splitting or just
changing an existing split container now.
As a nice side-effect, this commit brings back the "layout toggle"
feature we once had in i3 version 3 (see the userguide).
AFAIK, it is safe to use in-place restart to upgrade into versions
after this commit (switching to an older version will break your layout,
though).
Fixes #464
2012-08-03 21:04:00 -04:00
|
|
|
last_split_layout => 'splith',
|
2011-12-21 18:15:32 -05:00
|
|
|
scratchpad_state => 'none',
|
2011-11-22 18:10:47 -05: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',
|
2011-11-22 18:10:47 -05:00
|
|
|
'floating_nodes' => $ignore,
|
2012-09-16 16:53:41 -04:00
|
|
|
workspace_layout => 'default',
|
2012-09-23 19:14:00 -04:00
|
|
|
current_border_width => -1,
|
2010-03-27 10:25:51 -04:00
|
|
|
};
|
|
|
|
|
2011-11-22 18:10:47 -05:00
|
|
|
# a shallow copy is sufficient, since we only ignore values at the root
|
|
|
|
my $tree_copy = { %$tree };
|
|
|
|
|
|
|
|
for (keys %$expected) {
|
|
|
|
my $val = $expected->{$_};
|
|
|
|
|
|
|
|
# delete unwanted keys, so we can use is_deeply()
|
|
|
|
if (ref($val) eq 'SCALAR' and $val == $ignore) {
|
|
|
|
delete $tree_copy->{$_};
|
|
|
|
delete $expected->{$_};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
is_deeply($tree_copy, $expected, 'root node OK');
|
2010-03-27 10:25:51 -04:00
|
|
|
|
|
|
|
my @nodes = @{$tree->{nodes}};
|
|
|
|
|
|
|
|
ok(@nodes > 0, 'root node has at least one leaf');
|
|
|
|
|
2013-12-14 08:50:44 -05:00
|
|
|
ok((all { $_->{type} eq 'output' } @nodes), 'all nodes are of type CT_OUTPUT');
|
2010-03-27 10:25:51 -04:00
|
|
|
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) {
|
2013-12-14 08:50:44 -05:00
|
|
|
my $content = first { $_->{type} eq 'con' } @{$ws->{nodes}};
|
2011-02-20 17:43:03 -05:00
|
|
|
@workspaces = (@workspaces, @{$content->{nodes}});
|
2010-03-27 10:25:51 -04:00
|
|
|
}
|
|
|
|
|
2013-12-14 08:50:44 -05:00
|
|
|
ok((all { $_->{type} eq 'workspace' } @workspaces), 'all workspaces are of type CT_WORKSPACE');
|
2010-06-02 17:53:22 -04:00
|
|
|
#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;
|