]> git.sur5r.net Git - i3/i3/blob - testcases/t/231-ipc-floating-event.t
Merge branch 'release-4.10.3'
[i3/i3] / testcases / t / 231-ipc-floating-event.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • http://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 # Test that the window::floating event works correctly. This event should be
18 # emitted when a window transitions to or from the floating state.
19 # Bug still in: 4.8-7-gf4a8253
20 use i3test;
21
22 my $i3 = i3(get_socket_path());
23 $i3->connect->recv;
24
25 my $cv = AnyEvent->condvar;
26
27 $i3->subscribe({
28         window => sub {
29             my ($event) = @_;
30             $cv->send($event) if $event->{change} eq 'floating';
31         }
32     })->recv;
33
34 my $t;
35 $t = AnyEvent->timer(
36     after => 0.5,
37     cb => sub {
38         $cv->send(0);
39     }
40 );
41
42 my $win = open_window();
43
44 cmd '[id="' . $win->{id} . '"] floating enable';
45 my $e = $cv->recv;
46
47 isnt($e, 0, 'floating a container should send an ipc window event');
48 is($e->{container}->{window}, $win->{id}, 'the event should contain information about the window');
49 is($e->{container}->{floating}, 'user_on', 'the container should be floating');
50
51 $cv = AnyEvent->condvar;
52 cmd '[id="' . $win->{id} . '"] floating disable';
53 my $e = $cv->recv;
54
55 isnt($e, 0, 'disabling floating on a container should send an ipc window event');
56 is($e->{container}->{window}, $win->{id}, 'the event should contain information about the window');
57 is($e->{container}->{floating}, 'user_off', 'the container should not be floating');
58
59 done_testing;