🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2073 lines
77 KiB

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