[project @ 6332]
[audio-mpd-common.git] / t / 50-pl-info.t
blobfdbf91cb93525cc41bf06b08fba5a84497f2b0e9
1 #!perl
3 # This file is part of POE::Component::Client::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.
11 use strict;
12 use warnings;
14 use POE qw[ Component::Client::MPD::Message ];
15 use Readonly;
16 use Test::More;
19 our $nbtests = 10;
20 my @songs = qw[
21     title.ogg dir1/title-artist-album.ogg
22     dir1/title-artist.ogg dir2/album.ogg
24 our @tests   = (
25     # [ 'event', [ $arg1, $arg2, ... ], $answer_back, \&check_results ]
27     [ 'pl.clear', [],      $DISCARD, undef ],
28     [ 'pl.add',   \@songs, $DISCARD, undef ],
30     # pl.as_items
31     [ 'pl.as_items',            [],  $SEND, \&check_as_items      ],
33     # pl.items_changed_since
34     [ 'pl.items_changed_since', [0], $SEND, \&check_items_changed ],
39 # are we able to test module?
40 eval 'use POE::Component::Client::MPD::Test';
41 plan skip_all => $@ if $@ =~ s/\n+BEGIN failed--compilation aborted.*//s;
42 exit;
44 sub check_as_items {
45     my @items = @{ $_[0]->data };
46     isa_ok( $_, 'POE::Component::Client::MPD::Item::Song',
47         'pl.as_items() returns POCOCM::Item::Song objects' ) for @items;
48     is( $items[0]->title, 'ok-title', 'first song reported first' );
51 sub check_items_changed {
52     my @items = @{ $_[0]->data };
53     isa_ok( $_, 'POE::Component::Client::MPD::Item::Song',
54             'items_changed_since() returns POCOCM::Item::Song objects' )
55         for @items;
56     is( $items[0]->title, 'ok-title', 'first song reported first' );