extended copyright info to 2009
[audio-mpd.git] / t / 24-info.t
blob4feedabfe1e6d1c917e427df2e10b358037a7d13
1 #!perl
3 # This file is part of Audio::MPD
4 # Copyright (c) 2007-2009 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.
11 use strict;
12 use warnings;
14 use Audio::MPD;
15 use Test::More;
17 # are we able to test module?
18 eval 'use Audio::MPD::Test';
19 plan skip_all => $@ if $@ =~ s/\n+Compilation failed.*//s;
21 plan tests => 16;
22 my $mpd = Audio::MPD->new;
23 my $song;
26 # testing stats
27 $mpd->updatedb;
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' );
43 # testing status.
44 $mpd->play;
45 $mpd->pause;
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' );
57 # testing song.
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' );
66 # testing songid.
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' );
74 exit;