From 7a2e1059311288247cd844cb306b1fc370c7da6a Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 22 Sep 2012 13:10:01 +0200 Subject: [PATCH] tests: add testcase for the 'mode' IPC event --- testcases/Makefile.PL | 2 +- testcases/t/199-ipc-mode-event.t | 57 ++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 testcases/t/199-ipc-mode-event.t diff --git a/testcases/Makefile.PL b/testcases/Makefile.PL index b1e698ae..b522fc30 100755 --- a/testcases/Makefile.PL +++ b/testcases/Makefile.PL @@ -8,7 +8,7 @@ WriteMakefile( MIN_PERL_VERSION => '5.010000', # 5.10.0 PREREQ_PM => { 'AnyEvent' => 0, - 'AnyEvent::I3' => '0.09', + 'AnyEvent::I3' => '0.14', 'X11::XCB' => '0.03', 'Inline' => 0, 'ExtUtils::PkgConfig' => 0, diff --git a/testcases/t/199-ipc-mode-event.t b/testcases/t/199-ipc-mode-event.t new file mode 100644 index 00000000..43f7b178 --- /dev/null +++ b/testcases/t/199-ipc-mode-event.t @@ -0,0 +1,57 @@ +#!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) +# +# Verifies that the IPC 'mode' event is sent when modes are changed. +use i3test i3_autostart => 0; + +my $config = <connect->recv; + +my $cv = AnyEvent->condvar; + +$i3->subscribe({ + mode => sub { + my ($event) = @_; + $cv->send($event->{change} eq 'm1'); + } +})->recv; + +cmd 'mode "m1"'; + +# Timeout after 0.5s +my $t; +$t = AnyEvent->timer(after => 0.5, cb => sub { $cv->send(0); }); + +ok($cv->recv, 'Mode event received'); + +exit_gracefully($pid); + +done_testing; -- 2.39.2