2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • http://build.i3wm.org/docs/ipc.html
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 # (unless you are already familiar with Perl)
17 # Tests all kinds of matching methods
21 my $tmp = fresh_workspace;
23 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
26 my $window = open_window;
27 my $content = get_ws_content($tmp);
28 ok(@{$content} == 1, 'window mapped');
29 my $win = $content->[0];
31 ######################################################################
32 # first test that matches which should not match this window really do
34 ######################################################################
35 # TODO: specify more match types
36 # we can match on any (non-empty) class here since that window does not have
38 cmd q|[class=".*"] kill|;
39 cmd q|[con_id="99999"] kill|;
41 is_num_children($tmp, 1, 'window still there');
44 cmd 'nop now killing the window';
46 cmd qq|[con_id="$id"] kill|;
48 wait_for_unmap $window;
50 cmd 'nop checking if its gone';
51 is_num_children($tmp, 0, 'window killed');
53 # TODO: same test, but with pcre expressions
55 ######################################################################
56 # check that multiple criteria work are checked with a logical AND,
57 # not a logical OR (that is, matching is not cancelled after the first
59 ######################################################################
61 $tmp = fresh_workspace;
63 my $left = open_window(wm_class => 'special', name => 'left');
64 ok($left->mapped, 'left window mapped');
66 my $right = open_window(wm_class => 'special', name => 'right');
67 ok($right->mapped, 'right window mapped');
69 # two windows should be here
70 is_num_children($tmp, 2, 'two windows opened');
72 cmd '[class="special" title="left"] kill';
76 is_num_children($tmp, 1, 'one window still there');
78 ######################################################################
79 # check that regular expressions work
80 ######################################################################
82 $tmp = fresh_workspace;
84 $left = open_window(name => 'left', wm_class => 'special7');
85 ok($left->mapped, 'left window mapped');
86 is_num_children($tmp, 1, 'window opened');
88 cmd '[class="^special[0-9]$"] kill';
90 is_num_children($tmp, 0, 'window killed');
92 ######################################################################
93 # check that UTF-8 works when matching
94 ######################################################################
96 $tmp = fresh_workspace;
98 $left = open_window(name => 'ä 3', wm_class => 'special7');
99 ok($left->mapped, 'left window mapped');
100 is_num_children($tmp, 1, 'window opened');
102 cmd '[title="^\w [3]$"] kill';
103 wait_for_unmap $left;
104 is_num_children($tmp, 0, 'window killed');