3 # This file is part of Audio::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.
17 # are we able to test module?
18 eval 'use Audio::MPD::Test';
19 plan skip_all => $@ if $@ =~ s/\n+Compilation failed.*//s;
22 my $mpd = Audio::MPD->new;
28 $mpd->playlist->add( 'title.ogg' );
29 $mpd->playlist->add( 'dir1/title-artist-album.ogg' );
30 $mpd->playlist->add( 'dir1/title-artist.ogg' );
31 my $stats = $mpd->stats;
32 isa_ok( $stats, 'Audio::MPD::Common::Stats', 'stats() returns an AMC::Stats object' );
33 is( $stats->artists, 1, 'one artist in the database' );
34 is( $stats->albums, 1, 'one album in the database' );
35 is( $stats->songs, 4, '4 songs in the database' );
36 is( $stats->playtime, 0, 'already played 0 seconds' );
37 is( $stats->db_playtime, 8, '8 seconds worth of music in the db' );
38 isnt( $stats->uptime, undef, 'uptime is defined' );
39 isnt( $stats->db_update, 0, 'database has been updated' );
46 my $status = $mpd->status;
47 isa_ok( $status, 'Audio::MPD::Common::Status', 'status return an AMC::Status object' );
51 # testing current song.
52 $song = $mpd->current;
53 isa_ok( $song, 'Audio::MPD::Common::Item::Song', 'current return an AMC::Item::Song object' );
58 $song = $mpd->song(1);
59 isa_ok( $song, 'Audio::MPD::Common::Item::Song', 'song() returns an AMC::Item::Song object' );
60 is( $song->file, 'dir1/title-artist-album.ogg', 'song() returns the wanted song' );
61 $song = $mpd->song; # default to current song
62 is( $song->file, 'title.ogg', 'song() defaults to current song' );
67 $song = $mpd->songid(1);
68 isa_ok( $song, 'Audio::MPD::Common::Item::Song', 'songid() returns an AMC::Item::Song object' );
69 is( $song->file, 'dir1/title-artist-album.ogg', 'songid() returns the wanted song' );
70 $song = $mpd->songid; # default to current song
71 is( $song->file, 'title.ogg', 'songid() defaults to current song' );