]> git.sur5r.net Git - i3/i3/blob - testcases/t/277-ipc-window-urgent.t
Merge branch 'next' into master
[i3/i3] / testcases / t / 277-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 # • 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::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 fresh_workspace;
23 my $win = open_window;
24 my $dummy_win = open_window;
25
26 sub urgency_subtest {
27     my ($subscribecb, $win, $want) = @_;
28
29     my @events = events_for(
30         $subscribecb,
31         'window');
32
33     my @urgent = grep { $_->{change} eq 'urgent' } @events;
34     is(scalar @urgent, 1, 'Received 1 window::urgent event');
35     is($urgent[0]->{container}->{window}, $win->{id}, "window id matches");
36     is($urgent[0]->{container}->{urgent}, $want, "urgent is $want");
37 }
38
39 subtest "urgency set", \&urgency_subtest,
40     sub {
41         $win->add_hint('urgency');
42         sync_with_i3;
43     },
44     $win,
45     1;
46
47 subtest "urgency unset", \&urgency_subtest,
48     sub {
49         $win->delete_hint('urgency');
50         sync_with_i3;
51     },
52     $win,
53     0;
54
55 done_testing;