extended copyright info to 2009
[audio-mpd.git] / t / 23-output.t
blob02c96ce6912490fe89acd11969fc32a27d1f278b
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 => 5;
22 my $mpd = Audio::MPD->new;
26 # testing absolute volume.
27 my $oldvol = $mpd->status->volume; # saving volume.
28 $mpd->volume(10); # init to sthg that we know
29 $mpd->volume(42);
30 is( $mpd->status->volume, 42, 'setting volume' );
33 # testing positive relative volume.
34 $mpd->volume('+9');
35 is( $mpd->status->volume, 51, 'increasing volume' );
38 # testing negative relative volume.
39 $mpd->volume('-4');
40 is( $mpd->status->volume, 47, 'decreasing volume' );
41 $mpd->volume($oldvol);  # resoring volume.
44 # testing disable_output.
45 $mpd->playlist->add( 'title.ogg' );
46 $mpd->playlist->add( 'dir1/title-artist-album.ogg' );
47 $mpd->playlist->add( 'dir1/title-artist.ogg' );
48 $mpd->play;
49 $mpd->output_disable(0);
50 sleep(1);
51 SKIP: {
52     # FIXME?
53     my $error = $mpd->status->error;
54     skip "detection method doesn't always work - depends on timing", 1
55         unless defined $error;
56     like( $error, qr/^problems/, 'disabling output' );
60 # testing enable_output.
61 $mpd->output_enable(0);
62 sleep(1);
63 $mpd->play; $mpd->pause;
64 is( $mpd->status->error, undef, 'enabling output' );
67 exit;