1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#!perl
# vim:ts=4:sw=4:expandtab
#
# Please read the following documents before working on tests:
# • https://build.i3wm.org/docs/testsuite.html
# (or docs/testsuite)
#
# • https://build.i3wm.org/docs/lib-i3test.html
# (alternatively: perldoc ./testcases/lib/i3test.pm)
#
# • https://build.i3wm.org/docs/ipc.html
# (or docs/ipc)
#
# • https://i3wm.org/downloads/modern_perl_a4.pdf
# (unless you are already familiar with Perl)
#
# Test that the window::urgent event works correctly. The window::urgent event
# should be emitted when a window becomes urgent or loses its urgent status.
#
use i3test;
fresh_workspace;
my $win = open_window;
my $dummy_win = open_window;
sub urgency_subtest {
my ($subscribecb, $win, $want) = @_;
my @events = events_for(
$subscribecb,
'window');
my @urgent = grep { $_->{change} eq 'urgent' } @events;
is(scalar @urgent, 1, 'Received 1 window::urgent event');
is($urgent[0]->{container}->{window}, $win->{id}, "window id matches");
is($urgent[0]->{container}->{urgent}, $want, "urgent is $want");
}
subtest "urgency set", \&urgency_subtest,
sub {
$win->add_hint('urgency');
sync_with_i3;
},
$win,
1;
subtest "urgency unset", \&urgency_subtest,
sub {
$win->delete_hint('urgency');
sync_with_i3;
},
$win,
0;
done_testing;
|