2010-04-16 17:04:42 -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-04-16 17:04:42 -04:00
|
|
|
# Tests all kinds of matching methods
|
|
|
|
#
|
2011-03-09 14:25:17 -05:00
|
|
|
use i3test;
|
2010-04-16 17:04:42 -04:00
|
|
|
|
2011-03-09 14:25:17 -05:00
|
|
|
my $tmp = fresh_workspace;
|
2010-04-16 17:04:42 -04:00
|
|
|
|
|
|
|
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
|
|
|
|
|
|
|
|
# Open a new window
|
2011-11-21 18:47:32 -05:00
|
|
|
my $window = open_window;
|
2010-04-16 17:04:42 -04:00
|
|
|
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: specify more match types
|
2011-09-10 18:52:39 -04:00
|
|
|
# we can match on any (non-empty) class here since that window does not have
|
|
|
|
# WM_CLASS set
|
|
|
|
cmd q|[class=".*"] kill|;
|
2011-03-09 14:25:17 -05:00
|
|
|
cmd q|[con_id="99999"] kill|;
|
2010-04-16 17:04:42 -04:00
|
|
|
|
2012-09-04 16:24:13 -04:00
|
|
|
is_num_children($tmp, 1, 'window still there');
|
2010-04-16 17:04:42 -04:00
|
|
|
|
|
|
|
# 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};
|
2011-03-09 14:25:17 -05:00
|
|
|
cmd qq|[con_id="$id"] kill|;
|
2010-04-16 17:04:42 -04:00
|
|
|
|
2011-11-21 17:44:20 -05:00
|
|
|
wait_for_unmap $window;
|
2011-03-09 12:47:00 -05:00
|
|
|
|
|
|
|
cmd 'nop checking if its gone';
|
2012-09-04 16:24:13 -04:00
|
|
|
is_num_children($tmp, 0, 'window killed');
|
2010-04-16 17:04:42 -04:00
|
|
|
|
|
|
|
# TODO: same test, but with pcre expressions
|
|
|
|
|
2011-07-07 18:21:29 -04:00
|
|
|
######################################################################
|
|
|
|
# check that multiple criteria work are checked with a logical AND,
|
|
|
|
# not a logical OR (that is, matching is not cancelled after the first
|
|
|
|
# criterion matches).
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
|
2013-09-24 15:53:48 -04:00
|
|
|
my $left = open_window(wm_class => 'special', name => 'left');
|
2011-11-23 11:22:43 -05:00
|
|
|
ok($left->mapped, 'left window mapped');
|
|
|
|
|
2013-09-24 15:53:48 -04:00
|
|
|
my $right = open_window(wm_class => 'special', name => 'right');
|
2011-11-23 11:22:43 -05:00
|
|
|
ok($right->mapped, 'right window mapped');
|
2011-07-07 18:21:29 -04:00
|
|
|
|
|
|
|
# two windows should be here
|
2012-09-04 16:24:13 -04:00
|
|
|
is_num_children($tmp, 2, 'two windows opened');
|
2011-07-07 18:21:29 -04:00
|
|
|
|
|
|
|
cmd '[class="special" title="left"] kill';
|
|
|
|
|
2011-11-21 19:13:37 -05:00
|
|
|
sync_with_i3;
|
2011-07-08 19:01:52 -04:00
|
|
|
|
2012-09-04 16:24:13 -04:00
|
|
|
is_num_children($tmp, 1, 'one window still there');
|
2011-07-07 18:21:29 -04:00
|
|
|
|
2011-09-10 18:52:39 -04:00
|
|
|
######################################################################
|
|
|
|
# check that regular expressions work
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
|
2013-09-24 15:53:48 -04:00
|
|
|
$left = open_window(name => 'left', wm_class => 'special7');
|
2011-11-23 11:22:43 -05:00
|
|
|
ok($left->mapped, 'left window mapped');
|
2012-09-04 16:24:13 -04:00
|
|
|
is_num_children($tmp, 1, 'window opened');
|
2011-09-10 18:52:39 -04:00
|
|
|
|
|
|
|
cmd '[class="^special[0-9]$"] kill';
|
2011-11-21 17:44:20 -05:00
|
|
|
wait_for_unmap $left;
|
2012-09-04 16:24:13 -04:00
|
|
|
is_num_children($tmp, 0, 'window killed');
|
2011-09-10 18:52:39 -04:00
|
|
|
|
2011-09-11 06:40:51 -04:00
|
|
|
######################################################################
|
|
|
|
# check that UTF-8 works when matching
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
|
2013-09-24 15:53:48 -04:00
|
|
|
$left = open_window(name => 'ä 3', wm_class => 'special7');
|
2011-11-23 11:22:43 -05:00
|
|
|
ok($left->mapped, 'left window mapped');
|
2012-09-04 16:24:13 -04:00
|
|
|
is_num_children($tmp, 1, 'window opened');
|
2011-09-11 06:40:51 -04:00
|
|
|
|
|
|
|
cmd '[title="^\w [3]$"] kill';
|
2011-11-21 17:44:20 -05:00
|
|
|
wait_for_unmap $left;
|
2012-09-04 16:24:13 -04:00
|
|
|
is_num_children($tmp, 0, 'window killed');
|
2011-09-10 18:52:39 -04:00
|
|
|
|
2011-03-09 14:25:17 -05:00
|
|
|
done_testing;
|