3 # This file is part of POE::Component::Client::MPD.
4 # Copyright (c) 2007-2008 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.
16 my @songs = qw{ title.ogg dir1/title-artist-album.ogg dir1/title-artist.ogg };
19 # [ 'event', [ $arg1, $arg2, ... ], $sleep, \&check_results ]
22 [ 'updatedb', [], 0, \&check_success ],
23 [ 'pl.add', \@songs, 0, \&check_success ],
24 [ 'stats', [], 0, \&check_stats ],
27 [ 'play', [], 0, \&check_success ],
28 [ 'pause', [], 0, \&check_success ],
29 [ 'status', [], 0, \&check_status ],
32 [ 'current', [], 0, \&check_current ],
35 [ 'song', [1], 0, \&check_song ],
36 [ 'song', [], 0, \&check_song_current ],
38 # songid (use the same checkers as song)
39 [ 'songid', [1], 0, \&check_song ],
40 [ 'songid', [], 0, \&check_song_current ],
44 # are we able to test module?
45 eval 'use POE::Component::Client::MPD::Test nbtests=>$nbtests, tests=>\@tests';
46 diag($@), plan skip_all => $@ if $@ =~ s/\n+BEGIN failed--compilation aborted.*//s;
53 is($msg->status, 1, "command '" . $msg->request . "' returned an ok status");
57 my ($msg, $stats) = @_;
59 isa_ok($stats, 'Audio::MPD::Common::Stats', 'stats() return');
60 is($stats->artists, 1, 'one artist in the database');
61 is($stats->albums, 1, 'one album in the database');
62 is($stats->songs, 4, '4 songs in the database');
63 is($stats->playtime, 0, 'already played 0 seconds');
64 is($stats->db_playtime, 8, '8 seconds worth of music in the db');
65 isnt($stats->uptime, undef, 'uptime is defined');
66 isnt($stats->db_update, 0, 'database has been updated');
70 my ($msg, $status) = @_;
72 isa_ok( $status, 'Audio::MPD::Common::Status', 'status() return');
76 my ($msg, $song) = @_;
78 isa_ok($song, 'Audio::MPD::Common::Item::Song', 'current() return');
82 my ($msg, $song) = @_;
84 isa_ok($song, 'Audio::MPD::Common::Item::Song', 'song(id) return' );
85 is($song->file, 'dir1/title-artist-album.ogg', 'song(id) returns the wanted song');
88 sub check_song_current {
89 my ($msg, $song) = @_;
91 isa_ok($song, 'Audio::MPD::Common::Item::Song', 'song(id) return' );
92 is($song->file, 'title.ogg', 'song(id) defaults to current song' );