2010-04-16 23:04:42 +02:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
|
|
|
#
|
2012-09-10 14:09:01 +02:00
|
|
|
# Please read the following documents before working on tests:
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/testsuite.html
|
2012-09-10 14:09:01 +02:00
|
|
|
# (or docs/testsuite)
|
|
|
|
#
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/lib-i3test.html
|
2012-09-10 14:09:01 +02:00
|
|
|
# (alternatively: perldoc ./testcases/lib/i3test.pm)
|
|
|
|
#
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/ipc.html
|
2012-09-10 14:09:01 +02:00
|
|
|
# (or docs/ipc)
|
|
|
|
#
|
|
|
|
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
|
|
|
|
# (unless you are already familiar with Perl)
|
|
|
|
#
|
2010-04-16 23:04:42 +02:00
|
|
|
# Tests all kinds of matching methods
|
|
|
|
#
|
2011-03-09 20:25:17 +01:00
|
|
|
use i3test;
|
2010-04-16 23:04:42 +02:00
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
my $tmp = fresh_workspace;
|
2010-04-16 23:04:42 +02:00
|
|
|
|
|
|
|
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
|
|
|
|
|
|
|
|
# Open a new window
|
2011-11-22 00:47:32 +01:00
|
|
|
my $window = open_window;
|
2010-04-16 23:04:42 +02: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
|
2019-10-09 12:45:10 +02:00
|
|
|
# Try matching with an empty pattern since there isn't a WM_CLASS set.
|
2011-03-09 20:25:17 +01:00
|
|
|
cmd q|[con_id="99999"] kill|;
|
2010-04-16 23:04:42 +02:00
|
|
|
|
2012-09-04 22:24:13 +02:00
|
|
|
is_num_children($tmp, 1, 'window still there');
|
2010-04-16 23:04:42 +02:00
|
|
|
|
|
|
|
# now kill the window
|
2011-03-09 18:47:00 +01:00
|
|
|
cmd 'nop now killing the window';
|
2010-04-16 23:04:42 +02:00
|
|
|
my $id = $win->{id};
|
2011-03-09 20:25:17 +01:00
|
|
|
cmd qq|[con_id="$id"] kill|;
|
2010-04-16 23:04:42 +02:00
|
|
|
|
2011-11-21 23:44:20 +01:00
|
|
|
wait_for_unmap $window;
|
2011-03-09 18:47:00 +01:00
|
|
|
|
|
|
|
cmd 'nop checking if its gone';
|
2012-09-04 22:24:13 +02:00
|
|
|
is_num_children($tmp, 0, 'window killed');
|
2010-04-16 23:04:42 +02:00
|
|
|
|
|
|
|
# TODO: same test, but with pcre expressions
|
|
|
|
|
2011-07-08 00:21:29 +02: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 21:53:48 +02:00
|
|
|
my $left = open_window(wm_class => 'special', name => 'left');
|
2011-11-23 17:22:43 +01:00
|
|
|
ok($left->mapped, 'left window mapped');
|
|
|
|
|
2013-09-24 21:53:48 +02:00
|
|
|
my $right = open_window(wm_class => 'special', name => 'right');
|
2011-11-23 17:22:43 +01:00
|
|
|
ok($right->mapped, 'right window mapped');
|
2011-07-08 00:21:29 +02:00
|
|
|
|
|
|
|
# two windows should be here
|
2012-09-04 22:24:13 +02:00
|
|
|
is_num_children($tmp, 2, 'two windows opened');
|
2011-07-08 00:21:29 +02:00
|
|
|
|
|
|
|
cmd '[class="special" title="left"] kill';
|
|
|
|
|
2011-11-22 01:13:37 +01:00
|
|
|
sync_with_i3;
|
2011-07-09 01:01:52 +02:00
|
|
|
|
2012-09-04 22:24:13 +02:00
|
|
|
is_num_children($tmp, 1, 'one window still there');
|
2011-07-08 00:21:29 +02:00
|
|
|
|
2011-09-11 00:52:39 +02:00
|
|
|
######################################################################
|
|
|
|
# check that regular expressions work
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
|
2013-09-24 21:53:48 +02:00
|
|
|
$left = open_window(name => 'left', wm_class => 'special7');
|
2011-11-23 17:22:43 +01:00
|
|
|
ok($left->mapped, 'left window mapped');
|
2012-09-04 22:24:13 +02:00
|
|
|
is_num_children($tmp, 1, 'window opened');
|
2011-09-11 00:52:39 +02:00
|
|
|
|
|
|
|
cmd '[class="^special[0-9]$"] kill';
|
2011-11-21 23:44:20 +01:00
|
|
|
wait_for_unmap $left;
|
2012-09-04 22:24:13 +02:00
|
|
|
is_num_children($tmp, 0, 'window killed');
|
2011-09-11 00:52:39 +02:00
|
|
|
|
2011-09-11 12:40:51 +02:00
|
|
|
######################################################################
|
|
|
|
# check that UTF-8 works when matching
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
|
2013-09-24 21:53:48 +02:00
|
|
|
$left = open_window(name => 'ä 3', wm_class => 'special7');
|
2011-11-23 17:22:43 +01:00
|
|
|
ok($left->mapped, 'left window mapped');
|
2012-09-04 22:24:13 +02:00
|
|
|
is_num_children($tmp, 1, 'window opened');
|
2011-09-11 12:40:51 +02:00
|
|
|
|
|
|
|
cmd '[title="^\w [3]$"] kill';
|
2011-11-21 23:44:20 +01:00
|
|
|
wait_for_unmap $left;
|
2012-09-04 22:24:13 +02:00
|
|
|
is_num_children($tmp, 0, 'window killed');
|
2011-09-11 00:52:39 +02:00
|
|
|
|
2019-10-09 12:45:10 +02:00
|
|
|
######################################################################
|
|
|
|
# check that we can match empty properties
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
|
|
|
|
$left = open_window(name => 'class is empty', wm_class => '');
|
|
|
|
ok($left->mapped, 'left window mapped');
|
|
|
|
is_num_children($tmp, 1, 'window opened');
|
|
|
|
|
|
|
|
cmd '[class="^$"] kill';
|
|
|
|
wait_for_unmap $left;
|
|
|
|
is_num_children($tmp, 0, 'window killed');
|
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
done_testing;
|