2 # vim:ts=4:sw=4:expandtab
4 # Tests all kinds of matching methods
9 my $tmp = fresh_workspace;
11 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
14 my $x = X11::XCB::Connection->new;
15 my $window = $x->root->create_child(
16 class => WINDOW_CLASS_INPUT_OUTPUT,
17 rect => [ 0, 0, 30, 30 ],
18 background_color => '#C0C0C0',
22 # give it some time to be picked up by the window manager
23 # TODO: better check for $window->mapped or something like that?
24 # maybe we can even wait for getting mapped?
26 while (@{get_ws_content($tmp)} == 0 and $c++ < 5) {
29 my $content = get_ws_content($tmp);
30 ok(@{$content} == 1, 'window mapped');
31 my $win = $content->[0];
33 ######################################################################
34 # first test that matches which should not match this window really do
36 ######################################################################
37 # TODO: use PCRE expressions
38 # TODO: specify more match types
39 cmd q|[class="*"] kill|;
40 cmd q|[con_id="99999"] kill|;
42 $content = get_ws_content($tmp);
43 ok(@{$content} == 1, 'window still there');
46 cmd 'nop now killing the window';
48 cmd qq|[con_id="$id"] kill|;
50 # give i3 some time to pick up the UnmapNotify event
53 cmd 'nop checking if its gone';
54 $content = get_ws_content($tmp);
55 ok(@{$content} == 0, 'window killed');
57 # TODO: same test, but with pcre expressions
59 ######################################################################
60 # check that multiple criteria work are checked with a logical AND,
61 # not a logical OR (that is, matching is not cancelled after the first
63 ######################################################################
65 $tmp = fresh_workspace;
67 # TODO: move to X11::XCB
69 my ($id, $class, $instance) = @_;
71 # Add a _NET_WM_STRUT_PARTIAL hint
72 my $atomname = $x->atom(name => 'WM_CLASS');
73 my $atomtype = $x->atom(name => 'STRING');
81 length($class) + length($instance) + 2,
82 "$instance\x00$class\x00"
86 my $left = $x->root->create_child(
87 class => WINDOW_CLASS_INPUT_OUTPUT,
88 rect => [ 0, 0, 30, 30 ],
89 background_color => '#0000ff',
93 set_wm_class($left->id, 'special', 'special');
98 my $right = $x->root->create_child(
99 class => WINDOW_CLASS_INPUT_OUTPUT,
100 rect => [ 0, 0, 30, 30 ],
101 background_color => '#0000ff',
105 set_wm_class($right->id, 'special', 'special');
106 $right->name('right');
110 # two windows should be here
111 $content = get_ws_content($tmp);
112 ok(@{$content} == 2, 'two windows opened');
114 cmd '[class="special" title="left"] kill';
118 $content = get_ws_content($tmp);
119 is(@{$content}, 1, 'one window still there');