2014-06-20 14:33:02 +02:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
|
|
|
#
|
|
|
|
# Please read the following documents before working on tests:
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/testsuite.html
|
2014-06-20 14:33:02 +02:00
|
|
|
# (or docs/testsuite)
|
|
|
|
#
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/lib-i3test.html
|
2014-06-20 14:33:02 +02:00
|
|
|
# (alternatively: perldoc ./testcases/lib/i3test.pm)
|
|
|
|
#
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/ipc.html
|
2014-06-20 14:33:02 +02:00
|
|
|
# (or docs/ipc)
|
|
|
|
#
|
|
|
|
# • http://onyxneon.com/books/modern_perl/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;
|
|
|
|
|
2017-09-24 15:40:30 +02:00
|
|
|
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;
|
2014-06-20 14:33:02 +02:00
|
|
|
|
|
|
|
done_testing;
|