Mercurial > sdl-ios-xcode
changeset 3756:427f059bc814 gsoc2009_unit_tests
Added simple audio test.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Mon, 17 Aug 2009 17:52:42 +0000 |
parents | e04d9c69a6fd |
children | c5616d36b2ac |
files | test/automated/Makefile test/automated/audio/audio.c test/automated/audio/audio.h test/automated/testsdl.c |
diffstat | 4 files changed, 126 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/test/automated/Makefile Thu Aug 06 17:00:07 2009 +0000 +++ b/test/automated/Makefile Mon Aug 17 17:52:42 2009 +0000 @@ -11,11 +11,17 @@ 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 @@ -41,5 +47,8 @@ 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)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/automated/audio/audio.c Mon Aug 17 17:52:42 2009 +0000 @@ -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(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/automated/audio/audio.h Mon Aug 17 17:52:42 2009 +0000 @@ -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 */ +
--- a/test/automated/testsdl.c Thu Aug 06 17:00:07 2009 +0000 +++ b/test/automated/testsdl.c Mon Aug 17 17:52:42 2009 +0000 @@ -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 */ @@ -32,6 +33,7 @@ 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. @@ -52,6 +54,7 @@ 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"); @@ -69,6 +72,7 @@ { "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' }, @@ -96,6 +100,8 @@ run_surface = 0; else if (strcmp(str,"norender")==0) run_render = 0; + else if (strcmp(str,"noaudio")==0) + run_audio = 0; break; /* Manual. */ @@ -154,6 +160,8 @@ failed += test_surface(); if (run_render) failed += test_render(); + if (run_audio) + failed += test_audio(); /* Manual tests. */ if (run_manual) {