From e10ba7d47a4f9ffa72feebc99bd28791a7103f02 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 13 Mar 2010 17:38:59 +0100 Subject: [PATCH] Expand testcase for the get_workspaces message (needs i3 to be running) --- t/01-workspaces.t | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/t/01-workspaces.t b/t/01-workspaces.t index 5e708d13..f3206d89 100644 --- a/t/01-workspaces.t +++ b/t/01-workspaces.t @@ -1,12 +1,29 @@ #!perl -T +# vim:ts=4:sw=4:expandtab -use Test::More tests => 1; +use Test::More tests => 3; use AnyEvent::I3; +use AnyEvent; my $i3 = i3(); -my $cv = $i3->connect; -$cv->recv; +my $cv = AnyEvent->condvar; -ok(1, "connected"); +# Try to connect to i3 +$i3->connect->cb(sub { my ($v) = @_; $cv->send($v->recv) }); + +# But cancel if we are not connected after 0.5 seconds +my $t = AnyEvent->timer(after => 0.5, cb => sub { $cv->send(0) }); +my $connected = $cv->recv; + +SKIP: { + skip 'No connection to i3', 3 unless $connected; + + my $workspaces = $i3->message(1)->recv; + isa_ok($workspaces, 'ARRAY'); + + ok(@{$workspaces} > 0, 'More than zero workspaces found'); + + ok(defined(@{$workspaces}[0]->{num}), 'JSON deserialized'); +} diag( "Testing AnyEvent::I3 $AnyEvent::I3::VERSION, Perl $], $^X" ); -- 2.39.5