testautomation_surface.c 20 KB

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