--- a/include/SDL_test_assert.h Sat Dec 22 20:43:51 2012 -0800
+++ b/include/SDL_test_assert.h Mon Dec 24 14:43:57 2012 -0800
@@ -60,7 +60,7 @@
* \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0).
* \param assertDescription Message to log with the assert describing it.
*/
-void SDLTest_Assert(int assertCondition, char *assertDescription, ...);
+void SDLTest_Assert(int assertCondition, const char *assertDescription, ...);
/**
* \brief Assert for test cases that logs but does not break execution flow on failures. Updates assertion counters.
@@ -70,14 +70,14 @@
*
* \returns Returns the assertCondition so it can be used to externally to break execution flow if desired.
*/
-int SDLTest_AssertCheck(int assertCondition, char *assertDescription, ...);
+int SDLTest_AssertCheck(int assertCondition, const char *assertDescription, ...);
/**
* \brief Explicitely pass without checking an assertion condition. Updates assertion counter.
*
* \param assertDescription Message to log with the assert describing it.
*/
-void SDLTest_AssertPass(char *assertDescription, ...);
+void SDLTest_AssertPass(const char *assertDescription, ...);
/**
* \brief Resets the assert summary counters to zero.
--- a/include/SDL_test_compare.h Sat Dec 22 20:43:51 2012 -0800
+++ b/include/SDL_test_compare.h Mon Dec 24 14:43:57 2012 -0800
@@ -37,6 +37,7 @@
#define _SDL_test_compare_h
#include "SDL.h"
+
#include "SDL_test_images.h"
#include "begin_code.h"
@@ -50,13 +51,13 @@
/**
* \brief Compares a surface and with reference image data for equality
*
- * \param sur Surface used in comparison
- * \param img Test Surface used in comparison
- * \param allowable_error Allowable difference in blending accuracy
+ * \param surface Surface used in comparison
+ * \param referenceSurface Test Surface used in comparison
+ * \param allowable_error Allowable difference (squared) in blending accuracy.
*
- * \returns 0 if comparison succeeded, >0 (=number of pixels where comparison failed) if comparison failed, <0 for any other error.
+ * \returns 0 if comparison succeeded, >0 (=number of pixels where comparison failed) if comparison failed, -1 if any of the surfaces were NULL, -2 if the surface sizes differ.
*/
-int SDLTest_CompareSurfaces(SDL_Surface *sur, SDL_Surface *img, int allowable_error);
+int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error);
/* Ends C function definitions when using C++ */
--- a/include/SDL_test_log.h Sat Dec 22 20:43:51 2012 -0800
+++ b/include/SDL_test_log.h Mon Dec 24 14:43:57 2012 -0800
@@ -49,14 +49,14 @@
*
* \param fmt Message to be logged
*/
-void SDLTest_Log(char *fmt, ...);
+void SDLTest_Log(const char *fmt, ...);
/**
* \brief Prints given message with a timestamp in the TEST category and the ERROR priority.
*
* \param fmt Message to be logged
*/
-void SDLTest_LogError(char *fmt, ...);
+void SDLTest_LogError(const char *fmt, ...);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
--- a/src/test/SDL_test_assert.c Sat Dec 22 20:43:51 2012 -0800
+++ b/src/test/SDL_test_assert.c Mon Dec 24 14:43:57 2012 -0800
@@ -44,7 +44,7 @@
/*
* Assert that logs and break execution flow on failures (i.e. for harness errors).
*/
-void SDLTest_Assert(int assertCondition, char *assertDescription, ...)
+void SDLTest_Assert(int assertCondition, const char *assertDescription, ...)
{
va_list list;
char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH];
@@ -62,11 +62,10 @@
/*
* Assert that logs but does not break execution flow on failures (i.e. for test cases).
*/
-int SDLTest_AssertCheck(int assertCondition, char *assertDescription, ...)
+int SDLTest_AssertCheck(int assertCondition, const char *assertDescription, ...)
{
va_list list;
char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH];
- char *logFormat = (char *)SDLTest_AssertCheckFormat;
// Print assert description into a buffer
SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
@@ -78,12 +77,12 @@
if (assertCondition == ASSERT_FAIL)
{
SDLTest_AssertsFailed++;
- SDLTest_LogError(logFormat, logMessage, "Failed");
+ SDLTest_LogError(SDLTest_AssertCheckFormat, logMessage, "Failed");
}
else
{
SDLTest_AssertsPassed++;
- SDLTest_Log(logFormat, logMessage, "Passed");
+ SDLTest_Log(SDLTest_AssertCheckFormat, logMessage, "Passed");
}
return assertCondition;
@@ -92,11 +91,10 @@
/*
* Explicitly passing Assert that logs (i.e. for test cases).
*/
-void SDLTest_AssertPass(char *assertDescription, ...)
+void SDLTest_AssertPass(const char *assertDescription, ...)
{
va_list list;
char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH];
- char *logFormat = (char *)SDLTest_AssertCheckFormat;
// Print assert description into a buffer
SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
@@ -104,9 +102,9 @@
SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
va_end(list);
- // Log pass message
+ // Log pass message
SDLTest_AssertsPassed++;
- SDLTest_Log(logFormat, logMessage, "Pass");
+ SDLTest_Log(SDLTest_AssertCheckFormat, logMessage, "Pass");
}
/*
@@ -124,15 +122,14 @@
*/
void SDLTest_LogAssertSummary()
{
- char *logFormat = (char *)SDLTest_AssertSummaryFormat;
Uint32 totalAsserts = SDLTest_AssertsPassed + SDLTest_AssertsFailed;
if (SDLTest_AssertsFailed == 0)
{
- SDLTest_Log(logFormat, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
+ SDLTest_Log(SDLTest_AssertSummaryFormat, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
}
else
{
- SDLTest_LogError(logFormat, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
+ SDLTest_LogError(SDLTest_AssertSummaryFormat, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
}
}
--- a/src/test/SDL_test_compare.c Sat Dec 22 20:43:51 2012 -0800
+++ b/src/test/SDL_test_compare.c Mon Dec 24 14:43:57 2012 -0800
@@ -42,29 +42,37 @@
Uint8 R, G, B, A;
Uint8 Rd, Gd, Bd, Ad;
- /* Make surfacee size is the same. */
- if ((surface->w != referenceSurface->w) || (surface->h != referenceSurface->h))
- {
+ /* Validate input surfaces */
+ if (surface == NULL || referenceSurface == NULL) {
return -1;
}
+ /* Make surface size is the same. */
+ if ((surface->w != referenceSurface->w) || (surface->h != referenceSurface->h)) {
+ return -2;
+ }
+
+ /* Sanitize input */
+ if (allowable_error<0) {
+ allowable_error = 0;
+ }
+
SDL_LockSurface( surface );
SDL_LockSurface( referenceSurface );
ret = 0;
bpp = surface->format->BytesPerPixel;
bpp_reference = referenceSurface->format->BytesPerPixel;
-
/* Compare image - should be same format. */
for (j=0; j<surface->h; j++) {
for (i=0; i<surface->w; i++) {
p = (Uint8 *)surface->pixels + j * surface->pitch + i * bpp;
p_reference = (Uint8 *)referenceSurface->pixels + j * referenceSurface->pitch + i * bpp_reference;
- dist = 0;
SDL_GetRGBA(*(Uint32*)p, surface->format, &R, &G, &B, &A);
SDL_GetRGBA(*(Uint32*)p_reference, referenceSurface->format, &Rd, &Gd, &Bd, &Ad);
+ dist = 0;
dist += (R-Rd)*(R-Rd);
dist += (G-Gd)*(G-Gd);
dist += (B-Bd)*(B-Bd);
--- a/src/test/SDL_test_harness.c Sat Dec 22 20:43:51 2012 -0800
+++ b/src/test/SDL_test_harness.c Mon Dec 24 14:43:57 2012 -0800
@@ -51,7 +51,7 @@
* \returns The generated seed string
*/
char *
- SDLTest_GenerateRunSeed(const int length)
+SDLTest_GenerateRunSeed(const int length)
{
char *seed = NULL;
SDLTest_RandomContext randomContext;
@@ -97,7 +97,7 @@
*
*/
Uint64
- SDLTest_GenerateExecKey(char *runSeed, char *suiteName, char *testName, int iteration)
+SDLTest_GenerateExecKey(char *runSeed, char *suiteName, char *testName, int iteration)
{
SDLTest_Md5Context md5Context;
Uint64 *keys;
@@ -109,17 +109,17 @@
Uint32 entireStringLength;
char *buffer;
- if (runSeed == NULL || strlen(runSeed)==0) {
+ if (runSeed == NULL || SDL_strlen(runSeed)==0) {
SDLTest_LogError("Invalid runSeed string.");
return -1;
}
- if (suiteName == NULL || strlen(suiteName)==0) {
+ if (suiteName == NULL || SDL_strlen(suiteName)==0) {
SDLTest_LogError("Invalid suiteName string.");
return -1;
}
- if (testName == NULL || strlen(testName)==0) {
+ if (testName == NULL || SDL_strlen(testName)==0) {
SDLTest_LogError("Invalid testName string.");
return -1;
}
@@ -130,14 +130,14 @@
}
// Convert iteration number into a string
- memset(iterationString, 0, sizeof(iterationString));
+ SDL_memset(iterationString, 0, sizeof(iterationString));
SDL_snprintf(iterationString, sizeof(iterationString) - 1, "%d", iteration);
// Combine the parameters into single string
- runSeedLength = strlen(runSeed);
- suiteNameLength = strlen(suiteName);
- testNameLength = strlen(testName);
- iterationStringLength = strlen(iterationString);
+ runSeedLength = SDL_strlen(runSeed);
+ suiteNameLength = SDL_strlen(suiteName);
+ testNameLength = SDL_strlen(testName);
+ iterationStringLength = SDL_strlen(iterationString);
entireStringLength = runSeedLength + suiteNameLength + testNameLength + iterationStringLength + 1;
buffer = (char *)SDL_malloc(entireStringLength);
if (buffer == NULL) {
@@ -167,7 +167,7 @@
* \return Timer id or -1 on failure.
*/
SDL_TimerID
- SDLTest_SetTestTimeout(int timeout, void (*callback)())
+SDLTest_SetTestTimeout(int timeout, void (*callback)())
{
Uint32 timeoutInMilliseconds;
SDL_TimerID timerID;
@@ -371,7 +371,7 @@
}
// Generate run see if we don't have one already
- if (userRunSeed == NULL || strlen(userRunSeed) == 0) {
+ if (userRunSeed == NULL || SDL_strlen(userRunSeed) == 0) {
runSeed = SDLTest_GenerateRunSeed(16);
if (runSeed == NULL) {
SDLTest_LogError("Generating a random seed failed");
@@ -488,7 +488,7 @@
suiteCounter,
testCounter,
currentTestName);
- if (testCase->description != NULL && strlen(testCase->description)>0) {
+ if (testCase->description != NULL && SDL_strlen(testCase->description)>0) {
SDLTest_Log("Test Description: '%s'",
(testCase->description) ? testCase->description : SDLTest_InvalidNameFormat);
}
--- a/src/test/SDL_test_log.c Sat Dec 22 20:43:51 2012 -0800
+++ b/src/test/SDL_test_log.c Mon Dec 24 14:43:57 2012 -0800
@@ -31,10 +31,12 @@
#include "SDL_config.h"
#include <stdarg.h> /* va_list */
-#include <stdio.h>
+#include <stdio.h>
#include <string.h>
#include <time.h>
+#include "SDL.h"
+
#include "SDL_test.h"
/*!
@@ -54,7 +56,7 @@
static char buffer[64];
struct tm *local;
- memset(buffer, 0, sizeof(buffer));\
+ SDL_memset(buffer, 0, sizeof(buffer));\
copy = timestamp;
local = localtime(©);
strftime(buffer, sizeof(buffer), "%x %X", local);
@@ -65,13 +67,13 @@
/*
* Prints given message with a timestamp in the TEST category and INFO priority.
*/
-void SDLTest_Log(char *fmt, ...)
+void SDLTest_Log(const char *fmt, ...)
{
va_list list;
char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH];
// Print log message into a buffer
- memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
+ SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
va_start(list, fmt);
SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, fmt, list);
va_end(list);
@@ -83,13 +85,13 @@
/*
* Prints given message with a timestamp in the TEST category and the ERROR priority.
*/
-void SDLTest_LogError(char *fmt, ...)
+void SDLTest_LogError(const char *fmt, ...)
{
va_list list;
char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH];
// Print log message into a buffer
- memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
+ SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
va_start(list, fmt);
SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, fmt, list);
va_end(list);
--- a/test/Makefile.in Sat Dec 22 20:43:51 2012 -0800
+++ b/test/Makefile.in Mon Dec 24 14:43:57 2012 -0800
@@ -73,7 +73,8 @@
$(srcdir)/testautomation_platform.c \
$(srcdir)/testautomation_rect.c \
$(srcdir)/testautomation_render.c \
- $(srcdir)/testautomation_rwops.c
+ $(srcdir)/testautomation_rwops.c \
+ $(srcdir)/testautomation_audio.c
$(CC) -o $@ $^ $(CFLAGS) -lSDL2_test $(LIBS)
testmultiaudio$(EXE): $(srcdir)/testmultiaudio.c
--- a/test/testautomation.c Sat Dec 22 20:43:51 2012 -0800
+++ b/test/testautomation.c Mon Dec 24 14:43:57 2012 -0800
@@ -101,7 +101,7 @@
}
/* Call Harness */
- result = SDLTest_RunSuites(testSuites, userRunSeed, userExecKey, filter, testIterations);
+ result = SDLTest_RunSuites(testSuites, (const char *)userRunSeed, userExecKey, (const char *)filter, testIterations);
/* Clean up */
if (userRunSeed != NULL) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/testautomation_audio.c Mon Dec 24 14:43:57 2012 -0800
@@ -0,0 +1,209 @@
+/**
+ * Original code: automated SDL audio test written by Edgar Simo "bobbens"
+ * New/updated tests: aschiffler at ferzkopp dot net
+ */
+
+#include <stdio.h>
+
+#include "SDL.h"
+#include "SDL_test.h"
+
+/* ================= Test Case Implementation ================== */
+
+/* Fixture */
+
+void
+_audioSetUp(void *arg)
+{
+ /* Start SDL audio subsystem */
+ int ret = SDL_InitSubSystem( SDL_INIT_AUDIO );
+ SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_AUDIO)");
+ SDLTest_AssertCheck(ret==0, "Check result from SDL_InitSubSystem(SDL_INIT_AUDIO)");
+ if (ret != 0) {
+ SDLTest_LogError("%s", SDL_GetError());
+ }
+}
+
+
+/* Test case functions */
+
+/**
+ * \brief Enumerate and name available audio devices (output and capture).
+ *
+ * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetNumAudioDevices
+ * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetAudioDeviceName
+ */
+int audio_enumerateAndNameAudioDevices()
+{
+ int t, tt;
+ int i, n, nn;
+ const char *name, *nameAgain;
+
+ /* Iterate over types: t=0 output device, t=1 input/capture device */
+ for (t=0; t<2; t++) {
+
+ /* Get number of devices. */
+ n = SDL_GetNumAudioDevices(t);
+ SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(%i)", t);
+ SDLTest_Log("Number of %s devices < 0, reported as %i", (t) ? "output" : "capture", n);
+ SDLTest_AssertCheck(n >= 0, "Validate result is >= 0, got: %i", n);
+
+ /* Variation of non-zero type */
+ if (t==1) {
+ tt = t + SDLTest_RandomIntegerInRange(1,10);
+ nn = SDL_GetNumAudioDevices(tt);
+ SDLTest_AssertCheck(n==nn, "Verify result from SDL_GetNumAudioDevices(%i), expected same number of audio devices %i, got %i", tt, n, nn);
+ nn = SDL_GetNumAudioDevices(-tt);
+ SDLTest_AssertCheck(n==nn, "Verify result from SDL_GetNumAudioDevices(%i), expected same number of audio devices %i, got %i", -tt, n, nn);
+ }
+
+ /* List devices. */
+ if (n>0) {
+ for (i=0; i<n; i++) {
+ name = SDL_GetAudioDeviceName(i, t);
+ SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t);
+ SDLTest_AssertCheck(name != NULL, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not NULL", i, t);
+ if (name != NULL) {
+ SDLTest_AssertCheck(SDL_strlen(name)>0, "verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, t, name);
+ if (t==1) {
+ /* Also try non-zero type */
+ tt = t + SDLTest_RandomIntegerInRange(1,10);
+ nameAgain = SDL_GetAudioDeviceName(i, tt);
+ SDLTest_AssertCheck(nameAgain != NULL, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not NULL", i, tt);
+ if (nameAgain != NULL) {
+ SDLTest_AssertCheck(SDL_strlen(nameAgain)>0, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, tt, nameAgain);
+ SDLTest_AssertCheck(SDL_strcmp(name, nameAgain)==0,
+ "Verify SDL_GetAudioDeviceName(%i, %i) and SDL_GetAudioDeviceName(%i %i) return the same string",
+ i, t, i, tt);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return TEST_COMPLETED;
+}
+
+/**
+ * \brief Negative tests around enumeration and naming of audio devices.
+ *
+ * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetNumAudioDevices
+ * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetAudioDeviceName
+ */
+int audio_enumerateAndNameAudioDevicesNegativeTests()
+{
+ int t;
+ int i, j, no, nc;
+ const char *name;
+
+ /* Get number of devices. */
+ no = SDL_GetNumAudioDevices(0);
+ SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)");
+ nc = SDL_GetNumAudioDevices(1);
+ SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(1)");
+
+ /* Invalid device index when getting name */
+ for (t=0; t<2; t++) {
+ /* Negative device index */
+ i = SDLTest_RandomIntegerInRange(-10,-1);
+ name = SDL_GetAudioDeviceName(i, t);
+ SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t);
+ SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result NULL, expected NULL, got: %s", i, t, (name == NULL) ? "NULL" : name);
+
+ /* Device index past range */
+ for (j=0; j<3; j++) {
+ i = (t) ? nc+j : no+j;
+ name = SDL_GetAudioDeviceName(i, t);
+ SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t);
+ SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result, expected: NULL, got: %s", i, t, (name == NULL) ? "NULL" : name);
+ }
+
+ /* Capture index past capture range but within output range */
+ if ((no>0) && (no>nc) && (t==1)) {
+ i = no-1;
+ name = SDL_GetAudioDeviceName(i, t);
+ SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t);
+ SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result, expected: NULL, got: %s", i, t, (name == NULL) ? "NULL" : name);
+ }
+ }
+
+ return TEST_COMPLETED;
+}
+
+
+/**
+ * @brief Checks available audio driver names.
+ */
+int audio_printAudioDrivers()
+{
+ int i, n;
+ const char *name;
+
+ /* Get number of drivers */
+ n = SDL_GetNumAudioDrivers();
+ SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
+ SDLTest_AssertCheck(n>=0, "Verify number of audio drivers >= 0, got: %i", n);
+
+ /* List drivers. */
+ if (n>0)
+ {
+ for (i=0; i<n; i++) {
+ name = SDL_GetAudioDriver(i);
+ SDLTest_AssertPass("Call to SDL_GetAudioDriver(%i)", i);
+ SDLTest_AssertCheck(name != NULL, "Verify returned name is not NULL");
+ if (name != NULL) {
+ SDLTest_AssertCheck(SDL_strlen(name)>0, "Verify returned name is not empty, got: '%s'", name);
+ }
+ }
+ }
+
+ return TEST_COMPLETED;
+}
+
+
+/**
+ * @brief Checks current audio driver name with initialized audio.
+ */
+int audio_printCurrentAudioDriver()
+{
+ const char *name;
+
+ /* Check current audio driver */
+ name = SDL_GetCurrentAudioDriver();
+ SDLTest_AssertPass("Call to SDL_GetCurrentAudioDriver()");
+ SDLTest_AssertCheck(name != NULL, "Verify returned name is not NULL");
+ if (name != NULL) {
+ SDLTest_AssertCheck(SDL_strlen(name)>0, "Verify returned name is not empty, got: '%s'", name);
+ }
+
+ return TEST_COMPLETED;
+}
+
+/* ================= Test Case References ================== */
+
+/* Audio test cases */
+static const SDLTest_TestCaseReference audioTest1 =
+ { (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevices, "audio_enumerateAndNameAudioDevices", "Enumerate and name available audio devices (output and capture)", TEST_ENABLED };
+
+static const SDLTest_TestCaseReference audioTest2 =
+ { (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevicesNegativeTests, "audio_enumerateAndNameAudioDevicesNegativeTests", "Negative tests around enumeration and naming of audio devices.", TEST_ENABLED };
+
+static const SDLTest_TestCaseReference audioTest3 =
+ { (SDLTest_TestCaseFp)audio_printAudioDrivers, "audio_printAudioDrivers", "Checks available audio driver names.", TEST_ENABLED };
+
+static const SDLTest_TestCaseReference audioTest4 =
+ { (SDLTest_TestCaseFp)audio_printCurrentAudioDriver, "audio_printCurrentAudioDriver", "Checks current audio driver name with initialized audio.", TEST_ENABLED };
+
+/* Sequence of Audio test cases */
+static const SDLTest_TestCaseReference *audioTests[] = {
+ &audioTest1, &audioTest2, &audioTest3, &audioTest4, NULL
+};
+
+/* Audio test suite (global) */
+SDLTest_TestSuiteReference audioTestSuite = {
+ "Audio",
+ _audioSetUp,
+ audioTests,
+ NULL
+};
--- a/test/testautomation_rect.c Sat Dec 22 20:43:51 2012 -0800
+++ b/test/testautomation_rect.c Mon Dec 24 14:43:57 2012 -0800
@@ -951,12 +951,12 @@
SDL_Rect result;
SDL_bool anyEnclosed;
SDL_bool anyEnclosedNoResult;
+ SDL_bool expectedEnclosed = SDL_TRUE;
+ int newx, newy;
+ int minx = 0, maxx = 0, miny = 0, maxy = 0;
+ int i;
// Create input data, tracking result
- SDL_bool expectedEnclosed = SDL_TRUE;
- int newx, newy;
- int minx, maxx, miny, maxy;
- int i;
for (i=0; i<numPoints; i++) {
newx = SDLTest_RandomIntegerInRange(-1024, 1024);
newy = SDLTest_RandomIntegerInRange(-1024, 1024);
@@ -965,13 +965,15 @@
points[i].x = newx;
points[i].y = newy;
if (i==0) {
- minx=maxx=newx;
- miny=maxy=newy;
+ minx = newx;
+ maxx = newx;
+ miny = newy;
+ maxy = newy;
} else {
- if (newx<minx) minx=newx;
- if (newx>maxx) maxx=newx;
- if (newy<miny) miny=newy;
- if (newy>maxy) maxy=newy;
+ if (newx < minx) minx = newx;
+ if (newx > maxx) maxx = newx;
+ if (newy < miny) miny = newy;
+ if (newy > maxy) maxy = newy;
}
}
@@ -1020,12 +1022,12 @@
SDL_Rect result;
SDL_bool anyEnclosed;
SDL_bool anyEnclosedNoResult;
+ SDL_bool expectedEnclosed = SDL_TRUE;
+ int newx, newy;
+ int minx = 0, maxx = 0, miny = 0, maxy = 0;
+ int i;
// Create input data, tracking result
- SDL_bool expectedEnclosed = SDL_TRUE;
- int newx, newy;
- int minx, maxx, miny, maxy;
- int i;
for (i=0; i<numPoints; i++) {
if (i < halfPoints) {
newx = SDLTest_RandomIntegerInRange(-1024, 1024);
@@ -1039,13 +1041,15 @@
points[i].x = newx;
points[i].y = newy;
if (i==0) {
- minx=maxx=newx;
- miny=maxy=newy;
+ minx = newx;
+ maxx = newx;
+ miny = newy;
+ maxy = newy;
} else {
- if (newx<minx) minx=newx;
- if (newx>maxx) maxx=newx;
- if (newy<miny) miny=newy;
- if (newy>maxy) maxy=newy;
+ if (newx < minx) minx = newx;
+ if (newx > maxx) maxx = newx;
+ if (newy < miny) miny = newy;
+ if (newy > maxy) maxy = newy;
}
}
@@ -1097,7 +1101,7 @@
SDL_bool anyEnclosedNoResult;
SDL_bool expectedEnclosed = SDL_FALSE;
int newx, newy;
- int minx, maxx, miny, maxy;
+ int minx = 0, maxx = 0, miny = 0, maxy = 0;
int i;
// Setup clipping rectangle
@@ -1117,13 +1121,15 @@
if ((newx>=refClip.x) && (newx<(refClip.x + refClip.w)) &&
(newy>=refClip.y) && (newy<(refClip.y + refClip.h))) {
if (expectedEnclosed==SDL_FALSE) {
- minx=maxx=newx;
- miny=maxy=newy;
+ minx = newx;
+ maxx = newx;
+ miny = newy;
+ maxy = newy;
} else {
- if (newx<minx) minx=newx;
- if (newx>maxx) maxx=newx;
- if (newy<miny) miny=newy;
- if (newy>maxy) maxy=newy;
+ if (newx < minx) minx = newx;
+ if (newx > maxx) maxx = newx;
+ if (newy < miny) miny = newy;
+ if (newy > maxy) maxy = newy;
}
expectedEnclosed = SDL_TRUE;
}
--- a/test/testautomation_render.c Sat Dec 22 20:43:51 2012 -0800
+++ b/test/testautomation_render.c Mon Dec 24 14:43:57 2012 -0800
@@ -690,7 +690,6 @@
}
-
/**
* @brief Checks to see if functionality is supported. Helper function.
*/
@@ -722,6 +721,7 @@
ret = SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a );
if (!_isSupported(ret))
fail = 1;
+
/* Restore natural. */
ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE );
if (!_isSupported(ret))
@@ -730,6 +730,7 @@
/* Something failed, consider not available. */
if (fail)
return 0;
+
/* Not set properly, consider failed. */
else if ((r != 100) || (g != 100) || (b != 100) || (a != 100))
return 0;
@@ -839,7 +840,7 @@
/* Get test face. */
tface = _loadTestFace();
- if (tface == 0)
+ if (tface == NULL)
return 0;
/* See if supported. */
@@ -879,7 +880,7 @@
/* Get test face. */
tface = _loadTestFace();
- if (tface == 0)
+ if (tface == NULL)
return 0;
/* See if supported. */
@@ -901,7 +902,8 @@
return 1;
}
-static _renderCompareCount = 0;
+/* Counter for _compare calls use for filename creation when comparisons fail */
+static int _renderCompareCount = 0;
/**
* @brief Compares screen pixels with image pixels. Helper function.
@@ -920,7 +922,7 @@
{
int ret;
SDL_Rect rect;
- Uint8 pix[4*80*60];
+ Uint8 pix[4*TESTRENDER_SCREEN_W*TESTRENDER_SCREEN_H];
SDL_Surface *testsur;
char imageFilename[128];
char referenceFilename[128];
@@ -929,8 +931,8 @@
/* Explicitly specify the rect in case the window isn't expected size... */
rect.x = 0;
rect.y = 0;
- rect.w = 80;
- rect.h = 60;
+ rect.w = TESTRENDER_SCREEN_W;
+ rect.h = TESTRENDER_SCREEN_H;
ret = SDL_RenderReadPixels(renderer, &rect, RENDER_COMPARE_FORMAT, pix, 80*4 );
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderReadPixels, expected: 0, got: %i", ret);
@@ -943,17 +945,18 @@
ret = SDLTest_CompareSurfaces( testsur, s, allowable_error );
SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
+ /* Save source image and reference image for analysis */
_renderCompareCount++;
if (ret != 0) {
- SDL_snprintf(imageFilename, 127, "image%i.bmp", _renderCompareCount);
+ SDL_snprintf(imageFilename, 127, "compare%04d_SourceImage.bmp", _renderCompareCount);
SDL_SaveBMP(testsur, imageFilename);
- SDL_snprintf(referenceFilename, 127, "reference%i.bmp", _renderCompareCount);
+ SDL_snprintf(referenceFilename, 127, "compare%04d_ReferenceImage.bmp", _renderCompareCount);
SDL_SaveBMP(s, referenceFilename);
- SDLTest_LogError("Surfaces from failed comparison saved as %s and %s", imageFilename, referenceFilename);
+ SDLTest_LogError("Surfaces from failed comparison saved as '%s' and '%s'", imageFilename, referenceFilename);
}
/* Clean up. */
- SDL_FreeSurface( testsur );
+ SDL_FreeSurface(testsur);
}
/**
--- a/test/testautomation_suites.h Sat Dec 22 20:43:51 2012 -0800
+++ b/test/testautomation_suites.h Mon Dec 24 14:43:57 2012 -0800
@@ -9,7 +9,7 @@
#include "SDL_test.h"
// Test collections
-//extern SDLTest_TestSuiteReference audioTestSuite;
+extern SDLTest_TestSuiteReference audioTestSuite;
extern SDLTest_TestSuiteReference clipboardTestSuite;
//extern SDLTest_TestSuiteReference eventsTestSuite;
//extern SDLTest_TestSuiteReference keyboardTestSuite;
@@ -23,7 +23,7 @@
// All test suites
SDLTest_TestSuiteReference *testSuites[] = {
-// &audioTestSuite,
+ &audioTestSuite,
&clipboardTestSuite,
// &eventsTestSuite,
// &keyboardTestSuite,