mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-24 13:39:11 +00:00
tests: port failing SDL_Renderer test from pysdl2 to testautomation
This commit is contained in:
parent
a8f0eb4c33
commit
8436ce98b4
1 changed files with 95 additions and 1 deletions
|
@ -811,6 +811,96 @@ int render_testBlitBlend(void *arg)
|
||||||
return TEST_COMPLETED;
|
return TEST_COMPLETED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Uint32 read_surface_pixel32(SDL_Surface *surface, int x, int y) {
|
||||||
|
Uint32 result;
|
||||||
|
|
||||||
|
if (x >= surface->w || y >= surface->h) {
|
||||||
|
SDLTest_AssertCheck(x < surface->w, "x (%d) < surface->w (%d)", x, surface->w);
|
||||||
|
SDLTest_AssertCheck(y < surface->h, "y (%d) < surface->h (%d)", y, surface->h);
|
||||||
|
result = 0xdeadbabe;
|
||||||
|
} else {
|
||||||
|
SDL_memcpy(&result, (Uint8 *)surface->pixels + surface->pitch * y + surface->format->BytesPerPixel * x, sizeof(Uint32));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int render_testRGBSurfaceNoAlpha(void* arg)
|
||||||
|
{
|
||||||
|
SDL_Surface *surface;
|
||||||
|
SDL_Renderer *software_renderer;
|
||||||
|
SDL_Surface *surface2;
|
||||||
|
SDL_Texture *texture2;
|
||||||
|
int result;
|
||||||
|
SDL_Rect dest_rect;
|
||||||
|
SDL_Point point;
|
||||||
|
Uint32 pixel;
|
||||||
|
|
||||||
|
SDLTest_AssertPass("About to call SDL_CreateRGBSurface(0, 128, 128, 32, 0xff0000, 0xff00, 0xff, 0)");
|
||||||
|
surface = SDL_CreateRGBSurface(0, 128, 128, 32, 0xff0000, 0xff00, 0xff, 0);
|
||||||
|
SDLTest_AssertCheck(surface != NULL, "Returned surface must be not NULL");
|
||||||
|
|
||||||
|
SDLTest_AssertCheck(surface->format->BitsPerPixel == 32, "surface->format->BitsPerPixel should be 32, actual value is %d", surface->format->BitsPerPixel);
|
||||||
|
SDLTest_AssertCheck(surface->format->BytesPerPixel == 4, "surface->format->BytesPerPixels should be 4, actual value is %d", surface->format->BytesPerPixel);
|
||||||
|
|
||||||
|
SDLTest_AssertPass("About to call SDL_CreateSoftwareRenderer(surface)");
|
||||||
|
software_renderer = SDL_CreateSoftwareRenderer(surface);
|
||||||
|
SDLTest_AssertCheck(software_renderer != NULL, "Returned renderer must be not NULL");
|
||||||
|
|
||||||
|
SDLTest_AssertPass("About to call SDL_CreateRGBSurface(0, 16, 16, 32, 0xff0000, 0xff00, 0xff, 0)");
|
||||||
|
surface2 = SDL_CreateRGBSurface(0, 16, 16, 32, 0xff0000, 0xff00, 0xff, 0);
|
||||||
|
SDLTest_AssertCheck(surface2 != NULL, "Returned surface must be not NULL");
|
||||||
|
|
||||||
|
SDLTest_AssertPass("About to call SDL_FillRect(surface2, NULL, 0)");
|
||||||
|
result = SDL_FillRect(surface2, NULL, SDL_MapRGB(surface2->format, 0, 0, 0));
|
||||||
|
SDLTest_AssertCheck(result == 0, "Result should be 0, actual value is %d", result);
|
||||||
|
|
||||||
|
SDLTest_AssertPass("About to call SDL_CreateTextureFromSurface(software_renderer, surface2)");
|
||||||
|
texture2 = SDL_CreateTextureFromSurface(software_renderer, surface2);
|
||||||
|
SDLTest_AssertCheck(texture2 != NULL, "Returned texture is not NULL");
|
||||||
|
|
||||||
|
SDLTest_AssertPass("About to call SDL_SetRenderDrawColor(renderer, 0xaa, 0xbb, 0xcc, 0x0)");
|
||||||
|
result = SDL_SetRenderDrawColor(software_renderer, 0xaa, 0xbb, 0xcc, 0x0);
|
||||||
|
|
||||||
|
SDLTest_AssertPass("About to call SDL_RenderClear(renderer)");
|
||||||
|
result = SDL_RenderClear(software_renderer);
|
||||||
|
SDLTest_AssertCheck(result == 0, "Result should be 0, actual value is %d", result);
|
||||||
|
|
||||||
|
SDLTest_AssertPass("About to call SDL_SetRenderDrawColor(renderer, 0x0, 0x0, 0x0, 0x0)");
|
||||||
|
result = SDL_SetRenderDrawColor(software_renderer, 0x0, 0x0, 0x0, 0x0);
|
||||||
|
SDLTest_AssertCheck(result == 0, "Result should be 0, actual value is %d", result);
|
||||||
|
|
||||||
|
dest_rect.x = 32;
|
||||||
|
dest_rect.y = 32;
|
||||||
|
dest_rect.w = surface2->w;
|
||||||
|
dest_rect.h = surface2->h;
|
||||||
|
point.x = 0;
|
||||||
|
point.y = 0;
|
||||||
|
SDLTest_AssertPass("About to call SDL_RenderCopy(software_renderer, texture, NULL, &{%d, %d, %d, %d})",
|
||||||
|
dest_rect.x, dest_rect.h, dest_rect.w, dest_rect.h);
|
||||||
|
result = SDL_RenderCopyEx(software_renderer, texture2, NULL, &dest_rect, 180, &point, SDL_FLIP_NONE);
|
||||||
|
SDLTest_AssertCheck(result == 0, "Result should be 0, actual value is %d", result);
|
||||||
|
|
||||||
|
SDLTest_AssertPass("About to call SDL_RenderPresent(software_renderer)");
|
||||||
|
SDL_RenderPresent(software_renderer);
|
||||||
|
|
||||||
|
pixel = read_surface_pixel32(surface, 0, 0);
|
||||||
|
SDLTest_AssertCheck(pixel == 0xAABBCCu, "Pixel at (0, 0) should be 0x%08x, actual value is 0x%08" SDL_PRIx32, 0xAABBCCu, pixel);
|
||||||
|
pixel = read_surface_pixel32(surface, 15, 15);
|
||||||
|
SDLTest_AssertCheck(pixel == 0xAABBCCu, "Pixel at (15, 15) should be 0x%08x, actual value is 0x%08" SDL_PRIx32, 0xAABBCCu, pixel);
|
||||||
|
pixel = read_surface_pixel32(surface, 16, 16);
|
||||||
|
SDLTest_AssertCheck(pixel == 0xFF000000u, "Pixel at (16, 16) should be 0x%08x, actual value is 0x%08" SDL_PRIx32, 0xFF000000u, pixel);
|
||||||
|
pixel = read_surface_pixel32(surface, 31, 31);
|
||||||
|
SDLTest_AssertCheck(pixel == 0xFF000000u, "Pixel at (31, 31) should be 0x%08x, actual value is 0x%08" SDL_PRIx32, 0xFF000000u, pixel);
|
||||||
|
pixel = read_surface_pixel32(surface, 32, 32);
|
||||||
|
SDLTest_AssertCheck(pixel == 0xAABBCCu, "Pixel at (32, 32) should be 0x%08x, actual value is 0x%08" SDL_PRIx32, 0xAABBCCu, pixel);
|
||||||
|
|
||||||
|
SDL_DestroyTexture(texture2);
|
||||||
|
SDL_FreeSurface(surface2);
|
||||||
|
SDL_DestroyRenderer(software_renderer);
|
||||||
|
SDL_FreeSurface(surface);
|
||||||
|
return TEST_COMPLETED;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Tests setting and getting texture scale mode.
|
* @brief Tests setting and getting texture scale mode.
|
||||||
*
|
*
|
||||||
|
@ -1205,9 +1295,13 @@ static const SDLTest_TestCaseReference renderTest8 = {
|
||||||
(SDLTest_TestCaseFp)render_testGetSetTextureScaleMode, "render_testGetSetTextureScaleMode", "Tests setting/getting texture scale mode", TEST_ENABLED
|
(SDLTest_TestCaseFp)render_testGetSetTextureScaleMode, "render_testGetSetTextureScaleMode", "Tests setting/getting texture scale mode", TEST_ENABLED
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const SDLTest_TestCaseReference renderTest9 = {
|
||||||
|
(SDLTest_TestCaseFp)render_testRGBSurfaceNoAlpha, "render_testRGBSurfaceNoAlpha", "Tests RGB surface with no alpha using software renderer", TEST_ENABLED
|
||||||
|
};
|
||||||
|
|
||||||
/* Sequence of Render test cases */
|
/* Sequence of Render test cases */
|
||||||
static const SDLTest_TestCaseReference *renderTests[] = {
|
static const SDLTest_TestCaseReference *renderTests[] = {
|
||||||
&renderTest1, &renderTest2, &renderTest3, &renderTest4, &renderTest5, &renderTest6, &renderTest7, &renderTest8, NULL
|
&renderTest1, &renderTest2, &renderTest3, &renderTest4, &renderTest5, &renderTest6, &renderTest7, &renderTest8, &renderTest9, NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Render test suite (global) */
|
/* Render test suite (global) */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue