Ported surface tests.
authorMarkus Kauppila
Sat, 09 Jul 2011 17:55:35 +0300
changeset 5750337982ee35ac
parent 5749 0c63fb52e749
child 5751 cbb921210496
Ported surface tests.
test/test-automation/Makefile.am
test/test-automation/SDL_test.c
test/test-automation/build-scripts/install-tests.sh
test/test-automation/common/common.c
test/test-automation/common/common.h
test/test-automation/common/img_blit.c
test/test-automation/common/img_blitblend.c
test/test-automation/common/img_face.c
test/test-automation/common/img_primitives.c
test/test-automation/common/img_primitivesblend.c
test/test-automation/configure.ac
test/test-automation/icon.bmp
test/test-automation/plain_logger.c
test/test-automation/testsurface/Makefile.am
test/test-automation/testsurface/testsurface.c
     1.1 --- a/test/test-automation/Makefile.am	Fri Jul 08 19:58:16 2011 +0300
     1.2 +++ b/test/test-automation/Makefile.am	Sat Jul 09 17:55:35 2011 +0300
     1.3 @@ -1,6 +1,6 @@
     1.4  ACLOCAL_AMFLAGS = -I acinclude -I build-scripts
     1.5  
     1.6 -SUBDIRS = testdummy testrect testplatform testaudio
     1.7 +SUBDIRS = testdummy testrect testplatform testaudio testsurface
     1.8  
     1.9  bin_PROGRAMS = runner
    1.10  runner_SOURCES = runner.c SDL_test.c logger.c xml_logger.c plain_logger.c xml.c logger_helpers.c
     2.1 --- a/test/test-automation/SDL_test.c	Fri Jul 08 19:58:16 2011 +0300
     2.2 +++ b/test/test-automation/SDL_test.c	Sat Jul 09 17:55:35 2011 +0300
     2.3 @@ -74,7 +74,7 @@
     2.4        _testReturnValue = 1;
     2.5        _testAssertsFailed++;
     2.6     } else {
     2.7 -	   AssertWithValues("AssertEquals", 1, "AssertEquals passed",
     2.8 +	   AssertWithValues("AssertEquals", 1, buf,
     2.9      		  actual, expected, time(0));
    2.10  
    2.11        _testAssertsPassed++;
    2.12 @@ -92,15 +92,17 @@
    2.13        SDL_vsnprintf( buf, sizeof(buf), message, args );
    2.14        va_end( args );
    2.15  
    2.16 -      //printf("AssertTrue failed: %s\n", buf);
    2.17        Assert("AssertTrue", 0, buf, time(0));
    2.18  
    2.19        _testReturnValue = 1;
    2.20        _testAssertsFailed++;
    2.21     } else {
    2.22 -     //printf("AssertTrue passed\n");
    2.23 -	 Assert("AssertTrue", 1, "AssertTrue passed", time(0));
    2.24 -     _testAssertsPassed++;
    2.25 +		va_start( args, message );
    2.26 +		SDL_vsnprintf( buf, sizeof(buf), message, args );
    2.27 +		va_end( args );
    2.28 +
    2.29 +		Assert("AssertTrue", 1, buf, time(0));
    2.30 +		_testAssertsPassed++;
    2.31     }
    2.32  }
    2.33  
     3.1 --- a/test/test-automation/build-scripts/install-tests.sh	Fri Jul 08 19:58:16 2011 +0300
     3.2 +++ b/test/test-automation/build-scripts/install-tests.sh	Sat Jul 09 17:55:35 2011 +0300
     3.3 @@ -16,7 +16,7 @@
     3.4  fi
     3.5  
     3.6  # TODO: put the test in an array
     3.7 -for suite in "testdummy" "testplatform" "testrect" "testaudio"
     3.8 +for suite in "testdummy" "testplatform" "testrect" "testaudio" "testsurface"
     3.9  do
    3.10  	cp -f "$suite/.libs/lib$suite.$EXT" $DIRECTORY
    3.11  done
     4.1 --- a/test/test-automation/common/common.c	Fri Jul 08 19:58:16 2011 +0300
     4.2 +++ b/test/test-automation/common/common.c	Sat Jul 09 17:55:35 2011 +0300
     4.3 @@ -7,12 +7,9 @@
     4.4   */
     4.5  
     4.6  
     4.7 -#include "SDL.h"
     4.8 -#include "../SDL_at.h"
     4.9  
    4.10  #include "common.h"
    4.11  
    4.12 -
    4.13  /**
    4.14   * @brief Compares a surface and a surface image for equality.
    4.15   */
     5.1 --- a/test/test-automation/common/common.h	Fri Jul 08 19:58:16 2011 +0300
     5.2 +++ b/test/test-automation/common/common.h	Sat Jul 09 17:55:35 2011 +0300
     5.3 @@ -10,6 +10,7 @@
     5.4  #ifndef COMMON_H
     5.5  #  define COMMON_H
     5.6  
     5.7 +#include "SDL/SDL.h"
     5.8  
     5.9  #  define FORMAT  SDL_PIXELFORMAT_ARGB8888
    5.10  #  define AMASK   0xff000000 /**< Alpha bit mask. */
     6.1 --- a/test/test-automation/common/img_blit.c	Fri Jul 08 19:58:16 2011 +0300
     6.2 +++ b/test/test-automation/common/img_blit.c	Sat Jul 09 17:55:35 2011 +0300
     6.3 @@ -1,5 +1,7 @@
     6.4  /* GIMP RGB C-Source image dump (blit.c) */
     6.5  
     6.6 +#include "common.h"
     6.7 +
     6.8  static const SurfaceImage_t img_blit = {
     6.9    80, 60, 3,
    6.10    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
     7.1 --- a/test/test-automation/common/img_blitblend.c	Fri Jul 08 19:58:16 2011 +0300
     7.2 +++ b/test/test-automation/common/img_blitblend.c	Sat Jul 09 17:55:35 2011 +0300
     7.3 @@ -1,4 +1,5 @@
     7.4  /* GIMP RGB C-Source image dump (alpha.c) */
     7.5 +#include "common.h"
     7.6  
     7.7  static const SurfaceImage_t img_blendAdd = {
     7.8    80, 60, 3,
     8.1 --- a/test/test-automation/common/img_face.c	Fri Jul 08 19:58:16 2011 +0300
     8.2 +++ b/test/test-automation/common/img_face.c	Sat Jul 09 17:55:35 2011 +0300
     8.3 @@ -1,4 +1,5 @@
     8.4  /* GIMP RGBA C-Source image dump (face.c) */
     8.5 +#include "common.h"
     8.6  
     8.7  static const SurfaceImage_t img_face = {
     8.8    32, 32, 4,
     9.1 --- a/test/test-automation/common/img_primitives.c	Fri Jul 08 19:58:16 2011 +0300
     9.2 +++ b/test/test-automation/common/img_primitives.c	Sat Jul 09 17:55:35 2011 +0300
     9.3 @@ -1,4 +1,5 @@
     9.4  /* GIMP RGB C-Source image dump (primitives.c) */
     9.5 +#include "common.h"
     9.6  
     9.7  static const SurfaceImage_t img_primitives = {
     9.8    80, 60, 3,
    10.1 --- a/test/test-automation/common/img_primitivesblend.c	Fri Jul 08 19:58:16 2011 +0300
    10.2 +++ b/test/test-automation/common/img_primitivesblend.c	Sat Jul 09 17:55:35 2011 +0300
    10.3 @@ -1,4 +1,5 @@
    10.4  /* GIMP RGB C-Source image dump (alpha.c) */
    10.5 +#include "common.h"
    10.6  
    10.7  static const SurfaceImage_t img_blend = {
    10.8    80, 60, 3,
    11.1 --- a/test/test-automation/configure.ac	Fri Jul 08 19:58:16 2011 +0300
    11.2 +++ b/test/test-automation/configure.ac	Sat Jul 09 17:55:35 2011 +0300
    11.3 @@ -36,7 +36,8 @@
    11.4  				 testdummy/Makefile 
    11.5  				 testrect/Makefile
    11.6  				 testplatform/Makefile
    11.7 -				 testaudio/Makefile])
    11.8 +				 testaudio/Makefile
    11.9 +				 testsurface/Makefile])
   11.10  AC_OUTPUT
   11.11  
   11.12  echo ""
    12.1 Binary file test/test-automation/icon.bmp has changed
    13.1 --- a/test/test-automation/plain_logger.c	Fri Jul 08 19:58:16 2011 +0300
    13.2 +++ b/test/test-automation/plain_logger.c	Sat Jul 09 17:55:35 2011 +0300
    13.3 @@ -104,7 +104,7 @@
    13.4  		time_t eventTime)
    13.5  {
    13.6  	const char *result = (assertResult) ? "passed" : "failed";
    13.7 -	Output(indentLevel, "%s: %s", assertName, assertMessage);
    13.8 +	Output(indentLevel, "%s: %s; %s", assertName, result, assertMessage);
    13.9  }
   13.10  
   13.11  void
   13.12 @@ -112,8 +112,8 @@
   13.13  		int actualValue, int expected, time_t eventTime)
   13.14  {
   13.15  	const char *result = (assertResult) ? "passed" : "failed";
   13.16 -	Output(indentLevel, "%s %d (expected %d, actualValue &d): %s",
   13.17 -			assertName, assertResult, expected, actualValue, assertMessage);
   13.18 +	Output(indentLevel, "%s %s (expected %d, actualValue &d): %s",
   13.19 +			assertName, result, expected, actualValue, assertMessage);
   13.20  }
   13.21  
   13.22  void
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/test/test-automation/testsurface/Makefile.am	Sat Jul 09 17:55:35 2011 +0300
    14.3 @@ -0,0 +1,5 @@
    14.4 +lib_LTLIBRARIES = libtestsurface.la
    14.5 +libtestsurface_la_SOURCES = testsurface.c ../SDL_test.c ../logger.c ../logger_helpers.c ../plain_logger.c ../xml_logger.c ../xml.c \ 
    14.6 +	../common/common.c ../common/img_blit.c ../common/img_blitblend.c ../common/img_face.c ../common/img_primitives.c ../common/img_primitivesblend.c
    14.7 +libtestsurface_la_CLAGS = -fPIC -g
    14.8 +libtestsurface_la_LDFLAGS = `sdl-config --libs`
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/test/test-automation/testsurface/testsurface.c	Sat Jul 09 17:55:35 2011 +0300
    15.3 @@ -0,0 +1,398 @@
    15.4 +/**
    15.5 + * Original code: automated SDL surface test written by Edgar Simo "bobbens"
    15.6 + */
    15.7 +
    15.8 +#ifndef _TEST_C
    15.9 +#define _TEST_C
   15.10 +#include <stdio.h>
   15.11 +
   15.12 +#include <SDL/SDL.h>
   15.13 +
   15.14 +#include "../SDL_test.h"
   15.15 +
   15.16 +#include "../common/common.h"
   15.17 +#include "../common/images.h"
   15.18 +
   15.19 +
   15.20 +/* Test case references */
   15.21 +static const TestCaseReference test1 =
   15.22 +		(TestCaseReference){ "surface_testLoad", "Tests sprite loading.", TEST_ENABLED, 0, 0};
   15.23 +
   15.24 +static const TestCaseReference test2 =
   15.25 +		(TestCaseReference){ "surface_testBlit", "Tests some blitting routines.", TEST_ENABLED, 0, 0};
   15.26 +
   15.27 +static const TestCaseReference test3 =
   15.28 +		(TestCaseReference){ "surface_testBlitBlend", "Tests some more blitting routines.", TEST_ENABLED, 0, 0};
   15.29 +
   15.30 +
   15.31 +/* Test suite */
   15.32 +extern const TestCaseReference *testSuite[] =  {
   15.33 +	&test1, &test2, &test3, NULL
   15.34 +};
   15.35 +
   15.36 +
   15.37 +TestCaseReference **QueryTestSuite() {
   15.38 +	return (TestCaseReference **)testSuite;
   15.39 +}
   15.40 +
   15.41 +/* Test helpers */
   15.42 +
   15.43 +/*!
   15.44 + * Creates test surface
   15.45 + */
   15.46 +SDL_Surface *
   15.47 +CreateTestSurface() {
   15.48 +	SDL_Surface *testsur;
   15.49 +
   15.50 +	/* Create the test surface. */
   15.51 +	testsur = SDL_CreateRGBSurface( 0, 80, 60, 32,
   15.52 +		 RMASK, GMASK, BMASK, AMASK );
   15.53 +
   15.54 +	AssertTrue(testsur != NULL, "SDL_CreateRGBSurface");
   15.55 +
   15.56 +	return testsur;
   15.57 +}
   15.58 +
   15.59 +int testBlitBlendMode(SDL_Surface *testsur, SDL_Surface *face, int mode)
   15.60 +{
   15.61 +	int ret;
   15.62 +	int i, j, ni, nj;
   15.63 +	SDL_Rect rect;
   15.64 +
   15.65 +	/* Clear surface. */
   15.66 +	ret = SDL_FillRect( testsur, NULL,
   15.67 +		 SDL_MapRGB( testsur->format, 0, 0, 0 ) );
   15.68 +	if(ret == 0)
   15.69 +	  return 1;
   15.70 +
   15.71 +	/* Steps to take. */
   15.72 +	ni     = testsur->w - face->w;
   15.73 +	nj     = testsur->h - face->h;
   15.74 +
   15.75 +	/* Constant values. */
   15.76 +	rect.w = face->w;
   15.77 +	rect.h = face->h;
   15.78 +
   15.79 +	/* Test blend mode. */
   15.80 +	for (j=0; j <= nj; j+=4) {
   15.81 +	  for (i=0; i <= ni; i+=4) {
   15.82 +		 /* Set blend mode. */
   15.83 +		 ret = SDL_SetSurfaceBlendMode( face, mode );
   15.84 +		 if (ret == 0)
   15.85 +			return 1;
   15.86 +
   15.87 +		 /* Blitting. */
   15.88 +		 rect.x = i;
   15.89 +		 rect.y = j;
   15.90 +		 ret = SDL_BlitSurface( face, NULL, testsur, &rect );
   15.91 +		 if(ret == 0)
   15.92 +			return 1;
   15.93 +	  }
   15.94 +	}
   15.95 +
   15.96 +	   return 0;
   15.97 +}
   15.98 +
   15.99 +/* Test case functions */
  15.100 +/**
  15.101 + * @brief Tests sprite loading.
  15.102 + */
  15.103 +void surface_testLoad(void *arg)
  15.104 +{
  15.105 +	int ret;
  15.106 +    SDL_Surface *face, *rface;
  15.107 +
  15.108 +	ret = SDL_Init(SDL_INIT_VIDEO);
  15.109 +	AssertTrue(ret == 0, "SDL_Init(SDL_INIT_VIDEO)");
  15.110 +
  15.111 +	SDL_Surface *testsur = CreateTestSurface();
  15.112 +
  15.113 +   /* Clear surface. */
  15.114 +   ret = SDL_FillRect( testsur, NULL,
  15.115 +         SDL_MapRGB( testsur->format, 0, 0, 0 ) );
  15.116 +	AssertTrue(ret == 0,  "SDL_FillRect");
  15.117 +
  15.118 +   /* Create the blit surface. */
  15.119 +#ifdef __APPLE__
  15.120 +	face = SDL_LoadBMP("icon.bmp");
  15.121 +#else
  15.122 +	face = SDL_LoadBMP("../icon.bmp");
  15.123 +#endif
  15.124 +
  15.125 +	AssertTrue(face != NULL, "SDL_CreateLoadBmp");
  15.126 +
  15.127 +   /* Set transparent pixel as the pixel at (0,0) */
  15.128 +   if (face->format->palette) {
  15.129 +      ret = SDL_SetColorKey(face, SDL_RLEACCEL, *(Uint8 *) face->pixels);
  15.130 +      AssertTrue(ret == 0, "SDL_SetColorKey");
  15.131 +   }
  15.132 +
  15.133 +   /* Convert to 32 bit to compare. */
  15.134 +   rface = SDL_ConvertSurface( face, testsur->format, 0 );
  15.135 +   AssertTrue(rface != NULL, "SDL_ConvertSurface");
  15.136 +
  15.137 +   /* See if it's the same. */
  15.138 +   AssertTrue(surface_compare( rface, &img_face, 0 ) == 0,
  15.139 +		   "Primitives output not the same.");
  15.140 +
  15.141 +   /* Clean up. */
  15.142 +   SDL_FreeSurface( rface );
  15.143 +   SDL_FreeSurface( face );
  15.144 +
  15.145 +   SDL_FreeSurface( testsur );
  15.146 +
  15.147 +   SDL_Quit();
  15.148 +}
  15.149 +
  15.150 +
  15.151 +/**
  15.152 + * @brief Tests some blitting routines.
  15.153 + */
  15.154 +void surface_testBlit(void *arg)
  15.155 +{
  15.156 +   int ret;
  15.157 +   SDL_Rect rect;
  15.158 +   SDL_Surface *face;
  15.159 +   int i, j, ni, nj;
  15.160 +
  15.161 +	ret = SDL_Init(SDL_INIT_VIDEO);
  15.162 +	AssertTrue(ret == 0, "SDL_Init(SDL_INIT_VIDEO)");
  15.163 +
  15.164 +   SDL_Surface *testsur = CreateTestSurface();
  15.165 +
  15.166 +   /* Clear surface. */
  15.167 +   ret = SDL_FillRect( testsur, NULL,
  15.168 +         SDL_MapRGB( testsur->format, 0, 0, 0 ) );
  15.169 +
  15.170 +   AssertTrue(ret == 0, "SDL_FillRect");
  15.171 +
  15.172 +   /* Create face surface. */
  15.173 +   face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
  15.174 +         img_face.width, img_face.height, 32, img_face.width*4,
  15.175 +#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
  15.176 +         0xff000000, /* Red bit mask. */
  15.177 +         0x00ff0000, /* Green bit mask. */
  15.178 +         0x0000ff00, /* Blue bit mask. */
  15.179 +         0x000000ff /* Alpha bit mask. */
  15.180 +#else
  15.181 +         0x000000ff, /* Red bit mask. */
  15.182 +         0x0000ff00, /* Green bit mask. */
  15.183 +         0x00ff0000, /* Blue bit mask. */
  15.184 +         0xff000000 /* Alpha bit mask. */
  15.185 +#endif
  15.186 +         );
  15.187 +   AssertTrue(face != NULL, "SDL_CreateRGBSurfaceFrom");
  15.188 +
  15.189 +   /* Constant values. */
  15.190 +   rect.w = face->w;
  15.191 +   rect.h = face->h;
  15.192 +   ni     = testsur->w - face->w;
  15.193 +   nj     = testsur->h - face->h;
  15.194 +
  15.195 +   /* Loop blit. */
  15.196 +   for (j=0; j <= nj; j+=4) {
  15.197 +      for (i=0; i <= ni; i+=4) {
  15.198 +         /* Blitting. */
  15.199 +         rect.x = i;
  15.200 +         rect.y = j;
  15.201 +         ret = SDL_BlitSurface( face, NULL, testsur, &rect );
  15.202 +
  15.203 +         AssertTrue(ret == 0, "SDL_BlitSurface");
  15.204 +      }
  15.205 +   }
  15.206 +
  15.207 +   /* See if it's the same. */
  15.208 +   AssertTrue(surface_compare( testsur, &img_blit, 0 ) == 0,
  15.209 +		   "Blitting output not the same (normal blit).");
  15.210 +
  15.211 +   /* Clear surface. */
  15.212 +   ret = SDL_FillRect( testsur, NULL,
  15.213 +         SDL_MapRGB( testsur->format, 0, 0, 0 ) );
  15.214 +   AssertTrue(ret == 0, "SDL_FillRect");
  15.215 +
  15.216 +   /* Test blitting with colour mod. */
  15.217 +   for (j=0; j <= nj; j+=4) {
  15.218 +      for (i=0; i <= ni; i+=4) {
  15.219 +         /* Set colour mod. */
  15.220 +         ret = SDL_SetSurfaceColorMod( face, (255/nj)*j, (255/ni)*i, (255/nj)*j );
  15.221 +         AssertTrue(ret == 0, "SDL_SetSurfaceColorMod");
  15.222 +
  15.223 +         /* Blitting. */
  15.224 +         rect.x = i;
  15.225 +         rect.y = j;
  15.226 +         ret = SDL_BlitSurface( face, NULL, testsur, &rect );
  15.227 +
  15.228 +         AssertTrue(ret == 0, "SDL_BlitSurface");
  15.229 +      }
  15.230 +   }
  15.231 +
  15.232 +   /* See if it's the same. */
  15.233 +   AssertTrue(surface_compare( testsur, &img_blitColour, 0 ) == 0,
  15.234 +		   "Blitting output not the same (using SDL_SetSurfaceColorMod).");
  15.235 +
  15.236 +   /* Clear surface. */
  15.237 +   ret = SDL_FillRect( testsur, NULL,
  15.238 +         SDL_MapRGB( testsur->format, 0, 0, 0 ) );
  15.239 +   AssertTrue(ret == 0, "SDL_FillRect");
  15.240 +
  15.241 +   /* Restore colour. */
  15.242 +   ret = SDL_SetSurfaceColorMod( face, 255, 255, 255 );
  15.243 +   AssertTrue(ret == 0, "SDL_SetSurfaceColorMod");
  15.244 +
  15.245 +   /* Test blitting with colour mod. */
  15.246 +   for (j=0; j <= nj; j+=4) {
  15.247 +      for (i=0; i <= ni; i+=4) {
  15.248 +         /* Set alpha mod. */
  15.249 +         ret = SDL_SetSurfaceAlphaMod( face, (255/ni)*i );
  15.250 +         AssertTrue(ret == 0, "SDL_SetSurfaceAlphaMod");
  15.251 +
  15.252 +         /* Blitting. */
  15.253 +         rect.x = i;
  15.254 +         rect.y = j;
  15.255 +         ret = SDL_BlitSurface( face, NULL, testsur, &rect );
  15.256 +         AssertTrue(ret == 0, "SDL_BlitSurface");
  15.257 +      }
  15.258 +   }
  15.259 +
  15.260 +   /* See if it's the same. */
  15.261 +   AssertTrue(surface_compare( testsur, &img_blitAlpha, 0 ) == 0,
  15.262 +		   "Blitting output not the same (using SDL_SetSurfaceAlphaMod).");
  15.263 +
  15.264 +   /* Clean up. */
  15.265 +   SDL_FreeSurface( face );
  15.266 +   SDL_FreeSurface( testsur );
  15.267 +
  15.268 +   SDL_Quit();
  15.269 +}
  15.270 +
  15.271 +
  15.272 +/**
  15.273 + * @brief Tests a blend mode.
  15.274 + */
  15.275 +
  15.276 +
  15.277 +
  15.278 +/**
  15.279 + * @brief Tests some more blitting routines.
  15.280 + */
  15.281 +void surface_testBlitBlend(void *arg)
  15.282 +{
  15.283 +   int ret;
  15.284 +   SDL_Rect rect;
  15.285 +   SDL_Surface *face;
  15.286 +   int i, j, ni, nj;
  15.287 +   int mode;
  15.288 +
  15.289 +	ret = SDL_Init(SDL_INIT_VIDEO);
  15.290 +	AssertTrue(ret == 0, "SDL_Init(SDL_INIT_VIDEO)");
  15.291 +
  15.292 +   SDL_Surface *testsur = CreateTestSurface();
  15.293 +
  15.294 +   /* Clear surface. */
  15.295 +   ret = SDL_FillRect( testsur, NULL,
  15.296 +         SDL_MapRGB( testsur->format, 0, 0, 0 ) );
  15.297 +
  15.298 +   AssertTrue(ret == 0, "SDL_FillRect");
  15.299 +
  15.300 +   /* Create the blit surface. */
  15.301 +   face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
  15.302 +         img_face.width, img_face.height, 32, img_face.width*4,
  15.303 +#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
  15.304 +         0xff000000, /* Red bit mask. */
  15.305 +         0x00ff0000, /* Green bit mask. */
  15.306 +         0x0000ff00, /* Blue bit mask. */
  15.307 +         0x000000ff /* Alpha bit mask. */
  15.308 +#else
  15.309 +         0x000000ff, /* Red bit mask. */
  15.310 +         0x0000ff00, /* Green bit mask. */
  15.311 +         0x00ff0000, /* Blue bit mask. */
  15.312 +         0xff000000 /* Alpha bit mask. */
  15.313 +#endif
  15.314 +         );
  15.315 +   AssertTrue(face != NULL, "SDL_CreateRGBSurfaceFrom");
  15.316 +
  15.317 +   /* Set alpha mod. */
  15.318 +   ret = SDL_SetSurfaceAlphaMod( face, 100 );
  15.319 +   AssertTrue(ret == 0, "SDL_SetSurfaceAlphaMod");
  15.320 +
  15.321 +   /* Steps to take. */
  15.322 +   ni     = testsur->w - face->w;
  15.323 +   nj     = testsur->h - face->h;
  15.324 +
  15.325 +   /* Constant values. */
  15.326 +   rect.w = face->w;
  15.327 +   rect.h = face->h;
  15.328 +
  15.329 +   /* Test None. */
  15.330 +   if (testBlitBlendMode( testsur, face, SDL_BLENDMODE_NONE ))
  15.331 +      return;
  15.332 +   AssertTrue(surface_compare( testsur, &img_blendNone, 0 ) == 0,
  15.333 +		   "Blitting blending output not the same (using SDL_BLENDMODE_NONE).");
  15.334 +
  15.335 +
  15.336 +   /* Test Blend. */
  15.337 +   if (testBlitBlendMode( testsur, face, SDL_BLENDMODE_BLEND ))
  15.338 +      return;
  15.339 +   AssertTrue(surface_compare( testsur, &img_blendBlend, 0 ) == 0,
  15.340 +		   "Blitting blending output not the same (using SDL_BLENDMODE_BLEND).");
  15.341 +
  15.342 +   /* Test Add. */
  15.343 +   if (testBlitBlendMode( testsur, face, SDL_BLENDMODE_ADD ))
  15.344 +      return;
  15.345 +   AssertTrue(surface_compare( testsur, &img_blendAdd, 0 ) == 0,
  15.346 +		      "Blitting blending output not the same (using SDL_BLENDMODE_ADD).");
  15.347 +
  15.348 +   /* Test Mod. */
  15.349 +   if (testBlitBlendMode( testsur, face, SDL_BLENDMODE_MOD ))
  15.350 +      return;
  15.351 +   AssertTrue(surface_compare( testsur, &img_blendMod, 0 ) == 0,
  15.352 +		      "Blitting blending output not the same (using SDL_BLENDMODE_MOD).");
  15.353 +
  15.354 +   /* Clear surface. */
  15.355 +   ret = SDL_FillRect( testsur, NULL,
  15.356 +         SDL_MapRGB( testsur->format, 0, 0, 0 ) );
  15.357 +
  15.358 +   AssertTrue(ret == 0, "SDL_FillRect");
  15.359 +
  15.360 +   /* Loop blit. */
  15.361 +   for (j=0; j <= nj; j+=4) {
  15.362 +      for (i=0; i <= ni; i+=4) {
  15.363 +
  15.364 +         /* Set colour mod. */
  15.365 +         ret = SDL_SetSurfaceColorMod( face, (255/nj)*j, (255/ni)*i, (255/nj)*j );
  15.366 +         AssertTrue(ret == 0, "SDL_SetSurfaceColorMod");
  15.367 +
  15.368 +         /* Set alpha mod. */
  15.369 +         ret = SDL_SetSurfaceAlphaMod( face, (100/ni)*i );
  15.370 +         AssertTrue(ret == 0, "SDL_SetSurfaceAlphaMod");
  15.371 +
  15.372 +         /* Crazy blending mode magic. */
  15.373 +         mode = (i/4*j/4) % 4;
  15.374 +         if (mode==0) mode = SDL_BLENDMODE_NONE;
  15.375 +         else if (mode==1) mode = SDL_BLENDMODE_BLEND;
  15.376 +         else if (mode==2) mode = SDL_BLENDMODE_ADD;
  15.377 +         else if (mode==3) mode = SDL_BLENDMODE_MOD;
  15.378 +         ret = SDL_SetSurfaceBlendMode( face, mode );
  15.379 +
  15.380 +         AssertTrue(ret == 0, "SDL_SetSurfaceBlendMode");
  15.381 +
  15.382 +         /* Blitting. */
  15.383 +         rect.x = i;
  15.384 +         rect.y = j;
  15.385 +         ret = SDL_BlitSurface( face, NULL, testsur, &rect );
  15.386 +         AssertTrue(ret == 0, "SDL_BlitSurface");
  15.387 +      }
  15.388 +   }
  15.389 +
  15.390 +   /* Check to see if matches. */
  15.391 +   AssertTrue(surface_compare( testsur, &img_blendAll, 0 ) == 0,
  15.392 +		      "Blitting blending output not the same (using SDL_BLEND_*).");
  15.393 +
  15.394 +   /* Clean up. */
  15.395 +   SDL_FreeSurface( face );
  15.396 +   SDL_FreeSurface( testsur );
  15.397 +
  15.398 +   SDL_Quit();
  15.399 +}
  15.400 +
  15.401 +#endif