]> git.sur5r.net Git - i3/i3/blob - testcases/t/232-ipc-window-urgent.t
Kill windows between tests
[i3/i3] / testcases / t / 232-ipc-window-urgent.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::urgent event works correctly. The window::urgent event
18 # should be emitted when a window becomes urgent or loses its urgent status.
19 #
20 use i3test;
21
22 my $config = <<EOT;
23 # i3 config file (v4)
24 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
25
26 force_display_urgency_hint 0ms
27 EOT
28
29 my $i3 = i3(get_socket_path());
30 $i3->connect()->recv;
31
32 my $cv;
33 $i3->subscribe({
34     window => sub {
35         my ($event) = @_;
36         $cv->send($event) if $event->{change} eq 'urgent';
37     }
38 })->recv;
39
40 my $t;
41 $t = AnyEvent->timer(
42     after => 0.5,
43     cb => sub {
44         $cv->send(0);
45     }
46 );
47
48 $cv = AnyEvent->condvar;
49 fresh_workspace;
50 my $win = open_window;
51 my $dummy_win = open_window;
52
53 $win->add_hint('urgency');
54 my $event = $cv->recv;
55
56 isnt($event, 0, 'an urgent con should emit the window::urgent event');
57 is($event->{container}->{window}, $win->{id}, 'the event should contain information about the window');
58 is($event->{container}->{urgent}, 1, 'the container should be urgent');
59
60 $cv = AnyEvent->condvar;
61 $win->delete_hint('urgency');
62 $event = $cv->recv;
63
64 isnt($event, 0, 'an urgent con should emit the window::urgent event');
65 is($event->{container}->{window}, $win->{id}, 'the event should contain information about the window');
66 is($event->{container}->{urgent}, 0, 'the container should not be urgent');
67
68 done_testing;