testautomation_video.c 77 KB

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