testautomation_video.c 96 KB

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