Skip to content

Commit

Permalink
added silence.wav, audible test only width RELEASE_TESTING turned on
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Leich committed Feb 27, 2010
1 parent cccfdeb commit 1441578
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions t/mixer_channels.t
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,29 @@ my $finished = 0;
my $callback = sub{ printf("[channel_finished] callback called for channel %d\n", shift); $finished++; };
SDL::Mixer::Channels::channel_finished( $callback ); pass '[channel_finished] ran';

SDL::Mixer::Channels::volume( -1, 10 );
is( SDL::Mixer::Channels::volume( -1, 20 ), 10, "[volume] set to 20, previously was 10" );
my $delay = 100;
my $audio_test_file = 'test/data/silence.wav';

my $sample_chunk = SDL::Mixer::Samples::load_WAV('test/data/sample.wav');
if($ENV{'RELEASE_TESTING'})
{
SDL::Mixer::Channels::volume( -1, 10 );
is( SDL::Mixer::Channels::volume( -1, 20 ), 10, "[volume] set to 20, previously was 10" );
$delay = 2000;
$audio_test_file = 'test/data/sample.wav';
}
else
{
SDL::Mixer::Channels::volume( -1, 10 );
is( SDL::Mixer::Channels::volume( -1, 1 ), 10, "[volume] set to 1, previously was 10" );
}

my $sample_chunk = SDL::Mixer::Samples::load_WAV($audio_test_file);
my $playing_channel = SDL::Mixer::Channels::play_channel( -1, $sample_chunk, -1 );
isnt( $playing_channel, -1, "[play_channel] plays sample.wav on channel " . $playing_channel );
is( SDL::Mixer::Channels::fading_channel( $playing_channel ), MIX_NO_FADING, "[fading_channel] channel $playing_channel is not fading" );
is( SDL::Mixer::Channels::playing( $playing_channel ), 1, "[playing] channel $playing_channel is playing" );
is( SDL::Mixer::Channels::paused( $playing_channel ), 0, "[paused] channel $playing_channel is not paused" );

my $delay = 100; # set it to at least 2000 te hear the tests right

my $fading_channels = SDL::Mixer::Channels::fade_out_channel( $playing_channel, $delay );
is( $fading_channels > 0, 1, "[fade_out_channel] $delay ms for $fading_channels channel(s)" );
is( SDL::Mixer::Channels::fading_channel( $playing_channel ), MIX_FADING_OUT, "[fading_channel] channel $playing_channel is fading out" );
Expand All @@ -57,7 +68,7 @@ SDL::delay($delay);
SDL::Mixer::Channels::pause(-1); pass '[pause] ran';
is( SDL::Mixer::Channels::paused( $playing_channel ), 1, "[paused] channel $playing_channel is paused" );

SDL::delay(500);
SDL::delay($delay / 4);


SDL::Mixer::Channels::resume(-1); pass '[resume] ran';
Expand All @@ -71,7 +82,7 @@ SDL::delay($delay);

$playing_channel = SDL::Mixer::Channels::play_channel_timed( -1, $sample_chunk, 0, $delay );
isnt( $playing_channel, -1, "[play_channel_timed] play $delay ms for channel $playing_channel" );
SDL::delay(500);
SDL::delay($delay / 4);
my $expire_channel = SDL::Mixer::Channels::expire_channel( $playing_channel, $delay );
is( $expire_channel > 0, 1, "[expire_channel] stops after $delay ms for $expire_channel channel(s)" );

Expand All @@ -87,4 +98,7 @@ SDL::delay($delay * 4);
SDL::Mixer::close_audio(); pass '[close_audio] ran';

isnt ( $finished , 0 , '[callback_finished] called the callback got '. $finished);

SDL::quit();

done_testing();
Binary file added test/data/silence.wav
Binary file not shown.

0 comments on commit 1441578

Please sign in to comment.