File: 23-output.t

package info (click to toggle)
libaudio-mpd-perl 2.004-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 356 kB
  • sloc: perl: 1,444; makefile: 6
file content (74 lines) | stat: -rw-r--r-- 1,834 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!perl
#
# This file is part of Audio-MPD
#
# This software is copyright (c) 2007 by Jerome Quelin.
#
# This is free software; you can redistribute it and/or modify it under
# the same terms as the Perl 5 programming language system itself.
#

use strict;
use warnings;

use Audio::MPD;
use Test::More;

# are we able to test module?
eval 'use Test::Corpus::Audio::MPD';
plan skip_all => $@ if $@ =~ s/\n+Compilation failed.*//s;

plan tests => 9;
my $mpd = Audio::MPD->new;


#
# testing absolute volume.
my $oldvol = $mpd->status->volume; # saving volume.
$mpd->volume(10); # init to sthg that we know
$mpd->volume(42);
is( $mpd->status->volume, 42, 'setting volume' );

#
# testing positive relative volume.
$mpd->volume('+9');
is( $mpd->status->volume, 51, 'increasing volume' );

#
# testing negative relative volume.
$mpd->volume('-4');
is( $mpd->status->volume, 47, 'decreasing volume' );
$mpd->volume($oldvol);  # resoring volume.

#
# testing outputs.
my @outputs = $mpd->outputs;
is( scalar(@outputs), 1, 'list of outputs' );
my $o = shift @outputs;
isa_ok( $o, 'Audio::MPD::Common::Output', "outputs return AMC:Output objects" );
is( $o->id,   0,      "AMC:O object: id" );
is( $o->name, "null", "AMC:O object: name" );

#
# testing disable_output.
$mpd->playlist->add( 'title.ogg' );
$mpd->playlist->add( 'dir1/title-artist-album.ogg' );
$mpd->playlist->add( 'dir1/title-artist.ogg' );
$mpd->play;
$mpd->output_disable(0);
sleep(1);
SKIP: {
    # FIXME?
    my $error = $mpd->status->error;
    skip "detection method doesn't always work - depends on timing", 1
        unless defined $error;
    like( $error, qr/^problems|All audio outputs are disabled/, 'disabling output' );
}

#
# testing enable_output.
$mpd->output_enable(0);
sleep(1);
$mpd->play; $mpd->pause;
is( $mpd->status->error, undef, 'enabling output' );