test/testautomation_render.c
changeset 6772 5229a117ef97
parent 6769 b49778d885cd
child 6773 5ebc5a9e35b4
     1.1 --- a/test/testautomation_render.c	Sat Dec 22 20:43:51 2012 -0800
     1.2 +++ b/test/testautomation_render.c	Mon Dec 24 14:43:57 2012 -0800
     1.3 @@ -690,7 +690,6 @@
     1.4  }
     1.5  
     1.6  
     1.7 -
     1.8  /**
     1.9   * @brief Checks to see if functionality is supported. Helper function.
    1.10   */
    1.11 @@ -722,6 +721,7 @@
    1.12     ret = SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a );
    1.13     if (!_isSupported(ret))
    1.14        fail = 1;
    1.15 +      
    1.16     /* Restore natural. */
    1.17     ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE );
    1.18     if (!_isSupported(ret))
    1.19 @@ -730,6 +730,7 @@
    1.20     /* Something failed, consider not available. */
    1.21     if (fail)
    1.22        return 0;
    1.23 +      
    1.24     /* Not set properly, consider failed. */
    1.25     else if ((r != 100) || (g != 100) || (b != 100) || (a != 100))
    1.26        return 0;
    1.27 @@ -839,7 +840,7 @@
    1.28  
    1.29     /* Get test face. */
    1.30     tface = _loadTestFace();
    1.31 -   if (tface == 0)
    1.32 +   if (tface == NULL)
    1.33        return 0;
    1.34  
    1.35     /* See if supported. */
    1.36 @@ -879,7 +880,7 @@
    1.37  
    1.38     /* Get test face. */
    1.39     tface = _loadTestFace();
    1.40 -   if (tface == 0)
    1.41 +   if (tface == NULL)
    1.42        return 0;
    1.43  
    1.44     /* See if supported. */
    1.45 @@ -901,7 +902,8 @@
    1.46     return 1;
    1.47  }
    1.48  
    1.49 -static _renderCompareCount = 0;
    1.50 +/* Counter for _compare calls use for filename creation when comparisons fail */
    1.51 +static int _renderCompareCount = 0;
    1.52  
    1.53  /**
    1.54   * @brief Compares screen pixels with image pixels. Helper function.
    1.55 @@ -920,7 +922,7 @@
    1.56  {
    1.57     int ret;
    1.58     SDL_Rect rect;
    1.59 -   Uint8 pix[4*80*60];
    1.60 +   Uint8 pix[4*TESTRENDER_SCREEN_W*TESTRENDER_SCREEN_H];
    1.61     SDL_Surface *testsur;
    1.62     char imageFilename[128];
    1.63     char referenceFilename[128];
    1.64 @@ -929,8 +931,8 @@
    1.65     /* Explicitly specify the rect in case the window isn't expected size... */
    1.66     rect.x = 0;
    1.67     rect.y = 0;
    1.68 -   rect.w = 80;
    1.69 -   rect.h = 60;
    1.70 +   rect.w = TESTRENDER_SCREEN_W;
    1.71 +   rect.h = TESTRENDER_SCREEN_H;
    1.72     ret = SDL_RenderReadPixels(renderer, &rect, RENDER_COMPARE_FORMAT, pix, 80*4 );
    1.73     SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderReadPixels, expected: 0, got: %i", ret);
    1.74  
    1.75 @@ -943,17 +945,18 @@
    1.76     ret = SDLTest_CompareSurfaces( testsur, s, allowable_error );
    1.77     SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
    1.78  
    1.79 +   /* Save source image and reference image for analysis */
    1.80     _renderCompareCount++;
    1.81     if (ret != 0) {
    1.82 -      SDL_snprintf(imageFilename, 127, "image%i.bmp", _renderCompareCount);
    1.83 +      SDL_snprintf(imageFilename, 127, "compare%04d_SourceImage.bmp", _renderCompareCount);
    1.84        SDL_SaveBMP(testsur, imageFilename);
    1.85 -      SDL_snprintf(referenceFilename, 127, "reference%i.bmp", _renderCompareCount);
    1.86 +      SDL_snprintf(referenceFilename, 127, "compare%04d_ReferenceImage.bmp", _renderCompareCount);
    1.87        SDL_SaveBMP(s, referenceFilename);
    1.88 -      SDLTest_LogError("Surfaces from failed comparison saved as %s and %s", imageFilename, referenceFilename);
    1.89 +      SDLTest_LogError("Surfaces from failed comparison saved as '%s' and '%s'", imageFilename, referenceFilename);
    1.90     }
    1.91  
    1.92     /* Clean up. */
    1.93 -   SDL_FreeSurface( testsur );
    1.94 +   SDL_FreeSurface(testsur);
    1.95  }
    1.96  
    1.97  /**