testautomation_surface.c 20 KB

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