]> git.sur5r.net Git - i3/i3/blob - testcases/t/119-match.t
Merge pull request #2953 from CyberShadow/focus_wrapping
[i3/i3] / testcases / t / 119-match.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • https://build.i3wm.org/docs/ipc.html
12 #   (or docs/ipc)
13 #
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 #   (unless you are already familiar with Perl)
16 #
17 # Tests all kinds of matching methods
18 #
19 use i3test;
20
21 my $tmp = fresh_workspace;
22
23 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
24
25 # Open a new window
26 my $window = open_window;
27 my $content = get_ws_content($tmp);
28 ok(@{$content} == 1, 'window mapped');
29 my $win = $content->[0];
30
31 ######################################################################
32 # first test that matches which should not match this window really do
33 # not match it
34 ######################################################################
35 # TODO: specify more match types
36 # we can match on any (non-empty) class here since that window does not have
37 # WM_CLASS set
38 cmd q|[class=".*"] kill|;
39 cmd q|[con_id="99999"] kill|;
40
41 is_num_children($tmp, 1, 'window still there');
42
43 # now kill the window
44 cmd 'nop now killing the window';
45 my $id = $win->{id};
46 cmd qq|[con_id="$id"] kill|;
47
48 wait_for_unmap $window;
49
50 cmd 'nop checking if its gone';
51 is_num_children($tmp, 0, 'window killed');
52
53 # TODO: same test, but with pcre expressions
54
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
58 # criterion matches).
59 ######################################################################
60
61 $tmp = fresh_workspace;
62
63 my $left = open_window(wm_class => 'special', name => 'left');
64 ok($left->mapped, 'left window mapped');
65
66 my $right = open_window(wm_class => 'special', name => 'right');
67 ok($right->mapped, 'right window mapped');
68
69 # two windows should be here
70 is_num_children($tmp, 2, 'two windows opened');
71
72 cmd '[class="special" title="left"] kill';
73
74 sync_with_i3;
75
76 is_num_children($tmp, 1, 'one window still there');
77
78 ######################################################################
79 # check that regular expressions work
80 ######################################################################
81
82 $tmp = fresh_workspace;
83
84 $left = open_window(name => 'left', wm_class => 'special7');
85 ok($left->mapped, 'left window mapped');
86 is_num_children($tmp, 1, 'window opened');
87
88 cmd '[class="^special[0-9]$"] kill';
89 wait_for_unmap $left;
90 is_num_children($tmp, 0, 'window killed');
91
92 ######################################################################
93 # check that UTF-8 works when matching
94 ######################################################################
95
96 $tmp = fresh_workspace;
97
98 $left = open_window(name => 'ä 3', wm_class => 'special7');
99 ok($left->mapped, 'left window mapped');
100 is_num_children($tmp, 1, 'window opened');
101
102 cmd '[title="^\w [3]$"] kill';
103 wait_for_unmap $left;
104 is_num_children($tmp, 0, 'window killed');
105
106 done_testing;