2010-04-16 17:04:42 -04:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
|
|
|
#
|
|
|
|
# Tests all kinds of matching methods
|
|
|
|
#
|
2010-04-17 16:49:26 -04:00
|
|
|
use i3test tests => 4;
|
2010-04-16 17:04:42 -04:00
|
|
|
use X11::XCB qw(:all);
|
|
|
|
|
|
|
|
my $i3 = i3("/tmp/nestedcons");
|
|
|
|
|
|
|
|
my $tmp = get_unused_workspace();
|
|
|
|
$i3->command("workspace $tmp")->recv;
|
|
|
|
|
|
|
|
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
|
|
|
|
|
|
|
|
# Open a new window
|
|
|
|
my $x = X11::XCB::Connection->new;
|
|
|
|
my $window = $x->root->create_child(
|
|
|
|
class => WINDOW_CLASS_INPUT_OUTPUT,
|
|
|
|
rect => [ 0, 0, 30, 30 ],
|
|
|
|
background_color => '#C0C0C0',
|
|
|
|
);
|
|
|
|
|
|
|
|
$window->map;
|
|
|
|
# give it some time to be picked up by the window manager
|
|
|
|
# TODO: better check for $window->mapped or something like that?
|
|
|
|
# maybe we can even wait for getting mapped?
|
|
|
|
my $c = 0;
|
|
|
|
while (@{get_ws_content($tmp)} == 0 and $c++ < 5) {
|
|
|
|
sleep 0.25;
|
|
|
|
}
|
|
|
|
my $content = get_ws_content($tmp);
|
|
|
|
ok(@{$content} == 1, 'window mapped');
|
|
|
|
my $win = $content->[0];
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# first test that matches which should not match this window really do
|
|
|
|
# not match it
|
|
|
|
######################################################################
|
|
|
|
# TODO: use PCRE expressions
|
|
|
|
# TODO: specify more match types
|
|
|
|
$i3->command(q|[class="*"] kill|)->recv;
|
|
|
|
$i3->command(q|[con_id="99999"] kill|)->recv;
|
|
|
|
|
|
|
|
$content = get_ws_content($tmp);
|
|
|
|
ok(@{$content} == 1, 'window still there');
|
|
|
|
|
|
|
|
# now kill the window
|
2011-03-09 12:47:00 -05:00
|
|
|
cmd 'nop now killing the window';
|
2010-04-16 17:04:42 -04:00
|
|
|
my $id = $win->{id};
|
|
|
|
$i3->command(qq|[con_id="$id"] kill|)->recv;
|
|
|
|
|
2011-03-09 12:47:00 -05:00
|
|
|
# give i3 some time to pick up the UnmapNotify event
|
|
|
|
sleep 0.25;
|
|
|
|
|
|
|
|
cmd 'nop checking if its gone';
|
2010-04-16 17:04:42 -04:00
|
|
|
$content = get_ws_content($tmp);
|
|
|
|
ok(@{$content} == 0, 'window killed');
|
|
|
|
|
|
|
|
# TODO: same test, but with pcre expressions
|
|
|
|
|
|
|
|
diag( "Testing i3, Perl $], $^X" );
|