| 1 |
#!perl |
| 2 |
# vim:ts=4:sw=4:expandtab |
| 3 |
|
| 4 |
use Test::More tests => 3; |
| 5 |
use AnyEvent::I3; |
| 6 |
use AnyEvent; |
| 7 |
|
| 8 |
my $i3 = i3(); |
| 9 |
my $cv = AnyEvent->condvar; |
| 10 |
|
| 11 |
# Try to connect to i3 |
| 12 |
$i3->connect->cb(sub { my ($v) = @_; $cv->send($v->recv) }); |
| 13 |
|
| 14 |
# But cancel if we are not connected after 0.5 seconds |
| 15 |
my $t = AnyEvent->timer(after => 0.5, cb => sub { $cv->send(0) }); |
| 16 |
my $connected = $cv->recv; |
| 17 |
|
| 18 |
SKIP: { |
| 19 |
skip 'No connection to i3', 3 unless $connected; |
| 20 |
|
| 21 |
my $workspaces = $i3->message(1)->recv; |
| 22 |
isa_ok($workspaces, 'ARRAY'); |
| 23 |
|
| 24 |
ok(@{$workspaces} > 0, 'More than zero workspaces found'); |
| 25 |
|
| 26 |
ok(defined(@{$workspaces}[0]->{num}), 'JSON deserialized'); |
| 27 |
} |
| 28 |
|
| 29 |
diag( "Testing AnyEvent::I3 $AnyEvent::I3::VERSION, Perl $], $^X" ); |