]> git.sur5r.net Git - i3/i3/blob - testcases/t/231-ipc-floating-event.t
Merge branch 'next' into master
[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 # • https://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • https://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 sub floating_subtest {
23     my ($win, $cmd, $want) = @_;
24
25     my @events = events_for(
26         sub { cmd $cmd },
27         'window');
28
29     my @floating = grep { $_->{change} eq 'floating' } @events;
30     is(scalar @floating, 1, 'Received 1 floating event');
31     is($floating[0]->{container}->{window}, $win->{id}, "window id matches");
32     is($floating[0]->{container}->{floating}, $want, "floating is $want");
33 }
34
35 my $win = open_window();
36
37 subtest 'floating enable', \&floating_subtest, $win, '[id="' . $win->{id} . '"] floating enable', 'user_on';
38 subtest 'floating disable', \&floating_subtest, $win, '[id="' . $win->{id} . '"] floating disable', 'user_off';
39
40 done_testing;