]> git.sur5r.net Git - i3/i3/blob - testcases/t/19-match.t
tests: fix t/19-match.t, needs a delay for i3 to pick up the UnmapNotify event
[i3/i3] / testcases / t / 19-match.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Tests all kinds of matching methods
5 #
6 use i3test tests => 4;
7 use X11::XCB qw(:all);
8
9 my $i3 = i3("/tmp/nestedcons");
10
11 my $tmp = get_unused_workspace();
12 $i3->command("workspace $tmp")->recv;
13
14 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
15
16 # Open a new window
17 my $x = X11::XCB::Connection->new;
18 my $window = $x->root->create_child(
19     class => WINDOW_CLASS_INPUT_OUTPUT,
20     rect => [ 0, 0, 30, 30 ],
21     background_color => '#C0C0C0',
22 );
23
24 $window->map;
25 # give it some time to be picked up by the window manager
26 # TODO: better check for $window->mapped or something like that?
27 # maybe we can even wait for getting mapped?
28 my $c = 0;
29 while (@{get_ws_content($tmp)} == 0 and $c++ < 5) {
30     sleep 0.25;
31 }
32 my $content = get_ws_content($tmp);
33 ok(@{$content} == 1, 'window mapped');
34 my $win = $content->[0];
35
36 ######################################################################
37 # first test that matches which should not match this window really do
38 # not match it
39 ######################################################################
40 # TODO: use PCRE expressions
41 # TODO: specify more match types
42 $i3->command(q|[class="*"] kill|)->recv;
43 $i3->command(q|[con_id="99999"] kill|)->recv;
44
45 $content = get_ws_content($tmp);
46 ok(@{$content} == 1, 'window still there');
47
48 # now kill the window
49 cmd 'nop now killing the window';
50 my $id = $win->{id};
51 $i3->command(qq|[con_id="$id"] kill|)->recv;
52
53 # give i3 some time to pick up the UnmapNotify event
54 sleep 0.25;
55
56 cmd 'nop checking if its gone';
57 $content = get_ws_content($tmp);
58 ok(@{$content} == 0, 'window killed');
59
60 # TODO: same test, but with pcre expressions
61
62 diag( "Testing i3, Perl $], $^X" );