1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#!perl
#
# This file is part of POE-Component-Client-MPD
#
# This software is copyright (c) 2007 by Jerome Quelin.
#
# This is free software; you can redistribute it and/or modify it under
# the same terms as the Perl 5 programming language system itself.
#
use 5.010;
use strict;
use warnings;
# -- test session
{
package My::Session;
use MooseX::POE;
use Test::More;
sub START {
POE::Kernel->alias_set( 'tester' ); # refcount++
POE::Kernel->delay_set( kill => 0.5 ); # FIXME: use connected event to start tests in pococm-test
}
event check => sub {
my @procs = grep { /\smpd\s/ } grep { !/grep/ } qx{ ps -ef };
is( scalar @procs, 0, 'kill shuts down mpd' );
};
event kill => sub {
POE::Kernel->delay_set( check => 1 );
POE::Kernel->post( mpd => 'kill' );
POE::Kernel->alias_remove( 'tester' ); # refcount--
};
no Moose;
__PACKAGE__->meta->make_immutable;
1;
}
# -- main test
package main;
use POE;
use POE::Component::Client::MPD;
use Test::More;
eval 'use Test::Corpus::Audio::MPD';
plan skip_all => $@ if $@ =~ s/\n+BEGIN failed--compilation aborted.*//s;
plan tests => 1;
POE::Component::Client::MPD->spawn;
My::Session->new;
POE::Kernel->run;
exit;
|