SDL-mirror/test/test-automation/tests/testaudio/testaudio.c

141 lines
3.3 KiB
C
Raw Normal View History

2011-07-10 18:42:52 +03:00
/**
* Original code: automated SDL rect test written by Edgar Simo "bobbens"
*/
2011-07-05 22:11:12 +03:00
#include <stdio.h>
#include <SDL/SDL.h>
Reorganizing the project. --HG-- rename : test/test-automation/SDL_test.h => test/test-automation/include/SDL_test.h rename : test/test-automation/SDL_test.c => test/test-automation/src/libtest/SDL_test.c rename : test/test-automation/common/common.c => test/test-automation/src/libtest/common/common.c rename : test/test-automation/common/common.h => test/test-automation/src/libtest/common/common.h rename : test/test-automation/common/images.h => test/test-automation/src/libtest/common/images.h rename : test/test-automation/common/img_blit.c => test/test-automation/src/libtest/common/img_blit.c rename : test/test-automation/common/img_blitblend.c => test/test-automation/src/libtest/common/img_blitblend.c rename : test/test-automation/common/img_face.c => test/test-automation/src/libtest/common/img_face.c rename : test/test-automation/common/img_primitives.c => test/test-automation/src/libtest/common/img_primitives.c rename : test/test-automation/common/img_primitivesblend.c => test/test-automation/src/libtest/common/img_primitivesblend.c rename : test/test-automation/fuzzer/fuzzer.c => test/test-automation/src/libtest/fuzzer/fuzzer.c rename : test/test-automation/fuzzer/fuzzer.h => test/test-automation/src/libtest/fuzzer/fuzzer.h rename : test/test-automation/fuzzer/utl_crc32.c => test/test-automation/src/libtest/fuzzer/utl_crc32.c rename : test/test-automation/fuzzer/utl_crc32.h => test/test-automation/src/libtest/fuzzer/utl_crc32.h rename : test/test-automation/fuzzer/utl_md5.c => test/test-automation/src/libtest/fuzzer/utl_md5.c rename : test/test-automation/fuzzer/utl_md5.h => test/test-automation/src/libtest/fuzzer/utl_md5.h rename : test/test-automation/fuzzer/utl_random.c => test/test-automation/src/libtest/fuzzer/utl_random.c rename : test/test-automation/fuzzer/utl_random.h => test/test-automation/src/libtest/fuzzer/utl_random.h rename : test/test-automation/logger_helpers.c => test/test-automation/src/libtest/logger_helpers.c rename : test/test-automation/logger_helpers.h => test/test-automation/src/libtest/logger_helpers.h rename : test/test-automation/plain_logger.c => test/test-automation/src/libtest/plain_logger.c rename : test/test-automation/plain_logger.h => test/test-automation/src/libtest/plain_logger.h rename : test/test-automation/xml.c => test/test-automation/src/libtest/xml.c rename : test/test-automation/xml.h => test/test-automation/src/libtest/xml.h rename : test/test-automation/xml_logger.c => test/test-automation/src/libtest/xml_logger.c rename : test/test-automation/xml_logger.h => test/test-automation/src/libtest/xml_logger.h rename : test/test-automation/logger.h => test/test-automation/src/runner/logger.h rename : test/test-automation/runner.c => test/test-automation/src/runner/runner.c rename : test/test-automation/support.c => test/test-automation/src/runner/support.c rename : test/test-automation/support.h => test/test-automation/src/runner/support.h rename : test/test-automation/testaudio/Makefile.am => test/test-automation/tests/testaudio/Makefile.am rename : test/test-automation/testaudio/testaudio.c => test/test-automation/tests/testaudio/testaudio.c rename : test/test-automation/testdummy/Makefile.am => test/test-automation/tests/testdummy/Makefile.am rename : test/test-automation/testdummy/testdummy.c => test/test-automation/tests/testdummy/testdummy.c rename : test/test-automation/testplatform/Makefile.am => test/test-automation/tests/testplatform/Makefile.am rename : test/test-automation/testrect/Makefile.am => test/test-automation/tests/testrect/Makefile.am rename : test/test-automation/testrect/testrect.c => test/test-automation/tests/testrect/testrect.c rename : test/test-automation/testrender/Makefile.am => test/test-automation/tests/testrender/Makefile.am rename : test/test-automation/testrender/testrender.c => test/test-automation/tests/testrender/testrender.c rename : test/test-automation/testrwops/Makefile.am => test/test-automation/tests/testrwops/Makefile.am rename : test/test-automation/testrwops/testrwops.c => test/test-automation/tests/testrwops/testrwops.c rename : test/test-automation/testsurface/Makefile.am => test/test-automation/tests/testsurface/Makefile.am rename : test/test-automation/testsurface/testsurface.c => test/test-automation/tests/testsurface/testsurface.c
2011-08-06 17:35:58 +03:00
#include "../../include/SDL_test.h"
2011-07-05 22:11:12 +03:00
/* Test cases */
2011-07-05 22:11:12 +03:00
static const TestCaseReference test1 =
(TestCaseReference){ "audio_printOutputDevices", "Checks available output (non-capture) device names.", TEST_ENABLED, TEST_REQUIRES_AUDIO, 0};
2011-07-05 22:11:12 +03:00
static const TestCaseReference test2 =
(TestCaseReference){ "audio_printInputDevices", "Checks available input (capture) device names.", TEST_ENABLED, TEST_REQUIRES_AUDIO, 0};
2011-07-05 22:11:12 +03:00
static const TestCaseReference test3 =
(TestCaseReference){ "audio_printAudioDrivers", "Checks available audio driver names.", TEST_ENABLED, TEST_REQUIRES_AUDIO, 0};
2011-07-05 22:11:12 +03:00
static const TestCaseReference test4 =
(TestCaseReference){ "audio_printCurrentAudioDriver", "Checks current audio driver name with initialized audio.", TEST_ENABLED, TEST_REQUIRES_AUDIO, 0};
2011-07-05 22:11:12 +03:00
/* Test suite */
extern const TestCaseReference *testSuite[] = {
&test1, &test2, &test3, &test4, NULL
};
TestCaseReference **QueryTestSuite() {
return (TestCaseReference **)testSuite;
}
/* Test case functions */
/**
* @brief Checks available output (non-capture) device names.
*/
int audio_printOutputDevices()
{
int ret;
int i, n;
char *name;
/* Start SDL. */
ret = SDL_Init( SDL_INIT_AUDIO );
AssertTrue(ret==0, "SDL_Init(SDL_INIT_AUDIO): %s", SDL_GetError());
/* Get number of devices. */
n = SDL_GetNumAudioDevices(0);
AssertTrue(n>=0, "Number of output devices < 0, reported as %i", n);
/* List devices. */
if (n>0)
{
for (i=0; i<n; i++) {
name = SDL_GetAudioDeviceName(i, 0);
AssertTrue(name != NULL, "name != NULL");
AssertTrue(strlen(name)>0, "name blank");
}
}
/* Quit SDL. */
SDL_Quit();
}
/**
* @brief Checks available input (capture) device names.
*/
int audio_printInputDevices()
{
int ret;
int i, n;
char *name;
/* Start SDL. */
ret = SDL_Init( SDL_INIT_AUDIO );
AssertTrue(ret==0, "SDL_Init(SDL_INIT_AUDIO): %s", SDL_GetError());
/* Get number of devices. */
n = SDL_GetNumAudioDevices(1);
AssertTrue(n>=0, "Number of input devices < 0, reported as %i", n);
/* List devices. */
if (n>0)
{
for (i=0; i<n; i++) {
name = SDL_GetAudioDeviceName(i, 1);
AssertTrue(name != NULL, "name != NULL");
AssertTrue(strlen(name)>0, "name empty");
}
}
/* Quit SDL. */
SDL_Quit();
}
/**
* @brief Checks available audio driver names.
*/
int audio_printAudioDrivers()
{
int i, n;
char *name;
/* Get number of drivers */
n = SDL_GetNumAudioDrivers();
AssertTrue(n>=0, "Number of audio drivers >= 0");
/* List drivers. */
if (n>0)
{
for (i=0; i<n; i++) {
name = SDL_GetAudioDriver(i);
AssertTrue(name != NULL, "name != NULL");
AssertTrue(strlen(name)>0, "name empty");
}
}
}
/**
* @brief Checks current audio driver name with initialized audio.
*/
int audio_printCurrentAudioDriver()
{
int ret;
char *name;
/* Start SDL. */
ret = SDL_Init(SDL_INIT_AUDIO);
AssertTrue(ret==0, "SDL_Init(SDL_INIT_AUDIO): %s", SDL_GetError());
/* Check current audio driver */
name = SDL_GetCurrentAudioDriver();
AssertTrue(name != NULL, "name != NULL");
AssertTrue(strlen(name)>0, "name empty");
/* Quit SDL. */
SDL_Quit();
}