From: Michael Stapelberg Date: Sat, 22 Sep 2012 12:20:19 +0000 (+0200) Subject: tests: rename double t/198, add boilerplate X-Git-Tag: 4.4~141 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=66d786762aef77f6228e5359a2d2f1c324a40508;p=i3%2Fi3 tests: rename double t/198, add boilerplate --- diff --git a/testcases/t/198-urgency-timer.t b/testcases/t/198-urgency-timer.t deleted file mode 100644 index d3cdb3d9..00000000 --- a/testcases/t/198-urgency-timer.t +++ /dev/null @@ -1,95 +0,0 @@ -#!perl -# vim:ts=4:sw=4:expandtab -# -# Tests whether the urgency timer works as expected and does not break -# urgency handling. -# - -use List::Util qw(first); -use i3test i3_autostart => 0; -use Time::HiRes qw(sleep); - -# Ensure the pointer is at (0, 0) so that we really start on the first -# (the left) workspace. -$x->root->warp_pointer(0, 0); - -my $config = <add_hint('urgency'); -sync_with_i3; - -####################################################################### -# Create a window on ws1, then switch to ws2, set urgency, switch back -####################################################################### - -isnt($x->input_focus, $w->id, 'window not focused'); - -my @content = @{get_ws_content($tmp1)}; -my @urgent = grep { $_->{urgent} } @content; -is(@urgent, 1, "window marked as urgent"); - -# switch to ws1 -cmd "workspace $tmp1"; - -# this will start the timer -sleep(0.1); -@content = @{get_ws_content($tmp1)}; -@urgent = grep { $_->{urgent} } @content; -is(@urgent, 1, 'window still marked as urgent'); - -# now check if the timer was triggered -cmd "workspace $tmp2"; - -sleep(0.1); -@content = @{get_ws_content($tmp1)}; -@urgent = grep { $_->{urgent} } @content; -is(@urgent, 0, 'window not marked as urgent anymore'); - -####################################################################### -# Create another window on ws1, focus it, switch to ws2, make the other -# window urgent, and switch back. This should not trigger the timer. -####################################################################### - -cmd "workspace $tmp1"; -my $w2 = open_window; -is($x->input_focus, $w2->id, 'window 2 focused'); - -cmd "workspace $tmp2"; -$w->add_hint('urgency'); -sync_with_i3; - -@content = @{get_ws_content($tmp1)}; -@urgent = grep { $_->{urgent} } @content; -is(@urgent, 1, 'window 1 marked as urgent'); - -# Switch back to ws1. This should focus w2. -cmd "workspace $tmp1"; -is($x->input_focus, $w2->id, 'window 2 focused'); - -@content = @{get_ws_content($tmp1)}; -@urgent = grep { $_->{urgent} } @content; -is(@urgent, 1, 'window 1 still marked as urgent'); - -# explicitly focusing the window should result in immediate urgency reset -cmd '[id="' . $w->id . '"] focus'; -@content = @{get_ws_content($tmp1)}; -@urgent = grep { $_->{urgent} } @content; -is(@urgent, 0, 'window 1 not marked as urgent anymore'); - -done_testing; diff --git a/testcases/t/200-urgency-timer.t b/testcases/t/200-urgency-timer.t new file mode 100644 index 00000000..d6055114 --- /dev/null +++ b/testcases/t/200-urgency-timer.t @@ -0,0 +1,109 @@ +#!perl +# vim:ts=4:sw=4:expandtab +# +# Please read the following documents before working on tests: +# • http://build.i3wm.org/docs/testsuite.html +# (or docs/testsuite) +# +# • http://build.i3wm.org/docs/lib-i3test.html +# (alternatively: perldoc ./testcases/lib/i3test.pm) +# +# • http://build.i3wm.org/docs/ipc.html +# (or docs/ipc) +# +# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf +# (unless you are already familiar with Perl) +# +# +# Tests whether the urgency timer works as expected and does not break +# urgency handling. +# + +use List::Util qw(first); +use i3test i3_autostart => 0; +use Time::HiRes qw(sleep); + +# Ensure the pointer is at (0, 0) so that we really start on the first +# (the left) workspace. +$x->root->warp_pointer(0, 0); + +my $config = <add_hint('urgency'); +sync_with_i3; + +####################################################################### +# Create a window on ws1, then switch to ws2, set urgency, switch back +####################################################################### + +isnt($x->input_focus, $w->id, 'window not focused'); + +my @content = @{get_ws_content($tmp1)}; +my @urgent = grep { $_->{urgent} } @content; +is(@urgent, 1, "window marked as urgent"); + +# switch to ws1 +cmd "workspace $tmp1"; + +# this will start the timer +sleep(0.1); +@content = @{get_ws_content($tmp1)}; +@urgent = grep { $_->{urgent} } @content; +is(@urgent, 1, 'window still marked as urgent'); + +# now check if the timer was triggered +cmd "workspace $tmp2"; + +sleep(0.1); +@content = @{get_ws_content($tmp1)}; +@urgent = grep { $_->{urgent} } @content; +is(@urgent, 0, 'window not marked as urgent anymore'); + +####################################################################### +# Create another window on ws1, focus it, switch to ws2, make the other +# window urgent, and switch back. This should not trigger the timer. +####################################################################### + +cmd "workspace $tmp1"; +my $w2 = open_window; +is($x->input_focus, $w2->id, 'window 2 focused'); + +cmd "workspace $tmp2"; +$w->add_hint('urgency'); +sync_with_i3; + +@content = @{get_ws_content($tmp1)}; +@urgent = grep { $_->{urgent} } @content; +is(@urgent, 1, 'window 1 marked as urgent'); + +# Switch back to ws1. This should focus w2. +cmd "workspace $tmp1"; +is($x->input_focus, $w2->id, 'window 2 focused'); + +@content = @{get_ws_content($tmp1)}; +@urgent = grep { $_->{urgent} } @content; +is(@urgent, 1, 'window 1 still marked as urgent'); + +# explicitly focusing the window should result in immediate urgency reset +cmd '[id="' . $w->id . '"] focus'; +@content = @{get_ws_content($tmp1)}; +@urgent = grep { $_->{urgent} } @content; +is(@urgent, 0, 'window 1 not marked as urgent anymore'); + +done_testing;