test/testautomation_surface.c
changeset 6811 60d95fcfaf3c
parent 6780 111b37940b35
child 6822 18f6818ba281
     1.1 --- a/test/testautomation_surface.c	Sat Jan 12 14:06:58 2013 -0500
     1.2 +++ b/test/testautomation_surface.c	Sat Jan 12 22:58:12 2013 -0800
     1.3 @@ -4,7 +4,7 @@
     1.4   */
     1.5  
     1.6  /* Supress C4996 VS compiler warnings for unlink() */
     1.7 -#define _CRT_SECURE_NO_DEPRECATE
     1.8 +#define _CRT_SECURE_NO_DEPRECATE
     1.9  #define _CRT_NONSTDC_NO_DEPRECATE
    1.10  
    1.11  #include <stdio.h>
    1.12 @@ -27,26 +27,37 @@
    1.13  
    1.14  /* Fixture */
    1.15  
    1.16 -/* Create a 32-bit writable surface for screen tests */
    1.17 +/* Create a 32-bit writable surface for blitting tests */
    1.18  void
    1.19  _surfaceSetUp(void *arg)
    1.20  {
    1.21 -    Uint32 rmask, gmask, bmask, amask;
    1.22 -#if SDL_BYTEORDER == SDL_BIG_ENDIAN
    1.23 -    rmask = 0xff000000;
    1.24 -    gmask = 0x00ff0000;
    1.25 -    bmask = 0x0000ff00;
    1.26 -    amask = 0x000000ff;
    1.27 -#else
    1.28 -    rmask = 0x000000ff;
    1.29 -    gmask = 0x0000ff00;
    1.30 -    bmask = 0x00ff0000;
    1.31 -    amask = 0xff000000;
    1.32 -#endif
    1.33 -
    1.34 -	referenceSurface = SDLTest_ImageBlit(); /* For size info */
    1.35 -	testSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, referenceSurface->w, referenceSurface->h, 32, rmask, gmask, bmask, amask);
    1.36 +    int result;
    1.37 +    SDL_BlendMode blendMode = SDL_BLENDMODE_NONE;
    1.38 +    SDL_BlendMode currentBlendMode;
    1.39 +    Uint32 rmask, gmask, bmask, amask;
    1.40 +#if SDL_BYTEORDER == SDL_BIG_ENDIAN
    1.41 +    rmask = 0xff000000;
    1.42 +    gmask = 0x00ff0000;
    1.43 +    bmask = 0x0000ff00;
    1.44 +    amask = 0x000000ff;
    1.45 +#else
    1.46 +    rmask = 0x000000ff;
    1.47 +    gmask = 0x0000ff00;
    1.48 +    bmask = 0x00ff0000;
    1.49 +    amask = 0xff000000;
    1.50 +#endif
    1.51 +
    1.52 +    referenceSurface = SDLTest_ImageBlit(); /* For size info */
    1.53 +    testSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, referenceSurface->w, referenceSurface->h, 32, rmask, gmask, bmask, amask);
    1.54      SDLTest_AssertCheck(testSurface != NULL, "Check that testSurface is not NULL");
    1.55 +    if (testSurface != NULL) {
    1.56 +      /* Disable blend mode for target surface */
    1.57 +      result = SDL_SetSurfaceBlendMode(testSurface, blendMode);
    1.58 +      SDLTest_AssertCheck(result == 0, "Validate result from SDL_SetSurfaceBlendMode, expected: 0, got: %i", result);
    1.59 +      result = SDL_GetSurfaceBlendMode(testSurface, &currentBlendMode);
    1.60 +      SDLTest_AssertCheck(result == 0, "Validate result from SDL_GetSurfaceBlendMode, expected: 0, got: %i", result);
    1.61 +      SDLTest_AssertCheck(currentBlendMode == blendMode, "Validate blendMode, expected: %i, got: %i", blendMode, currentBlendMode);      
    1.62 +    }
    1.63  }
    1.64  
    1.65  void
    1.66 @@ -69,10 +80,10 @@
    1.67  {
    1.68  	int ret;
    1.69  	Uint32 color;
    1.70 -	
    1.71 +
    1.72  	/* Clear surface. */
    1.73 -	color = SDL_MapRGB( testSurface->format, 0, 0, 0);
    1.74 -	SDLTest_AssertPass("Call to SDL_MapRGB()");
    1.75 +	color = SDL_MapRGBA( testSurface->format, 0, 0, 0, 0);
    1.76 +	SDLTest_AssertPass("Call to SDL_MapRGBA()");
    1.77  	ret = SDL_FillRect( testSurface, NULL, color);
    1.78  	SDLTest_AssertPass("Call to SDL_FillRect()");
    1.79  	SDLTest_AssertCheck(ret == 0, "Verify result from SDL_FillRect, expected: 0, got: %i", ret);
    1.80 @@ -103,6 +114,21 @@
    1.81  	SDLTest_AssertCheck(face != NULL, "Verify face surface is not NULL");
    1.82  	if (face == NULL) return;
    1.83  
    1.84 +        /* Reset alpha modulation */	
    1.85 +	ret = SDL_SetSurfaceAlphaMod(face, 255);
    1.86 +	SDLTest_AssertPass("Call to SDL_SetSurfaceAlphaMod()");
    1.87 +	SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceAlphaMod(), expected: 0, got: %i", ret);
    1.88 +
    1.89 +        /* Reset color modulation */	
    1.90 +	ret = SDL_SetSurfaceColorMod(face, 255, 255, 255);
    1.91 +	SDLTest_AssertPass("Call to SDL_SetSurfaceColorMod()");
    1.92 +	SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceColorMod(), expected: 0, got: %i", ret);
    1.93 +
    1.94 +        /* Reset color key */	
    1.95 +	ret = SDL_SetColorKey(face, SDL_FALSE, 0);
    1.96 +	SDLTest_AssertPass("Call to SDL_SetColorKey()");
    1.97 +	SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey(), expected: 0, got: %i", ret);
    1.98 +
    1.99  	/* Clear the test surface */
   1.100          _clearTestSurface();
   1.101          
   1.102 @@ -141,11 +167,16 @@
   1.103  		else if (mode == -4) {
   1.104  			/* Crazy blending mode magic. */
   1.105  			nmode = (i/4*j/4) % 4;
   1.106 -			if (nmode==0) bmode = SDL_BLENDMODE_NONE;
   1.107 -			else if (nmode==1) bmode = SDL_BLENDMODE_BLEND;
   1.108 -			else if (nmode==2) bmode = SDL_BLENDMODE_ADD;
   1.109 -			else if (nmode==3) bmode = SDL_BLENDMODE_MOD;
   1.110 -			ret = SDL_SetSurfaceBlendMode( face, bmode );		
   1.111 +			if (nmode==0) {
   1.112 +				bmode = SDL_BLENDMODE_NONE;
   1.113 +			} else if (nmode==1) {
   1.114 +				bmode = SDL_BLENDMODE_BLEND;
   1.115 +			} else if (nmode==2) {
   1.116 +				bmode = SDL_BLENDMODE_ADD;				
   1.117 +			} else if (nmode==3) {
   1.118 +				bmode = SDL_BLENDMODE_MOD;
   1.119 +			}
   1.120 +			ret = SDL_SetSurfaceBlendMode( face, bmode );
   1.121  			if (ret != 0) checkFailCount4++;
   1.122  		}
   1.123  
   1.124 @@ -473,7 +504,7 @@
   1.125     int ret;
   1.126     SDL_Surface *referenceSurface;
   1.127  
   1.128 -   /* All blitting */ 
   1.129 +   /* All blitting modes */ 
   1.130     _testBlitBlendMode(-4);
   1.131     
   1.132     /* Verify result by comparing surfaces */