[project @ 5631]
[audio-mpd.git] / t / 23-output.t
blobafa282e9f0288c7a3870a474ed21fe4ab9006c21
1 #!perl
3 # This file is part of Audio::MPD.
4 # Copyright (c) 2007 Jerome Quelin <jquelin@cpan.org>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or (at
9 # your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 use strict;
23 use warnings;
25 use Audio::MPD;
26 use Test::More;
28 # are we able to test module?
29 eval 'use Audio::MPD::Test';
30 plan skip_all => $@ if $@ =~ s/\n+Compilation failed.*//s;
32 plan tests => 5;
33 my $mpd = Audio::MPD->new;
37 # testing absolute volume.
38 $mpd->volume(10); # init to sthg that we know
39 $mpd->volume(42);
40 is( $mpd->status->volume, 42, 'setting volume' );
43 # testing positive relative volume.
44 $mpd->volume('+9');
45 is( $mpd->status->volume, 51, 'increasing volume' );
48 # testing negative relative volume.
49 $mpd->volume('-4');
50 is( $mpd->status->volume, 47, 'decreasing volume' );
54 # testing disable_output.
55 $mpd->add( 'title.ogg' );
56 $mpd->add( 'dir1/title-artist-album.ogg' );
57 $mpd->add( 'dir1/title-artist.ogg' );
58 $mpd->play;
59 $mpd->output_disable(0);
60 sleep(1);
61 like( $mpd->status->error, qr/^problems/, 'disabling output' );
64 # testing enable_output.
65 $mpd->output_enable(0);
66 sleep(1);
67 $mpd->play; $mpd->pause;
68 is( $mpd->status->error, undef, 'enabling output' );
71 exit;