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

94 lines
2.1 KiB
C
Raw Normal View History

/**
* Original code: automated SDL platform test written by Edgar Simo "bobbens"
* Extended and updated by aschiffler at ferzkopp dot net
*/
#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"
/*!
* Note: Port tests from "/test/automated/render" here
*
*/
/* Test cases */
static const TestCaseReference test1 =
(TestCaseReference){ "render_testGetNumRenderDrivers", "Tests call to SDL_GetNumRenderDrivers", TEST_ENABLED, 0, 0 };
static const TestCaseReference test2 =
(TestCaseReference){ "render_testCreateRenderer", "Tests SDL_CreateRenderer", TEST_ENABLED, 0, 0 };
/* Test suite */
extern const TestCaseReference *testSuite[] = {
&test1, &test2, NULL
};
TestCaseReference **QueryTestSuite() {
return (TestCaseReference **)testSuite;
}
// Fixture
void
SetUp(void *arg)
{
/* Start SDL. */
int ret = SDL_Init( SDL_INIT_VIDEO );
AssertTrue(ret==0, "SDL_Init(SDL_INIT_VIDEO): %s", SDL_GetError());
}
void
TearDown(void *arg)
{
/* Quit SDL. */
SDL_Quit();
}
/**
* @brief Tests call to SDL_GetNumRenderDrivers
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_GetNumRenderDrivers
*/
int
render_testGetNumRenderDrivers(void *arg)
{
int n;
n = SDL_GetNumRenderDrivers();
AssertTrue(n>=1, "Number of renderers >= 1, reported as %i", n);
if (n<0) {
AssertFail("SDL_GetNumRenderDrivers() failed: %s", SDL_GetError());
}
}
/**
* @brief Tests call to SDL_CreateRenderer
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_CreateRenderer
*/
int
render_testCreateRenderer(void *arg)
{
SDL_Window *window = NULL;
SDL_Renderer *renderer = NULL;
int posX = 100, posY = 100, width = 320, height = 240;
window = SDL_CreateWindow("Hello World", posX, posY, width, height, 0);
if (window != NULL) {
AssertPass("Window created");
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
if (renderer) {
AssertPass("Renderer created");
SDL_DestroyRenderer(renderer);
} else {
AssertFail("Could not create renderer: %s", SDL_GetError());
}
SDL_DestroyWindow(window);
} else {
AssertFail("Could not create window: %s", SDL_GetError());
}
}