7 /* Visual Studio 2008 doesn't have stdint.h */
8 #if defined(_MSC_VER) && _MSC_VER <= 1500
9 #define UINT8_MAX ~(Uint8)0
10 #define UINT16_MAX ~(Uint16)0
11 #define UINT32_MAX ~(Uint32)0
12 #define UINT64_MAX ~(Uint64)0
23 * Create a test window
25 SDL_Window *_createVideoSuiteTestWindow(const char *title)
29 SDL_WindowFlags flags;
32 x = SDLTest_RandomIntegerInRange(1, 100);
33 y = SDLTest_RandomIntegerInRange(1, 100);
34 w = SDLTest_RandomIntegerInRange(320, 1024);
35 h = SDLTest_RandomIntegerInRange(320, 768);
36 flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS;
38 window = SDL_CreateWindow(title, x, y, w, h, flags);
39 SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
40 SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
48 void _destroyVideoSuiteTestWindow(SDL_Window *window)
51 SDL_DestroyWindow(window);
53 SDLTest_AssertPass("Call to SDL_DestroyWindow");
57 /* Test case functions */
60 * @brief Enable and disable screensaver while checking state
63 video_enableDisableScreensaver(void *arg)
65 SDL_bool initialResult;
68 /* Get current state and proceed according to current state */
69 initialResult = SDL_IsScreenSaverEnabled();
70 SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
71 if (initialResult == SDL_TRUE) {
73 /* Currently enabled: disable first, then enable again */
75 /* Disable screensaver and check */
76 SDL_DisableScreenSaver();
77 SDLTest_AssertPass("Call to SDL_DisableScreenSaver()");
78 result = SDL_IsScreenSaverEnabled();
79 SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
80 SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);
82 /* Enable screensaver and check */
83 SDL_EnableScreenSaver();
84 SDLTest_AssertPass("Call to SDL_EnableScreenSaver()");
85 result = SDL_IsScreenSaverEnabled();
86 SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
87 SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
91 /* Currently disabled: enable first, then disable again */
93 /* Enable screensaver and check */
94 SDL_EnableScreenSaver();
95 SDLTest_AssertPass("Call to SDL_EnableScreenSaver()");
96 result = SDL_IsScreenSaverEnabled();
97 SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
98 SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
100 /* Disable screensaver and check */
101 SDL_DisableScreenSaver();
102 SDLTest_AssertPass("Call to SDL_DisableScreenSaver()");
103 result = SDL_IsScreenSaverEnabled();
104 SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
105 SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);
108 return TEST_COMPLETED;
112 * @brief Tests the functionality of the SDL_CreateWindow function using different positions
115 video_createWindowVariousPositions(void *arg)
118 const char* title = "video_createWindowVariousPositions Test Window";
120 int xVariation, yVariation;
122 for (xVariation = 0; xVariation < 6; xVariation++) {
123 for (yVariation = 0; yVariation < 6; yVariation++) {
126 /* Zero X Position */
130 /* Random X position inside screen */
131 x = SDLTest_RandomIntegerInRange(1, 100);
134 /* Random X position outside screen (positive) */
135 x = SDLTest_RandomIntegerInRange(10000, 11000);
138 /* Random X position outside screen (negative) */
139 x = SDLTest_RandomIntegerInRange(-1000, -100);
142 /* Centered X position */
143 x = SDL_WINDOWPOS_CENTERED;
146 /* Undefined X position */
147 x = SDL_WINDOWPOS_UNDEFINED;
153 /* Zero X Position */
157 /* Random X position inside screen */
158 y = SDLTest_RandomIntegerInRange(1, 100);
161 /* Random X position outside screen (positive) */
162 y = SDLTest_RandomIntegerInRange(10000, 11000);
165 /* Random Y position outside screen (negative) */
166 y = SDLTest_RandomIntegerInRange(-1000, -100);
169 /* Centered Y position */
170 y = SDL_WINDOWPOS_CENTERED;
173 /* Undefined Y position */
174 y = SDL_WINDOWPOS_UNDEFINED;
178 w = SDLTest_RandomIntegerInRange(32, 96);
179 h = SDLTest_RandomIntegerInRange(32, 96);
180 window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN);
181 SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h);
182 SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
185 _destroyVideoSuiteTestWindow(window);
189 return TEST_COMPLETED;
193 * @brief Tests the functionality of the SDL_CreateWindow function using different sizes
196 video_createWindowVariousSizes(void *arg)
199 const char* title = "video_createWindowVariousSizes Test Window";
201 int wVariation, hVariation;
203 x = SDLTest_RandomIntegerInRange(1, 100);
204 y = SDLTest_RandomIntegerInRange(1, 100);
205 for (wVariation = 0; wVariation < 3; wVariation++) {
206 for (hVariation = 0; hVariation < 3; hVariation++) {
213 /* Random "normal" width */
214 w = SDLTest_RandomIntegerInRange(320, 1920);
217 /* Random "large" width */
218 w = SDLTest_RandomIntegerInRange(2048, 4095);
228 /* Random "normal" height */
229 h = SDLTest_RandomIntegerInRange(320, 1080);
232 /* Random "large" height */
233 h = SDLTest_RandomIntegerInRange(2048, 4095);
237 window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN);
238 SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h);
239 SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
242 _destroyVideoSuiteTestWindow(window);
246 return TEST_COMPLETED;
250 * @brief Tests the functionality of the SDL_CreateWindow function using different flags
253 video_createWindowVariousFlags(void *arg)
256 const char* title = "video_createWindowVariousFlags Test Window";
259 SDL_WindowFlags flags;
261 /* Standard window */
262 x = SDLTest_RandomIntegerInRange(1, 100);
263 y = SDLTest_RandomIntegerInRange(1, 100);
264 w = SDLTest_RandomIntegerInRange(320, 1024);
265 h = SDLTest_RandomIntegerInRange(320, 768);
267 for (fVariation = 0; fVariation < 13; fVariation++) {
270 flags = SDL_WINDOW_FULLSCREEN;
271 /* Skip - blanks screen; comment out next line to run test */
275 flags = SDL_WINDOW_FULLSCREEN_DESKTOP;
276 /* Skip - blanks screen; comment out next line to run test */
280 flags = SDL_WINDOW_OPENGL;
283 flags = SDL_WINDOW_SHOWN;
286 flags = SDL_WINDOW_HIDDEN;
289 flags = SDL_WINDOW_BORDERLESS;
292 flags = SDL_WINDOW_RESIZABLE;
295 flags = SDL_WINDOW_MINIMIZED;
298 flags = SDL_WINDOW_MAXIMIZED;
301 flags = SDL_WINDOW_INPUT_GRABBED;
304 flags = SDL_WINDOW_INPUT_FOCUS;
307 flags = SDL_WINDOW_MOUSE_FOCUS;
310 flags = SDL_WINDOW_FOREIGN;
314 window = SDL_CreateWindow(title, x, y, w, h, flags);
315 SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
316 SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
319 _destroyVideoSuiteTestWindow(window);
322 return TEST_COMPLETED;
327 * @brief Tests the functionality of the SDL_GetWindowFlags function
330 video_getWindowFlags(void *arg)
333 const char* title = "video_getWindowFlags Test Window";
334 SDL_WindowFlags flags;
337 /* Reliable flag set always set in test window */
338 flags = SDL_WINDOW_SHOWN;
340 /* Call against new test window */
341 window = _createVideoSuiteTestWindow(title);
342 if (window != NULL) {
343 actualFlags = SDL_GetWindowFlags(window);
344 SDLTest_AssertPass("Call to SDL_GetWindowFlags");
345 SDLTest_AssertCheck((flags & actualFlags) == flags, "Verify returned value has flags %d set, got: %d", flags, actualFlags);
349 _destroyVideoSuiteTestWindow(window);
351 return TEST_COMPLETED;
355 * @brief Tests the functionality of the SDL_GetNumDisplayModes function
358 video_getNumDisplayModes(void *arg)
364 /* Get number of displays */
365 displayNum = SDL_GetNumVideoDisplays();
366 SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays");
368 /* Make call for each display */
369 for (i=0; i<displayNum; i++) {
370 result = SDL_GetNumDisplayModes(i);
371 SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d)", i);
372 SDLTest_AssertCheck(result >= 1, "Validate returned value from function; expected: >=1; got: %d", result);
375 return TEST_COMPLETED;
379 * @brief Tests negative call to SDL_GetNumDisplayModes function
382 video_getNumDisplayModesNegative(void *arg)
388 /* Get number of displays */
389 displayNum = SDL_GetNumVideoDisplays();
390 SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays");
392 /* Invalid boundary values */
393 displayIndex = SDLTest_RandomSint32BoundaryValue(0, displayNum, SDL_FALSE);
394 result = SDL_GetNumDisplayModes(displayIndex);
395 SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/boundary)", displayIndex);
396 SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result);
398 /* Large (out-of-bounds) display index */
399 displayIndex = SDLTest_RandomIntegerInRange(-2000, -1000);
400 result = SDL_GetNumDisplayModes(displayIndex);
401 SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/large negative)", displayIndex);
402 SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result);
404 displayIndex = SDLTest_RandomIntegerInRange(1000, 2000);
405 result = SDL_GetNumDisplayModes(displayIndex);
406 SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/large positive)", displayIndex);
407 SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result);
409 return TEST_COMPLETED;
413 * @brief Tests the functionality of the SDL_GetClosestDisplayMode function against current resolution
416 video_getClosestDisplayModeCurrentResolution(void *arg)
419 SDL_DisplayMode current;
420 SDL_DisplayMode target;
421 SDL_DisplayMode closest;
422 SDL_DisplayMode* dResult;
427 /* Get number of displays */
428 displayNum = SDL_GetNumVideoDisplays();
429 SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays");
431 /* Make calls for each display */
432 for (i=0; i<displayNum; i++) {
433 SDLTest_Log("Testing against display: %d", i);
435 /* Get first display mode to get a sane resolution; this should always work */
436 result = SDL_GetDisplayMode(i, 0, ¤t);
437 SDLTest_AssertPass("Call to SDL_GetDisplayMode");
438 SDLTest_AssertCheck(result == 0, "Verify return value, expected: 0, got: %d", result);
443 /* Set the desired resolution equals to current resolution */
444 target.w = current.w;
445 target.h = current.h;
446 for (variation = 0; variation < 8; variation ++) {
447 /* Vary constraints on other query parameters */
448 target.format = (variation & 1) ? current.format : 0;
449 target.refresh_rate = (variation & 2) ? current.refresh_rate : 0;
450 target.driverdata = (variation & 4) ? current.driverdata : 0;
453 dResult = SDL_GetClosestDisplayMode(i, &target, &closest);
454 SDLTest_AssertPass("Call to SDL_GetClosestDisplayMode(target=current/variation%d)", variation);
455 SDLTest_AssertCheck(dResult != NULL, "Verify returned value is not NULL");
457 /* Check that one gets the current resolution back again */
458 SDLTest_AssertCheck(closest.w == current.w, "Verify returned width matches current width; expected: %d, got: %d", current.w, closest.w);
459 SDLTest_AssertCheck(closest.h == current.h, "Verify returned height matches current height; expected: %d, got: %d", current.h, closest.h);
460 SDLTest_AssertCheck(closest.w == dResult->w, "Verify return value matches assigned value; expected: %d, got: %d", closest.w, dResult->w);
461 SDLTest_AssertCheck(closest.h == dResult->h, "Verify return value matches assigned value; expected: %d, got: %d", closest.h, dResult->h);
465 return TEST_COMPLETED;
469 * @brief Tests the functionality of the SDL_GetClosestDisplayMode function against random resolution
472 video_getClosestDisplayModeRandomResolution(void *arg)
474 SDL_DisplayMode target;
475 SDL_DisplayMode closest;
476 SDL_DisplayMode* dResult;
481 /* Get number of displays */
482 displayNum = SDL_GetNumVideoDisplays();
483 SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays");
485 /* Make calls for each display */
486 for (i=0; i<displayNum; i++) {
487 SDLTest_Log("Testing against display: %d", i);
489 for (variation = 0; variation < 16; variation ++) {
491 /* Set random constraints */
492 target.w = (variation & 1) ? SDLTest_RandomIntegerInRange(1, 4096) : 0;
493 target.h = (variation & 2) ? SDLTest_RandomIntegerInRange(1, 4096) : 0;
494 target.format = (variation & 4) ? SDLTest_RandomIntegerInRange(1, 10) : 0;
495 target.refresh_rate = (variation & 8) ? SDLTest_RandomIntegerInRange(25, 120) : 0;
496 target.driverdata = 0;
498 /* Make call; may or may not find anything, so don't validate any further */
499 dResult = SDL_GetClosestDisplayMode(i, &target, &closest);
500 SDLTest_AssertPass("Call to SDL_GetClosestDisplayMode(target=random/variation%d)", variation);
504 return TEST_COMPLETED;
508 * @brief Tests call to SDL_GetWindowBrightness
510 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowBrightness
513 video_getWindowBrightness(void *arg)
516 const char* title = "video_getWindowBrightness Test Window";
519 /* Call against new test window */
520 window = _createVideoSuiteTestWindow(title);
521 if (window != NULL) {
522 result = SDL_GetWindowBrightness(window);
523 SDLTest_AssertPass("Call to SDL_GetWindowBrightness");
524 SDLTest_AssertCheck(result >= 0.0 && result <= 1.0, "Validate range of result value; expected: [0.0, 1.0], got: %f", result);
528 _destroyVideoSuiteTestWindow(window);
530 return TEST_COMPLETED;
534 * @brief Tests call to SDL_GetWindowBrightness with invalid input
536 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowBrightness
539 video_getWindowBrightnessNegative(void *arg)
541 const char *invalidWindowError = "Invalid window";
543 const char* title = "video_getWindowBrightnessNegative Test Window";
546 /* Call against invalid window */
547 result = SDL_GetWindowBrightness(NULL);
548 SDLTest_AssertPass("Call to SDL_GetWindowBrightness(window=NULL)");
549 SDLTest_AssertCheck(result == 1.0, "Validate result value; expected: 1.0, got: %f", result);
550 lastError = (char *)SDL_GetError();
551 SDLTest_AssertPass("SDL_GetError()");
552 SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
553 if (lastError != NULL) {
554 SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
555 "SDL_GetError(): expected message '%s', was message: '%s'",
560 return TEST_COMPLETED;
564 * @brief Tests call to SDL_GetWindowDisplayMode
566 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowDisplayMode
569 video_getWindowDisplayMode(void *arg)
572 const char* title = "video_getWindowDisplayMode Test Window";
573 SDL_DisplayMode mode;
576 /* Invalidate part of the mode content so we can check values later */
579 mode.refresh_rate = -1;
581 /* Call against new test window */
582 window = _createVideoSuiteTestWindow(title);
583 if (window != NULL) {
584 result = SDL_GetWindowDisplayMode(window, &mode);
585 SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode");
586 SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
587 SDLTest_AssertCheck(mode.w > 0, "Validate mode.w content; expected: >0, got: %d", mode.w);
588 SDLTest_AssertCheck(mode.h > 0, "Validate mode.h content; expected: >0, got: %d", mode.h);
589 SDLTest_AssertCheck(mode.refresh_rate > 0, "Validate mode.refresh_rate content; expected: >0, got: %d", mode.refresh_rate);
593 _destroyVideoSuiteTestWindow(window);
595 return TEST_COMPLETED;
598 /* Helper function that checks for an 'Invalid window' error */
599 void _checkInvalidWindowError()
601 const char *invalidWindowError = "Invalid window";
604 lastError = (char *)SDL_GetError();
605 SDLTest_AssertPass("SDL_GetError()");
606 SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
607 if (lastError != NULL) {
608 SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
609 "SDL_GetError(): expected message '%s', was message: '%s'",
613 SDLTest_AssertPass("Call to SDL_ClearError()");
618 * @brief Tests call to SDL_GetWindowDisplayMode with invalid input
620 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowDisplayMode
623 video_getWindowDisplayModeNegative(void *arg)
625 const char *expectedError = "Parameter 'mode' is invalid";
628 const char* title = "video_getWindowDisplayModeNegative Test Window";
629 SDL_DisplayMode mode;
632 /* Call against new test window */
633 window = _createVideoSuiteTestWindow(title);
634 if (window != NULL) {
635 result = SDL_GetWindowDisplayMode(window, NULL);
636 SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(...,mode=NULL)");
637 SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result);
638 lastError = (char *)SDL_GetError();
639 SDLTest_AssertPass("SDL_GetError()");
640 SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
641 if (lastError != NULL) {
642 SDLTest_AssertCheck(SDL_strcmp(lastError, expectedError) == 0,
643 "SDL_GetError(): expected message '%s', was message: '%s'",
650 _destroyVideoSuiteTestWindow(window);
652 /* Call against invalid window */
653 result = SDL_GetWindowDisplayMode(NULL, &mode);
654 SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(window=NULL,...)");
655 SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result);
656 _checkInvalidWindowError();
658 return TEST_COMPLETED;
662 * @brief Tests call to SDL_GetWindowGammaRamp
664 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGammaRamp
667 video_getWindowGammaRamp(void *arg)
670 const char* title = "video_getWindowGammaRamp Test Window";
676 /* Call against new test window */
677 window = _createVideoSuiteTestWindow(title);
678 if (window == NULL) return TEST_ABORTED;
680 /* Retrieve no channel */
681 result = SDL_GetWindowGammaRamp(window, NULL, NULL, NULL);
682 SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(all NULL)");
683 SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
685 /* Retrieve single channel */
686 result = SDL_GetWindowGammaRamp(window, red, NULL, NULL);
687 SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r)");
688 SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
690 result = SDL_GetWindowGammaRamp(window, NULL, green, NULL);
691 SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(g)");
692 SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
694 result = SDL_GetWindowGammaRamp(window, NULL, NULL, blue);
695 SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(b)");
696 SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
698 /* Retrieve two channels */
699 result = SDL_GetWindowGammaRamp(window, red, green, NULL);
700 SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r, g)");
701 SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
703 result = SDL_GetWindowGammaRamp(window, NULL, green, blue);
704 SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(g,b)");
705 SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
707 result = SDL_GetWindowGammaRamp(window, red, NULL, blue);
708 SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r,b)");
709 SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
711 /* Retrieve all channels */
712 result = SDL_GetWindowGammaRamp(window, red, green, blue);
713 SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r,g,b)");
714 SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
717 _destroyVideoSuiteTestWindow(window);
719 return TEST_COMPLETED;
723 * @brief Tests call to SDL_GetWindowGammaRamp with invalid input
725 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGammaRamp
728 video_getWindowGammaRampNegative(void *arg)
730 const char* title = "video_getWindowGammaRampNegative Test Window";
737 SDLTest_AssertPass("Call to SDL_ClearError()");
739 /* Call against invalid window */
740 result = SDL_GetWindowGammaRamp(NULL, red, green, blue);
741 SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(window=NULL,r,g,b)");
742 SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %f", result);
743 _checkInvalidWindowError();
745 return TEST_COMPLETED;
748 /* Helper for setting and checking the window grab state */
750 _setAndCheckWindowGrabState(SDL_Window* window, SDL_bool desiredState)
752 SDL_bool currentState;
755 SDL_SetWindowGrab(window, desiredState);
756 SDLTest_AssertPass("Call to SDL_SetWindowGrab(%s)", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
758 /* Get and check state */
759 currentState = SDL_GetWindowGrab(window);
760 SDLTest_AssertPass("Call to SDL_GetWindowGrab()");
762 currentState == desiredState,
763 "Validate returned state; expected: %s, got: %s",
764 (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE",
765 (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
769 * @brief Tests call to SDL_GetWindowGrab and SDL_SetWindowGrab
771 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGrab
772 * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowGrab
775 video_getSetWindowGrab(void *arg)
777 const char* title = "video_getSetWindowGrab Test Window";
779 SDL_bool originalState, dummyState, currentState, desiredState;
781 /* Call against new test window */
782 window = _createVideoSuiteTestWindow(title);
783 if (window == NULL) return TEST_ABORTED;
786 originalState = SDL_GetWindowGrab(window);
787 SDLTest_AssertPass("Call to SDL_GetWindowGrab()");
790 _setAndCheckWindowGrabState(window, SDL_FALSE);
793 _setAndCheckWindowGrabState(window, SDL_FALSE);
796 _setAndCheckWindowGrabState(window, SDL_TRUE);
799 _setAndCheckWindowGrabState(window, SDL_TRUE);
802 _setAndCheckWindowGrabState(window, SDL_FALSE);
805 dummyState = SDL_GetWindowGrab(NULL);
806 SDLTest_AssertPass("Call to SDL_GetWindowGrab(window=NULL)");
807 _checkInvalidWindowError();
809 SDL_SetWindowGrab(NULL, SDL_FALSE);
810 SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
811 _checkInvalidWindowError();
813 SDL_SetWindowGrab(NULL, SDL_TRUE);
814 SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
815 _checkInvalidWindowError();
817 /* State should still be F */
818 desiredState = SDL_FALSE;
819 currentState = SDL_GetWindowGrab(window);
820 SDLTest_AssertPass("Call to SDL_GetWindowGrab()");
822 currentState == desiredState,
823 "Validate returned state; expected: %s, got: %s",
824 (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE",
825 (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
828 _setAndCheckWindowGrabState(window, originalState);
831 _destroyVideoSuiteTestWindow(window);
833 return TEST_COMPLETED;
838 * @brief Tests call to SDL_GetWindowID and SDL_GetWindowFromID
840 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowID
841 * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowFromID
844 video_getWindowId(void *arg)
846 const char* title = "video_getWindowId Test Window";
851 /* Call against new test window */
852 window = _createVideoSuiteTestWindow(title);
853 if (window == NULL) return TEST_ABORTED;
856 id = SDL_GetWindowID(window);
857 SDLTest_AssertPass("Call to SDL_GetWindowID()");
859 /* Get window from ID */
860 result = SDL_GetWindowFromID(id);
861 SDLTest_AssertPass("Call to SDL_GetWindowID(%d)", id);
862 SDLTest_AssertCheck(result == window, "Verify result matches window pointer");
864 /* Get window from random large ID, no result check */
865 randomId = SDLTest_RandomIntegerInRange(UINT8_MAX,UINT16_MAX);
866 result = SDL_GetWindowFromID(randomId);
867 SDLTest_AssertPass("Call to SDL_GetWindowID(%d/random_large)", randomId);
869 /* Get window from 0 and Uint32 max ID, no result check */
870 result = SDL_GetWindowFromID(0);
871 SDLTest_AssertPass("Call to SDL_GetWindowID(0)");
872 result = SDL_GetWindowFromID(UINT32_MAX);
873 SDLTest_AssertPass("Call to SDL_GetWindowID(UINT32_MAX)");
876 _destroyVideoSuiteTestWindow(window);
878 /* Get window from ID for closed window*/
879 result = SDL_GetWindowFromID(id);
880 SDLTest_AssertPass("Call to SDL_GetWindowID(%d/closed_window)", id);
881 SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
885 SDLTest_AssertPass("Call to SDL_ClearError()");
886 id = SDL_GetWindowID(NULL);
887 SDLTest_AssertPass("Call to SDL_GetWindowID(window=NULL)");
888 _checkInvalidWindowError();
890 return TEST_COMPLETED;
894 * @brief Tests call to SDL_GetWindowPixelFormat
896 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowPixelFormat
899 video_getWindowPixelFormat(void *arg)
901 const char* title = "video_getWindowPixelFormat Test Window";
905 /* Call against new test window */
906 window = _createVideoSuiteTestWindow(title);
907 if (window == NULL) return TEST_ABORTED;
910 format = SDL_GetWindowPixelFormat(window);
911 SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat()");
912 SDLTest_AssertCheck(format != SDL_PIXELFORMAT_UNKNOWN, "Verify that returned format is valid; expected: != %d, got: %d", SDL_PIXELFORMAT_UNKNOWN, format);
915 _destroyVideoSuiteTestWindow(window);
919 SDLTest_AssertPass("Call to SDL_ClearError()");
920 format = SDL_GetWindowPixelFormat(NULL);
921 SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat(window=NULL)");
922 _checkInvalidWindowError();
924 return TEST_COMPLETED;
928 * @brief Tests call to SDL_GetWindowPosition and SDL_SetWindowPosition
930 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowPosition
931 * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowPosition
934 video_getSetWindowPosition(void *arg)
936 const char* title = "video_getSetWindowPosition Test Window";
938 int xVariation, yVariation;
939 int referenceX, referenceY;
940 int currentX, currentY;
941 int desiredX, desiredY;
943 /* Call against new test window */
944 window = _createVideoSuiteTestWindow(title);
945 if (window == NULL) return TEST_ABORTED;
947 for (xVariation = 0; xVariation < 4; xVariation++) {
948 for (yVariation = 0; yVariation < 4; yVariation++) {
951 /* Zero X Position */
955 /* Random X position inside screen */
956 desiredX = SDLTest_RandomIntegerInRange(1, 100);
959 /* Random X position outside screen (positive) */
960 desiredX = SDLTest_RandomIntegerInRange(10000, 11000);
963 /* Random X position outside screen (negative) */
964 desiredX = SDLTest_RandomIntegerInRange(-1000, -100);
970 /* Zero X Position */
974 /* Random X position inside screen */
975 desiredY = SDLTest_RandomIntegerInRange(1, 100);
978 /* Random X position outside screen (positive) */
979 desiredY = SDLTest_RandomIntegerInRange(10000, 11000);
982 /* Random Y position outside screen (negative) */
983 desiredY = SDLTest_RandomIntegerInRange(-1000, -100);
988 SDL_SetWindowPosition(window, desiredX, desiredY);
989 SDLTest_AssertPass("Call to SDL_SetWindowPosition(...,%d,%d)", desiredX, desiredY);
992 currentX = desiredX + 1;
993 currentY = desiredY + 1;
994 SDL_GetWindowPosition(window, ¤tX, ¤tY);
995 SDLTest_AssertPass("Call to SDL_GetWindowPosition()");
996 SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX);
997 SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY);
1000 currentX = desiredX + 1;
1001 SDL_GetWindowPosition(window, ¤tX, NULL);
1002 SDLTest_AssertPass("Call to SDL_GetWindowPosition(&y=NULL)");
1003 SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX);
1005 /* Get position Y */
1006 currentY = desiredY + 1;
1007 SDL_GetWindowPosition(window, NULL, ¤tY);
1008 SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL)");
1009 SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY);
1013 /* Dummy call with both pointers NULL */
1014 SDL_GetWindowPosition(window, NULL, NULL);
1015 SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL,&y=NULL)");
1018 _destroyVideoSuiteTestWindow(window);
1020 /* Set some 'magic' value for later check that nothing was changed */
1021 referenceX = SDLTest_RandomSint32();
1022 referenceY = SDLTest_RandomSint32();
1023 currentX = referenceX;
1024 currentY = referenceY;
1025 desiredX = SDLTest_RandomSint32();
1026 desiredY = SDLTest_RandomSint32();
1028 /* Negative tests */
1030 SDLTest_AssertPass("Call to SDL_ClearError()");
1031 SDL_GetWindowPosition(NULL, ¤tX, ¤tY);
1032 SDLTest_AssertPass("Call to SDL_GetWindowPosition(window=NULL)");
1033 SDLTest_AssertCheck(
1034 currentX == referenceX && currentY == referenceY,
1035 "Verify that content of X and Y pointers has not been modified; expected: %d,%d; got: %d,%d",
1036 referenceX, referenceY,
1037 currentX, currentY);
1038 _checkInvalidWindowError();
1040 SDL_GetWindowPosition(NULL, NULL, NULL);
1041 SDLTest_AssertPass("Call to SDL_GetWindowPosition(NULL, NULL, NULL)");
1042 _checkInvalidWindowError();
1044 SDL_SetWindowPosition(NULL, desiredX, desiredY);
1045 SDLTest_AssertPass("Call to SDL_SetWindowPosition(window=NULL)");
1046 _checkInvalidWindowError();
1048 return TEST_COMPLETED;
1051 /* Helper function that checks for an 'Invalid parameter' error */
1052 void _checkInvalidParameterError()
1054 const char *invalidParameterError = "Parameter";
1057 lastError = (char *)SDL_GetError();
1058 SDLTest_AssertPass("SDL_GetError()");
1059 SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
1060 if (lastError != NULL) {
1061 SDLTest_AssertCheck(SDL_strncmp(lastError, invalidParameterError, SDL_strlen(invalidParameterError)) == 0,
1062 "SDL_GetError(): expected message starts with '%s', was message: '%s'",
1063 invalidParameterError,
1066 SDLTest_AssertPass("Call to SDL_ClearError()");
1071 * @brief Tests call to SDL_GetWindowSize and SDL_SetWindowSize
1073 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowSize
1074 * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowSize
1077 video_getSetWindowSize(void *arg)
1079 const char* title = "video_getSetWindowSize Test Window";
1083 int wVariation, hVariation;
1084 int referenceW, referenceH;
1085 int currentW, currentH;
1086 int desiredW, desiredH;
1088 /* Get display bounds for size range */
1089 result = SDL_GetDisplayBounds(0, &display);
1090 SDLTest_AssertPass("SDL_GetDisplayBounds()");
1091 SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
1092 if (result != 0) return TEST_ABORTED;
1094 /* Call against new test window */
1095 window = _createVideoSuiteTestWindow(title);
1096 if (window == NULL) return TEST_ABORTED;
1098 for (wVariation = 0; wVariation < 4; wVariation++) {
1099 for (hVariation = 0; hVariation < 4; hVariation++) {
1100 switch(wVariation) {
1106 /* Random width inside screen */
1107 desiredW = SDLTest_RandomIntegerInRange(1, 100);
1110 /* Width at screen size */
1111 desiredW = display.w;
1114 /* Width 1 pixel larger than screen */
1115 desiredW = display.w + 1;
1119 switch(hVariation) {
1125 /* Random height inside screen */
1126 desiredH = SDLTest_RandomIntegerInRange(1, 100);
1129 /* Height at screen size */
1130 desiredH = display.h;
1133 /* Height 1 pixel larger than screen */
1134 desiredH = display.h + 1;
1139 SDL_SetWindowSize(window, desiredW, desiredH);
1140 SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH);
1143 currentW = desiredW + 1;
1144 currentH = desiredH + 1;
1145 SDL_GetWindowSize(window, ¤tW, ¤tH);
1146 SDLTest_AssertPass("Call to SDL_GetWindowSize()");
1147 SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
1148 SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
1150 /* Get just width */
1151 currentW = desiredW + 1;
1152 SDL_GetWindowSize(window, ¤tW, NULL);
1153 SDLTest_AssertPass("Call to SDL_GetWindowSize(&h=NULL)");
1154 SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
1156 /* Get just height */
1157 currentH = desiredH + 1;
1158 SDL_GetWindowSize(window, NULL, ¤tH);
1159 SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL)");
1160 SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
1164 /* Dummy call with both pointers NULL */
1165 SDL_GetWindowSize(window, NULL, NULL);
1166 SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL,&h=NULL)");
1168 /* Negative tests for parameter input */
1170 SDLTest_AssertPass("Call to SDL_ClearError()");
1171 for (desiredH = -2; desiredH < 2; desiredH++) {
1172 for (desiredW = -2; desiredW < 2; desiredW++) {
1173 if (desiredW <= 0 || desiredH <= 0) {
1174 SDL_SetWindowSize(window, desiredW, desiredH);
1175 SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH);
1176 _checkInvalidParameterError();
1182 _destroyVideoSuiteTestWindow(window);
1184 /* Set some 'magic' value for later check that nothing was changed */
1185 referenceW = SDLTest_RandomSint32();
1186 referenceH = SDLTest_RandomSint32();
1187 currentW = referenceW;
1188 currentH = referenceH;
1189 desiredW = SDLTest_RandomSint32();
1190 desiredH = SDLTest_RandomSint32();
1192 /* Negative tests for window input */
1194 SDLTest_AssertPass("Call to SDL_ClearError()");
1195 SDL_GetWindowSize(NULL, ¤tW, ¤tH);
1196 SDLTest_AssertPass("Call to SDL_GetWindowSize(window=NULL)");
1197 SDLTest_AssertCheck(
1198 currentW == referenceW && currentH == referenceH,
1199 "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
1200 referenceW, referenceH,
1201 currentW, currentH);
1202 _checkInvalidWindowError();
1204 SDL_GetWindowSize(NULL, NULL, NULL);
1205 SDLTest_AssertPass("Call to SDL_GetWindowSize(NULL, NULL, NULL)");
1206 _checkInvalidWindowError();
1208 SDL_SetWindowSize(NULL, desiredW, desiredH);
1209 SDLTest_AssertPass("Call to SDL_SetWindowSize(window=NULL)");
1210 _checkInvalidWindowError();
1212 return TEST_COMPLETED;
1216 * @brief Tests call to SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize
1220 video_getSetWindowMinimumSize(void *arg)
1222 const char* title = "video_getSetWindowMinimumSize Test Window";
1226 int wVariation, hVariation;
1227 int referenceW, referenceH;
1228 int currentW, currentH;
1229 int desiredW, desiredH;
1231 /* Get display bounds for size range */
1232 result = SDL_GetDisplayBounds(0, &display);
1233 SDLTest_AssertPass("SDL_GetDisplayBounds()");
1234 SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
1235 if (result != 0) return TEST_ABORTED;
1237 /* Call against new test window */
1238 window = _createVideoSuiteTestWindow(title);
1239 if (window == NULL) return TEST_ABORTED;
1241 for (wVariation = 0; wVariation < 5; wVariation++) {
1242 for (hVariation = 0; hVariation < 5; hVariation++) {
1243 switch(wVariation) {
1249 /* Random width inside screen */
1250 desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1);
1253 /* Width at screen size */
1254 desiredW = display.w;
1258 switch(hVariation) {
1264 /* Random height inside screen */
1265 desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1);
1268 /* Height at screen size */
1269 desiredH = display.h;
1272 /* Height 1 pixel larger than screen */
1273 desiredH = display.h + 1;
1278 SDL_SetWindowMinimumSize(window, desiredW, desiredH);
1279 SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH);
1282 currentW = desiredW + 1;
1283 currentH = desiredH + 1;
1284 SDL_GetWindowMinimumSize(window, ¤tW, ¤tH);
1285 SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize()");
1286 SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
1287 SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
1289 /* Get just width */
1290 currentW = desiredW + 1;
1291 SDL_GetWindowMinimumSize(window, ¤tW, NULL);
1292 SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&h=NULL)");
1293 SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
1295 /* Get just height */
1296 currentH = desiredH + 1;
1297 SDL_GetWindowMinimumSize(window, NULL, ¤tH);
1298 SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL)");
1299 SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
1303 /* Dummy call with both pointers NULL */
1304 SDL_GetWindowMinimumSize(window, NULL, NULL);
1305 SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL,&h=NULL)");
1307 /* Negative tests for parameter input */
1309 SDLTest_AssertPass("Call to SDL_ClearError()");
1310 for (desiredH = -2; desiredH < 2; desiredH++) {
1311 for (desiredW = -2; desiredW < 2; desiredW++) {
1312 if (desiredW <= 0 || desiredH <= 0) {
1313 SDL_SetWindowMinimumSize(window, desiredW, desiredH);
1314 SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH);
1315 _checkInvalidParameterError();
1321 _destroyVideoSuiteTestWindow(window);
1323 /* Set some 'magic' value for later check that nothing was changed */
1324 referenceW = SDLTest_RandomSint32();
1325 referenceH = SDLTest_RandomSint32();
1326 currentW = referenceW;
1327 currentH = referenceH;
1328 desiredW = SDLTest_RandomSint32();
1329 desiredH = SDLTest_RandomSint32();
1331 /* Negative tests for window input */
1333 SDLTest_AssertPass("Call to SDL_ClearError()");
1334 SDL_GetWindowMinimumSize(NULL, ¤tW, ¤tH);
1335 SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(window=NULL)");
1336 SDLTest_AssertCheck(
1337 currentW == referenceW && currentH == referenceH,
1338 "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
1339 referenceW, referenceH,
1340 currentW, currentH);
1341 _checkInvalidWindowError();
1343 SDL_GetWindowMinimumSize(NULL, NULL, NULL);
1344 SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(NULL, NULL, NULL)");
1345 _checkInvalidWindowError();
1347 SDL_SetWindowMinimumSize(NULL, desiredW, desiredH);
1348 SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(window=NULL)");
1349 _checkInvalidWindowError();
1351 return TEST_COMPLETED;
1355 * @brief Tests call to SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize
1359 video_getSetWindowMaximumSize(void *arg)
1361 const char* title = "video_getSetWindowMaximumSize Test Window";
1365 int wVariation, hVariation;
1366 int referenceW, referenceH;
1367 int currentW, currentH;
1368 int desiredW, desiredH;
1370 /* Get display bounds for size range */
1371 result = SDL_GetDisplayBounds(0, &display);
1372 SDLTest_AssertPass("SDL_GetDisplayBounds()");
1373 SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
1374 if (result != 0) return TEST_ABORTED;
1376 /* Call against new test window */
1377 window = _createVideoSuiteTestWindow(title);
1378 if (window == NULL) return TEST_ABORTED;
1380 for (wVariation = 0; wVariation < 3; wVariation++) {
1381 for (hVariation = 0; hVariation < 3; hVariation++) {
1382 switch(wVariation) {
1388 /* Random width inside screen */
1389 desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1);
1392 /* Width at screen size */
1393 desiredW = display.w;
1397 switch(hVariation) {
1403 /* Random height inside screen */
1404 desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1);
1407 /* Height at screen size */
1408 desiredH = display.h;
1413 SDL_SetWindowMaximumSize(window, desiredW, desiredH);
1414 SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH);
1417 currentW = desiredW + 1;
1418 currentH = desiredH + 1;
1419 SDL_GetWindowMaximumSize(window, ¤tW, ¤tH);
1420 SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize()");
1421 SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
1422 SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
1424 /* Get just width */
1425 currentW = desiredW + 1;
1426 SDL_GetWindowMaximumSize(window, ¤tW, NULL);
1427 SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&h=NULL)");
1428 SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
1430 /* Get just height */
1431 currentH = desiredH + 1;
1432 SDL_GetWindowMaximumSize(window, NULL, ¤tH);
1433 SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL)");
1434 SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
1438 /* Dummy call with both pointers NULL */
1439 SDL_GetWindowMaximumSize(window, NULL, NULL);
1440 SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL,&h=NULL)");
1442 /* Negative tests for parameter input */
1444 SDLTest_AssertPass("Call to SDL_ClearError()");
1445 for (desiredH = -2; desiredH < 2; desiredH++) {
1446 for (desiredW = -2; desiredW < 2; desiredW++) {
1447 if (desiredW <= 0 || desiredH <= 0) {
1448 SDL_SetWindowMaximumSize(window, desiredW, desiredH);
1449 SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH);
1450 _checkInvalidParameterError();
1456 _destroyVideoSuiteTestWindow(window);
1458 /* Set some 'magic' value for later check that nothing was changed */
1459 referenceW = SDLTest_RandomSint32();
1460 referenceH = SDLTest_RandomSint32();
1461 currentW = referenceW;
1462 currentH = referenceH;
1463 desiredW = SDLTest_RandomSint32();
1464 desiredH = SDLTest_RandomSint32();
1466 /* Negative tests */
1468 SDLTest_AssertPass("Call to SDL_ClearError()");
1469 SDL_GetWindowMaximumSize(NULL, ¤tW, ¤tH);
1470 SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(window=NULL)");
1471 SDLTest_AssertCheck(
1472 currentW == referenceW && currentH == referenceH,
1473 "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
1474 referenceW, referenceH,
1475 currentW, currentH);
1476 _checkInvalidWindowError();
1478 SDL_GetWindowMaximumSize(NULL, NULL, NULL);
1479 SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(NULL, NULL, NULL)");
1480 _checkInvalidWindowError();
1482 SDL_SetWindowMaximumSize(NULL, desiredW, desiredH);
1483 SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(window=NULL)");
1484 _checkInvalidWindowError();
1486 return TEST_COMPLETED;
1489 /* ================= Test References ================== */
1491 /* Video test cases */
1492 static const SDLTest_TestCaseReference videoTest1 =
1493 { (SDLTest_TestCaseFp)video_enableDisableScreensaver, "video_enableDisableScreensaver", "Enable and disable screenaver while checking state", TEST_ENABLED };
1495 static const SDLTest_TestCaseReference videoTest2 =
1496 { (SDLTest_TestCaseFp)video_createWindowVariousPositions, "video_createWindowVariousPositions", "Create windows at various locations", TEST_ENABLED };
1498 static const SDLTest_TestCaseReference videoTest3 =
1499 { (SDLTest_TestCaseFp)video_createWindowVariousSizes, "video_createWindowVariousSizes", "Create windows with various sizes", TEST_ENABLED };
1501 static const SDLTest_TestCaseReference videoTest4 =
1502 { (SDLTest_TestCaseFp)video_createWindowVariousFlags, "video_createWindowVariousFlags", "Create windows using various flags", TEST_ENABLED };
1504 static const SDLTest_TestCaseReference videoTest5 =
1505 { (SDLTest_TestCaseFp)video_getWindowFlags, "video_getWindowFlags", "Get window flags set during SDL_CreateWindow", TEST_ENABLED };
1507 static const SDLTest_TestCaseReference videoTest6 =
1508 { (SDLTest_TestCaseFp)video_getNumDisplayModes, "video_getNumDisplayModes", "Use SDL_GetNumDisplayModes function to get number of display modes", TEST_ENABLED };
1510 static const SDLTest_TestCaseReference videoTest7 =
1511 { (SDLTest_TestCaseFp)video_getNumDisplayModesNegative, "video_getNumDisplayModesNegative", "Negative tests for SDL_GetNumDisplayModes", TEST_ENABLED };
1513 static const SDLTest_TestCaseReference videoTest8 =
1514 { (SDLTest_TestCaseFp)video_getClosestDisplayModeCurrentResolution, "video_getClosestDisplayModeCurrentResolution", "Use function to get closes match to requested display mode for current resolution", TEST_ENABLED };
1516 static const SDLTest_TestCaseReference videoTest9 =
1517 { (SDLTest_TestCaseFp)video_getClosestDisplayModeRandomResolution, "video_getClosestDisplayModeRandomResolution", "Use function to get closes match to requested display mode for random resolution", TEST_ENABLED };
1519 static const SDLTest_TestCaseReference videoTest10 =
1520 { (SDLTest_TestCaseFp)video_getWindowBrightness, "video_getWindowBrightness", "Get window brightness", TEST_ENABLED };
1522 static const SDLTest_TestCaseReference videoTest11 =
1523 { (SDLTest_TestCaseFp)video_getWindowBrightnessNegative, "video_getWindowBrightnessNegative", "Get window brightness with invalid input", TEST_ENABLED };
1525 static const SDLTest_TestCaseReference videoTest12 =
1526 { (SDLTest_TestCaseFp)video_getWindowDisplayMode, "video_getWindowDisplayMode", "Get window display mode", TEST_ENABLED };
1528 static const SDLTest_TestCaseReference videoTest13 =
1529 { (SDLTest_TestCaseFp)video_getWindowDisplayModeNegative, "video_getWindowDisplayModeNegative", "Get window display mode with invalid input", TEST_ENABLED };
1531 static const SDLTest_TestCaseReference videoTest14 =
1532 { (SDLTest_TestCaseFp)video_getWindowGammaRamp, "video_getWindowGammaRamp", "Get window gamma ramp", TEST_ENABLED };
1534 static const SDLTest_TestCaseReference videoTest15 =
1535 { (SDLTest_TestCaseFp)video_getWindowGammaRampNegative, "video_getWindowGammaRampNegative", "Get window gamma ramp against invalid input", TEST_ENABLED };
1537 static const SDLTest_TestCaseReference videoTest16 =
1538 { (SDLTest_TestCaseFp)video_getSetWindowGrab, "video_getSetWindowGrab", "Checks SDL_GetWindowGrab and SDL_SetWindowGrab positive and negative cases", TEST_ENABLED };
1540 static const SDLTest_TestCaseReference videoTest17 =
1541 { (SDLTest_TestCaseFp)video_getWindowId, "video_getWindowId", "Checks SDL_GetWindowID and SDL_GetWindowFromID", TEST_ENABLED };
1543 static const SDLTest_TestCaseReference videoTest18 =
1544 { (SDLTest_TestCaseFp)video_getWindowPixelFormat, "video_getWindowPixelFormat", "Checks SDL_GetWindowPixelFormat", TEST_ENABLED };
1546 static const SDLTest_TestCaseReference videoTest19 =
1547 { (SDLTest_TestCaseFp)video_getSetWindowPosition, "video_getSetWindowPosition", "Checks SDL_GetWindowPosition and SDL_SetWindowPosition positive and negative cases", TEST_ENABLED };
1549 static const SDLTest_TestCaseReference videoTest20 =
1550 { (SDLTest_TestCaseFp)video_getSetWindowSize, "video_getSetWindowSize", "Checks SDL_GetWindowSize and SDL_SetWindowSize positive and negative cases", TEST_ENABLED };
1552 static const SDLTest_TestCaseReference videoTest21 =
1553 { (SDLTest_TestCaseFp)video_getSetWindowMinimumSize, "video_getSetWindowMinimumSize", "Checks SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize positive and negative cases", TEST_ENABLED };
1555 static const SDLTest_TestCaseReference videoTest22 =
1556 { (SDLTest_TestCaseFp)video_getSetWindowMaximumSize, "video_getSetWindowMaximumSize", "Checks SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize positive and negative cases", TEST_ENABLED };
1558 /* Sequence of Video test cases */
1559 static const SDLTest_TestCaseReference *videoTests[] = {
1560 &videoTest1, &videoTest2, &videoTest3, &videoTest4, &videoTest5, &videoTest6,
1561 &videoTest7, &videoTest8, &videoTest9, &videoTest10, &videoTest11, &videoTest12,
1562 &videoTest13, &videoTest14, &videoTest15, &videoTest16, &videoTest17,
1563 &videoTest18, &videoTest19, &videoTest20, &videoTest21, &videoTest22,
1567 /* Video test suite (global) */
1568 SDLTest_TestSuiteReference videoTestSuite = {