3 # This file is part of POE::Component::Client::MPD.
4 # Copyright (c) 2007 Jerome Quelin, all rights reserved.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the same terms as Perl itself.
14 use POE qw[ Component::Client::MPD::Message ];
20 title.ogg dir1/title-artist-album.ogg
21 dir1/title-artist.ogg dir2/album.ogg
26 # [ 'event', [ $arg1, $arg2, ... ], $answer_back, \&check_results ]
28 # pl.delete / pl.deleteid
29 # should come first to be sure songid #0 is really here.
30 [ 'pl.clear', [], $DISCARD, undef ],
31 [ 'pl.add', \@songs, $DISCARD, undef ],
32 [ 'status', [], $SEND, \&get_nb ],
33 [ 'pl.delete', [1,2], $DISCARD, undef ],
34 [ 'status', [], $SEND, \&check_del ],
35 [ 'status', [], $SEND, \&get_nb ],
36 [ 'pl.deleteid', [0], $DISCARD, undef ],
37 [ 'status', [], $SEND, \&check_delid ],
40 [ 'pl.clear', [], $DISCARD, undef ],
41 [ 'status', [], $SEND, \&get_nb ],
42 [ 'pl.add', [ 'title.ogg' ], $DISCARD, undef ],
43 [ 'pl.add', \@songs, $DISCARD, undef ],
44 [ 'status', [], $SEND, \&check_add ],
47 [ 'pl.add', \@songs, $DISCARD, undef ],
48 [ 'pl.clear', [], $DISCARD, undef ],
49 [ 'status', [], $SEND, \&check_clear ],
52 [ 'pl.add', \@songs, $DISCARD, undef ],
53 [ 'play', [1], $DISCARD, undef ], # to set song
54 [ 'stop', [], $DISCARD, undef ],
55 [ 'pl.crop', [], $SLEEP1, undef ],
56 [ 'status', [], $SEND, \&check_crop ],
61 # are we able to test module?
62 eval 'use POE::Component::Client::MPD::Test';
63 plan skip_all => $@ if $@ =~ s/\n+BEGIN failed--compilation aborted.*//s;
66 sub get_nb { $nb = $_[0]->data->playlistlength }
67 sub check_add { is( $_[0]->data->playlistlength, $nb+5, 'add() songs' ); }
68 sub check_del { is( $_[0]->data->playlistlength, $nb-2, 'delete() songs' ); }
69 sub check_delid { is( $_[0]->data->playlistlength, $nb-1, 'deleteid() songs' ); }
70 sub check_clear { is( $_[0]->data->playlistlength, 0, 'clear() leaves 0 song' ); }
71 sub check_crop { is( $_[0]->data->playlistlength, 1, 'crop() leaves only 1 song' ); }