Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Added simple audio test.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbens committed Aug 17, 2009
1 parent 405adec commit 51b56ea
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/automated/Makefile
Expand Up @@ -11,11 +11,17 @@ SRC := testsdl.c \
rwops/rwops.c \
platform/platform.c \
surface/surface.c \
render/render.c
render/render.c \
audio/audio.c
COMMON_SRC := SDL_at.c common/common.c
COMMON_INCLUDE := SDL_at.h

TESTS_ALL := testsdl rwops/rwops platform/platform surface/surface render/render
TESTS_ALL := testsdl \
rwops/rwops \
platform/platform \
surface/surface \
render/render \
audio/audio


.PHONY: all clean test
Expand All @@ -41,5 +47,8 @@ surface/surface: surface/surface.c $(COMMON_INCLUDE) $(COMMON_SRC)
render/render: render/render.c $(COMMON_INCLUDE) $(COMMON_SRC)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ render/render.c $(COMMON_SRC) -DTEST_STANDALONE

audio/audio: audio/audio.c $(COMMON_INCLUDE) $(COMMON_SRC)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ audio/audio.c $(COMMON_SRC) -DTEST_STANDALONE

clean:
$(RM) $(TESTS_ALL)
89 changes: 89 additions & 0 deletions test/automated/audio/audio.c
@@ -0,0 +1,89 @@
/**
* Automated SDL_RWops test.
*
* Written by Edgar Simo "bobbens"
*
* Released under Public Domain.
*/


#include "SDL.h"
#include "SDL_at.h"


/**
* @brief Prints available devices.
*/
static int audio_printDevices( int iscapture )
{
int i, n;

/* Get number of devices. */
n = SDL_GetNumAudioDevices(iscapture);
SDL_ATprintVerbose( 1, "%d %s Audio Devices\n",
n, iscapture ? "Capture" : "Output" );

/* List devices. */
for (i=0; i<n; i++) {
SDL_ATprintVerbose( 1, " %d) %s\n", i+1, SDL_GetAudioDeviceName( i, iscapture ) );
}

return 0;
}


/**
* @brief Makes sure parameters work properly.
*/
static void audio_testOpen (void)
{
int i, n;
int ret;

/* Begin testcase. */
SDL_ATbegin( "Audio Open" );

/* List drivers. */
n = SDL_GetNumAudioDrivers();
SDL_ATprintVerbose( 1, "%d Audio Drivers\n", n );
for (i=0; i<n; i++) {
SDL_ATprintVerbose( 1, " %s\n", SDL_GetAudioDriver(i) );
}

/* Start SDL. */
ret = SDL_Init( SDL_INIT_AUDIO );
if (SDL_ATvassert( ret==0, "SDL_Init( SDL_INIT_AUDIO ): %s", SDL_GetError()))
return;

/* Print devices. */
SDL_ATprintVerbose( 1, "Using Audio Driver '%s'\n", SDL_GetCurrentAudioDriver() );
audio_printDevices(0);
audio_printDevices(1);

/* Quit SDL. */
SDL_Quit();

/* End testcase. */
SDL_ATend();
}


/**
* @brief Entry point.
*/
#ifdef TEST_STANDALONE
int main( int argc, const char *argv[] )
{
(void) argc;
(void) argv;
#else /* TEST_STANDALONE */
int test_audio (void)
{
#endif /* TEST_STANDALONE */

SDL_ATinit( "SDL_Audio" );

audio_testOpen();

return SDL_ATfinish();
}
18 changes: 18 additions & 0 deletions test/automated/audio/audio.h
@@ -0,0 +1,18 @@
/**
* Part of SDL test suite.
*
* Written by Edgar Simo "bobbens"
*
* Released under Public Domain.
*/


#ifndef _TEST_AUDIO
# define _TEST_AUDIO


int test_audio (void);


#endif /* _TEST_AUDIO */

8 changes: 8 additions & 0 deletions test/automated/testsdl.c
Expand Up @@ -14,6 +14,7 @@
#include "rwops/rwops.h"
#include "surface/surface.h"
#include "render/render.h"
#include "audio/audio.h"

#include <stdio.h> /* printf */
#include <stdlib.h> /* exit */
Expand All @@ -32,6 +33,7 @@ static int run_platform = 1; /**< Run platform tests. */
static int run_rwops = 1; /**< Run RWops tests. */
static int run_surface = 1; /**< Run surface tests. */
static int run_render = 1; /**< Run render tests. */
static int run_audio = 1; /**< Run audio tests. */

/*
* Prototypes.
Expand All @@ -52,6 +54,7 @@ static void print_usage( const char *name )
printf(" --norwops do not run the rwops tests\n");
printf(" --nosurface do not run the surface tests\n");
printf(" --norender do not run the render tests\n");
printf(" --noaudio do not run the audio tests\n");
printf(" -v, --verbose increases verbosity level by 1 for each -v\n");
printf(" -q, --quiet only displays errors\n");
printf(" -h, --help display this message and exit\n");
Expand All @@ -69,6 +72,7 @@ static void parse_options( int argc, char *argv[] )
{ "norwops", no_argument, 0, 0 },
{ "nosurface", no_argument, 0, 0 },
{ "norender", no_argument, 0, 0 },
{ "noaudio", no_argument, 0, 0 },
{ "verbose", no_argument, 0, 'v' },
{ "quiet", no_argument, 0, 'q' },
{ "help", no_argument, 0, 'h' },
Expand Down Expand Up @@ -96,6 +100,8 @@ static void parse_options( int argc, char *argv[] )
run_surface = 0;
else if (strcmp(str,"norender")==0)
run_render = 0;
else if (strcmp(str,"noaudio")==0)
run_audio = 0;
break;

/* Manual. */
Expand Down Expand Up @@ -154,6 +160,8 @@ int main( int argc, char *argv[] )
failed += test_surface();
if (run_render)
failed += test_render();
if (run_audio)
failed += test_audio();

/* Manual tests. */
if (run_manual) {
Expand Down

0 comments on commit 51b56ea

Please sign in to comment.