PageRenderTime 37ms CodeModel.GetById 30ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/t/mixer_mixmusic.t

http://github.com/PerlGameDev/SDL
Unknown | 64 lines | 47 code | 17 blank | 0 comment | 0 complexity | 225094dc0fb6d8c9b2869e69cbbabff7 MD5 | raw file
 1use strict;
 2use warnings;
 3use SDL;
 4use SDL::Config;
 5
 6my $audiodriver;
 7
 8BEGIN {
 9	use Config;
10	if ( !$Config{'useithreads'} ) {
11		print("1..0 # Skip: Perl not compiled with 'useithreads'\n");
12		exit(0);
13	}
14
15	use Test::More;
16	use lib 't/lib';
17	use SDL::TestTool;
18
19	$audiodriver = $ENV{SDL_AUDIODRIVER};
20	$ENV{SDL_AUDIODRIVER} = 'dummy' unless $ENV{SDL_RELEASE_TESTING};
21
22	if ( !SDL::TestTool->init(SDL_INIT_AUDIO) ) {
23		plan( skip_all => 'Failed to init sound' );
24	} elsif ( !SDL::Config->has('SDL_mixer') ) {
25		plan( skip_all => 'SDL_mixer support not compiled' );
26	} else {
27		plan( tests => 6 );
28	}
29}
30
31use_ok('SDL::Mixer');
32use_ok('SDL::Mixer::Music');
33use_ok('SDL::Mixer::MixMusic');
34
35is( SDL::Mixer::open_audio( 44100, SDL::Audio::AUDIO_S16SYS, 2, 4096 ),
36	0, 'open_audio passed'
37);
38
39my $mix_music = SDL::Mixer::Music::load_MUS('test/data/tribe_i.wav')
40	; # from Matthew Newman, http://opengameart.org/content/vocal-grunts-tribeiwav
41
42#warn 'Error:'. SDL::get_error() if (!$mix_music);
43
44{
45
46	# I'm not sure why this fails
47	isa_ok( $mix_music, 'SDL::Mixer::MixMusic' );
48};
49
50SDL::Mixer::Music::play_music( $mix_music, 0 );
51
52# we close straight away so no audio is actually played
53
54SDL::Mixer::close_audio();
55
56ok( 1, 'Got to the end' );
57
58if ($audiodriver) {
59	$ENV{SDL_AUDIODRIVER} = $audiodriver;
60} else {
61	delete $ENV{SDL_AUDIODRIVER};
62}
63
64sleep(2);