testautomation_video.c 78 KB

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