]> git.sur5r.net Git - i3/i3/blob - testcases/t/19-match.t
less boilerplate by using Test::Kit and -It/lib in Makefile
[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 use v5.10;
9
10 my $i3 = i3("/tmp/nestedcons");
11
12 my $tmp = get_unused_workspace();
13 $i3->command("workspace $tmp")->recv;
14
15 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
16
17 # Open a new window
18 my $x = X11::XCB::Connection->new;
19 my $window = $x->root->create_child(
20     class => WINDOW_CLASS_INPUT_OUTPUT,
21     rect => [ 0, 0, 30, 30 ],
22     background_color => '#C0C0C0',
23 );
24
25 $window->map;
26 # give it some time to be picked up by the window manager
27 # TODO: better check for $window->mapped or something like that?
28 # maybe we can even wait for getting mapped?
29 my $c = 0;
30 while (@{get_ws_content($tmp)} == 0 and $c++ < 5) {
31     sleep 0.25;
32 }
33 my $content = get_ws_content($tmp);
34 ok(@{$content} == 1, 'window mapped');
35 my $win = $content->[0];
36
37 ######################################################################
38 # first test that matches which should not match this window really do
39 # not match it
40 ######################################################################
41 # TODO: use PCRE expressions
42 # TODO: specify more match types
43 $i3->command(q|[class="*"] kill|)->recv;
44 $i3->command(q|[con_id="99999"] kill|)->recv;
45
46 $content = get_ws_content($tmp);
47 ok(@{$content} == 1, 'window still there');
48
49 # now kill the window
50 my $id = $win->{id};
51 $i3->command(qq|[con_id="$id"] kill|)->recv;
52
53 $content = get_ws_content($tmp);
54 ok(@{$content} == 0, 'window killed');
55
56 # TODO: same test, but with pcre expressions
57
58 diag( "Testing i3, Perl $], $^X" );