2 # vim:ts=4:sw=4:expandtab
4 # Tests all kinds of matching methods
7 use X11::XCB qw(PROP_MODE_REPLACE);
9 my $tmp = fresh_workspace;
11 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
14 my $window = open_window;
15 my $content = get_ws_content($tmp);
16 ok(@{$content} == 1, 'window mapped');
17 my $win = $content->[0];
19 ######################################################################
20 # first test that matches which should not match this window really do
22 ######################################################################
23 # TODO: specify more match types
24 # we can match on any (non-empty) class here since that window does not have
26 cmd q|[class=".*"] kill|;
27 cmd q|[con_id="99999"] kill|;
29 $content = get_ws_content($tmp);
30 ok(@{$content} == 1, 'window still there');
33 cmd 'nop now killing the window';
35 cmd qq|[con_id="$id"] kill|;
37 wait_for_unmap $window;
39 cmd 'nop checking if its gone';
40 $content = get_ws_content($tmp);
41 ok(@{$content} == 0, 'window killed');
43 # TODO: same test, but with pcre expressions
45 ######################################################################
46 # check that multiple criteria work are checked with a logical AND,
47 # not a logical OR (that is, matching is not cancelled after the first
49 ######################################################################
51 $tmp = fresh_workspace;
53 # TODO: move to X11::XCB
55 my ($id, $class, $instance) = @_;
57 # Add a _NET_WM_STRUT_PARTIAL hint
58 my $atomname = $x->atom(name => 'WM_CLASS');
59 my $atomtype = $x->atom(name => 'STRING');
67 length($class) + length($instance) + 2,
68 "$instance\x00$class\x00"
74 my $wm_class = delete($args{wm_class}) || 'special';
78 before_map => sub { set_wm_class($_->id, $wm_class, $wm_class) },
82 my $left = open_special(name => 'left');
83 ok($left->mapped, 'left window mapped');
85 my $right = open_special(name => 'right');
86 ok($right->mapped, 'right window mapped');
88 # two windows should be here
89 $content = get_ws_content($tmp);
90 ok(@{$content} == 2, 'two windows opened');
92 cmd '[class="special" title="left"] kill';
96 $content = get_ws_content($tmp);
97 is(@{$content}, 1, 'one window still there');
99 ######################################################################
100 # check that regular expressions work
101 ######################################################################
103 $tmp = fresh_workspace;
105 $left = open_special(name => 'left', wm_class => 'special7');
106 ok($left->mapped, 'left window mapped');
108 # two windows should be here
109 $content = get_ws_content($tmp);
110 ok(@{$content} == 1, 'window opened');
112 cmd '[class="^special[0-9]$"] kill';
114 wait_for_unmap $left;
116 $content = get_ws_content($tmp);
117 is(@{$content}, 0, 'window killed');
119 ######################################################################
120 # check that UTF-8 works when matching
121 ######################################################################
123 $tmp = fresh_workspace;
125 $left = open_special(name => 'รค 3', wm_class => 'special7');
126 ok($left->mapped, 'left window mapped');
128 # two windows should be here
129 $content = get_ws_content($tmp);
130 ok(@{$content} == 1, 'window opened');
132 cmd '[title="^\w [3]$"] kill';
134 wait_for_unmap $left;
136 $content = get_ws_content($tmp);
137 is(@{$content}, 0, 'window killed');