testautomation_video.c 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927
  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. static 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_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. static 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_ScreenSaverEnabled();
  47. SDLTest_AssertPass("Call to SDL_ScreenSaverEnabled()");
  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_ScreenSaverEnabled();
  54. SDLTest_AssertPass("Call to SDL_ScreenSaverEnabled()");
  55. SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_ScreenSaverEnabled, 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_ScreenSaverEnabled();
  60. SDLTest_AssertPass("Call to SDL_ScreenSaverEnabled()");
  61. SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_ScreenSaverEnabled, 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_ScreenSaverEnabled();
  68. SDLTest_AssertPass("Call to SDL_ScreenSaverEnabled()");
  69. SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_ScreenSaverEnabled, 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_ScreenSaverEnabled();
  74. SDLTest_AssertPass("Call to SDL_ScreenSaverEnabled()");
  75. SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_ScreenSaverEnabled, 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, 0);
  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, 0);
  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_EXCLUSIVE;
  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 = 0;
  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 = 0;
  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. SDL_zero(target);
  374. target.pixel_w = current.pixel_w;
  375. target.pixel_h = current.pixel_h;
  376. for (variation = 0; variation < 8; variation++) {
  377. /* Vary constraints on other query parameters */
  378. target.format = (variation & 1) ? current.format : 0;
  379. target.refresh_rate = (variation & 2) ? current.refresh_rate : 0.0f;
  380. target.driverdata = (variation & 4) ? current.driverdata : 0;
  381. /* Make call */
  382. dResult = SDL_GetClosestDisplayMode(i, &target, &closest);
  383. SDLTest_AssertPass("Call to SDL_GetClosestDisplayMode(target=current/variation%d)", variation);
  384. SDLTest_Assert(dResult != NULL, "Verify returned value is not NULL");
  385. /* Check that one gets the current resolution back again */
  386. SDLTest_AssertCheck(closest.pixel_w == current.pixel_w, "Verify returned width matches current width; expected: %d, got: %d", current.pixel_w, closest.pixel_w);
  387. SDLTest_AssertCheck(closest.pixel_h == current.pixel_h, "Verify returned height matches current height; expected: %d, got: %d", current.pixel_h, closest.pixel_h);
  388. /* NOLINTBEGIN(clang-analyzer-core.NullDereference): Checked earlier for NULL */
  389. SDLTest_AssertCheck(closest.pixel_w == dResult->pixel_w, "Verify return value matches assigned value; expected: %d, got: %d", closest.pixel_w, dResult->pixel_w);
  390. SDLTest_AssertCheck(closest.pixel_h == dResult->pixel_h, "Verify return value matches assigned value; expected: %d, got: %d", closest.pixel_h, dResult->pixel_h);
  391. /* NOLINTEND(clang-analyzer-core.NullDereference) */
  392. }
  393. }
  394. return TEST_COMPLETED;
  395. }
  396. /**
  397. * @brief Tests the functionality of the SDL_GetClosestDisplayMode function against random resolution
  398. */
  399. int video_getClosestDisplayModeRandomResolution(void *arg)
  400. {
  401. SDL_DisplayMode target;
  402. SDL_DisplayMode closest;
  403. int displayNum;
  404. int i;
  405. int variation;
  406. /* Get number of displays */
  407. displayNum = SDL_GetNumVideoDisplays();
  408. SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()");
  409. /* Make calls for each display */
  410. for (i = 0; i < displayNum; i++) {
  411. SDLTest_Log("Testing against display: %d", i);
  412. for (variation = 0; variation < 16; variation++) {
  413. /* Set random constraints */
  414. SDL_zero(target);
  415. target.pixel_w = (variation & 1) ? SDLTest_RandomIntegerInRange(1, 4096) : 0;
  416. target.pixel_h = (variation & 2) ? SDLTest_RandomIntegerInRange(1, 4096) : 0;
  417. target.format = (variation & 4) ? SDLTest_RandomIntegerInRange(1, 10) : 0;
  418. target.refresh_rate = (variation & 8) ? (float)SDLTest_RandomIntegerInRange(25, 120) : 0.0f;
  419. /* Make call; may or may not find anything, so don't validate any further */
  420. SDL_GetClosestDisplayMode(i, &target, &closest);
  421. SDLTest_AssertPass("Call to SDL_GetClosestDisplayMode(target=random/variation%d)", variation);
  422. }
  423. }
  424. return TEST_COMPLETED;
  425. }
  426. /**
  427. * @brief Tests call to SDL_GetWindowDisplayMode
  428. *
  429. * @sa http://wiki.libsdl.org/SDL_GetWindowDisplayMode
  430. */
  431. int video_getWindowDisplayMode(void *arg)
  432. {
  433. SDL_Window *window;
  434. const char *title = "video_getWindowDisplayMode Test Window";
  435. SDL_DisplayMode mode;
  436. int result;
  437. /* Invalidate part of the mode content so we can check values later */
  438. mode.pixel_w = -1;
  439. mode.pixel_h = -1;
  440. mode.refresh_rate = -1.0f;
  441. /* Call against new test window */
  442. window = createVideoSuiteTestWindow(title);
  443. if (window != NULL) {
  444. result = SDL_GetWindowDisplayMode(window, &mode);
  445. SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode()");
  446. SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
  447. SDLTest_AssertCheck(mode.pixel_w > 0, "Validate mode.w content; expected: >0, got: %d", mode.pixel_w);
  448. SDLTest_AssertCheck(mode.pixel_h > 0, "Validate mode.h content; expected: >0, got: %d", mode.pixel_h);
  449. SDLTest_AssertCheck(mode.refresh_rate > 0.0f, "Validate mode.refresh_rate content; expected: >0, got: %g", mode.refresh_rate);
  450. }
  451. /* Clean up */
  452. destroyVideoSuiteTestWindow(window);
  453. return TEST_COMPLETED;
  454. }
  455. /* Helper function that checks for an 'Invalid window' error */
  456. static void checkInvalidWindowError()
  457. {
  458. const char *invalidWindowError = "Invalid window";
  459. char *lastError;
  460. lastError = (char *)SDL_GetError();
  461. SDLTest_AssertPass("SDL_GetError()");
  462. SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
  463. if (lastError != NULL) {
  464. SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
  465. "SDL_GetError(): expected message '%s', was message: '%s'",
  466. invalidWindowError,
  467. lastError);
  468. SDL_ClearError();
  469. SDLTest_AssertPass("Call to SDL_ClearError()");
  470. }
  471. }
  472. /**
  473. * @brief Tests call to SDL_GetWindowDisplayMode with invalid input
  474. *
  475. * @sa http://wiki.libsdl.org/SDL_GetWindowDisplayMode
  476. */
  477. int video_getWindowDisplayModeNegative(void *arg)
  478. {
  479. const char *expectedError = "Parameter 'mode' is invalid";
  480. char *lastError;
  481. SDL_Window *window;
  482. const char *title = "video_getWindowDisplayModeNegative Test Window";
  483. SDL_DisplayMode mode;
  484. int result;
  485. /* Call against new test window */
  486. window = createVideoSuiteTestWindow(title);
  487. if (window != NULL) {
  488. result = SDL_GetWindowDisplayMode(window, NULL);
  489. SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(...,mode=NULL)");
  490. SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result);
  491. lastError = (char *)SDL_GetError();
  492. SDLTest_AssertPass("SDL_GetError()");
  493. SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
  494. if (lastError != NULL) {
  495. SDLTest_AssertCheck(SDL_strcmp(lastError, expectedError) == 0,
  496. "SDL_GetError(): expected message '%s', was message: '%s'",
  497. expectedError,
  498. lastError);
  499. }
  500. }
  501. /* Clean up */
  502. destroyVideoSuiteTestWindow(window);
  503. /* Call against invalid window */
  504. result = SDL_GetWindowDisplayMode(NULL, &mode);
  505. SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(window=NULL,...)");
  506. SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result);
  507. checkInvalidWindowError();
  508. return TEST_COMPLETED;
  509. }
  510. /* Helper for setting and checking the window mouse grab state */
  511. static void setAndCheckWindowMouseGrabState(SDL_Window *window, SDL_bool desiredState)
  512. {
  513. SDL_bool currentState;
  514. /* Set state */
  515. SDL_SetWindowMouseGrab(window, desiredState);
  516. SDLTest_AssertPass("Call to SDL_SetWindowMouseGrab(%s)", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
  517. /* Get and check state */
  518. currentState = SDL_GetWindowMouseGrab(window);
  519. SDLTest_AssertPass("Call to SDL_GetWindowMouseGrab()");
  520. SDLTest_AssertCheck(
  521. currentState == desiredState,
  522. "Validate returned state; expected: %s, got: %s",
  523. (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE",
  524. (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
  525. if (desiredState) {
  526. SDLTest_AssertCheck(
  527. SDL_GetGrabbedWindow() == window,
  528. "Grabbed window should be to our window");
  529. SDLTest_AssertCheck(
  530. SDL_GetWindowGrab(window),
  531. "SDL_GetWindowGrab() should return SDL_TRUE");
  532. SDLTest_AssertCheck(
  533. SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_GRABBED,
  534. "SDL_WINDOW_MOUSE_GRABBED should be set");
  535. } else {
  536. SDLTest_AssertCheck(
  537. !(SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_GRABBED),
  538. "SDL_WINDOW_MOUSE_GRABBED should be unset");
  539. }
  540. }
  541. /* Helper for setting and checking the window keyboard grab state */
  542. static void setAndCheckWindowKeyboardGrabState(SDL_Window *window, SDL_bool desiredState)
  543. {
  544. SDL_bool currentState;
  545. /* Set state */
  546. SDL_SetWindowKeyboardGrab(window, desiredState);
  547. SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(%s)", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
  548. /* Get and check state */
  549. currentState = SDL_GetWindowKeyboardGrab(window);
  550. SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab()");
  551. SDLTest_AssertCheck(
  552. currentState == desiredState,
  553. "Validate returned state; expected: %s, got: %s",
  554. (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE",
  555. (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
  556. if (desiredState) {
  557. SDLTest_AssertCheck(
  558. SDL_GetGrabbedWindow() == window,
  559. "Grabbed window should be set to our window");
  560. SDLTest_AssertCheck(
  561. SDL_GetWindowGrab(window),
  562. "SDL_GetWindowGrab() should return SDL_TRUE");
  563. SDLTest_AssertCheck(
  564. SDL_GetWindowFlags(window) & SDL_WINDOW_KEYBOARD_GRABBED,
  565. "SDL_WINDOW_KEYBOARD_GRABBED should be set");
  566. } else {
  567. SDLTest_AssertCheck(
  568. !(SDL_GetWindowFlags(window) & SDL_WINDOW_KEYBOARD_GRABBED),
  569. "SDL_WINDOW_KEYBOARD_GRABBED should be unset");
  570. }
  571. }
  572. /**
  573. * @brief Tests keyboard and mouse grab support
  574. *
  575. * @sa http://wiki.libsdl.org/SDL_GetWindowGrab
  576. * @sa http://wiki.libsdl.org/SDL_SetWindowGrab
  577. */
  578. int video_getSetWindowGrab(void *arg)
  579. {
  580. const char *title = "video_getSetWindowGrab Test Window";
  581. SDL_Window *window;
  582. SDL_bool originalMouseState, originalKeyboardState;
  583. /* Call against new test window */
  584. window = createVideoSuiteTestWindow(title);
  585. if (window == NULL) {
  586. return TEST_ABORTED;
  587. }
  588. /* Get state */
  589. originalMouseState = SDL_GetWindowMouseGrab(window);
  590. SDLTest_AssertPass("Call to SDL_GetWindowMouseGrab()");
  591. originalKeyboardState = SDL_GetWindowKeyboardGrab(window);
  592. SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab()");
  593. /* F */
  594. setAndCheckWindowKeyboardGrabState(window, SDL_FALSE);
  595. setAndCheckWindowMouseGrabState(window, SDL_FALSE);
  596. SDLTest_AssertCheck(!SDL_GetWindowGrab(window),
  597. "SDL_GetWindowGrab should return SDL_FALSE");
  598. SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL,
  599. "Expected NULL grabbed window");
  600. /* F --> F */
  601. setAndCheckWindowMouseGrabState(window, SDL_FALSE);
  602. setAndCheckWindowKeyboardGrabState(window, SDL_FALSE);
  603. SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL,
  604. "Expected NULL grabbed window");
  605. /* F --> T */
  606. setAndCheckWindowMouseGrabState(window, SDL_TRUE);
  607. setAndCheckWindowKeyboardGrabState(window, SDL_TRUE);
  608. SDLTest_AssertCheck(SDL_GetWindowGrab(window),
  609. "SDL_GetWindowGrab() should return SDL_TRUE");
  610. /* T --> T */
  611. setAndCheckWindowKeyboardGrabState(window, SDL_TRUE);
  612. setAndCheckWindowMouseGrabState(window, SDL_TRUE);
  613. SDLTest_AssertCheck(SDL_GetWindowGrab(window),
  614. "SDL_GetWindowGrab() should return SDL_TRUE");
  615. /* M: T --> F */
  616. /* K: T --> T */
  617. setAndCheckWindowKeyboardGrabState(window, SDL_TRUE);
  618. setAndCheckWindowMouseGrabState(window, SDL_FALSE);
  619. SDLTest_AssertCheck(SDL_GetWindowGrab(window),
  620. "SDL_GetWindowGrab() should return SDL_TRUE");
  621. /* M: F --> T */
  622. /* K: T --> F */
  623. setAndCheckWindowMouseGrabState(window, SDL_TRUE);
  624. setAndCheckWindowKeyboardGrabState(window, SDL_FALSE);
  625. SDLTest_AssertCheck(SDL_GetWindowGrab(window),
  626. "SDL_GetWindowGrab() should return SDL_TRUE");
  627. /* M: T --> F */
  628. /* K: F --> F */
  629. setAndCheckWindowMouseGrabState(window, SDL_FALSE);
  630. setAndCheckWindowKeyboardGrabState(window, SDL_FALSE);
  631. SDLTest_AssertCheck(!SDL_GetWindowGrab(window),
  632. "SDL_GetWindowGrab() should return SDL_FALSE");
  633. SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL,
  634. "Expected NULL grabbed window");
  635. /* Using the older SDL_SetWindowGrab API should only grab mouse by default */
  636. SDL_SetWindowGrab(window, SDL_TRUE);
  637. SDLTest_AssertPass("Call to SDL_SetWindowGrab(SDL_TRUE)");
  638. SDLTest_AssertCheck(SDL_GetWindowGrab(window),
  639. "SDL_GetWindowGrab() should return SDL_TRUE");
  640. SDLTest_AssertCheck(SDL_GetWindowMouseGrab(window),
  641. "SDL_GetWindowMouseGrab() should return SDL_TRUE");
  642. SDLTest_AssertCheck(!SDL_GetWindowKeyboardGrab(window),
  643. "SDL_GetWindowKeyboardGrab() should return SDL_FALSE");
  644. SDL_SetWindowGrab(window, SDL_FALSE);
  645. SDLTest_AssertCheck(!SDL_GetWindowGrab(window),
  646. "SDL_GetWindowGrab() should return SDL_FALSE");
  647. SDLTest_AssertCheck(!SDL_GetWindowMouseGrab(window),
  648. "SDL_GetWindowMouseGrab() should return SDL_FALSE");
  649. SDLTest_AssertCheck(!SDL_GetWindowKeyboardGrab(window),
  650. "SDL_GetWindowKeyboardGrab() should return SDL_FALSE");
  651. /* Now test with SDL_HINT_GRAB_KEYBOARD set. We should get keyboard grab now. */
  652. SDL_SetHint(SDL_HINT_GRAB_KEYBOARD, "1");
  653. SDL_SetWindowGrab(window, SDL_TRUE);
  654. SDLTest_AssertPass("Call to SDL_SetWindowGrab(SDL_TRUE)");
  655. SDLTest_AssertCheck(SDL_GetWindowGrab(window),
  656. "SDL_GetWindowGrab() should return SDL_TRUE");
  657. SDLTest_AssertCheck(SDL_GetWindowMouseGrab(window),
  658. "SDL_GetWindowMouseGrab() should return SDL_TRUE");
  659. SDLTest_AssertCheck(SDL_GetWindowKeyboardGrab(window),
  660. "SDL_GetWindowKeyboardGrab() should return SDL_TRUE");
  661. SDL_SetWindowGrab(window, SDL_FALSE);
  662. SDLTest_AssertCheck(!SDL_GetWindowGrab(window),
  663. "SDL_GetWindowGrab() should return SDL_FALSE");
  664. SDLTest_AssertCheck(!SDL_GetWindowMouseGrab(window),
  665. "SDL_GetWindowMouseGrab() should return SDL_FALSE");
  666. SDLTest_AssertCheck(!SDL_GetWindowKeyboardGrab(window),
  667. "SDL_GetWindowKeyboardGrab() should return SDL_FALSE");
  668. /* Negative tests */
  669. SDL_GetWindowGrab(NULL);
  670. SDLTest_AssertPass("Call to SDL_GetWindowGrab(window=NULL)");
  671. checkInvalidWindowError();
  672. SDL_GetWindowKeyboardGrab(NULL);
  673. SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab(window=NULL)");
  674. checkInvalidWindowError();
  675. SDL_SetWindowGrab(NULL, SDL_FALSE);
  676. SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
  677. checkInvalidWindowError();
  678. SDL_SetWindowKeyboardGrab(NULL, SDL_FALSE);
  679. SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(window=NULL,SDL_FALSE)");
  680. checkInvalidWindowError();
  681. SDL_SetWindowGrab(NULL, SDL_TRUE);
  682. SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_TRUE)");
  683. checkInvalidWindowError();
  684. SDL_SetWindowKeyboardGrab(NULL, SDL_TRUE);
  685. SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(window=NULL,SDL_TRUE)");
  686. checkInvalidWindowError();
  687. /* Restore state */
  688. setAndCheckWindowMouseGrabState(window, originalMouseState);
  689. setAndCheckWindowKeyboardGrabState(window, originalKeyboardState);
  690. /* Clean up */
  691. destroyVideoSuiteTestWindow(window);
  692. return TEST_COMPLETED;
  693. }
  694. /**
  695. * @brief Tests call to SDL_GetWindowID and SDL_GetWindowFromID
  696. *
  697. * @sa http://wiki.libsdl.org/SDL_GetWindowID
  698. * @sa http://wiki.libsdl.org/SDL_SetWindowFromID
  699. */
  700. int video_getWindowId(void *arg)
  701. {
  702. const char *title = "video_getWindowId Test Window";
  703. SDL_Window *window;
  704. SDL_Window *result;
  705. Uint32 id, randomId;
  706. /* Call against new test window */
  707. window = createVideoSuiteTestWindow(title);
  708. if (window == NULL) {
  709. return TEST_ABORTED;
  710. }
  711. /* Get ID */
  712. id = SDL_GetWindowID(window);
  713. SDLTest_AssertPass("Call to SDL_GetWindowID()");
  714. /* Get window from ID */
  715. result = SDL_GetWindowFromID(id);
  716. SDLTest_AssertPass("Call to SDL_GetWindowID(%" SDL_PRIu32 ")", id);
  717. SDLTest_AssertCheck(result == window, "Verify result matches window pointer");
  718. /* Get window from random large ID, no result check */
  719. randomId = SDLTest_RandomIntegerInRange(UINT8_MAX, UINT16_MAX);
  720. result = SDL_GetWindowFromID(randomId);
  721. SDLTest_AssertPass("Call to SDL_GetWindowID(%" SDL_PRIu32 "/random_large)", randomId);
  722. /* Get window from 0 and Uint32 max ID, no result check */
  723. result = SDL_GetWindowFromID(0);
  724. SDLTest_AssertPass("Call to SDL_GetWindowID(0)");
  725. result = SDL_GetWindowFromID(UINT32_MAX);
  726. SDLTest_AssertPass("Call to SDL_GetWindowID(UINT32_MAX)");
  727. /* Clean up */
  728. destroyVideoSuiteTestWindow(window);
  729. /* Get window from ID for closed window */
  730. result = SDL_GetWindowFromID(id);
  731. SDLTest_AssertPass("Call to SDL_GetWindowID(%" SDL_PRIu32 "/closed_window)", id);
  732. SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
  733. /* Negative test */
  734. SDL_ClearError();
  735. SDLTest_AssertPass("Call to SDL_ClearError()");
  736. id = SDL_GetWindowID(NULL);
  737. SDLTest_AssertPass("Call to SDL_GetWindowID(window=NULL)");
  738. checkInvalidWindowError();
  739. return TEST_COMPLETED;
  740. }
  741. /**
  742. * @brief Tests call to SDL_GetWindowPixelFormat
  743. *
  744. * @sa http://wiki.libsdl.org/SDL_GetWindowPixelFormat
  745. */
  746. int video_getWindowPixelFormat(void *arg)
  747. {
  748. const char *title = "video_getWindowPixelFormat Test Window";
  749. SDL_Window *window;
  750. Uint32 format;
  751. /* Call against new test window */
  752. window = createVideoSuiteTestWindow(title);
  753. if (window == NULL) {
  754. return TEST_ABORTED;
  755. }
  756. /* Get format */
  757. format = SDL_GetWindowPixelFormat(window);
  758. SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat()");
  759. SDLTest_AssertCheck(format != SDL_PIXELFORMAT_UNKNOWN, "Verify that returned format is valid; expected: != %d, got: %" SDL_PRIu32, SDL_PIXELFORMAT_UNKNOWN, format);
  760. /* Clean up */
  761. destroyVideoSuiteTestWindow(window);
  762. /* Negative test */
  763. SDL_ClearError();
  764. SDLTest_AssertPass("Call to SDL_ClearError()");
  765. format = SDL_GetWindowPixelFormat(NULL);
  766. SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat(window=NULL)");
  767. checkInvalidWindowError();
  768. return TEST_COMPLETED;
  769. }
  770. /**
  771. * @brief Tests call to SDL_GetWindowPosition and SDL_SetWindowPosition
  772. *
  773. * @sa http://wiki.libsdl.org/SDL_GetWindowPosition
  774. * @sa http://wiki.libsdl.org/SDL_SetWindowPosition
  775. */
  776. int video_getSetWindowPosition(void *arg)
  777. {
  778. const char *title = "video_getSetWindowPosition Test Window";
  779. SDL_Window *window;
  780. int xVariation, yVariation;
  781. int referenceX, referenceY;
  782. int currentX, currentY;
  783. int desiredX, desiredY;
  784. /* Call against new test window */
  785. window = createVideoSuiteTestWindow(title);
  786. if (window == NULL) {
  787. return TEST_ABORTED;
  788. }
  789. for (xVariation = 0; xVariation < 4; xVariation++) {
  790. for (yVariation = 0; yVariation < 4; yVariation++) {
  791. switch (xVariation) {
  792. default:
  793. case 0:
  794. /* Zero X Position */
  795. desiredX = 0;
  796. break;
  797. case 1:
  798. /* Random X position inside screen */
  799. desiredX = SDLTest_RandomIntegerInRange(1, 100);
  800. break;
  801. case 2:
  802. /* Random X position outside screen (positive) */
  803. desiredX = SDLTest_RandomIntegerInRange(10000, 11000);
  804. break;
  805. case 3:
  806. /* Random X position outside screen (negative) */
  807. desiredX = SDLTest_RandomIntegerInRange(-1000, -100);
  808. break;
  809. }
  810. switch (yVariation) {
  811. default:
  812. case 0:
  813. /* Zero X Position */
  814. desiredY = 0;
  815. break;
  816. case 1:
  817. /* Random X position inside screen */
  818. desiredY = SDLTest_RandomIntegerInRange(1, 100);
  819. break;
  820. case 2:
  821. /* Random X position outside screen (positive) */
  822. desiredY = SDLTest_RandomIntegerInRange(10000, 11000);
  823. break;
  824. case 3:
  825. /* Random Y position outside screen (negative) */
  826. desiredY = SDLTest_RandomIntegerInRange(-1000, -100);
  827. break;
  828. }
  829. /* Set position */
  830. SDL_SetWindowPosition(window, desiredX, desiredY);
  831. SDLTest_AssertPass("Call to SDL_SetWindowPosition(...,%d,%d)", desiredX, desiredY);
  832. /* Get position */
  833. currentX = desiredX + 1;
  834. currentY = desiredY + 1;
  835. SDL_GetWindowPosition(window, &currentX, &currentY);
  836. SDLTest_AssertPass("Call to SDL_GetWindowPosition()");
  837. SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX);
  838. SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY);
  839. /* Get position X */
  840. currentX = desiredX + 1;
  841. SDL_GetWindowPosition(window, &currentX, NULL);
  842. SDLTest_AssertPass("Call to SDL_GetWindowPosition(&y=NULL)");
  843. SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX);
  844. /* Get position Y */
  845. currentY = desiredY + 1;
  846. SDL_GetWindowPosition(window, NULL, &currentY);
  847. SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL)");
  848. SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY);
  849. }
  850. }
  851. /* Dummy call with both pointers NULL */
  852. SDL_GetWindowPosition(window, NULL, NULL);
  853. SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL,&y=NULL)");
  854. /* Clean up */
  855. destroyVideoSuiteTestWindow(window);
  856. /* Set some 'magic' value for later check that nothing was changed */
  857. referenceX = SDLTest_RandomSint32();
  858. referenceY = SDLTest_RandomSint32();
  859. currentX = referenceX;
  860. currentY = referenceY;
  861. desiredX = SDLTest_RandomSint32();
  862. desiredY = SDLTest_RandomSint32();
  863. /* Negative tests */
  864. SDL_ClearError();
  865. SDLTest_AssertPass("Call to SDL_ClearError()");
  866. SDL_GetWindowPosition(NULL, &currentX, &currentY);
  867. SDLTest_AssertPass("Call to SDL_GetWindowPosition(window=NULL)");
  868. SDLTest_AssertCheck(
  869. currentX == referenceX && currentY == referenceY,
  870. "Verify that content of X and Y pointers has not been modified; expected: %d,%d; got: %d,%d",
  871. referenceX, referenceY,
  872. currentX, currentY);
  873. checkInvalidWindowError();
  874. SDL_GetWindowPosition(NULL, NULL, NULL);
  875. SDLTest_AssertPass("Call to SDL_GetWindowPosition(NULL, NULL, NULL)");
  876. checkInvalidWindowError();
  877. SDL_SetWindowPosition(NULL, desiredX, desiredY);
  878. SDLTest_AssertPass("Call to SDL_SetWindowPosition(window=NULL)");
  879. checkInvalidWindowError();
  880. return TEST_COMPLETED;
  881. }
  882. /* Helper function that checks for an 'Invalid parameter' error */
  883. static void checkInvalidParameterError()
  884. {
  885. const char *invalidParameterError = "Parameter";
  886. char *lastError;
  887. lastError = (char *)SDL_GetError();
  888. SDLTest_AssertPass("SDL_GetError()");
  889. SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
  890. if (lastError != NULL) {
  891. SDLTest_AssertCheck(SDL_strncmp(lastError, invalidParameterError, SDL_strlen(invalidParameterError)) == 0,
  892. "SDL_GetError(): expected message starts with '%s', was message: '%s'",
  893. invalidParameterError,
  894. lastError);
  895. SDL_ClearError();
  896. SDLTest_AssertPass("Call to SDL_ClearError()");
  897. }
  898. }
  899. /**
  900. * @brief Tests call to SDL_GetWindowSize and SDL_SetWindowSize
  901. *
  902. * @sa http://wiki.libsdl.org/SDL_GetWindowSize
  903. * @sa http://wiki.libsdl.org/SDL_SetWindowSize
  904. */
  905. int video_getSetWindowSize(void *arg)
  906. {
  907. const char *title = "video_getSetWindowSize Test Window";
  908. SDL_Window *window;
  909. int result;
  910. SDL_Rect display;
  911. int maxwVariation, maxhVariation;
  912. int wVariation, hVariation;
  913. int referenceW, referenceH;
  914. int currentW, currentH;
  915. int desiredW, desiredH;
  916. /* Get display bounds for size range */
  917. result = SDL_GetDisplayBounds(0, &display);
  918. SDLTest_AssertPass("SDL_GetDisplayBounds()");
  919. SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
  920. if (result != 0) {
  921. return TEST_ABORTED;
  922. }
  923. /* Call against new test window */
  924. window = createVideoSuiteTestWindow(title);
  925. if (window == NULL) {
  926. return TEST_ABORTED;
  927. }
  928. #ifdef __WIN32__
  929. /* Platform clips window size to screen size */
  930. maxwVariation = 4;
  931. maxhVariation = 4;
  932. #else
  933. /* Platform allows window size >= screen size */
  934. maxwVariation = 5;
  935. maxhVariation = 5;
  936. #endif
  937. for (wVariation = 0; wVariation < maxwVariation; wVariation++) {
  938. for (hVariation = 0; hVariation < maxhVariation; hVariation++) {
  939. switch (wVariation) {
  940. default:
  941. case 0:
  942. /* 1 Pixel Wide */
  943. desiredW = 1;
  944. break;
  945. case 1:
  946. /* Random width inside screen */
  947. desiredW = SDLTest_RandomIntegerInRange(1, 100);
  948. break;
  949. case 2:
  950. /* Width 1 pixel smaller than screen */
  951. desiredW = display.w - 1;
  952. break;
  953. case 3:
  954. /* Width at screen size */
  955. desiredW = display.w;
  956. break;
  957. case 4:
  958. /* Width 1 pixel larger than screen */
  959. desiredW = display.w + 1;
  960. break;
  961. }
  962. switch (hVariation) {
  963. default:
  964. case 0:
  965. /* 1 Pixel High */
  966. desiredH = 1;
  967. break;
  968. case 1:
  969. /* Random height inside screen */
  970. desiredH = SDLTest_RandomIntegerInRange(1, 100);
  971. break;
  972. case 2:
  973. /* Height 1 pixel smaller than screen */
  974. desiredH = display.h - 1;
  975. break;
  976. case 3:
  977. /* Height at screen size */
  978. desiredH = display.h;
  979. break;
  980. case 4:
  981. /* Height 1 pixel larger than screen */
  982. desiredH = display.h + 1;
  983. break;
  984. }
  985. /* Set size */
  986. SDL_SetWindowSize(window, desiredW, desiredH);
  987. SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH);
  988. /* Get size */
  989. currentW = desiredW + 1;
  990. currentH = desiredH + 1;
  991. SDL_GetWindowSize(window, &currentW, &currentH);
  992. SDLTest_AssertPass("Call to SDL_GetWindowSize()");
  993. SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
  994. SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
  995. /* Get just width */
  996. currentW = desiredW + 1;
  997. SDL_GetWindowSize(window, &currentW, NULL);
  998. SDLTest_AssertPass("Call to SDL_GetWindowSize(&h=NULL)");
  999. SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
  1000. /* Get just height */
  1001. currentH = desiredH + 1;
  1002. SDL_GetWindowSize(window, NULL, &currentH);
  1003. SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL)");
  1004. SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
  1005. }
  1006. }
  1007. /* Dummy call with both pointers NULL */
  1008. SDL_GetWindowSize(window, NULL, NULL);
  1009. SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL,&h=NULL)");
  1010. /* Negative tests for parameter input */
  1011. SDL_ClearError();
  1012. SDLTest_AssertPass("Call to SDL_ClearError()");
  1013. for (desiredH = -2; desiredH < 2; desiredH++) {
  1014. for (desiredW = -2; desiredW < 2; desiredW++) {
  1015. if (desiredW <= 0 || desiredH <= 0) {
  1016. SDL_SetWindowSize(window, desiredW, desiredH);
  1017. SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH);
  1018. checkInvalidParameterError();
  1019. }
  1020. }
  1021. }
  1022. /* Clean up */
  1023. destroyVideoSuiteTestWindow(window);
  1024. /* Set some 'magic' value for later check that nothing was changed */
  1025. referenceW = SDLTest_RandomSint32();
  1026. referenceH = SDLTest_RandomSint32();
  1027. currentW = referenceW;
  1028. currentH = referenceH;
  1029. desiredW = SDLTest_RandomSint32();
  1030. desiredH = SDLTest_RandomSint32();
  1031. /* Negative tests for window input */
  1032. SDL_ClearError();
  1033. SDLTest_AssertPass("Call to SDL_ClearError()");
  1034. SDL_GetWindowSize(NULL, &currentW, &currentH);
  1035. SDLTest_AssertPass("Call to SDL_GetWindowSize(window=NULL)");
  1036. SDLTest_AssertCheck(
  1037. currentW == referenceW && currentH == referenceH,
  1038. "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
  1039. referenceW, referenceH,
  1040. currentW, currentH);
  1041. checkInvalidWindowError();
  1042. SDL_GetWindowSize(NULL, NULL, NULL);
  1043. SDLTest_AssertPass("Call to SDL_GetWindowSize(NULL, NULL, NULL)");
  1044. checkInvalidWindowError();
  1045. SDL_SetWindowSize(NULL, desiredW, desiredH);
  1046. SDLTest_AssertPass("Call to SDL_SetWindowSize(window=NULL)");
  1047. checkInvalidWindowError();
  1048. return TEST_COMPLETED;
  1049. }
  1050. /**
  1051. * @brief Tests call to SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize
  1052. *
  1053. */
  1054. int video_getSetWindowMinimumSize(void *arg)
  1055. {
  1056. const char *title = "video_getSetWindowMinimumSize Test Window";
  1057. SDL_Window *window;
  1058. int result;
  1059. SDL_Rect display;
  1060. int wVariation, hVariation;
  1061. int referenceW, referenceH;
  1062. int currentW, currentH;
  1063. int desiredW = 1;
  1064. int desiredH = 1;
  1065. /* Get display bounds for size range */
  1066. result = SDL_GetDisplayBounds(0, &display);
  1067. SDLTest_AssertPass("SDL_GetDisplayBounds()");
  1068. SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
  1069. if (result != 0) {
  1070. return TEST_ABORTED;
  1071. }
  1072. /* Call against new test window */
  1073. window = createVideoSuiteTestWindow(title);
  1074. if (window == NULL) {
  1075. return TEST_ABORTED;
  1076. }
  1077. for (wVariation = 0; wVariation < 5; wVariation++) {
  1078. for (hVariation = 0; hVariation < 5; hVariation++) {
  1079. switch (wVariation) {
  1080. case 0:
  1081. /* 1 Pixel Wide */
  1082. desiredW = 1;
  1083. break;
  1084. case 1:
  1085. /* Random width inside screen */
  1086. desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1);
  1087. break;
  1088. case 2:
  1089. /* Width at screen size */
  1090. desiredW = display.w;
  1091. break;
  1092. }
  1093. switch (hVariation) {
  1094. case 0:
  1095. /* 1 Pixel High */
  1096. desiredH = 1;
  1097. break;
  1098. case 1:
  1099. /* Random height inside screen */
  1100. desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1);
  1101. break;
  1102. case 2:
  1103. /* Height at screen size */
  1104. desiredH = display.h;
  1105. break;
  1106. case 4:
  1107. /* Height 1 pixel larger than screen */
  1108. desiredH = display.h + 1;
  1109. break;
  1110. }
  1111. /* Set size */
  1112. SDL_SetWindowMinimumSize(window, desiredW, desiredH);
  1113. SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH);
  1114. /* Get size */
  1115. currentW = desiredW + 1;
  1116. currentH = desiredH + 1;
  1117. SDL_GetWindowMinimumSize(window, &currentW, &currentH);
  1118. SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize()");
  1119. SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
  1120. SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
  1121. /* Get just width */
  1122. currentW = desiredW + 1;
  1123. SDL_GetWindowMinimumSize(window, &currentW, NULL);
  1124. SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&h=NULL)");
  1125. SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
  1126. /* Get just height */
  1127. currentH = desiredH + 1;
  1128. SDL_GetWindowMinimumSize(window, NULL, &currentH);
  1129. SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL)");
  1130. SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
  1131. }
  1132. }
  1133. /* Dummy call with both pointers NULL */
  1134. SDL_GetWindowMinimumSize(window, NULL, NULL);
  1135. SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL,&h=NULL)");
  1136. /* Negative tests for parameter input */
  1137. SDL_ClearError();
  1138. SDLTest_AssertPass("Call to SDL_ClearError()");
  1139. for (desiredH = -2; desiredH < 2; desiredH++) {
  1140. for (desiredW = -2; desiredW < 2; desiredW++) {
  1141. if (desiredW <= 0 || desiredH <= 0) {
  1142. SDL_SetWindowMinimumSize(window, desiredW, desiredH);
  1143. SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH);
  1144. checkInvalidParameterError();
  1145. }
  1146. }
  1147. }
  1148. /* Clean up */
  1149. destroyVideoSuiteTestWindow(window);
  1150. /* Set some 'magic' value for later check that nothing was changed */
  1151. referenceW = SDLTest_RandomSint32();
  1152. referenceH = SDLTest_RandomSint32();
  1153. currentW = referenceW;
  1154. currentH = referenceH;
  1155. desiredW = SDLTest_RandomSint32();
  1156. desiredH = SDLTest_RandomSint32();
  1157. /* Negative tests for window input */
  1158. SDL_ClearError();
  1159. SDLTest_AssertPass("Call to SDL_ClearError()");
  1160. SDL_GetWindowMinimumSize(NULL, &currentW, &currentH);
  1161. SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(window=NULL)");
  1162. SDLTest_AssertCheck(
  1163. currentW == referenceW && currentH == referenceH,
  1164. "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
  1165. referenceW, referenceH,
  1166. currentW, currentH);
  1167. checkInvalidWindowError();
  1168. SDL_GetWindowMinimumSize(NULL, NULL, NULL);
  1169. SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(NULL, NULL, NULL)");
  1170. checkInvalidWindowError();
  1171. SDL_SetWindowMinimumSize(NULL, desiredW, desiredH);
  1172. SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(window=NULL)");
  1173. checkInvalidWindowError();
  1174. return TEST_COMPLETED;
  1175. }
  1176. /**
  1177. * @brief Tests call to SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize
  1178. *
  1179. */
  1180. int video_getSetWindowMaximumSize(void *arg)
  1181. {
  1182. const char *title = "video_getSetWindowMaximumSize Test Window";
  1183. SDL_Window *window;
  1184. int result;
  1185. SDL_Rect display;
  1186. int wVariation, hVariation;
  1187. int referenceW, referenceH;
  1188. int currentW, currentH;
  1189. int desiredW, desiredH;
  1190. /* Get display bounds for size range */
  1191. result = SDL_GetDisplayBounds(0, &display);
  1192. SDLTest_AssertPass("SDL_GetDisplayBounds()");
  1193. SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
  1194. if (result != 0) {
  1195. return TEST_ABORTED;
  1196. }
  1197. /* Call against new test window */
  1198. window = createVideoSuiteTestWindow(title);
  1199. if (window == NULL) {
  1200. return TEST_ABORTED;
  1201. }
  1202. for (wVariation = 0; wVariation < 3; wVariation++) {
  1203. for (hVariation = 0; hVariation < 3; hVariation++) {
  1204. switch (wVariation) {
  1205. case 0:
  1206. /* 1 Pixel Wide */
  1207. desiredW = 1;
  1208. break;
  1209. case 1:
  1210. /* Random width inside screen */
  1211. desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1);
  1212. break;
  1213. case 2:
  1214. /* Width at screen size */
  1215. desiredW = display.w;
  1216. break;
  1217. }
  1218. switch (hVariation) {
  1219. case 0:
  1220. /* 1 Pixel High */
  1221. desiredH = 1;
  1222. break;
  1223. case 1:
  1224. /* Random height inside screen */
  1225. desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1);
  1226. break;
  1227. case 2:
  1228. /* Height at screen size */
  1229. desiredH = display.h;
  1230. break;
  1231. }
  1232. /* Set size */
  1233. SDL_SetWindowMaximumSize(window, desiredW, desiredH);
  1234. SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH);
  1235. /* Get size */
  1236. currentW = desiredW + 1;
  1237. currentH = desiredH + 1;
  1238. SDL_GetWindowMaximumSize(window, &currentW, &currentH);
  1239. SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize()");
  1240. SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
  1241. SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
  1242. /* Get just width */
  1243. currentW = desiredW + 1;
  1244. SDL_GetWindowMaximumSize(window, &currentW, NULL);
  1245. SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&h=NULL)");
  1246. SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
  1247. /* Get just height */
  1248. currentH = desiredH + 1;
  1249. SDL_GetWindowMaximumSize(window, NULL, &currentH);
  1250. SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL)");
  1251. SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
  1252. }
  1253. }
  1254. /* Dummy call with both pointers NULL */
  1255. SDL_GetWindowMaximumSize(window, NULL, NULL);
  1256. SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL,&h=NULL)");
  1257. /* Negative tests for parameter input */
  1258. SDL_ClearError();
  1259. SDLTest_AssertPass("Call to SDL_ClearError()");
  1260. for (desiredH = -2; desiredH < 2; desiredH++) {
  1261. for (desiredW = -2; desiredW < 2; desiredW++) {
  1262. if (desiredW <= 0 || desiredH <= 0) {
  1263. SDL_SetWindowMaximumSize(window, desiredW, desiredH);
  1264. SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH);
  1265. checkInvalidParameterError();
  1266. }
  1267. }
  1268. }
  1269. /* Clean up */
  1270. destroyVideoSuiteTestWindow(window);
  1271. /* Set some 'magic' value for later check that nothing was changed */
  1272. referenceW = SDLTest_RandomSint32();
  1273. referenceH = SDLTest_RandomSint32();
  1274. currentW = referenceW;
  1275. currentH = referenceH;
  1276. desiredW = SDLTest_RandomSint32();
  1277. desiredH = SDLTest_RandomSint32();
  1278. /* Negative tests */
  1279. SDL_ClearError();
  1280. SDLTest_AssertPass("Call to SDL_ClearError()");
  1281. SDL_GetWindowMaximumSize(NULL, &currentW, &currentH);
  1282. SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(window=NULL)");
  1283. SDLTest_AssertCheck(
  1284. currentW == referenceW && currentH == referenceH,
  1285. "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
  1286. referenceW, referenceH,
  1287. currentW, currentH);
  1288. checkInvalidWindowError();
  1289. SDL_GetWindowMaximumSize(NULL, NULL, NULL);
  1290. SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(NULL, NULL, NULL)");
  1291. checkInvalidWindowError();
  1292. SDL_SetWindowMaximumSize(NULL, desiredW, desiredH);
  1293. SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(window=NULL)");
  1294. checkInvalidWindowError();
  1295. return TEST_COMPLETED;
  1296. }
  1297. /**
  1298. * @brief Tests call to SDL_SetWindowData and SDL_GetWindowData
  1299. *
  1300. * @sa http://wiki.libsdl.org/SDL_SetWindowData
  1301. * @sa http://wiki.libsdl.org/SDL_GetWindowData
  1302. */
  1303. int video_getSetWindowData(void *arg)
  1304. {
  1305. int returnValue = TEST_COMPLETED;
  1306. const char *title = "video_setGetWindowData Test Window";
  1307. SDL_Window *window;
  1308. const char *referenceName = "TestName";
  1309. const char *name = "TestName";
  1310. const char *referenceName2 = "TestName2";
  1311. const char *name2 = "TestName2";
  1312. int datasize;
  1313. char *referenceUserdata = NULL;
  1314. char *userdata = NULL;
  1315. char *referenceUserdata2 = NULL;
  1316. char *userdata2 = NULL;
  1317. char *result;
  1318. int iteration;
  1319. /* Call against new test window */
  1320. window = createVideoSuiteTestWindow(title);
  1321. if (window == NULL) {
  1322. return TEST_ABORTED;
  1323. }
  1324. /* Create testdata */
  1325. datasize = SDLTest_RandomIntegerInRange(1, 32);
  1326. referenceUserdata = SDLTest_RandomAsciiStringOfSize(datasize);
  1327. if (referenceUserdata == NULL) {
  1328. returnValue = TEST_ABORTED;
  1329. goto cleanup;
  1330. }
  1331. userdata = SDL_strdup(referenceUserdata);
  1332. if (userdata == NULL) {
  1333. returnValue = TEST_ABORTED;
  1334. goto cleanup;
  1335. }
  1336. datasize = SDLTest_RandomIntegerInRange(1, 32);
  1337. referenceUserdata2 = SDLTest_RandomAsciiStringOfSize(datasize);
  1338. if (referenceUserdata2 == NULL) {
  1339. returnValue = TEST_ABORTED;
  1340. goto cleanup;
  1341. }
  1342. userdata2 = SDL_strdup(referenceUserdata2);
  1343. if (userdata2 == NULL) {
  1344. returnValue = TEST_ABORTED;
  1345. goto cleanup;
  1346. }
  1347. /* Get non-existent data */
  1348. result = (char *)SDL_GetWindowData(window, name);
  1349. SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name);
  1350. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1351. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1352. /* Set data */
  1353. result = (char *)SDL_SetWindowData(window, name, userdata);
  1354. SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s)", name, userdata);
  1355. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1356. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1357. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
  1358. /* Get data (twice) */
  1359. for (iteration = 1; iteration <= 2; iteration++) {
  1360. result = (char *)SDL_GetWindowData(window, name);
  1361. SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [iteration %d]", name, iteration);
  1362. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
  1363. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1364. }
  1365. /* Set data again twice */
  1366. for (iteration = 1; iteration <= 2; iteration++) {
  1367. result = (char *)SDL_SetWindowData(window, name, userdata);
  1368. SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [iteration %d]", name, userdata, iteration);
  1369. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
  1370. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1371. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
  1372. }
  1373. /* Get data again */
  1374. result = (char *)SDL_GetWindowData(window, name);
  1375. SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [again]", name);
  1376. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
  1377. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1378. /* Set data with new data */
  1379. result = (char *)SDL_SetWindowData(window, name, userdata2);
  1380. SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [new userdata]", name, userdata2);
  1381. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
  1382. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1383. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
  1384. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
  1385. /* Set data with new data again */
  1386. result = (char *)SDL_SetWindowData(window, name, userdata2);
  1387. SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [new userdata again]", name, userdata2);
  1388. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result);
  1389. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1390. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
  1391. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
  1392. /* Get new data */
  1393. result = (char *)SDL_GetWindowData(window, name);
  1394. SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name);
  1395. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result);
  1396. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1397. /* Set data with NULL to clear */
  1398. result = (char *)SDL_SetWindowData(window, name, NULL);
  1399. SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,NULL)", name);
  1400. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result);
  1401. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1402. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
  1403. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
  1404. /* Set data with NULL to clear again */
  1405. result = (char *)SDL_SetWindowData(window, name, NULL);
  1406. SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,NULL) [again]", name);
  1407. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1408. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1409. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
  1410. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
  1411. /* Get non-existent data */
  1412. result = (char *)SDL_GetWindowData(window, name);
  1413. SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name);
  1414. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1415. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1416. /* Get non-existent data new name */
  1417. result = (char *)SDL_GetWindowData(window, name2);
  1418. SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name2);
  1419. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1420. SDLTest_AssertCheck(SDL_strcmp(referenceName2, name2) == 0, "Validate that name2 was not changed, expected: %s, got: %s", referenceName2, name2);
  1421. /* Set data (again) */
  1422. result = (char *)SDL_SetWindowData(window, name, userdata);
  1423. SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [again, after clear]", name, userdata);
  1424. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1425. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1426. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
  1427. /* Get data (again) */
  1428. result = (char *)SDL_GetWindowData(window, name);
  1429. SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [again, after clear]", name);
  1430. SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
  1431. SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1432. /* Negative test */
  1433. SDL_ClearError();
  1434. SDLTest_AssertPass("Call to SDL_ClearError()");
  1435. /* Set with invalid window */
  1436. result = (char *)SDL_SetWindowData(NULL, name, userdata);
  1437. SDLTest_AssertPass("Call to SDL_SetWindowData(window=NULL)");
  1438. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1439. checkInvalidWindowError();
  1440. /* Set data with NULL name, valid userdata */
  1441. result = (char *)SDL_SetWindowData(window, NULL, userdata);
  1442. SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL)");
  1443. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1444. checkInvalidParameterError();
  1445. /* Set data with empty name, valid userdata */
  1446. result = (char *)SDL_SetWindowData(window, "", userdata);
  1447. SDLTest_AssertPass("Call to SDL_SetWindowData(name='')");
  1448. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1449. checkInvalidParameterError();
  1450. /* Set data with NULL name, NULL userdata */
  1451. result = (char *)SDL_SetWindowData(window, NULL, NULL);
  1452. SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL,userdata=NULL)");
  1453. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1454. checkInvalidParameterError();
  1455. /* Set data with empty name, NULL userdata */
  1456. result = (char *)SDL_SetWindowData(window, "", NULL);
  1457. SDLTest_AssertPass("Call to SDL_SetWindowData(name='',userdata=NULL)");
  1458. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1459. checkInvalidParameterError();
  1460. /* Get with invalid window */
  1461. result = (char *)SDL_GetWindowData(NULL, name);
  1462. SDLTest_AssertPass("Call to SDL_GetWindowData(window=NULL)");
  1463. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1464. checkInvalidWindowError();
  1465. /* Get data with NULL name */
  1466. result = (char *)SDL_GetWindowData(window, NULL);
  1467. SDLTest_AssertPass("Call to SDL_GetWindowData(name=NULL)");
  1468. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1469. checkInvalidParameterError();
  1470. /* Get data with empty name */
  1471. result = (char *)SDL_GetWindowData(window, "");
  1472. SDLTest_AssertPass("Call to SDL_GetWindowData(name='')");
  1473. SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1474. checkInvalidParameterError();
  1475. /* Clean up */
  1476. destroyVideoSuiteTestWindow(window);
  1477. cleanup:
  1478. SDL_free(referenceUserdata);
  1479. SDL_free(referenceUserdata2);
  1480. SDL_free(userdata);
  1481. SDL_free(userdata2);
  1482. return returnValue;
  1483. }
  1484. /**
  1485. * @brief Tests the functionality of the SDL_WINDOWPOS_CENTERED_DISPLAY along with SDL_WINDOW_FULLSCREEN_DESKTOP.
  1486. *
  1487. * Espeically useful when run on a multi-monitor system with different DPI scales per monitor,
  1488. * to test that the window size is maintained when moving between monitors.
  1489. */
  1490. int video_setWindowCenteredOnDisplay(void *arg)
  1491. {
  1492. SDL_Window *window;
  1493. const char *title = "video_setWindowCenteredOnDisplay Test Window";
  1494. int x, y, w, h;
  1495. int xVariation, yVariation;
  1496. int displayNum;
  1497. int result;
  1498. SDL_Rect display0, display1;
  1499. displayNum = SDL_GetNumVideoDisplays();
  1500. /* Get display bounds */
  1501. result = SDL_GetDisplayBounds(0 % displayNum, &display0);
  1502. SDLTest_AssertPass("SDL_GetDisplayBounds()");
  1503. SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
  1504. if (result != 0) {
  1505. return TEST_ABORTED;
  1506. }
  1507. result = SDL_GetDisplayBounds(1 % displayNum, &display1);
  1508. SDLTest_AssertPass("SDL_GetDisplayBounds()");
  1509. SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
  1510. if (result != 0) {
  1511. return TEST_ABORTED;
  1512. }
  1513. for (xVariation = 0; xVariation < 2; xVariation++) {
  1514. for (yVariation = 0; yVariation < 2; yVariation++) {
  1515. int currentX = 0, currentY = 0;
  1516. int currentW = 0, currentH = 0;
  1517. int expectedX = 0, expectedY = 0;
  1518. int currentDisplay;
  1519. int expectedDisplay;
  1520. SDL_Rect expectedDisplayRect;
  1521. /* xVariation is the display we start on */
  1522. expectedDisplay = xVariation % displayNum;
  1523. x = SDL_WINDOWPOS_CENTERED_DISPLAY(expectedDisplay);
  1524. y = SDL_WINDOWPOS_CENTERED_DISPLAY(expectedDisplay);
  1525. w = SDLTest_RandomIntegerInRange(640, 800);
  1526. h = SDLTest_RandomIntegerInRange(400, 600);
  1527. expectedDisplayRect = (xVariation == 0) ? display0 : display1;
  1528. expectedX = (expectedDisplayRect.x + ((expectedDisplayRect.w - w) / 2));
  1529. expectedY = (expectedDisplayRect.y + ((expectedDisplayRect.h - h) / 2));
  1530. window = SDL_CreateWindow(title, x, y, w, h, 0);
  1531. SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h);
  1532. SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
  1533. /* Check the window is centered on the requested display */
  1534. currentDisplay = SDL_GetWindowDisplayIndex(window);
  1535. SDL_GetWindowSize(window, &currentW, &currentH);
  1536. SDL_GetWindowPosition(window, &currentX, &currentY);
  1537. SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay);
  1538. SDLTest_AssertCheck(currentW == w, "Validate width (current: %d, expected: %d)", currentW, w);
  1539. SDLTest_AssertCheck(currentH == h, "Validate height (current: %d, expected: %d)", currentH, h);
  1540. SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX);
  1541. SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY);
  1542. /* Enter fullscreen desktop */
  1543. result = SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
  1544. SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
  1545. /* Check we are filling the full display */
  1546. currentDisplay = SDL_GetWindowDisplayIndex(window);
  1547. SDL_GetWindowSize(window, &currentW, &currentH);
  1548. SDL_GetWindowPosition(window, &currentX, &currentY);
  1549. SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay);
  1550. SDLTest_AssertCheck(currentW == expectedDisplayRect.w, "Validate width (current: %d, expected: %d)", currentW, expectedDisplayRect.w);
  1551. SDLTest_AssertCheck(currentH == expectedDisplayRect.h, "Validate height (current: %d, expected: %d)", currentH, expectedDisplayRect.h);
  1552. SDLTest_AssertCheck(currentX == expectedDisplayRect.x, "Validate x (current: %d, expected: %d)", currentX, expectedDisplayRect.x);
  1553. SDLTest_AssertCheck(currentY == expectedDisplayRect.y, "Validate y (current: %d, expected: %d)", currentY, expectedDisplayRect.y);
  1554. /* Leave fullscreen desktop */
  1555. result = SDL_SetWindowFullscreen(window, 0);
  1556. SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
  1557. /* Check window was restored correctly */
  1558. currentDisplay = SDL_GetWindowDisplayIndex(window);
  1559. SDL_GetWindowSize(window, &currentW, &currentH);
  1560. SDL_GetWindowPosition(window, &currentX, &currentY);
  1561. SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay);
  1562. SDLTest_AssertCheck(currentW == w, "Validate width (current: %d, expected: %d)", currentW, w);
  1563. SDLTest_AssertCheck(currentH == h, "Validate height (current: %d, expected: %d)", currentH, h);
  1564. SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX);
  1565. SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY);
  1566. /* Center on display yVariation, and check window properties */
  1567. expectedDisplay = yVariation % displayNum;
  1568. x = SDL_WINDOWPOS_CENTERED_DISPLAY(expectedDisplay);
  1569. y = SDL_WINDOWPOS_CENTERED_DISPLAY(expectedDisplay);
  1570. expectedDisplayRect = (expectedDisplay == 0) ? display0 : display1;
  1571. expectedX = (expectedDisplayRect.x + ((expectedDisplayRect.w - w) / 2));
  1572. expectedY = (expectedDisplayRect.y + ((expectedDisplayRect.h - h) / 2));
  1573. SDL_SetWindowPosition(window, x, y);
  1574. currentDisplay = SDL_GetWindowDisplayIndex(window);
  1575. SDL_GetWindowSize(window, &currentW, &currentH);
  1576. SDL_GetWindowPosition(window, &currentX, &currentY);
  1577. SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay);
  1578. SDLTest_AssertCheck(currentW == w, "Validate width (current: %d, expected: %d)", currentW, w);
  1579. SDLTest_AssertCheck(currentH == h, "Validate height (current: %d, expected: %d)", currentH, h);
  1580. SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX);
  1581. SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY);
  1582. /* Clean up */
  1583. destroyVideoSuiteTestWindow(window);
  1584. }
  1585. }
  1586. return TEST_COMPLETED;
  1587. }
  1588. /* ================= Test References ================== */
  1589. /* Video test cases */
  1590. static const SDLTest_TestCaseReference videoTest1 = {
  1591. (SDLTest_TestCaseFp)video_enableDisableScreensaver, "video_enableDisableScreensaver", "Enable and disable screenaver while checking state", TEST_ENABLED
  1592. };
  1593. static const SDLTest_TestCaseReference videoTest2 = {
  1594. (SDLTest_TestCaseFp)video_createWindowVariousPositions, "video_createWindowVariousPositions", "Create windows at various locations", TEST_ENABLED
  1595. };
  1596. static const SDLTest_TestCaseReference videoTest3 = {
  1597. (SDLTest_TestCaseFp)video_createWindowVariousSizes, "video_createWindowVariousSizes", "Create windows with various sizes", TEST_ENABLED
  1598. };
  1599. static const SDLTest_TestCaseReference videoTest4 = {
  1600. (SDLTest_TestCaseFp)video_createWindowVariousFlags, "video_createWindowVariousFlags", "Create windows using various flags", TEST_ENABLED
  1601. };
  1602. static const SDLTest_TestCaseReference videoTest5 = {
  1603. (SDLTest_TestCaseFp)video_getWindowFlags, "video_getWindowFlags", "Get window flags set during SDL_CreateWindow", TEST_ENABLED
  1604. };
  1605. static const SDLTest_TestCaseReference videoTest6 = {
  1606. (SDLTest_TestCaseFp)video_getNumDisplayModes, "video_getNumDisplayModes", "Use SDL_GetNumDisplayModes function to get number of display modes", TEST_ENABLED
  1607. };
  1608. static const SDLTest_TestCaseReference videoTest7 = {
  1609. (SDLTest_TestCaseFp)video_getNumDisplayModesNegative, "video_getNumDisplayModesNegative", "Negative tests for SDL_GetNumDisplayModes", TEST_ENABLED
  1610. };
  1611. static const SDLTest_TestCaseReference videoTest8 = {
  1612. (SDLTest_TestCaseFp)video_getClosestDisplayModeCurrentResolution, "video_getClosestDisplayModeCurrentResolution", "Use function to get closes match to requested display mode for current resolution", TEST_ENABLED
  1613. };
  1614. static const SDLTest_TestCaseReference videoTest9 = {
  1615. (SDLTest_TestCaseFp)video_getClosestDisplayModeRandomResolution, "video_getClosestDisplayModeRandomResolution", "Use function to get closes match to requested display mode for random resolution", TEST_ENABLED
  1616. };
  1617. static const SDLTest_TestCaseReference videoTest10 = {
  1618. (SDLTest_TestCaseFp)video_getWindowDisplayMode, "video_getWindowDisplayMode", "Get window display mode", TEST_ENABLED
  1619. };
  1620. static const SDLTest_TestCaseReference videoTest11 = {
  1621. (SDLTest_TestCaseFp)video_getWindowDisplayModeNegative, "video_getWindowDisplayModeNegative", "Get window display mode with invalid input", TEST_ENABLED
  1622. };
  1623. static const SDLTest_TestCaseReference videoTest12 = {
  1624. (SDLTest_TestCaseFp)video_getSetWindowGrab, "video_getSetWindowGrab", "Checks SDL_GetWindowGrab and SDL_SetWindowGrab positive and negative cases", TEST_ENABLED
  1625. };
  1626. static const SDLTest_TestCaseReference videoTest13 = {
  1627. (SDLTest_TestCaseFp)video_getWindowId, "video_getWindowId", "Checks SDL_GetWindowID and SDL_GetWindowFromID", TEST_ENABLED
  1628. };
  1629. static const SDLTest_TestCaseReference videoTest14 = {
  1630. (SDLTest_TestCaseFp)video_getWindowPixelFormat, "video_getWindowPixelFormat", "Checks SDL_GetWindowPixelFormat", TEST_ENABLED
  1631. };
  1632. static const SDLTest_TestCaseReference videoTest15 = {
  1633. (SDLTest_TestCaseFp)video_getSetWindowPosition, "video_getSetWindowPosition", "Checks SDL_GetWindowPosition and SDL_SetWindowPosition positive and negative cases", TEST_ENABLED
  1634. };
  1635. static const SDLTest_TestCaseReference videoTest16 = {
  1636. (SDLTest_TestCaseFp)video_getSetWindowSize, "video_getSetWindowSize", "Checks SDL_GetWindowSize and SDL_SetWindowSize positive and negative cases", TEST_ENABLED
  1637. };
  1638. static const SDLTest_TestCaseReference videoTest17 = {
  1639. (SDLTest_TestCaseFp)video_getSetWindowMinimumSize, "video_getSetWindowMinimumSize", "Checks SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize positive and negative cases", TEST_ENABLED
  1640. };
  1641. static const SDLTest_TestCaseReference videoTest18 = {
  1642. (SDLTest_TestCaseFp)video_getSetWindowMaximumSize, "video_getSetWindowMaximumSize", "Checks SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize positive and negative cases", TEST_ENABLED
  1643. };
  1644. static const SDLTest_TestCaseReference videoTest19 = {
  1645. (SDLTest_TestCaseFp)video_getSetWindowData, "video_getSetWindowData", "Checks SDL_SetWindowData and SDL_GetWindowData positive and negative cases", TEST_ENABLED
  1646. };
  1647. static const SDLTest_TestCaseReference videoTest20 = {
  1648. (SDLTest_TestCaseFp)video_setWindowCenteredOnDisplay, "video_setWindowCenteredOnDisplay", "Checks using SDL_WINDOWPOS_CENTERED_DISPLAY centers the window on a display", TEST_ENABLED
  1649. };
  1650. /* Sequence of Video test cases */
  1651. static const SDLTest_TestCaseReference *videoTests[] = {
  1652. &videoTest1, &videoTest2, &videoTest3, &videoTest4, &videoTest5, &videoTest6,
  1653. &videoTest7, &videoTest8, &videoTest9, &videoTest10, &videoTest11, &videoTest12,
  1654. &videoTest13, &videoTest14, &videoTest15, &videoTest16, &videoTest17,
  1655. &videoTest18, &videoTest19, &videoTest20, NULL
  1656. };
  1657. /* Video test suite (global) */
  1658. SDLTest_TestSuiteReference videoTestSuite = {
  1659. "Video",
  1660. NULL,
  1661. videoTests,
  1662. NULL
  1663. };