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