testautomation_video.c 77 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928
  1. /**
  2. * Video test suite
  3. */
  4. #include <SDL3/SDL.h>
  5. #include <SDL3/SDL_test.h>
  6. /* Private helpers */
  7. /*
  8. * Create a test window
  9. */
  10. SDL_Window *_createVideoSuiteTestWindow(const char *title)
  11. {
  12. SDL_Window *window;
  13. int x, y, w, h;
  14. SDL_WindowFlags flags;
  15. /* Standard window */
  16. x = SDLTest_RandomIntegerInRange(1, 100);
  17. y = SDLTest_RandomIntegerInRange(1, 100);
  18. w = SDLTest_RandomIntegerInRange(320, 1024);
  19. h = SDLTest_RandomIntegerInRange(320, 768);
  20. flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS;
  21. window = SDL_CreateWindow(title, x, y, w, h, flags);
  22. SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
  23. SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
  24. return window;
  25. }
  26. /*
  27. * Destroy test window
  28. */
  29. void _destroyVideoSuiteTestWindow(SDL_Window *window)
  30. {
  31. if (window != NULL) {
  32. SDL_DestroyWindow(window);
  33. window = NULL;
  34. SDLTest_AssertPass("Call to SDL_DestroyWindow()");
  35. }
  36. }
  37. /* Test case functions */
  38. /**
  39. * @brief Enable and disable screensaver while checking state
  40. */
  41. int video_enableDisableScreensaver(void *arg)
  42. {
  43. SDL_bool initialResult;
  44. SDL_bool result;
  45. /* Get current state and proceed according to current state */
  46. initialResult = SDL_IsScreenSaverEnabled();
  47. SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
  48. if (initialResult == SDL_TRUE) {
  49. /* Currently enabled: disable first, then enable again */
  50. /* Disable screensaver and check */
  51. SDL_DisableScreenSaver();
  52. SDLTest_AssertPass("Call to SDL_DisableScreenSaver()");
  53. result = SDL_IsScreenSaverEnabled();
  54. SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
  55. SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);
  56. /* Enable screensaver and check */
  57. SDL_EnableScreenSaver();
  58. SDLTest_AssertPass("Call to SDL_EnableScreenSaver()");
  59. result = SDL_IsScreenSaverEnabled();
  60. SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
  61. SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
  62. } else {
  63. /* Currently disabled: enable first, then disable again */
  64. /* Enable screensaver and check */
  65. SDL_EnableScreenSaver();
  66. SDLTest_AssertPass("Call to SDL_EnableScreenSaver()");
  67. result = SDL_IsScreenSaverEnabled();
  68. SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
  69. SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
  70. /* Disable screensaver and check */
  71. SDL_DisableScreenSaver();
  72. SDLTest_AssertPass("Call to SDL_DisableScreenSaver()");
  73. result = SDL_IsScreenSaverEnabled();
  74. SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
  75. SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);
  76. }
  77. return TEST_COMPLETED;
  78. }
  79. /**
  80. * @brief Tests the functionality of the SDL_CreateWindow function using different positions
  81. */
  82. int video_createWindowVariousPositions(void *arg)
  83. {
  84. SDL_Window *window;
  85. const char *title = "video_createWindowVariousPositions Test Window";
  86. int x, y, w, h;
  87. int xVariation, yVariation;
  88. for (xVariation = 0; xVariation < 6; xVariation++) {
  89. for (yVariation = 0; yVariation < 6; yVariation++) {
  90. switch (xVariation) {
  91. default:
  92. case 0:
  93. /* Zero X Position */
  94. x = 0;
  95. break;
  96. case 1:
  97. /* Random X position inside screen */
  98. x = SDLTest_RandomIntegerInRange(1, 100);
  99. break;
  100. case 2:
  101. /* Random X position outside screen (positive) */
  102. x = SDLTest_RandomIntegerInRange(10000, 11000);
  103. break;
  104. case 3:
  105. /* Random X position outside screen (negative) */
  106. x = SDLTest_RandomIntegerInRange(-1000, -100);
  107. break;
  108. case 4:
  109. /* Centered X position */
  110. x = SDL_WINDOWPOS_CENTERED;
  111. break;
  112. case 5:
  113. /* Undefined X position */
  114. x = SDL_WINDOWPOS_UNDEFINED;
  115. break;
  116. }
  117. switch (yVariation) {
  118. default:
  119. case 0:
  120. /* Zero X Position */
  121. y = 0;
  122. break;
  123. case 1:
  124. /* Random X position inside screen */
  125. y = SDLTest_RandomIntegerInRange(1, 100);
  126. break;
  127. case 2:
  128. /* Random X position outside screen (positive) */
  129. y = SDLTest_RandomIntegerInRange(10000, 11000);
  130. break;
  131. case 3:
  132. /* Random Y position outside screen (negative) */
  133. y = SDLTest_RandomIntegerInRange(-1000, -100);
  134. break;
  135. case 4:
  136. /* Centered Y position */
  137. y = SDL_WINDOWPOS_CENTERED;
  138. break;
  139. case 5:
  140. /* Undefined Y position */
  141. y = SDL_WINDOWPOS_UNDEFINED;
  142. break;
  143. }
  144. w = SDLTest_RandomIntegerInRange(32, 96);
  145. h = SDLTest_RandomIntegerInRange(32, 96);
  146. window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN);
  147. SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h);
  148. SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
  149. /* Clean up */
  150. _destroyVideoSuiteTestWindow(window);
  151. }
  152. }
  153. return TEST_COMPLETED;
  154. }
  155. /**
  156. * @brief Tests the functionality of the SDL_CreateWindow function using different sizes
  157. */
  158. int video_createWindowVariousSizes(void *arg)
  159. {
  160. SDL_Window *window;
  161. const char *title = "video_createWindowVariousSizes Test Window";
  162. int x, y, w, h;
  163. int wVariation, hVariation;
  164. x = SDLTest_RandomIntegerInRange(1, 100);
  165. y = SDLTest_RandomIntegerInRange(1, 100);
  166. for (wVariation = 0; wVariation < 3; wVariation++) {
  167. for (hVariation = 0; hVariation < 3; hVariation++) {
  168. switch (wVariation) {
  169. case 0:
  170. /* Width of 1 */
  171. w = 1;
  172. break;
  173. case 1:
  174. /* Random "normal" width */
  175. w = SDLTest_RandomIntegerInRange(320, 1920);
  176. break;
  177. case 2:
  178. /* Random "large" width */
  179. w = SDLTest_RandomIntegerInRange(2048, 4095);
  180. break;
  181. }
  182. switch (hVariation) {
  183. case 0:
  184. /* Height of 1 */
  185. h = 1;
  186. break;
  187. case 1:
  188. /* Random "normal" height */
  189. h = SDLTest_RandomIntegerInRange(320, 1080);
  190. break;
  191. case 2:
  192. /* Random "large" height */
  193. h = SDLTest_RandomIntegerInRange(2048, 4095);
  194. break;
  195. }
  196. window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN);
  197. SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h);
  198. SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
  199. /* Clean up */
  200. _destroyVideoSuiteTestWindow(window);
  201. }
  202. }
  203. return TEST_COMPLETED;
  204. }
  205. /**
  206. * @brief Tests the functionality of the SDL_CreateWindow function using different flags
  207. */
  208. int video_createWindowVariousFlags(void *arg)
  209. {
  210. SDL_Window *window;
  211. const char *title = "video_createWindowVariousFlags Test Window";
  212. int x, y, w, h;
  213. int fVariation;
  214. SDL_WindowFlags flags;
  215. /* Standard window */
  216. x = SDLTest_RandomIntegerInRange(1, 100);
  217. y = SDLTest_RandomIntegerInRange(1, 100);
  218. w = SDLTest_RandomIntegerInRange(320, 1024);
  219. h = SDLTest_RandomIntegerInRange(320, 768);
  220. for (fVariation = 0; fVariation < 14; fVariation++) {
  221. switch (fVariation) {
  222. default:
  223. case 0:
  224. flags = SDL_WINDOW_FULLSCREEN;
  225. /* Skip - blanks screen; comment out next line to run test */
  226. continue;
  227. break;
  228. case 1:
  229. flags = SDL_WINDOW_FULLSCREEN_DESKTOP;
  230. /* Skip - blanks screen; comment out next line to run test */
  231. continue;
  232. break;
  233. case 2:
  234. flags = SDL_WINDOW_OPENGL;
  235. break;
  236. case 3:
  237. flags = SDL_WINDOW_SHOWN;
  238. break;
  239. case 4:
  240. flags = SDL_WINDOW_HIDDEN;
  241. break;
  242. case 5:
  243. flags = SDL_WINDOW_BORDERLESS;
  244. break;
  245. case 6:
  246. flags = SDL_WINDOW_RESIZABLE;
  247. break;
  248. case 7:
  249. flags = SDL_WINDOW_MINIMIZED;
  250. break;
  251. case 8:
  252. flags = SDL_WINDOW_MAXIMIZED;
  253. break;
  254. case 9:
  255. flags = SDL_WINDOW_MOUSE_GRABBED;
  256. break;
  257. case 10:
  258. flags = SDL_WINDOW_INPUT_FOCUS;
  259. break;
  260. case 11:
  261. flags = SDL_WINDOW_MOUSE_FOCUS;
  262. break;
  263. case 12:
  264. flags = SDL_WINDOW_FOREIGN;
  265. break;
  266. case 13:
  267. flags = SDL_WINDOW_KEYBOARD_GRABBED;
  268. break;
  269. }
  270. window = SDL_CreateWindow(title, x, y, w, h, flags);
  271. SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
  272. SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
  273. /* Clean up */
  274. _destroyVideoSuiteTestWindow(window);
  275. }
  276. return TEST_COMPLETED;
  277. }
  278. /**
  279. * @brief Tests the functionality of the SDL_GetWindowFlags function
  280. */
  281. int video_getWindowFlags(void *arg)
  282. {
  283. SDL_Window *window;
  284. const char *title = "video_getWindowFlags Test Window";
  285. SDL_WindowFlags flags;
  286. Uint32 actualFlags;
  287. /* Reliable flag set always set in test window */
  288. flags = SDL_WINDOW_SHOWN;
  289. /* Call against new test window */
  290. window = _createVideoSuiteTestWindow(title);
  291. if (window != NULL) {
  292. actualFlags = SDL_GetWindowFlags(window);
  293. SDLTest_AssertPass("Call to SDL_GetWindowFlags()");
  294. SDLTest_AssertCheck((flags & actualFlags) == flags, "Verify returned value has flags %d set, got: %" SDL_PRIu32, flags, actualFlags);
  295. }
  296. /* Clean up */
  297. _destroyVideoSuiteTestWindow(window);
  298. return TEST_COMPLETED;
  299. }
  300. /**
  301. * @brief Tests the functionality of the SDL_GetNumDisplayModes function
  302. */
  303. int video_getNumDisplayModes(void *arg)
  304. {
  305. int result;
  306. int displayNum;
  307. int i;
  308. /* Get number of displays */
  309. displayNum = SDL_GetNumVideoDisplays();
  310. SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()");
  311. /* Make call for each display */
  312. for (i = 0; i < displayNum; i++) {
  313. result = SDL_GetNumDisplayModes(i);
  314. SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d)", i);
  315. SDLTest_AssertCheck(result >= 1, "Validate returned value from function; expected: >=1; got: %d", result);
  316. }
  317. return TEST_COMPLETED;
  318. }
  319. /**
  320. * @brief Tests negative call to SDL_GetNumDisplayModes function
  321. */
  322. int video_getNumDisplayModesNegative(void *arg)
  323. {
  324. int result;
  325. int displayNum;
  326. int displayIndex;
  327. /* Get number of displays */
  328. displayNum = SDL_GetNumVideoDisplays();
  329. SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()");
  330. /* Invalid boundary values */
  331. displayIndex = SDLTest_RandomSint32BoundaryValue(0, displayNum, SDL_FALSE);
  332. result = SDL_GetNumDisplayModes(displayIndex);
  333. SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/boundary)", displayIndex);
  334. SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result);
  335. /* Large (out-of-bounds) display index */
  336. displayIndex = SDLTest_RandomIntegerInRange(-2000, -1000);
  337. result = SDL_GetNumDisplayModes(displayIndex);
  338. SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/large negative)", displayIndex);
  339. SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result);
  340. displayIndex = SDLTest_RandomIntegerInRange(1000, 2000);
  341. result = SDL_GetNumDisplayModes(displayIndex);
  342. SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/large positive)", displayIndex);
  343. SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result);
  344. return TEST_COMPLETED;
  345. }
  346. /**
  347. * @brief Tests the functionality of the SDL_GetClosestDisplayMode function against current resolution
  348. */
  349. int video_getClosestDisplayModeCurrentResolution(void *arg)
  350. {
  351. int result;
  352. SDL_DisplayMode current;
  353. SDL_DisplayMode target;
  354. SDL_DisplayMode closest;
  355. SDL_DisplayMode *dResult;
  356. int displayNum;
  357. int i;
  358. int variation;
  359. /* Get number of displays */
  360. displayNum = SDL_GetNumVideoDisplays();
  361. SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()");
  362. /* Make calls for each display */
  363. for (i = 0; i < displayNum; i++) {
  364. SDLTest_Log("Testing against display: %d", i);
  365. /* Get first display mode to get a sane resolution; this should always work */
  366. result = SDL_GetDisplayMode(i, 0, &current);
  367. SDLTest_AssertPass("Call to SDL_GetDisplayMode()");
  368. SDLTest_AssertCheck(result == 0, "Verify return value, expected: 0, got: %d", result);
  369. if (result != 0) {
  370. return TEST_ABORTED;
  371. }
  372. /* Set the desired resolution equals to current resolution */
  373. target.w = current.w;
  374. target.h = current.h;
  375. for (variation = 0; variation < 8; variation++) {
  376. /* Vary constraints on other query parameters */
  377. target.format = (variation & 1) ? current.format : 0;
  378. target.refresh_rate = (variation & 2) ? current.refresh_rate : 0;
  379. target.driverdata = (variation & 4) ? current.driverdata : 0;
  380. /* Make call */
  381. dResult = SDL_GetClosestDisplayMode(i, &target, &closest);
  382. SDLTest_AssertPass("Call to SDL_GetClosestDisplayMode(target=current/variation%d)", variation);
  383. SDLTest_Assert(dResult != NULL, "Verify returned value is not NULL");
  384. /* Check that one gets the current resolution back again */
  385. SDLTest_AssertCheck(closest.w == current.w, "Verify returned width matches current width; expected: %d, got: %d", current.w, closest.w);
  386. SDLTest_AssertCheck(closest.h == current.h, "Verify returned height matches current height; expected: %d, got: %d", current.h, closest.h);
  387. /* NOLINTBEGIN(clang-analyzer-core.NullDereference): Checked earlier for NULL */
  388. SDLTest_AssertCheck(closest.w == dResult->w, "Verify return value matches assigned value; expected: %d, got: %d", closest.w, dResult->w);
  389. SDLTest_AssertCheck(closest.h == dResult->h, "Verify return value matches assigned value; expected: %d, got: %d", closest.h, dResult->h);
  390. /* NOLINTEND(clang-analyzer-core.NullDereference) */
  391. }
  392. }
  393. return TEST_COMPLETED;
  394. }
  395. /**
  396. * @brief Tests the functionality of the SDL_GetClosestDisplayMode function against random resolution
  397. */
  398. int video_getClosestDisplayModeRandomResolution(void *arg)
  399. {
  400. SDL_DisplayMode target;
  401. SDL_DisplayMode closest;
  402. int displayNum;
  403. int i;
  404. int variation;
  405. /* Get number of displays */
  406. displayNum = SDL_GetNumVideoDisplays();
  407. SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()");
  408. /* Make calls for each display */
  409. for (i = 0; i < displayNum; i++) {
  410. SDLTest_Log("Testing against display: %d", i);
  411. for (variation = 0; variation < 16; variation++) {
  412. /* Set random constraints */
  413. target.w = (variation & 1) ? SDLTest_RandomIntegerInRange(1, 4096) : 0;
  414. target.h = (variation & 2) ? SDLTest_RandomIntegerInRange(1, 4096) : 0;
  415. target.format = (variation & 4) ? SDLTest_RandomIntegerInRange(1, 10) : 0;
  416. target.refresh_rate = (variation & 8) ? SDLTest_RandomIntegerInRange(25, 120) : 0;
  417. target.driverdata = 0;
  418. /* Make call; may or may not find anything, so don't validate any further */
  419. SDL_GetClosestDisplayMode(i, &target, &closest);
  420. SDLTest_AssertPass("Call to SDL_GetClosestDisplayMode(target=random/variation%d)", variation);
  421. }
  422. }
  423. return TEST_COMPLETED;
  424. }
  425. /**
  426. * @brief Tests call to SDL_GetWindowDisplayMode
  427. *
  428. * @sa http://wiki.libsdl.org/SDL_GetWindowDisplayMode
  429. */
  430. int video_getWindowDisplayMode(void *arg)
  431. {
  432. SDL_Window *window;
  433. const char *title = "video_getWindowDisplayMode Test Window";
  434. SDL_DisplayMode mode;
  435. int result;
  436. /* Invalidate part of the mode content so we can check values later */
  437. mode.w = -1;
  438. mode.h = -1;
  439. mode.refresh_rate = -1;
  440. /* Call against new test window */
  441. window = _createVideoSuiteTestWindow(title);
  442. if (window != NULL) {
  443. result = SDL_GetWindowDisplayMode(window, &mode);
  444. SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode()");
  445. SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
  446. SDLTest_AssertCheck(mode.w > 0, "Validate mode.w content; expected: >0, got: %d", mode.w);
  447. SDLTest_AssertCheck(mode.h > 0, "Validate mode.h content; expected: >0, got: %d", mode.h);
  448. SDLTest_AssertCheck(mode.refresh_rate > 0, "Validate mode.refresh_rate content; expected: >0, got: %d", mode.refresh_rate);
  449. }
  450. /* Clean up */
  451. _destroyVideoSuiteTestWindow(window);
  452. return TEST_COMPLETED;
  453. }
  454. /* Helper function that checks for an 'Invalid window' error */
  455. void _checkInvalidWindowError()
  456. {
  457. const char *invalidWindowError = "Invalid window";
  458. char *lastError;
  459. lastError = (char *)SDL_GetError();
  460. SDLTest_AssertPass("SDL_GetError()");
  461. SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
  462. if (lastError != NULL) {
  463. SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
  464. "SDL_GetError(): expected message '%s', was message: '%s'",
  465. invalidWindowError,
  466. lastError);
  467. SDL_ClearError();
  468. SDLTest_AssertPass("Call to SDL_ClearError()");
  469. }
  470. }
  471. /**
  472. * @brief Tests call to SDL_GetWindowDisplayMode with invalid input
  473. *
  474. * @sa http://wiki.libsdl.org/SDL_GetWindowDisplayMode
  475. */
  476. int video_getWindowDisplayModeNegative(void *arg)
  477. {
  478. const char *expectedError = "Parameter 'mode' is invalid";
  479. char *lastError;
  480. SDL_Window *window;
  481. const char *title = "video_getWindowDisplayModeNegative Test Window";
  482. SDL_DisplayMode mode;
  483. int result;
  484. /* Call against new test window */
  485. window = _createVideoSuiteTestWindow(title);
  486. if (window != NULL) {
  487. result = SDL_GetWindowDisplayMode(window, NULL);
  488. SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(...,mode=NULL)");
  489. SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result);
  490. lastError = (char *)SDL_GetError();
  491. SDLTest_AssertPass("SDL_GetError()");
  492. SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
  493. if (lastError != NULL) {
  494. SDLTest_AssertCheck(SDL_strcmp(lastError, expectedError) == 0,
  495. "SDL_GetError(): expected message '%s', was message: '%s'",
  496. expectedError,
  497. lastError);
  498. }
  499. }
  500. /* Clean up */
  501. _destroyVideoSuiteTestWindow(window);
  502. /* Call against invalid window */
  503. result = SDL_GetWindowDisplayMode(NULL, &mode);
  504. SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(window=NULL,...)");
  505. SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result);
  506. _checkInvalidWindowError();
  507. return TEST_COMPLETED;
  508. }
  509. /* Helper for setting and checking the window mouse grab state */
  510. void _setAndCheckWindowMouseGrabState(SDL_Window *window, SDL_bool desiredState)
  511. {
  512. SDL_bool currentState;
  513. /* Set state */
  514. SDL_SetWindowMouseGrab(window, desiredState);
  515. SDLTest_AssertPass("Call to SDL_SetWindowMouseGrab(%s)", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
  516. /* Get and check state */
  517. currentState = SDL_GetWindowMouseGrab(window);
  518. SDLTest_AssertPass("Call to SDL_GetWindowMouseGrab()");
  519. SDLTest_AssertCheck(
  520. currentState == desiredState,
  521. "Validate returned state; expected: %s, got: %s",
  522. (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE",
  523. (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
  524. if (desiredState) {
  525. SDLTest_AssertCheck(
  526. SDL_GetGrabbedWindow() == window,
  527. "Grabbed window should be to our window");
  528. SDLTest_AssertCheck(
  529. SDL_GetWindowGrab(window),
  530. "SDL_GetWindowGrab() should return SDL_TRUE");
  531. SDLTest_AssertCheck(
  532. SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_GRABBED,
  533. "SDL_WINDOW_MOUSE_GRABBED should be set");
  534. } else {
  535. SDLTest_AssertCheck(
  536. !(SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_GRABBED),
  537. "SDL_WINDOW_MOUSE_GRABBED should be unset");
  538. }
  539. }
  540. /* Helper for setting and checking the window keyboard grab state */
  541. void _setAndCheckWindowKeyboardGrabState(SDL_Window *window, SDL_bool desiredState)
  542. {
  543. SDL_bool currentState;
  544. /* Set state */
  545. SDL_SetWindowKeyboardGrab(window, desiredState);
  546. SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(%s)", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
  547. /* Get and check state */
  548. currentState = SDL_GetWindowKeyboardGrab(window);
  549. SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab()");
  550. SDLTest_AssertCheck(
  551. currentState == desiredState,
  552. "Validate returned state; expected: %s, got: %s",
  553. (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE",
  554. (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
  555. if (desiredState) {
  556. SDLTest_AssertCheck(
  557. SDL_GetGrabbedWindow() == window,
  558. "Grabbed window should be set to our window");
  559. SDLTest_AssertCheck(
  560. SDL_GetWindowGrab(window),
  561. "SDL_GetWindowGrab() should return SDL_TRUE");
  562. SDLTest_AssertCheck(
  563. SDL_GetWindowFlags(window) & SDL_WINDOW_KEYBOARD_GRABBED,
  564. "SDL_WINDOW_KEYBOARD_GRABBED should be set");
  565. } else {
  566. SDLTest_AssertCheck(
  567. !(SDL_GetWindowFlags(window) & SDL_WINDOW_KEYBOARD_GRABBED),
  568. "SDL_WINDOW_KEYBOARD_GRABBED should be unset");
  569. }
  570. }
  571. /**
  572. * @brief Tests keyboard and mouse grab support
  573. *
  574. * @sa http://wiki.libsdl.org/SDL_GetWindowGrab
  575. * @sa http://wiki.libsdl.org/SDL_SetWindowGrab
  576. */
  577. int video_getSetWindowGrab(void *arg)
  578. {
  579. const char *title = "video_getSetWindowGrab Test Window";
  580. SDL_Window *window;
  581. SDL_bool originalMouseState, originalKeyboardState;
  582. /* Call against new test window */
  583. window = _createVideoSuiteTestWindow(title);
  584. if (window == NULL) {
  585. return TEST_ABORTED;
  586. }
  587. /* Get state */
  588. originalMouseState = SDL_GetWindowMouseGrab(window);
  589. SDLTest_AssertPass("Call to SDL_GetWindowMouseGrab()");
  590. originalKeyboardState = SDL_GetWindowKeyboardGrab(window);
  591. SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab()");
  592. /* F */
  593. _setAndCheckWindowKeyboardGrabState(window, SDL_FALSE);
  594. _setAndCheckWindowMouseGrabState(window, SDL_FALSE);
  595. SDLTest_AssertCheck(!SDL_GetWindowGrab(window),
  596. "SDL_GetWindowGrab should return SDL_FALSE");
  597. SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL,
  598. "Expected NULL grabbed window");
  599. /* F --> F */
  600. _setAndCheckWindowMouseGrabState(window, SDL_FALSE);
  601. _setAndCheckWindowKeyboardGrabState(window, SDL_FALSE);
  602. SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL,
  603. "Expected NULL grabbed window");
  604. /* F --> T */
  605. _setAndCheckWindowMouseGrabState(window, SDL_TRUE);
  606. _setAndCheckWindowKeyboardGrabState(window, SDL_TRUE);
  607. SDLTest_AssertCheck(SDL_GetWindowGrab(window),
  608. "SDL_GetWindowGrab() should return SDL_TRUE");
  609. /* T --> T */
  610. _setAndCheckWindowKeyboardGrabState(window, SDL_TRUE);
  611. _setAndCheckWindowMouseGrabState(window, SDL_TRUE);
  612. SDLTest_AssertCheck(SDL_GetWindowGrab(window),
  613. "SDL_GetWindowGrab() should return SDL_TRUE");
  614. /* M: T --> F */
  615. /* K: T --> T */
  616. _setAndCheckWindowKeyboardGrabState(window, SDL_TRUE);
  617. _setAndCheckWindowMouseGrabState(window, SDL_FALSE);
  618. SDLTest_AssertCheck(SDL_GetWindowGrab(window),
  619. "SDL_GetWindowGrab() should return SDL_TRUE");
  620. /* M: F --> T */
  621. /* K: T --> F */
  622. _setAndCheckWindowMouseGrabState(window, SDL_TRUE);
  623. _setAndCheckWindowKeyboardGrabState(window, SDL_FALSE);
  624. SDLTest_AssertCheck(SDL_GetWindowGrab(window),
  625. "SDL_GetWindowGrab() should return SDL_TRUE");
  626. /* M: T --> F */
  627. /* K: F --> F */
  628. _setAndCheckWindowMouseGrabState(window, SDL_FALSE);
  629. _setAndCheckWindowKeyboardGrabState(window, SDL_FALSE);
  630. SDLTest_AssertCheck(!SDL_GetWindowGrab(window),
  631. "SDL_GetWindowGrab() should return SDL_FALSE");
  632. SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL,
  633. "Expected NULL grabbed window");
  634. /* Using the older SDL_SetWindowGrab API should only grab mouse by default */
  635. SDL_SetWindowGrab(window, SDL_TRUE);
  636. SDLTest_AssertPass("Call to SDL_SetWindowGrab(SDL_TRUE)");
  637. SDLTest_AssertCheck(SDL_GetWindowGrab(window),
  638. "SDL_GetWindowGrab() should return SDL_TRUE");
  639. SDLTest_AssertCheck(SDL_GetWindowMouseGrab(window),
  640. "SDL_GetWindowMouseGrab() should return SDL_TRUE");
  641. SDLTest_AssertCheck(!SDL_GetWindowKeyboardGrab(window),
  642. "SDL_GetWindowKeyboardGrab() should return SDL_FALSE");
  643. SDL_SetWindowGrab(window, SDL_FALSE);
  644. SDLTest_AssertCheck(!SDL_GetWindowGrab(window),
  645. "SDL_GetWindowGrab() should return SDL_FALSE");
  646. SDLTest_AssertCheck(!SDL_GetWindowMouseGrab(window),
  647. "SDL_GetWindowMouseGrab() should return SDL_FALSE");
  648. SDLTest_AssertCheck(!SDL_GetWindowKeyboardGrab(window),
  649. "SDL_GetWindowKeyboardGrab() should return SDL_FALSE");
  650. /* Now test with SDL_HINT_GRAB_KEYBOARD set. We should get keyboard grab now. */
  651. SDL_SetHint(SDL_HINT_GRAB_KEYBOARD, "1");
  652. SDL_SetWindowGrab(window, SDL_TRUE);
  653. SDLTest_AssertPass("Call to SDL_SetWindowGrab(SDL_TRUE)");
  654. SDLTest_AssertCheck(SDL_GetWindowGrab(window),
  655. "SDL_GetWindowGrab() should return SDL_TRUE");
  656. SDLTest_AssertCheck(SDL_GetWindowMouseGrab(window),
  657. "SDL_GetWindowMouseGrab() should return SDL_TRUE");
  658. SDLTest_AssertCheck(SDL_GetWindowKeyboardGrab(window),
  659. "SDL_GetWindowKeyboardGrab() should return SDL_TRUE");
  660. SDL_SetWindowGrab(window, SDL_FALSE);
  661. SDLTest_AssertCheck(!SDL_GetWindowGrab(window),
  662. "SDL_GetWindowGrab() should return SDL_FALSE");
  663. SDLTest_AssertCheck(!SDL_GetWindowMouseGrab(window),
  664. "SDL_GetWindowMouseGrab() should return SDL_FALSE");
  665. SDLTest_AssertCheck(!SDL_GetWindowKeyboardGrab(window),
  666. "SDL_GetWindowKeyboardGrab() should return SDL_FALSE");
  667. /* Negative tests */
  668. SDL_GetWindowGrab(NULL);
  669. SDLTest_AssertPass("Call to SDL_GetWindowGrab(window=NULL)");
  670. _checkInvalidWindowError();
  671. SDL_GetWindowKeyboardGrab(NULL);
  672. SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab(window=NULL)");
  673. _checkInvalidWindowError();
  674. SDL_SetWindowGrab(NULL, SDL_FALSE);
  675. SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
  676. _checkInvalidWindowError();
  677. SDL_SetWindowKeyboardGrab(NULL, SDL_FALSE);
  678. SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(window=NULL,SDL_FALSE)");
  679. _checkInvalidWindowError();
  680. SDL_SetWindowGrab(NULL, SDL_TRUE);
  681. SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_TRUE)");
  682. _checkInvalidWindowError();
  683. SDL_SetWindowKeyboardGrab(NULL, SDL_TRUE);
  684. SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(window=NULL,SDL_TRUE)");
  685. _checkInvalidWindowError();
  686. /* Restore state */
  687. _setAndCheckWindowMouseGrabState(window, originalMouseState);
  688. _setAndCheckWindowKeyboardGrabState(window, originalKeyboardState);
  689. /* Clean up */
  690. _destroyVideoSuiteTestWindow(window);
  691. return TEST_COMPLETED;
  692. }
  693. /**
  694. * @brief Tests call to SDL_GetWindowID and SDL_GetWindowFromID
  695. *
  696. * @sa http://wiki.libsdl.org/SDL_GetWindowID
  697. * @sa http://wiki.libsdl.org/SDL_SetWindowFromID
  698. */
  699. int video_getWindowId(void *arg)
  700. {
  701. const char *title = "video_getWindowId Test Window";
  702. SDL_Window *window;
  703. SDL_Window *result;
  704. Uint32 id, randomId;
  705. /* Call against new test window */
  706. window = _createVideoSuiteTestWindow(title);
  707. if (window == NULL) {
  708. return TEST_ABORTED;
  709. }
  710. /* Get ID */
  711. id = SDL_GetWindowID(window);
  712. SDLTest_AssertPass("Call to SDL_GetWindowID()");
  713. /* Get window from ID */
  714. result = SDL_GetWindowFromID(id);
  715. SDLTest_AssertPass("Call to SDL_GetWindowID(%" SDL_PRIu32 ")", id);
  716. SDLTest_AssertCheck(result == window, "Verify result matches window pointer");
  717. /* Get window from random large ID, no result check */
  718. randomId = SDLTest_RandomIntegerInRange(UINT8_MAX, UINT16_MAX);
  719. result = SDL_GetWindowFromID(randomId);
  720. SDLTest_AssertPass("Call to SDL_GetWindowID(%" SDL_PRIu32 "/random_large)", randomId);
  721. /* Get window from 0 and Uint32 max ID, no result check */
  722. result = SDL_GetWindowFromID(0);
  723. SDLTest_AssertPass("Call to SDL_GetWindowID(0)");
  724. result = SDL_GetWindowFromID(UINT32_MAX);
  725. SDLTest_AssertPass("Call to SDL_GetWindowID(UINT32_MAX)");
  726. /* Clean up */
  727. _destroyVideoSuiteTestWindow(window);
  728. /* Get window from ID for closed window */
  729. result = SDL_GetWindowFromID(id);
  730. SDLTest_AssertPass("Call to SDL_GetWindowID(%" SDL_PRIu32 "/closed_window)", id);
  731. SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
  732. /* Negative test */
  733. SDL_ClearError();
  734. SDLTest_AssertPass("Call to SDL_ClearError()");
  735. id = SDL_GetWindowID(NULL);
  736. SDLTest_AssertPass("Call to SDL_GetWindowID(window=NULL)");
  737. _checkInvalidWindowError();
  738. return TEST_COMPLETED;
  739. }
  740. /**
  741. * @brief Tests call to SDL_GetWindowPixelFormat
  742. *
  743. * @sa http://wiki.libsdl.org/SDL_GetWindowPixelFormat
  744. */
  745. int video_getWindowPixelFormat(void *arg)
  746. {
  747. const char *title = "video_getWindowPixelFormat Test Window";
  748. SDL_Window *window;
  749. Uint32 format;
  750. /* Call against new test window */
  751. window = _createVideoSuiteTestWindow(title);
  752. if (window == NULL) {
  753. return TEST_ABORTED;
  754. }
  755. /* Get format */
  756. format = SDL_GetWindowPixelFormat(window);
  757. SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat()");
  758. SDLTest_AssertCheck(format != SDL_PIXELFORMAT_UNKNOWN, "Verify that returned format is valid; expected: != %d, got: %" SDL_PRIu32, SDL_PIXELFORMAT_UNKNOWN, format);
  759. /* Clean up */
  760. _destroyVideoSuiteTestWindow(window);
  761. /* Negative test */
  762. SDL_ClearError();
  763. SDLTest_AssertPass("Call to SDL_ClearError()");
  764. format = SDL_GetWindowPixelFormat(NULL);
  765. SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat(window=NULL)");
  766. _checkInvalidWindowError();
  767. return TEST_COMPLETED;
  768. }
  769. /**
  770. * @brief Tests call to SDL_GetWindowPosition and SDL_SetWindowPosition
  771. *
  772. * @sa http://wiki.libsdl.org/SDL_GetWindowPosition
  773. * @sa http://wiki.libsdl.org/SDL_SetWindowPosition
  774. */
  775. int video_getSetWindowPosition(void *arg)
  776. {
  777. const char *title = "video_getSetWindowPosition Test Window";
  778. SDL_Window *window;
  779. int xVariation, yVariation;
  780. int referenceX, referenceY;
  781. int currentX, currentY;
  782. int desiredX, desiredY;
  783. /* Call against new test window */
  784. window = _createVideoSuiteTestWindow(title);
  785. if (window == NULL) {
  786. return TEST_ABORTED;
  787. }
  788. for (xVariation = 0; xVariation < 4; xVariation++) {
  789. for (yVariation = 0; yVariation < 4; yVariation++) {
  790. switch (xVariation) {
  791. default:
  792. case 0:
  793. /* Zero X Position */
  794. desiredX = 0;
  795. break;
  796. case 1:
  797. /* Random X position inside screen */
  798. desiredX = SDLTest_RandomIntegerInRange(1, 100);
  799. break;
  800. case 2:
  801. /* Random X position outside screen (positive) */
  802. desiredX = SDLTest_RandomIntegerInRange(10000, 11000);
  803. break;
  804. case 3:
  805. /* Random X position outside screen (negative) */
  806. desiredX = SDLTest_RandomIntegerInRange(-1000, -100);
  807. break;
  808. }
  809. switch (yVariation) {
  810. default:
  811. case 0:
  812. /* Zero X Position */
  813. desiredY = 0;
  814. break;
  815. case 1:
  816. /* Random X position inside screen */
  817. desiredY = SDLTest_RandomIntegerInRange(1, 100);
  818. break;
  819. case 2:
  820. /* Random X position outside screen (positive) */
  821. desiredY = SDLTest_RandomIntegerInRange(10000, 11000);
  822. break;
  823. case 3:
  824. /* Random Y position outside screen (negative) */
  825. desiredY = SDLTest_RandomIntegerInRange(-1000, -100);
  826. break;
  827. }
  828. /* Set position */
  829. SDL_SetWindowPosition(window, desiredX, desiredY);
  830. SDLTest_AssertPass("Call to SDL_SetWindowPosition(...,%d,%d)", desiredX, desiredY);
  831. /* Get position */
  832. currentX = desiredX + 1;
  833. currentY = desiredY + 1;
  834. SDL_GetWindowPosition(window, &currentX, &currentY);
  835. SDLTest_AssertPass("Call to SDL_GetWindowPosition()");
  836. SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX);
  837. SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY);
  838. /* Get position X */
  839. currentX = desiredX + 1;
  840. SDL_GetWindowPosition(window, &currentX, NULL);
  841. SDLTest_AssertPass("Call to SDL_GetWindowPosition(&y=NULL)");
  842. SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX);
  843. /* Get position Y */
  844. currentY = desiredY + 1;
  845. SDL_GetWindowPosition(window, NULL, &currentY);
  846. SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL)");
  847. SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY);
  848. }
  849. }
  850. /* Dummy call with both pointers NULL */
  851. SDL_GetWindowPosition(window, NULL, NULL);
  852. SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL,&y=NULL)");
  853. /* Clean up */
  854. _destroyVideoSuiteTestWindow(window);
  855. /* Set some 'magic' value for later check that nothing was changed */
  856. referenceX = SDLTest_RandomSint32();
  857. referenceY = SDLTest_RandomSint32();
  858. currentX = referenceX;
  859. currentY = referenceY;
  860. desiredX = SDLTest_RandomSint32();
  861. desiredY = SDLTest_RandomSint32();
  862. /* Negative tests */
  863. SDL_ClearError();
  864. SDLTest_AssertPass("Call to SDL_ClearError()");
  865. SDL_GetWindowPosition(NULL, &currentX, &currentY);
  866. SDLTest_AssertPass("Call to SDL_GetWindowPosition(window=NULL)");
  867. SDLTest_AssertCheck(
  868. currentX == referenceX && currentY == referenceY,
  869. "Verify that content of X and Y pointers has not been modified; expected: %d,%d; got: %d,%d",
  870. referenceX, referenceY,
  871. currentX, currentY);
  872. _checkInvalidWindowError();
  873. SDL_GetWindowPosition(NULL, NULL, NULL);
  874. SDLTest_AssertPass("Call to SDL_GetWindowPosition(NULL, NULL, NULL)");
  875. _checkInvalidWindowError();
  876. SDL_SetWindowPosition(NULL, desiredX, desiredY);
  877. SDLTest_AssertPass("Call to SDL_SetWindowPosition(window=NULL)");
  878. _checkInvalidWindowError();
  879. return TEST_COMPLETED;
  880. }
  881. /* Helper function that checks for an 'Invalid parameter' error */
  882. void _checkInvalidParameterError()
  883. {
  884. const char *invalidParameterError = "Parameter";
  885. char *lastError;
  886. lastError = (char *)SDL_GetError();
  887. SDLTest_AssertPass("SDL_GetError()");
  888. SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
  889. if (lastError != NULL) {
  890. SDLTest_AssertCheck(SDL_strncmp(lastError, invalidParameterError, SDL_strlen(invalidParameterError)) == 0,
  891. "SDL_GetError(): expected message starts with '%s', was message: '%s'",
  892. invalidParameterError,
  893. lastError);
  894. SDL_ClearError();
  895. SDLTest_AssertPass("Call to SDL_ClearError()");
  896. }
  897. }
  898. /**
  899. * @brief Tests call to SDL_GetWindowSize and SDL_SetWindowSize
  900. *
  901. * @sa http://wiki.libsdl.org/SDL_GetWindowSize
  902. * @sa http://wiki.libsdl.org/SDL_SetWindowSize
  903. */
  904. int video_getSetWindowSize(void *arg)
  905. {
  906. const char *title = "video_getSetWindowSize Test Window";
  907. SDL_Window *window;
  908. int result;
  909. SDL_Rect display;
  910. int maxwVariation, maxhVariation;
  911. int wVariation, hVariation;
  912. int referenceW, referenceH;
  913. int currentW, currentH;
  914. int desiredW, desiredH;
  915. /* Get display bounds for size range */
  916. result = SDL_GetDisplayBounds(0, &display);
  917. SDLTest_AssertPass("SDL_GetDisplayBounds()");
  918. SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
  919. if (result != 0) {
  920. return TEST_ABORTED;
  921. }
  922. /* Call against new test window */
  923. window = _createVideoSuiteTestWindow(title);
  924. if (window == NULL) {
  925. return TEST_ABORTED;
  926. }
  927. #ifdef __WIN32__
  928. /* Platform clips window size to screen size */
  929. maxwVariation = 4;
  930. maxhVariation = 4;
  931. #else
  932. /* Platform allows window size >= screen size */
  933. maxwVariation = 5;
  934. maxhVariation = 5;
  935. #endif
  936. for (wVariation = 0; wVariation < maxwVariation; wVariation++) {
  937. for (hVariation = 0; hVariation < maxhVariation; hVariation++) {
  938. switch (wVariation) {
  939. default:
  940. case 0:
  941. /* 1 Pixel Wide */
  942. desiredW = 1;
  943. break;
  944. case 1:
  945. /* Random width inside screen */
  946. desiredW = SDLTest_RandomIntegerInRange(1, 100);
  947. break;
  948. case 2:
  949. /* Width 1 pixel smaller than screen */
  950. desiredW = display.w - 1;
  951. break;
  952. case 3:
  953. /* Width at screen size */
  954. desiredW = display.w;
  955. break;
  956. case 4:
  957. /* Width 1 pixel larger than screen */
  958. desiredW = display.w + 1;
  959. break;
  960. }
  961. switch (hVariation) {
  962. default:
  963. case 0:
  964. /* 1 Pixel High */
  965. desiredH = 1;
  966. break;
  967. case 1:
  968. /* Random height inside screen */
  969. desiredH = SDLTest_RandomIntegerInRange(1, 100);
  970. break;
  971. case 2:
  972. /* Height 1 pixel smaller than screen */
  973. desiredH = display.h - 1;
  974. break;
  975. case 3:
  976. /* Height at screen size */
  977. desiredH = display.h;
  978. break;
  979. case 4:
  980. /* Height 1 pixel larger than screen */
  981. desiredH = display.h + 1;
  982. break;
  983. }
  984. /* Set size */
  985. SDL_SetWindowSize(window, desiredW, desiredH);
  986. SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH);
  987. /* Get size */
  988. currentW = desiredW + 1;
  989. currentH = desiredH + 1;
  990. SDL_GetWindowSize(window, &currentW, &currentH);
  991. SDLTest_AssertPass("Call to SDL_GetWindowSize()");
  992. SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
  993. SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
  994. /* Get just width */
  995. currentW = desiredW + 1;
  996. SDL_GetWindowSize(window, &currentW, NULL);
  997. SDLTest_AssertPass("Call to SDL_GetWindowSize(&h=NULL)");
  998. SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
  999. /* Get just height */
  1000. currentH = desiredH + 1;
  1001. SDL_GetWindowSize(window, NULL, &currentH);
  1002. SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL)");
  1003. SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
  1004. }
  1005. }
  1006. /* Dummy call with both pointers NULL */
  1007. SDL_GetWindowSize(window, NULL, NULL);
  1008. SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL,&h=NULL)");
  1009. /* Negative tests for parameter input */
  1010. SDL_ClearError();
  1011. SDLTest_AssertPass("Call to SDL_ClearError()");
  1012. for (desiredH = -2; desiredH < 2; desiredH++) {
  1013. for (desiredW = -2; desiredW < 2; desiredW++) {
  1014. if (desiredW <= 0 || desiredH <= 0) {
  1015. SDL_SetWindowSize(window, desiredW, desiredH);
  1016. SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH);
  1017. _checkInvalidParameterError();
  1018. }
  1019. }
  1020. }
  1021. /* Clean up */
  1022. _destroyVideoSuiteTestWindow(window);
  1023. /* Set some 'magic' value for later check that nothing was changed */
  1024. referenceW = SDLTest_RandomSint32();
  1025. referenceH = SDLTest_RandomSint32();
  1026. currentW = referenceW;
  1027. currentH = referenceH;
  1028. desiredW = SDLTest_RandomSint32();
  1029. desiredH = SDLTest_RandomSint32();
  1030. /* Negative tests for window input */
  1031. SDL_ClearError();
  1032. SDLTest_AssertPass("Call to SDL_ClearError()");
  1033. SDL_GetWindowSize(NULL, &currentW, &currentH);
  1034. SDLTest_AssertPass("Call to SDL_GetWindowSize(window=NULL)");
  1035. SDLTest_AssertCheck(
  1036. currentW == referenceW && currentH == referenceH,
  1037. "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
  1038. referenceW, referenceH,
  1039. currentW, currentH);
  1040. _checkInvalidWindowError();
  1041. SDL_GetWindowSize(NULL, NULL, NULL);
  1042. SDLTest_AssertPass("Call to SDL_GetWindowSize(NULL, NULL, NULL)");
  1043. _checkInvalidWindowError();
  1044. SDL_SetWindowSize(NULL, desiredW, desiredH);
  1045. SDLTest_AssertPass("Call to SDL_SetWindowSize(window=NULL)");
  1046. _checkInvalidWindowError();
  1047. return TEST_COMPLETED;
  1048. }
  1049. /**
  1050. * @brief Tests call to SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize
  1051. *
  1052. */
  1053. int video_getSetWindowMinimumSize(void *arg)
  1054. {
  1055. const char *title = "video_getSetWindowMinimumSize Test Window";
  1056. SDL_Window *window;
  1057. int result;
  1058. SDL_Rect display;
  1059. int wVariation, hVariation;
  1060. int referenceW, referenceH;
  1061. int currentW, currentH;
  1062. int desiredW = 1;
  1063. int desiredH = 1;
  1064. /* Get display bounds for size range */
  1065. result = SDL_GetDisplayBounds(0, &display);
  1066. SDLTest_AssertPass("SDL_GetDisplayBounds()");
  1067. SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
  1068. if (result != 0) {
  1069. return TEST_ABORTED;
  1070. }
  1071. /* Call against new test window */
  1072. window = _createVideoSuiteTestWindow(title);
  1073. if (window == NULL) {
  1074. return TEST_ABORTED;
  1075. }
  1076. for (wVariation = 0; wVariation < 5; wVariation++) {
  1077. for (hVariation = 0; hVariation < 5; hVariation++) {
  1078. switch (wVariation) {
  1079. case 0:
  1080. /* 1 Pixel Wide */
  1081. desiredW = 1;
  1082. break;
  1083. case 1:
  1084. /* Random width inside screen */
  1085. desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1);
  1086. break;
  1087. case 2:
  1088. /* Width at screen size */
  1089. desiredW = display.w;
  1090. break;
  1091. }
  1092. switch (hVariation) {
  1093. case 0:
  1094. /* 1 Pixel High */
  1095. desiredH = 1;
  1096. break;
  1097. case 1:
  1098. /* Random height inside screen */
  1099. desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1);
  1100. break;
  1101. case 2:
  1102. /* Height at screen size */
  1103. desiredH = display.h;
  1104. break;
  1105. case 4:
  1106. /* Height 1 pixel larger than screen */
  1107. desiredH = display.h + 1;
  1108. break;
  1109. }
  1110. /* Set size */
  1111. SDL_SetWindowMinimumSize(window, desiredW, desiredH);
  1112. SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH);
  1113. /* Get size */
  1114. currentW = desiredW + 1;
  1115. currentH = desiredH + 1;
  1116. SDL_GetWindowMinimumSize(window, &currentW, &currentH);
  1117. SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize()");
  1118. SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
  1119. SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
  1120. /* Get just width */
  1121. currentW = desiredW + 1;
  1122. SDL_GetWindowMinimumSize(window, &currentW, NULL);
  1123. SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&h=NULL)");
  1124. SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
  1125. /* Get just height */
  1126. currentH = desiredH + 1;
  1127. SDL_GetWindowMinimumSize(window, NULL, &currentH);
  1128. SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL)");
  1129. SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
  1130. }
  1131. }
  1132. /* Dummy call with both pointers NULL */
  1133. SDL_GetWindowMinimumSize(window, NULL, NULL);
  1134. SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL,&h=NULL)");
  1135. /* Negative tests for parameter input */
  1136. SDL_ClearError();
  1137. SDLTest_AssertPass("Call to SDL_ClearError()");
  1138. for (desiredH = -2; desiredH < 2; desiredH++) {
  1139. for (desiredW = -2; desiredW < 2; desiredW++) {
  1140. if (desiredW <= 0 || desiredH <= 0) {
  1141. SDL_SetWindowMinimumSize(window, desiredW, desiredH);
  1142. SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH);
  1143. _checkInvalidParameterError();
  1144. }
  1145. }
  1146. }
  1147. /* Clean up */
  1148. _destroyVideoSuiteTestWindow(window);
  1149. /* Set some 'magic' value for later check that nothing was changed */
  1150. referenceW = SDLTest_RandomSint32();
  1151. referenceH = SDLTest_RandomSint32();
  1152. currentW = referenceW;
  1153. currentH = referenceH;
  1154. desiredW = SDLTest_RandomSint32();
  1155. desiredH = SDLTest_RandomSint32();
  1156. /* Negative tests for window input */
  1157. SDL_ClearError();
  1158. SDLTest_AssertPass("Call to SDL_ClearError()");
  1159. SDL_GetWindowMinimumSize(NULL, &currentW, &currentH);
  1160. SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(window=NULL)");
  1161. SDLTest_AssertCheck(
  1162. currentW == referenceW && currentH == referenceH,
  1163. "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
  1164. referenceW, referenceH,
  1165. currentW, currentH);
  1166. _checkInvalidWindowError();
  1167. SDL_GetWindowMinimumSize(NULL, NULL, NULL);
  1168. SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(NULL, NULL, NULL)");
  1169. _checkInvalidWindowError();
  1170. SDL_SetWindowMinimumSize(NULL, desiredW, desiredH);
  1171. SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(window=NULL)");
  1172. _checkInvalidWindowError();
  1173. return TEST_COMPLETED;
  1174. }
  1175. /**
  1176. * @brief Tests call to SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize
  1177. *
  1178. */
  1179. int video_getSetWindowMaximumSize(void *arg)
  1180. {
  1181. const char *title = "video_getSetWindowMaximumSize Test Window";
  1182. SDL_Window *window;
  1183. int result;
  1184. SDL_Rect display;
  1185. int wVariation, hVariation;
  1186. int referenceW, referenceH;
  1187. int currentW, currentH;
  1188. int desiredW, desiredH;
  1189. /* Get display bounds for size range */
  1190. result = SDL_GetDisplayBounds(0, &display);
  1191. SDLTest_AssertPass("SDL_GetDisplayBounds()");
  1192. SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
  1193. if (result != 0) {
  1194. return TEST_ABORTED;
  1195. }
  1196. /* Call against new test window */
  1197. window = _createVideoSuiteTestWindow(title);
  1198. if (window == NULL) {
  1199. return TEST_ABORTED;
  1200. }
  1201. for (wVariation = 0; wVariation < 3; wVariation++) {
  1202. for (hVariation = 0; hVariation < 3; hVariation++) {
  1203. switch (wVariation) {
  1204. case 0:
  1205. /* 1 Pixel Wide */
  1206. desiredW = 1;
  1207. break;
  1208. case 1:
  1209. /* Random width inside screen */
  1210. desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1);
  1211. break;
  1212. case 2:
  1213. /* Width at screen size */
  1214. desiredW = display.w;
  1215. break;
  1216. }
  1217. switch (hVariation) {
  1218. case 0:
  1219. /* 1 Pixel High */
  1220. desiredH = 1;
  1221. break;
  1222. case 1:
  1223. /* Random height inside screen */
  1224. desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1);
  1225. break;
  1226. case 2:
  1227. /* Height at screen size */
  1228. desiredH = display.h;
  1229. break;
  1230. }
  1231. /* Set size */
  1232. SDL_SetWindowMaximumSize(window, desiredW, desiredH);
  1233. SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH);
  1234. /* Get size */
  1235. currentW = desiredW + 1;
  1236. currentH = desiredH + 1;
  1237. SDL_GetWindowMaximumSize(window, &currentW, &currentH);
  1238. SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize()");
  1239. SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
  1240. SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
  1241. /* Get just width */
  1242. currentW = desiredW + 1;
  1243. SDL_GetWindowMaximumSize(window, &currentW, NULL);
  1244. SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&h=NULL)");
  1245. SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
  1246. /* Get just height */
  1247. currentH = desiredH + 1;
  1248. SDL_GetWindowMaximumSize(window, NULL, &currentH);
  1249. SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL)");
  1250. SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
  1251. }
  1252. }
  1253. /* Dummy call with both pointers NULL */
  1254. SDL_GetWindowMaximumSize(window, NULL, NULL);
  1255. SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL,&h=NULL)");
  1256. /* Negative tests for parameter input */
  1257. SDL_ClearError();
  1258. SDLTest_AssertPass("Call to SDL_ClearError()");
  1259. for (desiredH = -2; desiredH < 2; desiredH++) {
  1260. for (desiredW = -2; desiredW < 2; desiredW++) {
  1261. if (desiredW <= 0 || desiredH <= 0) {
  1262. SDL_SetWindowMaximumSize(window, desiredW, desiredH);
  1263. SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH);
  1264. _checkInvalidParameterError();
  1265. }
  1266. }
  1267. }
  1268. /* Clean up */
  1269. _destroyVideoSuiteTestWindow(window);
  1270. /* Set some 'magic' value for later check that nothing was changed */
  1271. referenceW = SDLTest_RandomSint32();
  1272. referenceH = SDLTest_RandomSint32();
  1273. currentW = referenceW;
  1274. currentH = referenceH;
  1275. desiredW = SDLTest_RandomSint32();
  1276. desiredH = SDLTest_RandomSint32();
  1277. /* Negative tests */
  1278. SDL_ClearError();
  1279. SDLTest_AssertPass("Call to SDL_ClearError()");
  1280. SDL_GetWindowMaximumSize(NULL, &currentW, &currentH);
  1281. SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(window=NULL)");
  1282. SDLTest_AssertCheck(
  1283. currentW == referenceW && currentH == referenceH,
  1284. "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
  1285. referenceW, referenceH,
  1286. currentW, currentH);
  1287. _checkInvalidWindowError();
  1288. SDL_GetWindowMaximumSize(NULL, NULL, NULL);
  1289. SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(NULL, NULL, NULL)");
  1290. _checkInvalidWindowError();
  1291. SDL_SetWindowMaximumSize(NULL, desiredW, desiredH);
  1292. SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(window=NULL)");
  1293. _checkInvalidWindowError();
  1294. return TEST_COMPLETED;
  1295. }
  1296. /**
  1297. * @brief Tests call to SDL_SetWindowData and SDL_GetWindowData
  1298. *
  1299. * @sa http://wiki.libsdl.org/SDL_SetWindowData
  1300. * @sa http://wiki.libsdl.org/SDL_GetWindowData
  1301. */
  1302. int video_getSetWindowData(void *arg)
  1303. {
  1304. int returnValue = TEST_COMPLETED;
  1305. const char *title = "video_setGetWindowData Test Window";
  1306. SDL_Window *window;
  1307. const char *referenceName = "TestName";
  1308. const char *name = "TestName";
  1309. const char *referenceName2 = "TestName2";
  1310. const char *name2 = "TestName2";
  1311. int datasize;
  1312. char *referenceUserdata = NULL;
  1313. char *userdata = NULL;
  1314. char *referenceUserdata2 = NULL;
  1315. char *userdata2 = NULL;
  1316. char *result;
  1317. int iteration;
  1318. /* Call against new test window */
  1319. window = _createVideoSuiteTestWindow(title);
  1320. if (window == NULL) {
  1321. return TEST_ABORTED;
  1322. }
  1323. /* Create testdata */
  1324. datasize = SDLTest_RandomIntegerInRange(1, 32);
  1325. referenceUserdata = SDLTest_RandomAsciiStringOfSize(datasize);
  1326. if (referenceUserdata == NULL) {
  1327. returnValue = TEST_ABORTED;
  1328. goto cleanup;
  1329. }
  1330. userdata = SDL_strdup(referenceUserdata);
  1331. if (userdata == NULL) {
  1332. returnValue = TEST_ABORTED;
  1333. goto cleanup;
  1334. }
  1335. datasize = SDLTest_RandomIntegerInRange(1, 32);
  1336. referenceUserdata2 = SDLTest_RandomAsciiStringOfSize(datasize);
  1337. if (referenceUserdata2 == NULL) {
  1338. returnValue = TEST_ABORTED;
  1339. goto cleanup;
  1340. }
  1341. userdata2 = SDL_strdup(referenceUserdata2);
  1342. if (userdata2 == NULL) {
  1343. returnValue = TEST_ABORTED;
  1344. goto cleanup;
  1345. }
  1346. /* Get non-existent data */
  1347. result = (char *)SDL_GetWindowData(window, name);
  1348. SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name);
  1349. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1350. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1351. /* Set data */
  1352. result = (char *)SDL_SetWindowData(window, name, userdata);
  1353. SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s)", name, userdata);
  1354. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1355. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1356. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
  1357. /* Get data (twice) */
  1358. for (iteration = 1; iteration <= 2; iteration++) {
  1359. result = (char *)SDL_GetWindowData(window, name);
  1360. SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [iteration %d]", name, iteration);
  1361. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
  1362. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1363. }
  1364. /* Set data again twice */
  1365. for (iteration = 1; iteration <= 2; iteration++) {
  1366. result = (char *)SDL_SetWindowData(window, name, userdata);
  1367. SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [iteration %d]", name, userdata, iteration);
  1368. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
  1369. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1370. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
  1371. }
  1372. /* Get data again */
  1373. result = (char *)SDL_GetWindowData(window, name);
  1374. SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [again]", name);
  1375. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
  1376. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1377. /* Set data with new data */
  1378. result = (char *)SDL_SetWindowData(window, name, userdata2);
  1379. SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [new userdata]", name, userdata2);
  1380. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
  1381. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1382. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
  1383. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
  1384. /* Set data with new data again */
  1385. result = (char *)SDL_SetWindowData(window, name, userdata2);
  1386. SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [new userdata again]", name, userdata2);
  1387. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result);
  1388. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1389. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
  1390. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
  1391. /* Get new data */
  1392. result = (char *)SDL_GetWindowData(window, name);
  1393. SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name);
  1394. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result);
  1395. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1396. /* Set data with NULL to clear */
  1397. result = (char *)SDL_SetWindowData(window, name, NULL);
  1398. SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,NULL)", name);
  1399. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result);
  1400. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1401. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
  1402. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
  1403. /* Set data with NULL to clear again */
  1404. result = (char *)SDL_SetWindowData(window, name, NULL);
  1405. SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,NULL) [again]", name);
  1406. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1407. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1408. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
  1409. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
  1410. /* Get non-existent data */
  1411. result = (char *)SDL_GetWindowData(window, name);
  1412. SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name);
  1413. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1414. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1415. /* Get non-existent data new name */
  1416. result = (char *)SDL_GetWindowData(window, name2);
  1417. SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name2);
  1418. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1419. SDLTest_AssertCheck(SDL_strcmp(referenceName2, name2) == 0, "Validate that name2 was not changed, expected: %s, got: %s", referenceName2, name2);
  1420. /* Set data (again) */
  1421. result = (char *)SDL_SetWindowData(window, name, userdata);
  1422. SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [again, after clear]", name, userdata);
  1423. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1424. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1425. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
  1426. /* Get data (again) */
  1427. result = (char *)SDL_GetWindowData(window, name);
  1428. SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [again, after clear]", name);
  1429. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
  1430. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1431. /* Negative test */
  1432. SDL_ClearError();
  1433. SDLTest_AssertPass("Call to SDL_ClearError()");
  1434. /* Set with invalid window */
  1435. result = (char *)SDL_SetWindowData(NULL, name, userdata);
  1436. SDLTest_AssertPass("Call to SDL_SetWindowData(window=NULL)");
  1437. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1438. _checkInvalidWindowError();
  1439. /* Set data with NULL name, valid userdata */
  1440. result = (char *)SDL_SetWindowData(window, NULL, userdata);
  1441. SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL)");
  1442. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1443. _checkInvalidParameterError();
  1444. /* Set data with empty name, valid userdata */
  1445. result = (char *)SDL_SetWindowData(window, "", userdata);
  1446. SDLTest_AssertPass("Call to SDL_SetWindowData(name='')");
  1447. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1448. _checkInvalidParameterError();
  1449. /* Set data with NULL name, NULL userdata */
  1450. result = (char *)SDL_SetWindowData(window, NULL, NULL);
  1451. SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL,userdata=NULL)");
  1452. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1453. _checkInvalidParameterError();
  1454. /* Set data with empty name, NULL userdata */
  1455. result = (char *)SDL_SetWindowData(window, "", NULL);
  1456. SDLTest_AssertPass("Call to SDL_SetWindowData(name='',userdata=NULL)");
  1457. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1458. _checkInvalidParameterError();
  1459. /* Get with invalid window */
  1460. result = (char *)SDL_GetWindowData(NULL, name);
  1461. SDLTest_AssertPass("Call to SDL_GetWindowData(window=NULL)");
  1462. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1463. _checkInvalidWindowError();
  1464. /* Get data with NULL name */
  1465. result = (char *)SDL_GetWindowData(window, NULL);
  1466. SDLTest_AssertPass("Call to SDL_GetWindowData(name=NULL)");
  1467. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1468. _checkInvalidParameterError();
  1469. /* Get data with empty name */
  1470. result = (char *)SDL_GetWindowData(window, "");
  1471. SDLTest_AssertPass("Call to SDL_GetWindowData(name='')");
  1472. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1473. _checkInvalidParameterError();
  1474. /* Clean up */
  1475. _destroyVideoSuiteTestWindow(window);
  1476. cleanup:
  1477. SDL_free(referenceUserdata);
  1478. SDL_free(referenceUserdata2);
  1479. SDL_free(userdata);
  1480. SDL_free(userdata2);
  1481. return returnValue;
  1482. }
  1483. /**
  1484. * @brief Tests the functionality of the SDL_WINDOWPOS_CENTERED_DISPLAY along with SDL_WINDOW_FULLSCREEN_DESKTOP.
  1485. *
  1486. * Espeically useful when run on a multi-monitor system with different DPI scales per monitor,
  1487. * to test that the window size is maintained when moving between monitors.
  1488. */
  1489. int video_setWindowCenteredOnDisplay(void *arg)
  1490. {
  1491. SDL_Window *window;
  1492. const char *title = "video_setWindowCenteredOnDisplay Test Window";
  1493. int x, y, w, h;
  1494. int xVariation, yVariation;
  1495. int displayNum;
  1496. int result;
  1497. SDL_Rect display0, display1;
  1498. displayNum = SDL_GetNumVideoDisplays();
  1499. /* Get display bounds */
  1500. result = SDL_GetDisplayBounds(0 % displayNum, &display0);
  1501. SDLTest_AssertPass("SDL_GetDisplayBounds()");
  1502. SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
  1503. if (result != 0) {
  1504. return TEST_ABORTED;
  1505. }
  1506. result = SDL_GetDisplayBounds(1 % displayNum, &display1);
  1507. SDLTest_AssertPass("SDL_GetDisplayBounds()");
  1508. SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
  1509. if (result != 0) {
  1510. return TEST_ABORTED;
  1511. }
  1512. for (xVariation = 0; xVariation < 2; xVariation++) {
  1513. for (yVariation = 0; yVariation < 2; yVariation++) {
  1514. int currentX = 0, currentY = 0;
  1515. int currentW = 0, currentH = 0;
  1516. int expectedX = 0, expectedY = 0;
  1517. int currentDisplay;
  1518. int expectedDisplay;
  1519. SDL_Rect expectedDisplayRect;
  1520. /* xVariation is the display we start on */
  1521. expectedDisplay = xVariation % displayNum;
  1522. x = SDL_WINDOWPOS_CENTERED_DISPLAY(expectedDisplay);
  1523. y = SDL_WINDOWPOS_CENTERED_DISPLAY(expectedDisplay);
  1524. w = SDLTest_RandomIntegerInRange(640, 800);
  1525. h = SDLTest_RandomIntegerInRange(400, 600);
  1526. expectedDisplayRect = (xVariation == 0) ? display0 : display1;
  1527. expectedX = (expectedDisplayRect.x + ((expectedDisplayRect.w - w) / 2));
  1528. expectedY = (expectedDisplayRect.y + ((expectedDisplayRect.h - h) / 2));
  1529. window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI);
  1530. SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h);
  1531. SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
  1532. /* Check the window is centered on the requested display */
  1533. currentDisplay = SDL_GetWindowDisplayIndex(window);
  1534. SDL_GetWindowSize(window, &currentW, &currentH);
  1535. SDL_GetWindowPosition(window, &currentX, &currentY);
  1536. SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay);
  1537. SDLTest_AssertCheck(currentW == w, "Validate width (current: %d, expected: %d)", currentW, w);
  1538. SDLTest_AssertCheck(currentH == h, "Validate height (current: %d, expected: %d)", currentH, h);
  1539. SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX);
  1540. SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY);
  1541. /* Enter fullscreen desktop */
  1542. result = SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
  1543. SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
  1544. /* Check we are filling the full display */
  1545. currentDisplay = SDL_GetWindowDisplayIndex(window);
  1546. SDL_GetWindowSize(window, &currentW, &currentH);
  1547. SDL_GetWindowPosition(window, &currentX, &currentY);
  1548. SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay);
  1549. SDLTest_AssertCheck(currentW == expectedDisplayRect.w, "Validate width (current: %d, expected: %d)", currentW, expectedDisplayRect.w);
  1550. SDLTest_AssertCheck(currentH == expectedDisplayRect.h, "Validate height (current: %d, expected: %d)", currentH, expectedDisplayRect.h);
  1551. SDLTest_AssertCheck(currentX == expectedDisplayRect.x, "Validate x (current: %d, expected: %d)", currentX, expectedDisplayRect.x);
  1552. SDLTest_AssertCheck(currentY == expectedDisplayRect.y, "Validate y (current: %d, expected: %d)", currentY, expectedDisplayRect.y);
  1553. /* Leave fullscreen desktop */
  1554. result = SDL_SetWindowFullscreen(window, 0);
  1555. SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
  1556. /* Check window was restored correctly */
  1557. currentDisplay = SDL_GetWindowDisplayIndex(window);
  1558. SDL_GetWindowSize(window, &currentW, &currentH);
  1559. SDL_GetWindowPosition(window, &currentX, &currentY);
  1560. SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay);
  1561. SDLTest_AssertCheck(currentW == w, "Validate width (current: %d, expected: %d)", currentW, w);
  1562. SDLTest_AssertCheck(currentH == h, "Validate height (current: %d, expected: %d)", currentH, h);
  1563. SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX);
  1564. SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY);
  1565. /* Center on display yVariation, and check window properties */
  1566. expectedDisplay = yVariation % displayNum;
  1567. x = SDL_WINDOWPOS_CENTERED_DISPLAY(expectedDisplay);
  1568. y = SDL_WINDOWPOS_CENTERED_DISPLAY(expectedDisplay);
  1569. expectedDisplayRect = (expectedDisplay == 0) ? display0 : display1;
  1570. expectedX = (expectedDisplayRect.x + ((expectedDisplayRect.w - w) / 2));
  1571. expectedY = (expectedDisplayRect.y + ((expectedDisplayRect.h - h) / 2));
  1572. SDL_SetWindowPosition(window, x, y);
  1573. currentDisplay = SDL_GetWindowDisplayIndex(window);
  1574. SDL_GetWindowSize(window, &currentW, &currentH);
  1575. SDL_GetWindowPosition(window, &currentX, &currentY);
  1576. SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay);
  1577. SDLTest_AssertCheck(currentW == w, "Validate width (current: %d, expected: %d)", currentW, w);
  1578. SDLTest_AssertCheck(currentH == h, "Validate height (current: %d, expected: %d)", currentH, h);
  1579. SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX);
  1580. SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY);
  1581. /* Clean up */
  1582. _destroyVideoSuiteTestWindow(window);
  1583. }
  1584. }
  1585. return TEST_COMPLETED;
  1586. }
  1587. /* ================= Test References ================== */
  1588. /* Video test cases */
  1589. static const SDLTest_TestCaseReference videoTest1 = {
  1590. (SDLTest_TestCaseFp)video_enableDisableScreensaver, "video_enableDisableScreensaver", "Enable and disable screenaver while checking state", TEST_ENABLED
  1591. };
  1592. static const SDLTest_TestCaseReference videoTest2 = {
  1593. (SDLTest_TestCaseFp)video_createWindowVariousPositions, "video_createWindowVariousPositions", "Create windows at various locations", TEST_ENABLED
  1594. };
  1595. static const SDLTest_TestCaseReference videoTest3 = {
  1596. (SDLTest_TestCaseFp)video_createWindowVariousSizes, "video_createWindowVariousSizes", "Create windows with various sizes", TEST_ENABLED
  1597. };
  1598. static const SDLTest_TestCaseReference videoTest4 = {
  1599. (SDLTest_TestCaseFp)video_createWindowVariousFlags, "video_createWindowVariousFlags", "Create windows using various flags", TEST_ENABLED
  1600. };
  1601. static const SDLTest_TestCaseReference videoTest5 = {
  1602. (SDLTest_TestCaseFp)video_getWindowFlags, "video_getWindowFlags", "Get window flags set during SDL_CreateWindow", TEST_ENABLED
  1603. };
  1604. static const SDLTest_TestCaseReference videoTest6 = {
  1605. (SDLTest_TestCaseFp)video_getNumDisplayModes, "video_getNumDisplayModes", "Use SDL_GetNumDisplayModes function to get number of display modes", TEST_ENABLED
  1606. };
  1607. static const SDLTest_TestCaseReference videoTest7 = {
  1608. (SDLTest_TestCaseFp)video_getNumDisplayModesNegative, "video_getNumDisplayModesNegative", "Negative tests for SDL_GetNumDisplayModes", TEST_ENABLED
  1609. };
  1610. static const SDLTest_TestCaseReference videoTest8 = {
  1611. (SDLTest_TestCaseFp)video_getClosestDisplayModeCurrentResolution, "video_getClosestDisplayModeCurrentResolution", "Use function to get closes match to requested display mode for current resolution", TEST_ENABLED
  1612. };
  1613. static const SDLTest_TestCaseReference videoTest9 = {
  1614. (SDLTest_TestCaseFp)video_getClosestDisplayModeRandomResolution, "video_getClosestDisplayModeRandomResolution", "Use function to get closes match to requested display mode for random resolution", TEST_ENABLED
  1615. };
  1616. static const SDLTest_TestCaseReference videoTest10 = {
  1617. (SDLTest_TestCaseFp)video_getWindowDisplayMode, "video_getWindowDisplayMode", "Get window display mode", TEST_ENABLED
  1618. };
  1619. static const SDLTest_TestCaseReference videoTest11 = {
  1620. (SDLTest_TestCaseFp)video_getWindowDisplayModeNegative, "video_getWindowDisplayModeNegative", "Get window display mode with invalid input", TEST_ENABLED
  1621. };
  1622. static const SDLTest_TestCaseReference videoTest12 = {
  1623. (SDLTest_TestCaseFp)video_getSetWindowGrab, "video_getSetWindowGrab", "Checks SDL_GetWindowGrab and SDL_SetWindowGrab positive and negative cases", TEST_ENABLED
  1624. };
  1625. static const SDLTest_TestCaseReference videoTest13 = {
  1626. (SDLTest_TestCaseFp)video_getWindowId, "video_getWindowId", "Checks SDL_GetWindowID and SDL_GetWindowFromID", TEST_ENABLED
  1627. };
  1628. static const SDLTest_TestCaseReference videoTest14 = {
  1629. (SDLTest_TestCaseFp)video_getWindowPixelFormat, "video_getWindowPixelFormat", "Checks SDL_GetWindowPixelFormat", TEST_ENABLED
  1630. };
  1631. static const SDLTest_TestCaseReference videoTest15 = {
  1632. (SDLTest_TestCaseFp)video_getSetWindowPosition, "video_getSetWindowPosition", "Checks SDL_GetWindowPosition and SDL_SetWindowPosition positive and negative cases", TEST_ENABLED
  1633. };
  1634. static const SDLTest_TestCaseReference videoTest16 = {
  1635. (SDLTest_TestCaseFp)video_getSetWindowSize, "video_getSetWindowSize", "Checks SDL_GetWindowSize and SDL_SetWindowSize positive and negative cases", TEST_ENABLED
  1636. };
  1637. static const SDLTest_TestCaseReference videoTest17 = {
  1638. (SDLTest_TestCaseFp)video_getSetWindowMinimumSize, "video_getSetWindowMinimumSize", "Checks SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize positive and negative cases", TEST_ENABLED
  1639. };
  1640. static const SDLTest_TestCaseReference videoTest18 = {
  1641. (SDLTest_TestCaseFp)video_getSetWindowMaximumSize, "video_getSetWindowMaximumSize", "Checks SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize positive and negative cases", TEST_ENABLED
  1642. };
  1643. static const SDLTest_TestCaseReference videoTest19 = {
  1644. (SDLTest_TestCaseFp)video_getSetWindowData, "video_getSetWindowData", "Checks SDL_SetWindowData and SDL_GetWindowData positive and negative cases", TEST_ENABLED
  1645. };
  1646. static const SDLTest_TestCaseReference videoTest20 = {
  1647. (SDLTest_TestCaseFp)video_setWindowCenteredOnDisplay, "video_setWindowCenteredOnDisplay", "Checks using SDL_WINDOWPOS_CENTERED_DISPLAY centers the window on a display", TEST_ENABLED
  1648. };
  1649. /* Sequence of Video test cases */
  1650. static const SDLTest_TestCaseReference *videoTests[] = {
  1651. &videoTest1, &videoTest2, &videoTest3, &videoTest4, &videoTest5, &videoTest6,
  1652. &videoTest7, &videoTest8, &videoTest9, &videoTest10, &videoTest11, &videoTest12,
  1653. &videoTest13, &videoTest14, &videoTest15, &videoTest16, &videoTest17,
  1654. &videoTest18, &videoTest19, &videoTest20, NULL
  1655. };
  1656. /* Video test suite (global) */
  1657. SDLTest_TestSuiteReference videoTestSuite = {
  1658. "Video",
  1659. NULL,
  1660. videoTests,
  1661. NULL
  1662. };
  1663. /* vi: set ts=4 sw=4 expandtab: */