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;
26 # testing play / playid.
27 $mpd->playlist->clear;
28 $mpd->playlist->add( 'title.ogg' );
29 $mpd->playlist->add( 'dir1/title-artist-album.ogg' );
30 $mpd->playlist->add( 'dir1/title-artist.ogg' );
31 $mpd->playlist->add( 'dir2/album.ogg' );
34 is( $mpd->status->state, 'play', 'play() starts playback' );
36 is( $mpd->status->song, 2, 'play() can start playback at a given song' );
42 is( $mpd->status->state, 'play', 'playid() starts playback' );
44 is( $mpd->status->songid, 1, 'playid() can start playback at a given song' );
50 is( $mpd->status->state, 'pause', 'pause() forces playback pause' );
52 is( $mpd->status->state, 'play', 'pause() can force playback resume' );
54 is( $mpd->status->state, 'pause', 'pause() toggles to pause' );
56 is( $mpd->status->state, 'play', 'pause() toggles to play' );
62 is( $mpd->status->state, 'stop', 'stop() forces full stop' );
66 # testing prev / next.
67 $mpd->play(1); $mpd->pause;
69 is( $mpd->status->song, 2, 'next() changes track to next one' );
71 is( $mpd->status->song, 1, 'prev() changes track to previous one' );
75 # testing seek / seekid.
78 is( $mpd->status->song, 2, 'seek() can change the current track' );
79 is( $mpd->status->time->sofar_secs, 1, 'seek() seeks in the song' );
81 is( $mpd->status->time->sofar_secs, 0, 'seek() defaults to beginning of song' );
83 is( $mpd->status->time->sofar_secs, 1, 'seek() defaults to current song ' );
87 is( $mpd->status->songid, 1, 'seekid() can change the current track' );
88 is( $mpd->status->time->sofar_secs, 1, 'seekid() seeks in the song' );
90 is( $mpd->status->time->sofar_secs, 0, 'seekid() defaults to beginning of song' );
92 is( $mpd->status->time->sofar_secs, 1, 'seekid() defaults to current song' );