test/testautomation_surface.c
author Ryan C. Gordon <icculus@icculus.org>
Thu, 18 Dec 2014 00:19:52 -0500
changeset 9278 8900afb78a19
parent 9218 74b8ddd028c7
child 9281 85246fbeeac1
permissions -rw-r--r--
Initial merge of Emscripten port!

With this commit, you can compile SDL2 with Emscripten
( http://emscripten.org/ ), and make your SDL-based C/C++ program
into a web app.

This port was due to the efforts of several people, including: Charlie Birks,
Sathyanarayanan Gunasekaran, Jukka Jylänki, Alon Zakai, Edward Rudd,
Bruce Mitchener, and Martin Gerhardy. (Thanks, everyone!)
     1 /**
     2  * Original code: automated SDL surface test written by Edgar Simo "bobbens"
     3  * Adapted/rewritten for test lib by Andreas Schiffler
     4  */
     5 
     6 /* Supress C4996 VS compiler warnings for unlink() */
     7 #define _CRT_SECURE_NO_DEPRECATE
     8 #define _CRT_NONSTDC_NO_DEPRECATE
     9 
    10 #include <stdio.h>
    11 #include <unistd.h>
    12 #include <sys/stat.h>
    13 
    14 #include "SDL.h"
    15 #include "SDL_test.h"
    16 
    17 #ifdef __MACOSX__
    18 #include <unistd.h> /* For unlink() */
    19 #endif
    20 
    21 /* ================= Test Case Implementation ================== */
    22 
    23 /* Shared test surface */
    24 
    25 static SDL_Surface *referenceSurface = NULL;
    26 static SDL_Surface *testSurface = NULL;
    27 
    28 /* Helper functions for the test cases */
    29 
    30 #define TEST_SURFACE_WIDTH testSurface->w
    31 #define TEST_SURFACE_HEIGHT testSurface->h
    32 
    33 /* Fixture */
    34 
    35 /* Create a 32-bit writable surface for blitting tests */
    36 void
    37 _surfaceSetUp(void *arg)
    38 {
    39     int result;
    40     SDL_BlendMode blendMode = SDL_BLENDMODE_NONE;
    41     SDL_BlendMode currentBlendMode;
    42     Uint32 rmask, gmask, bmask, amask;
    43 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
    44     rmask = 0xff000000;
    45     gmask = 0x00ff0000;
    46     bmask = 0x0000ff00;
    47     amask = 0x000000ff;
    48 #else
    49     rmask = 0x000000ff;
    50     gmask = 0x0000ff00;
    51     bmask = 0x00ff0000;
    52     amask = 0xff000000;
    53 #endif
    54 
    55     referenceSurface = SDLTest_ImageBlit(); /* For size info */
    56     testSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, referenceSurface->w, referenceSurface->h, 32, rmask, gmask, bmask, amask);
    57     SDLTest_AssertCheck(testSurface != NULL, "Check that testSurface is not NULL");
    58     if (testSurface != NULL) {
    59       /* Disable blend mode for target surface */
    60       result = SDL_SetSurfaceBlendMode(testSurface, blendMode);
    61       SDLTest_AssertCheck(result == 0, "Validate result from SDL_SetSurfaceBlendMode, expected: 0, got: %i", result);
    62       result = SDL_GetSurfaceBlendMode(testSurface, &currentBlendMode);
    63       SDLTest_AssertCheck(result == 0, "Validate result from SDL_GetSurfaceBlendMode, expected: 0, got: %i", result);
    64       SDLTest_AssertCheck(currentBlendMode == blendMode, "Validate blendMode, expected: %i, got: %i", blendMode, currentBlendMode);
    65     }
    66 }
    67 
    68 void
    69 _surfaceTearDown(void *arg)
    70 {
    71     SDL_FreeSurface(referenceSurface);
    72     referenceSurface = NULL;
    73     SDL_FreeSurface(testSurface);
    74     testSurface = NULL;
    75 }
    76 
    77 /**
    78  * Helper that clears the test surface
    79  */
    80 void _clearTestSurface()
    81 {
    82     int ret;
    83     Uint32 color;
    84 
    85     /* Clear surface. */
    86     color = SDL_MapRGBA( testSurface->format, 0, 0, 0, 0);
    87     SDLTest_AssertPass("Call to SDL_MapRGBA()");
    88     ret = SDL_FillRect( testSurface, NULL, color);
    89     SDLTest_AssertPass("Call to SDL_FillRect()");
    90     SDLTest_AssertCheck(ret == 0, "Verify result from SDL_FillRect, expected: 0, got: %i", ret);
    91 }
    92 
    93 /**
    94  * Helper that blits in a specific blend mode, -1 for basic blitting, -2 for color mod, -3 for alpha mod, -4 for mixed blend modes.
    95  */
    96 void _testBlitBlendMode(int mode)
    97 {
    98     int ret;
    99     int i, j, ni, nj;
   100     SDL_Surface *face;
   101     SDL_Rect rect;
   102     int nmode;
   103     SDL_BlendMode bmode;
   104     int checkFailCount1;
   105     int checkFailCount2;
   106     int checkFailCount3;
   107     int checkFailCount4;
   108 
   109     /* Check test surface */
   110     SDLTest_AssertCheck(testSurface != NULL, "Verify testSurface is not NULL");
   111     if (testSurface == NULL) return;
   112 
   113     /* Create sample surface */
   114     face = SDLTest_ImageFace();
   115     SDLTest_AssertCheck(face != NULL, "Verify face surface is not NULL");
   116     if (face == NULL) return;
   117 
   118         /* Reset alpha modulation */
   119     ret = SDL_SetSurfaceAlphaMod(face, 255);
   120     SDLTest_AssertPass("Call to SDL_SetSurfaceAlphaMod()");
   121     SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceAlphaMod(), expected: 0, got: %i", ret);
   122 
   123         /* Reset color modulation */
   124     ret = SDL_SetSurfaceColorMod(face, 255, 255, 255);
   125     SDLTest_AssertPass("Call to SDL_SetSurfaceColorMod()");
   126     SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceColorMod(), expected: 0, got: %i", ret);
   127 
   128         /* Reset color key */
   129     ret = SDL_SetColorKey(face, SDL_FALSE, 0);
   130     SDLTest_AssertPass("Call to SDL_SetColorKey()");
   131     SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey(), expected: 0, got: %i", ret);
   132 
   133     /* Clear the test surface */
   134         _clearTestSurface();
   135 
   136     /* Target rect size */
   137     rect.w = face->w;
   138     rect.h = face->h;
   139 
   140     /* Steps to take */
   141     ni = testSurface->w - face->w;
   142     nj = testSurface->h - face->h;
   143 
   144     /* Optionally set blend mode. */
   145     if (mode >= 0) {
   146         ret = SDL_SetSurfaceBlendMode( face, (SDL_BlendMode)mode );
   147         SDLTest_AssertPass("Call to SDL_SetSurfaceBlendMode()");
   148         SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceBlendMode(..., %i), expected: 0, got: %i", mode, ret);
   149     }
   150 
   151     /* Test blend mode. */
   152     checkFailCount1 = 0;
   153     checkFailCount2 = 0;
   154     checkFailCount3 = 0;
   155     checkFailCount4 = 0;
   156     for (j=0; j <= nj; j+=4) {
   157       for (i=0; i <= ni; i+=4) {
   158         if (mode == -2) {
   159             /* Set color mod. */
   160             ret = SDL_SetSurfaceColorMod( face, (255/nj)*j, (255/ni)*i, (255/nj)*j );
   161             if (ret != 0) checkFailCount2++;
   162         }
   163         else if (mode == -3) {
   164             /* Set alpha mod. */
   165             ret = SDL_SetSurfaceAlphaMod( face, (255/ni)*i );
   166             if (ret != 0) checkFailCount3++;
   167         }
   168         else if (mode == -4) {
   169             /* Crazy blending mode magic. */
   170             nmode = (i/4*j/4) % 4;
   171             if (nmode==0) {
   172                 bmode = SDL_BLENDMODE_NONE;
   173             } else if (nmode==1) {
   174                 bmode = SDL_BLENDMODE_BLEND;
   175             } else if (nmode==2) {
   176                 bmode = SDL_BLENDMODE_ADD;
   177             } else if (nmode==3) {
   178                 bmode = SDL_BLENDMODE_MOD;
   179             }
   180             ret = SDL_SetSurfaceBlendMode( face, bmode );
   181             if (ret != 0) checkFailCount4++;
   182         }
   183 
   184          /* Blitting. */
   185          rect.x = i;
   186          rect.y = j;
   187          ret = SDL_BlitSurface( face, NULL, testSurface, &rect );
   188          if (ret != 0) checkFailCount1++;
   189       }
   190     }
   191     SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_BlitSurface, expected: 0, got: %i", checkFailCount1);
   192     SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetSurfaceColorMod, expected: 0, got: %i", checkFailCount2);
   193     SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_SetSurfaceAlphaMod, expected: 0, got: %i", checkFailCount3);
   194     SDLTest_AssertCheck(checkFailCount4 == 0, "Validate results from calls to SDL_SetSurfaceBlendMode, expected: 0, got: %i", checkFailCount4);
   195 
   196     /* Clean up */
   197     SDL_FreeSurface(face);
   198     face = NULL;
   199 }
   200 
   201 /* Helper to check that a file exists */
   202 void
   203 _AssertFileExist(const char *filename)
   204 {
   205     struct stat st;
   206     int ret = stat(filename, &st);
   207 
   208     SDLTest_AssertCheck(ret == 0, "Verify file '%s' exists", filename);
   209 }
   210 
   211 
   212 /* Test case functions */
   213 
   214 /**
   215  * @brief Tests sprite saving and loading
   216  */
   217 int
   218 surface_testSaveLoadBitmap(void *arg)
   219 {
   220     int ret;
   221     const char *sampleFilename = "testSaveLoadBitmap.bmp";
   222     SDL_Surface *face;
   223     SDL_Surface *rface;
   224 
   225     /* Create sample surface */
   226     face = SDLTest_ImageFace();
   227     SDLTest_AssertCheck(face != NULL, "Verify face surface is not NULL");
   228     if (face == NULL) return TEST_ABORTED;
   229 
   230     /* Delete test file; ignore errors */
   231     unlink(sampleFilename);
   232 
   233     /* Save a surface */
   234     ret = SDL_SaveBMP(face, sampleFilename);
   235     SDLTest_AssertPass("Call to SDL_SaveBMP()");
   236     SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SaveBMP, expected: 0, got: %i", ret);
   237     _AssertFileExist(sampleFilename);
   238 
   239     /* Load a surface */
   240     rface = SDL_LoadBMP(sampleFilename);
   241     SDLTest_AssertPass("Call to SDL_LoadBMP()");
   242     SDLTest_AssertCheck(rface != NULL, "Verify result from SDL_LoadBMP is not NULL");
   243     if (rface != NULL) {
   244         SDLTest_AssertCheck(face->w == rface->w, "Verify width of loaded surface, expected: %i, got: %i", face->w, rface->w);
   245         SDLTest_AssertCheck(face->h == rface->h, "Verify height of loaded surface, expected: %i, got: %i", face->h, rface->h);
   246     }
   247 
   248     /* Delete test file; ignore errors */
   249     unlink(sampleFilename);
   250 
   251     /* Clean up */
   252     SDL_FreeSurface(face);
   253     face = NULL;
   254     SDL_FreeSurface(rface);
   255     rface = NULL;
   256 
   257     return TEST_COMPLETED;
   258 }
   259 
   260 /* !
   261  *  Tests surface conversion.
   262  */
   263 int
   264 surface_testSurfaceConversion(void *arg)
   265 {
   266     SDL_Surface *rface = NULL, *face = NULL;
   267     int ret = 0;
   268 
   269     /* Create sample surface */
   270     face = SDLTest_ImageFace();
   271     SDLTest_AssertCheck(face != NULL, "Verify face surface is not NULL");
   272     if (face == NULL)
   273         return TEST_ABORTED;
   274 
   275     /* Set transparent pixel as the pixel at (0,0) */
   276     if (face->format->palette) {
   277        ret = SDL_SetColorKey(face, SDL_RLEACCEL, *(Uint8 *) face->pixels);
   278        SDLTest_AssertPass("Call to SDL_SetColorKey()");
   279        SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey, expected: 0, got: %i", ret);
   280     }
   281 
   282     /* Convert to 32 bit to compare. */
   283     rface = SDL_ConvertSurface( face, testSurface->format, 0 );
   284     SDLTest_AssertPass("Call to SDL_ConvertSurface()");
   285     SDLTest_AssertCheck(rface != NULL, "Verify result from SDL_ConvertSurface is not NULL");
   286 
   287     /* Compare surface. */
   288     ret = SDLTest_CompareSurfaces( rface, face, 0 );
   289     SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
   290 
   291     /* Clean up. */
   292     SDL_FreeSurface(face);
   293     face = NULL;
   294     SDL_FreeSurface(rface);
   295     rface = NULL;
   296 
   297     return TEST_COMPLETED;
   298 }
   299 
   300 
   301 /* !
   302  *  Tests surface conversion across all pixel formats.
   303  */
   304 int
   305 surface_testCompleteSurfaceConversion(void *arg)
   306 {
   307     Uint32 pixel_formats[] = {
   308         SDL_PIXELFORMAT_INDEX8,
   309         SDL_PIXELFORMAT_RGB332,
   310         SDL_PIXELFORMAT_RGB444,
   311         SDL_PIXELFORMAT_RGB555,
   312         SDL_PIXELFORMAT_BGR555,
   313         SDL_PIXELFORMAT_ARGB4444,
   314         SDL_PIXELFORMAT_RGBA4444,
   315         SDL_PIXELFORMAT_ABGR4444,
   316         SDL_PIXELFORMAT_BGRA4444,
   317         SDL_PIXELFORMAT_ARGB1555,
   318         SDL_PIXELFORMAT_RGBA5551,
   319         SDL_PIXELFORMAT_ABGR1555,
   320         SDL_PIXELFORMAT_BGRA5551,
   321         SDL_PIXELFORMAT_RGB565,
   322         SDL_PIXELFORMAT_BGR565,
   323         SDL_PIXELFORMAT_RGB24,
   324         SDL_PIXELFORMAT_BGR24,
   325         SDL_PIXELFORMAT_RGB888,
   326         SDL_PIXELFORMAT_RGBX8888,
   327         SDL_PIXELFORMAT_BGR888,
   328         SDL_PIXELFORMAT_BGRX8888,
   329         SDL_PIXELFORMAT_ARGB8888,
   330         SDL_PIXELFORMAT_RGBA8888,
   331         SDL_PIXELFORMAT_ABGR8888,
   332         SDL_PIXELFORMAT_BGRA8888,
   333         SDL_PIXELFORMAT_ARGB2101010,
   334     };
   335     SDL_Surface *face = NULL, *cvt1, *cvt2, *final;
   336     SDL_PixelFormat *fmt1, *fmt2;
   337     int i, j, ret = 0;
   338 
   339     /* Create sample surface */
   340     face = SDLTest_ImageFace();
   341     SDLTest_AssertCheck(face != NULL, "Verify face surface is not NULL");
   342     if (face == NULL)
   343         return TEST_ABORTED;
   344 
   345     /* Set transparent pixel as the pixel at (0,0) */
   346     if (face->format->palette) {
   347        ret = SDL_SetColorKey(face, SDL_RLEACCEL, *(Uint8 *) face->pixels);
   348        SDLTest_AssertPass("Call to SDL_SetColorKey()");
   349        SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey, expected: 0, got: %i", ret);
   350     }
   351 
   352     for ( i = 0; i < SDL_arraysize(pixel_formats); ++i ) {
   353         for ( j = 0; j < SDL_arraysize(pixel_formats); ++j ) {
   354             fmt1 = SDL_AllocFormat(pixel_formats[i]);
   355             SDL_assert(fmt1 != NULL);
   356             cvt1 = SDL_ConvertSurface(face, fmt1, 0);
   357             SDL_assert(cvt1 != NULL);
   358 
   359             fmt2 = SDL_AllocFormat(pixel_formats[j]);
   360             SDL_assert(fmt1 != NULL);
   361             cvt2 = SDL_ConvertSurface(cvt1, fmt2, 0);
   362             SDL_assert(cvt2 != NULL);
   363 
   364             if ( fmt1->BytesPerPixel == face->format->BytesPerPixel &&
   365                  fmt2->BytesPerPixel == face->format->BytesPerPixel &&
   366                  (fmt1->Amask != 0) == (face->format->Amask != 0) &&
   367                  (fmt2->Amask != 0) == (face->format->Amask != 0) ) {
   368                 final = SDL_ConvertSurface( cvt2, face->format, 0 );
   369                 SDL_assert(final != NULL);
   370 
   371                 /* Compare surface. */
   372                 ret = SDLTest_CompareSurfaces( face, final, 0 );
   373                 SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
   374                 SDL_FreeSurface(final);
   375             }
   376 
   377             SDL_FreeSurface(cvt1);
   378             SDL_FreeFormat(fmt1);
   379             SDL_FreeSurface(cvt2);
   380             SDL_FreeFormat(fmt2);
   381         }
   382     }
   383 
   384     /* Clean up. */
   385     SDL_FreeSurface( face );
   386 
   387     return TEST_COMPLETED;
   388 }
   389 
   390 
   391 /**
   392  * @brief Tests sprite loading. A failure case.
   393  */
   394 int
   395 surface_testLoadFailure(void *arg)
   396 {
   397     SDL_Surface *face = SDL_LoadBMP("nonexistant.bmp");
   398     SDLTest_AssertCheck(face == NULL, "SDL_CreateLoadBmp");
   399 
   400     return TEST_COMPLETED;
   401 }
   402 
   403 /**
   404  * @brief Tests some blitting routines.
   405  */
   406 int
   407 surface_testBlit(void *arg)
   408 {
   409    int ret;
   410    SDL_Surface *compareSurface;
   411 
   412    /* Basic blitting */
   413    _testBlitBlendMode(-1);
   414 
   415    /* Verify result by comparing surfaces */
   416    compareSurface = SDLTest_ImageBlit();
   417    ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
   418    SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
   419 
   420    /* Clean up. */
   421    SDL_FreeSurface(compareSurface);
   422 
   423    return TEST_COMPLETED;
   424 }
   425 
   426 /**
   427  * @brief Tests some blitting routines with color mod
   428  */
   429 int
   430 surface_testBlitColorMod(void *arg)
   431 {
   432    int ret;
   433    SDL_Surface *compareSurface;
   434 
   435    /* Basic blitting with color mod */
   436    _testBlitBlendMode(-2);
   437 
   438    /* Verify result by comparing surfaces */
   439    compareSurface = SDLTest_ImageBlitColor();
   440    ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
   441    SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
   442 
   443    /* Clean up. */
   444    SDL_FreeSurface(compareSurface);
   445 
   446    return TEST_COMPLETED;
   447 }
   448 
   449 /**
   450  * @brief Tests some blitting routines with alpha mod
   451  */
   452 int
   453 surface_testBlitAlphaMod(void *arg)
   454 {
   455    int ret;
   456    SDL_Surface *compareSurface;
   457 
   458    /* Basic blitting with alpha mod */
   459    _testBlitBlendMode(-3);
   460 
   461    /* Verify result by comparing surfaces */
   462    compareSurface = SDLTest_ImageBlitAlpha();
   463    ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
   464    SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
   465 
   466    /* Clean up. */
   467    SDL_FreeSurface(compareSurface);
   468 
   469    return TEST_COMPLETED;
   470 }
   471 
   472 
   473 /**
   474  * @brief Tests some more blitting routines.
   475  */
   476 int
   477 surface_testBlitBlendNone(void *arg)
   478 {
   479    int ret;
   480    SDL_Surface *compareSurface;
   481 
   482    /* Basic blitting */
   483    _testBlitBlendMode(SDL_BLENDMODE_NONE);
   484 
   485    /* Verify result by comparing surfaces */
   486    compareSurface = SDLTest_ImageBlitBlendNone();
   487    ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
   488    SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
   489 
   490    /* Clean up. */
   491    SDL_FreeSurface(compareSurface);
   492 
   493    return TEST_COMPLETED;
   494 }
   495 
   496 /**
   497  * @brief Tests some more blitting routines.
   498  */
   499 int
   500 surface_testBlitBlendBlend(void *arg)
   501 {
   502    int ret;
   503    SDL_Surface *compareSurface;
   504 
   505    /* Blend blitting */
   506    _testBlitBlendMode(SDL_BLENDMODE_BLEND);
   507 
   508    /* Verify result by comparing surfaces */
   509    compareSurface = SDLTest_ImageBlitBlend();
   510    ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
   511    SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
   512 
   513    /* Clean up. */
   514    SDL_FreeSurface(compareSurface);
   515 
   516    return TEST_COMPLETED;
   517 }
   518 
   519 /**
   520  * @brief Tests some more blitting routines.
   521  */
   522 int
   523 surface_testBlitBlendAdd(void *arg)
   524 {
   525    int ret;
   526    SDL_Surface *compareSurface;
   527 
   528    /* Add blitting */
   529    _testBlitBlendMode(SDL_BLENDMODE_ADD);
   530 
   531    /* Verify result by comparing surfaces */
   532    compareSurface = SDLTest_ImageBlitBlendAdd();
   533    ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
   534    SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
   535 
   536    /* Clean up. */
   537    SDL_FreeSurface(compareSurface);
   538 
   539    return TEST_COMPLETED;
   540 }
   541 
   542 /**
   543  * @brief Tests some more blitting routines.
   544  */
   545 int
   546 surface_testBlitBlendMod(void *arg)
   547 {
   548    int ret;
   549    SDL_Surface *compareSurface;
   550 
   551    /* Mod blitting */
   552    _testBlitBlendMode(SDL_BLENDMODE_MOD);
   553 
   554    /* Verify result by comparing surfaces */
   555    compareSurface = SDLTest_ImageBlitBlendMod();
   556    ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
   557    SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
   558 
   559    /* Clean up. */
   560    SDL_FreeSurface(compareSurface);
   561 
   562    return TEST_COMPLETED;
   563 }
   564 
   565 /**
   566  * @brief Tests some more blitting routines with loop
   567  */
   568 int
   569 surface_testBlitBlendLoop(void *arg) {
   570 
   571    int ret;
   572    SDL_Surface *compareSurface;
   573 
   574    /* All blitting modes */
   575    _testBlitBlendMode(-4);
   576 
   577    /* Verify result by comparing surfaces */
   578    compareSurface = SDLTest_ImageBlitBlendAll();
   579    ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
   580    SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
   581 
   582    /* Clean up. */
   583    SDL_FreeSurface(compareSurface);
   584 
   585    return TEST_COMPLETED;
   586 
   587 }
   588 
   589 /* ================= Test References ================== */
   590 
   591 /* Surface test cases */
   592 static const SDLTest_TestCaseReference surfaceTest1 =
   593         { (SDLTest_TestCaseFp)surface_testSaveLoadBitmap, "surface_testSaveLoadBitmap", "Tests sprite saving and loading.", TEST_ENABLED};
   594 
   595 static const SDLTest_TestCaseReference surfaceTest2 =
   596         { (SDLTest_TestCaseFp)surface_testBlit, "surface_testBlit", "Tests basic blitting.", TEST_ENABLED};
   597 
   598 static const SDLTest_TestCaseReference surfaceTest3 =
   599         { (SDLTest_TestCaseFp)surface_testBlitBlendNone, "surface_testBlitBlendNone", "Tests blitting routines with none blending mode.", TEST_ENABLED};
   600 
   601 static const SDLTest_TestCaseReference surfaceTest4 =
   602         { (SDLTest_TestCaseFp)surface_testLoadFailure, "surface_testLoadFailure", "Tests sprite loading. A failure case.", TEST_ENABLED};
   603 
   604 static const SDLTest_TestCaseReference surfaceTest5 =
   605         { (SDLTest_TestCaseFp)surface_testSurfaceConversion, "surface_testSurfaceConversion", "Tests surface conversion.", TEST_ENABLED};
   606 
   607 static const SDLTest_TestCaseReference surfaceTest6 =
   608         { (SDLTest_TestCaseFp)surface_testCompleteSurfaceConversion, "surface_testCompleteSurfaceConversion", "Tests surface conversion across all pixel formats", TEST_ENABLED};
   609 
   610 static const SDLTest_TestCaseReference surfaceTest7 =
   611         { (SDLTest_TestCaseFp)surface_testBlitColorMod, "surface_testBlitColorMod", "Tests some blitting routines with color mod.", TEST_ENABLED};
   612 
   613 static const SDLTest_TestCaseReference surfaceTest8 =
   614         { (SDLTest_TestCaseFp)surface_testBlitAlphaMod, "surface_testBlitAlphaMod", "Tests some blitting routines with alpha mod.", TEST_ENABLED};
   615 
   616 /* TODO: rewrite test case, define new test data and re-enable; current implementation fails */
   617 static const SDLTest_TestCaseReference surfaceTest9 =
   618         { (SDLTest_TestCaseFp)surface_testBlitBlendLoop, "surface_testBlitBlendLoop", "Test blitting routines with various blending modes", TEST_DISABLED};
   619 
   620 /* TODO: rewrite test case, define new test data and re-enable; current implementation fails */
   621 static const SDLTest_TestCaseReference surfaceTest10 =
   622         { (SDLTest_TestCaseFp)surface_testBlitBlendBlend, "surface_testBlitBlendBlend", "Tests blitting routines with blend blending mode.", TEST_DISABLED};
   623 
   624 /* TODO: rewrite test case, define new test data and re-enable; current implementation fails */
   625 static const SDLTest_TestCaseReference surfaceTest11 =
   626         { (SDLTest_TestCaseFp)surface_testBlitBlendAdd, "surface_testBlitBlendAdd", "Tests blitting routines with add blending mode.", TEST_DISABLED};
   627 
   628 static const SDLTest_TestCaseReference surfaceTest12 =
   629         { (SDLTest_TestCaseFp)surface_testBlitBlendMod, "surface_testBlitBlendMod", "Tests blitting routines with mod blending mode.", TEST_ENABLED};
   630 
   631 /* Sequence of Surface test cases */
   632 static const SDLTest_TestCaseReference *surfaceTests[] =  {
   633     &surfaceTest1, &surfaceTest2, &surfaceTest3, &surfaceTest4, &surfaceTest5,
   634     &surfaceTest6, &surfaceTest7, &surfaceTest8, &surfaceTest9, &surfaceTest10,
   635     &surfaceTest11, &surfaceTest12, NULL
   636 };
   637 
   638 /* Surface test suite (global) */
   639 SDLTest_TestSuiteReference surfaceTestSuite = {
   640     "Surface",
   641     _surfaceSetUp,
   642     surfaceTests,
   643     _surfaceTearDown
   644 
   645 };