test/testautomation_render.c
changeset 6822 18f6818ba281
parent 6773 5ebc5a9e35b4
child 7155 7f35cb1d1f51
     1.1 --- a/test/testautomation_render.c	Wed Jan 23 08:03:19 2013 -0800
     1.2 +++ b/test/testautomation_render.c	Thu Jan 24 07:58:59 2013 -0800
     1.3 @@ -969,30 +969,37 @@
     1.4  static void
     1.5  _compare(SDL_Surface *referenceSurface, int allowable_error)
     1.6  {
     1.7 -   int ret;
     1.8 +   int result;
     1.9     SDL_Rect rect;
    1.10 -   Uint8 pix[4*TESTRENDER_SCREEN_W*TESTRENDER_SCREEN_H];
    1.11 +   Uint8 *pixels;
    1.12     SDL_Surface *testSurface;
    1.13  
    1.14     /* Read pixels. */
    1.15 +   pixels = (Uint8 *)SDL_malloc(4*TESTRENDER_SCREEN_W*TESTRENDER_SCREEN_H);
    1.16 +   SDLTest_AssertCheck(pixels != NULL, "Validate allocated temp pixel buffer");
    1.17 +   if (pixels == NULL) return;
    1.18 +
    1.19     /* Explicitly specify the rect in case the window isn't the expected size... */
    1.20     rect.x = 0;
    1.21     rect.y = 0;
    1.22     rect.w = TESTRENDER_SCREEN_W;
    1.23     rect.h = TESTRENDER_SCREEN_H;
    1.24 -   ret = SDL_RenderReadPixels(renderer, &rect, RENDER_COMPARE_FORMAT, pix, 80*4 );
    1.25 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderReadPixels, expected: 0, got: %i", ret);
    1.26 +   result = SDL_RenderReadPixels(renderer, &rect, RENDER_COMPARE_FORMAT, pixels, 80*4 );
    1.27 +   SDLTest_AssertCheck(result == 0, "Validate result from SDL_RenderReadPixels, expected: 0, got: %i", result);
    1.28  
    1.29     /* Create surface. */
    1.30 -   testSurface = SDL_CreateRGBSurfaceFrom( pix, TESTRENDER_SCREEN_W, TESTRENDER_SCREEN_H, 32, TESTRENDER_SCREEN_W*4,
    1.31 +   testSurface = SDL_CreateRGBSurfaceFrom(pixels, TESTRENDER_SCREEN_W, TESTRENDER_SCREEN_H, 32, TESTRENDER_SCREEN_W*4,
    1.32                                         RENDER_COMPARE_RMASK, RENDER_COMPARE_GMASK, RENDER_COMPARE_BMASK, RENDER_COMPARE_AMASK);
    1.33 -   SDLTest_AssertCheck(testSurface != NULL, "Verify result from SDL_CreateRGBSurfaceFrom");
    1.34 +   SDLTest_AssertCheck(testSurface != NULL, "Verify result from SDL_CreateRGBSurfaceFrom is not NULL");
    1.35  
    1.36     /* Compare surface. */
    1.37 -   ret = SDLTest_CompareSurfaces( testSurface, referenceSurface, allowable_error );
    1.38 -   SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
    1.39 +   result = SDLTest_CompareSurfaces( testSurface, referenceSurface, allowable_error );
    1.40 +   SDLTest_AssertCheck(result == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", result);
    1.41  
    1.42     /* Clean up. */
    1.43 +   if (pixels != NULL) {
    1.44 +	   SDL_free(pixels);
    1.45 +   }
    1.46     if (testSurface != NULL) {
    1.47         SDL_FreeSurface(testSurface);
    1.48     }