SDL 2.0
testautomation_video.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include "SDL.h"
#include "SDL_test.h"
+ Include dependency graph for testautomation_video.c:

Go to the source code of this file.

Functions

SDL_Window_createVideoSuiteTestWindow (const char *title)
 
void _destroyVideoSuiteTestWindow (SDL_Window *window)
 
int video_enableDisableScreensaver (void *arg)
 Enable and disable screensaver while checking state. More...
 
int video_createWindowVariousPositions (void *arg)
 Tests the functionality of the SDL_CreateWindow function using different positions. More...
 
int video_createWindowVariousSizes (void *arg)
 Tests the functionality of the SDL_CreateWindow function using different sizes. More...
 
int video_createWindowVariousFlags (void *arg)
 Tests the functionality of the SDL_CreateWindow function using different flags. More...
 
int video_getWindowFlags (void *arg)
 Tests the functionality of the SDL_GetWindowFlags function. More...
 
int video_getNumDisplayModes (void *arg)
 Tests the functionality of the SDL_GetNumDisplayModes function. More...
 
int video_getNumDisplayModesNegative (void *arg)
 Tests negative call to SDL_GetNumDisplayModes function. More...
 
int video_getClosestDisplayModeCurrentResolution (void *arg)
 Tests the functionality of the SDL_GetClosestDisplayMode function against current resolution. More...
 
int video_getClosestDisplayModeRandomResolution (void *arg)
 Tests the functionality of the SDL_GetClosestDisplayMode function against random resolution. More...
 
int video_getWindowBrightness (void *arg)
 Tests call to SDL_GetWindowBrightness. More...
 
int video_getWindowBrightnessNegative (void *arg)
 Tests call to SDL_GetWindowBrightness with invalid input. More...
 
int video_getWindowDisplayMode (void *arg)
 Tests call to SDL_GetWindowDisplayMode. More...
 
void _checkInvalidWindowError ()
 
int video_getWindowDisplayModeNegative (void *arg)
 Tests call to SDL_GetWindowDisplayMode with invalid input. More...
 
int video_getWindowGammaRamp (void *arg)
 Tests call to SDL_GetWindowGammaRamp. More...
 
int video_getWindowGammaRampNegative (void *arg)
 Tests call to SDL_GetWindowGammaRamp with invalid input. More...
 
void _setAndCheckWindowGrabState (SDL_Window *window, SDL_bool desiredState)
 
int video_getSetWindowGrab (void *arg)
 Tests call to SDL_GetWindowGrab and SDL_SetWindowGrab. More...
 
int video_getWindowId (void *arg)
 Tests call to SDL_GetWindowID and SDL_GetWindowFromID. More...
 
int video_getWindowPixelFormat (void *arg)
 Tests call to SDL_GetWindowPixelFormat. More...
 
int video_getSetWindowPosition (void *arg)
 Tests call to SDL_GetWindowPosition and SDL_SetWindowPosition. More...
 
void _checkInvalidParameterError ()
 
int video_getSetWindowSize (void *arg)
 Tests call to SDL_GetWindowSize and SDL_SetWindowSize. More...
 
int video_getSetWindowMinimumSize (void *arg)
 Tests call to SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize. More...
 
int video_getSetWindowMaximumSize (void *arg)
 Tests call to SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize. More...
 
int video_getSetWindowData (void *arg)
 Tests call to SDL_SetWindowData and SDL_GetWindowData. More...
 

Variables

static const SDLTest_TestCaseReference videoTest1
 
static const SDLTest_TestCaseReference videoTest2
 
static const SDLTest_TestCaseReference videoTest3
 
static const SDLTest_TestCaseReference videoTest4
 
static const SDLTest_TestCaseReference videoTest5
 
static const SDLTest_TestCaseReference videoTest6
 
static const SDLTest_TestCaseReference videoTest7
 
static const SDLTest_TestCaseReference videoTest8
 
static const SDLTest_TestCaseReference videoTest9
 
static const SDLTest_TestCaseReference videoTest10
 
static const SDLTest_TestCaseReference videoTest11
 
static const SDLTest_TestCaseReference videoTest12
 
static const SDLTest_TestCaseReference videoTest13
 
static const SDLTest_TestCaseReference videoTest14
 
static const SDLTest_TestCaseReference videoTest15
 
static const SDLTest_TestCaseReference videoTest16
 
static const SDLTest_TestCaseReference videoTest17
 
static const SDLTest_TestCaseReference videoTest18
 
static const SDLTest_TestCaseReference videoTest19
 
static const SDLTest_TestCaseReference videoTest20
 
static const SDLTest_TestCaseReference videoTest21
 
static const SDLTest_TestCaseReference videoTest22
 
static const SDLTest_TestCaseReference videoTest23
 
static const SDLTest_TestCaseReferencevideoTests []
 
SDLTest_TestSuiteReference videoTestSuite
 

Function Documentation

◆ _checkInvalidParameterError()

void _checkInvalidParameterError ( )

Definition at line 1051 of file testautomation_video.c.

1052{
1053 const char *invalidParameterError = "Parameter";
1054 char *lastError;
1055
1056 lastError = (char *)SDL_GetError();
1057 SDLTest_AssertPass("SDL_GetError()");
1058 SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
1059 if (lastError != NULL) {
1060 SDLTest_AssertCheck(SDL_strncmp(lastError, invalidParameterError, SDL_strlen(invalidParameterError)) == 0,
1061 "SDL_GetError(): expected message starts with '%s', was message: '%s'",
1062 invalidParameterError,
1063 lastError);
1065 SDLTest_AssertPass("Call to SDL_ClearError()");
1066 }
1067}
#define SDL_GetError
#define SDL_strncmp
#define SDL_strlen
#define SDL_ClearError
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
#define NULL
Definition: begin_code.h:167

References NULL, SDL_ClearError, SDL_GetError, SDL_strlen, SDL_strncmp, SDLTest_AssertCheck(), and SDLTest_AssertPass().

Referenced by video_getSetWindowData(), video_getSetWindowMaximumSize(), video_getSetWindowMinimumSize(), and video_getSetWindowSize().

◆ _checkInvalidWindowError()

void _checkInvalidWindowError ( )

Definition at line 599 of file testautomation_video.c.

600{
601 const char *invalidWindowError = "Invalid window";
602 char *lastError;
603
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'",
610 invalidWindowError,
611 lastError);
613 SDLTest_AssertPass("Call to SDL_ClearError()");
614 }
615}
#define SDL_strcmp

References NULL, SDL_ClearError, SDL_GetError, SDL_strcmp, SDLTest_AssertCheck(), and SDLTest_AssertPass().

Referenced by video_getSetWindowData(), video_getSetWindowGrab(), video_getSetWindowMaximumSize(), video_getSetWindowMinimumSize(), video_getSetWindowPosition(), video_getSetWindowSize(), video_getWindowDisplayModeNegative(), video_getWindowGammaRampNegative(), video_getWindowId(), and video_getWindowPixelFormat().

◆ _createVideoSuiteTestWindow()

SDL_Window * _createVideoSuiteTestWindow ( const char *  title)

Video test suite

Definition at line 26 of file testautomation_video.c.

27{
29 int x, y, w, h;
31
32 /* Standard window */
38
39 window = SDL_CreateWindow(title, x, y, w, h, flags);
40 SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
41 SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
42
43 return window;
44}
#define SDL_CreateWindow
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
GLbitfield flags
GLfloat GLfloat GLfloat GLfloat h
GLubyte GLubyte GLubyte GLubyte w
Sint32 SDLTest_RandomIntegerInRange(Sint32 min, Sint32 max)
SDL_WindowFlags
The flags on a window.
Definition: SDL_video.h:98
@ SDL_WINDOW_SHOWN
Definition: SDL_video.h:102
@ SDL_WINDOW_RESIZABLE
Definition: SDL_video.h:105
@ SDL_WINDOW_BORDERLESS
Definition: SDL_video.h:104
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
The type used to identify a window.
Definition: SDL_sysvideo.h:74

References NULL, SDL_CreateWindow, SDL_WINDOW_BORDERLESS, SDL_WINDOW_RESIZABLE, SDL_WINDOW_SHOWN, SDLTest_AssertCheck(), SDLTest_AssertPass(), and SDLTest_RandomIntegerInRange().

Referenced by video_getSetWindowData(), video_getSetWindowGrab(), video_getSetWindowMaximumSize(), video_getSetWindowMinimumSize(), video_getSetWindowPosition(), video_getSetWindowSize(), video_getWindowBrightness(), video_getWindowDisplayMode(), video_getWindowDisplayModeNegative(), video_getWindowFlags(), video_getWindowGammaRamp(), video_getWindowId(), and video_getWindowPixelFormat().

◆ _destroyVideoSuiteTestWindow()

◆ _setAndCheckWindowGrabState()

void _setAndCheckWindowGrabState ( SDL_Window window,
SDL_bool  desiredState 
)

Definition at line 749 of file testautomation_video.c.

750{
751 SDL_bool currentState;
752
753 /* Set state */
754 SDL_SetWindowGrab(window, desiredState);
755 SDLTest_AssertPass("Call to SDL_SetWindowGrab(%s)", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
756
757 /* Get and check state */
758 currentState = SDL_GetWindowGrab(window);
759 SDLTest_AssertPass("Call to SDL_GetWindowGrab()");
761 currentState == desiredState,
762 "Validate returned state; expected: %s, got: %s",
763 (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE",
764 (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
765}
#define SDL_GetWindowGrab
#define SDL_SetWindowGrab
SDL_bool
Definition: SDL_stdinc.h:162
@ SDL_FALSE
Definition: SDL_stdinc.h:163

References SDL_FALSE, SDL_GetWindowGrab, SDL_SetWindowGrab, SDLTest_AssertCheck(), and SDLTest_AssertPass().

Referenced by video_getSetWindowGrab().

◆ video_createWindowVariousFlags()

int video_createWindowVariousFlags ( void arg)

Tests the functionality of the SDL_CreateWindow function using different flags.

Definition at line 254 of file testautomation_video.c.

255{
257 const char* title = "video_createWindowVariousFlags Test Window";
258 int x, y, w, h;
259 int fVariation;
261
262 /* Standard window */
265 w = SDLTest_RandomIntegerInRange(320, 1024);
267
268 for (fVariation = 0; fVariation < 13; fVariation++) {
269 switch(fVariation) {
270 case 0:
272 /* Skip - blanks screen; comment out next line to run test */
273 continue;
274 break;
275 case 1:
277 /* Skip - blanks screen; comment out next line to run test */
278 continue;
279 break;
280 case 2:
282 break;
283 case 3:
285 break;
286 case 4:
288 break;
289 case 5:
291 break;
292 case 6:
294 break;
295 case 7:
297 break;
298 case 8:
300 break;
301 case 9:
303 break;
304 case 10:
306 break;
307 case 11:
309 break;
310 case 12:
312 break;
313 }
314
315 window = SDL_CreateWindow(title, x, y, w, h, flags);
316 SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
317 SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
318
319 /* Clean up */
321 }
322
323 return TEST_COMPLETED;
324}
#define TEST_COMPLETED
@ SDL_WINDOW_FOREIGN
Definition: SDL_video.h:112
@ SDL_WINDOW_OPENGL
Definition: SDL_video.h:101
@ SDL_WINDOW_MINIMIZED
Definition: SDL_video.h:106
@ SDL_WINDOW_MOUSE_FOCUS
Definition: SDL_video.h:110
@ SDL_WINDOW_INPUT_GRABBED
Definition: SDL_video.h:108
@ SDL_WINDOW_FULLSCREEN_DESKTOP
Definition: SDL_video.h:111
@ SDL_WINDOW_FULLSCREEN
Definition: SDL_video.h:100
@ SDL_WINDOW_MAXIMIZED
Definition: SDL_video.h:107
@ SDL_WINDOW_HIDDEN
Definition: SDL_video.h:103
@ SDL_WINDOW_INPUT_FOCUS
Definition: SDL_video.h:109
void _destroyVideoSuiteTestWindow(SDL_Window *window)

References _destroyVideoSuiteTestWindow(), NULL, SDL_CreateWindow, SDL_WINDOW_BORDERLESS, SDL_WINDOW_FOREIGN, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_FULLSCREEN_DESKTOP, SDL_WINDOW_HIDDEN, SDL_WINDOW_INPUT_FOCUS, SDL_WINDOW_INPUT_GRABBED, SDL_WINDOW_MAXIMIZED, SDL_WINDOW_MINIMIZED, SDL_WINDOW_MOUSE_FOCUS, SDL_WINDOW_OPENGL, SDL_WINDOW_RESIZABLE, SDL_WINDOW_SHOWN, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_RandomIntegerInRange(), and TEST_COMPLETED.

◆ video_createWindowVariousPositions()

int video_createWindowVariousPositions ( void arg)

Tests the functionality of the SDL_CreateWindow function using different positions.

Definition at line 116 of file testautomation_video.c.

117{
119 const char* title = "video_createWindowVariousPositions Test Window";
120 int x, y, w, h;
121 int xVariation, yVariation;
122
123 for (xVariation = 0; xVariation < 6; xVariation++) {
124 for (yVariation = 0; yVariation < 6; yVariation++) {
125 switch(xVariation) {
126 case 0:
127 /* Zero X Position */
128 x = 0;
129 break;
130 case 1:
131 /* Random X position inside screen */
133 break;
134 case 2:
135 /* Random X position outside screen (positive) */
136 x = SDLTest_RandomIntegerInRange(10000, 11000);
137 break;
138 case 3:
139 /* Random X position outside screen (negative) */
140 x = SDLTest_RandomIntegerInRange(-1000, -100);
141 break;
142 case 4:
143 /* Centered X position */
145 break;
146 case 5:
147 /* Undefined X position */
149 break;
150 }
151
152 switch(yVariation) {
153 case 0:
154 /* Zero X Position */
155 y = 0;
156 break;
157 case 1:
158 /* Random X position inside screen */
160 break;
161 case 2:
162 /* Random X position outside screen (positive) */
163 y = SDLTest_RandomIntegerInRange(10000, 11000);
164 break;
165 case 3:
166 /* Random Y position outside screen (negative) */
167 y = SDLTest_RandomIntegerInRange(-1000, -100);
168 break;
169 case 4:
170 /* Centered Y position */
172 break;
173 case 5:
174 /* Undefined Y position */
176 break;
177 }
178
182 SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h);
183 SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
184
185 /* Clean up */
187 }
188 }
189
190 return TEST_COMPLETED;
191}
#define SDL_WINDOWPOS_UNDEFINED
Definition: SDL_video.h:130
#define SDL_WINDOWPOS_CENTERED
Definition: SDL_video.h:139

References _destroyVideoSuiteTestWindow(), NULL, SDL_CreateWindow, SDL_WINDOW_SHOWN, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_UNDEFINED, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_RandomIntegerInRange(), and TEST_COMPLETED.

◆ video_createWindowVariousSizes()

int video_createWindowVariousSizes ( void arg)

Tests the functionality of the SDL_CreateWindow function using different sizes.

Definition at line 197 of file testautomation_video.c.

198{
200 const char* title = "video_createWindowVariousSizes Test Window";
201 int x, y, w, h;
202 int wVariation, hVariation;
203
206 for (wVariation = 0; wVariation < 3; wVariation++) {
207 for (hVariation = 0; hVariation < 3; hVariation++) {
208 switch(wVariation) {
209 case 0:
210 /* Width of 1 */
211 w = 1;
212 break;
213 case 1:
214 /* Random "normal" width */
215 w = SDLTest_RandomIntegerInRange(320, 1920);
216 break;
217 case 2:
218 /* Random "large" width */
219 w = SDLTest_RandomIntegerInRange(2048, 4095);
220 break;
221 }
222
223 switch(hVariation) {
224 case 0:
225 /* Height of 1 */
226 h = 1;
227 break;
228 case 1:
229 /* Random "normal" height */
230 h = SDLTest_RandomIntegerInRange(320, 1080);
231 break;
232 case 2:
233 /* Random "large" height */
234 h = SDLTest_RandomIntegerInRange(2048, 4095);
235 break;
236 }
237
239 SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h);
240 SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
241
242 /* Clean up */
244 }
245 }
246
247 return TEST_COMPLETED;
248}

References _destroyVideoSuiteTestWindow(), NULL, SDL_CreateWindow, SDL_WINDOW_SHOWN, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_RandomIntegerInRange(), and TEST_COMPLETED.

◆ video_enableDisableScreensaver()

int video_enableDisableScreensaver ( void arg)

Enable and disable screensaver while checking state.

Definition at line 64 of file testautomation_video.c.

65{
66 SDL_bool initialResult;
68
69 /* Get current state and proceed according to current state */
70 initialResult = SDL_IsScreenSaverEnabled();
71 SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
72 if (initialResult == SDL_TRUE) {
73
74 /* Currently enabled: disable first, then enable again */
75
76 /* Disable screensaver and check */
78 SDLTest_AssertPass("Call to SDL_DisableScreenSaver()");
80 SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
81 SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);
82
83 /* Enable screensaver and check */
85 SDLTest_AssertPass("Call to SDL_EnableScreenSaver()");
87 SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
88 SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
89
90 } else {
91
92 /* Currently disabled: enable first, then disable again */
93
94 /* Enable screensaver and check */
96 SDLTest_AssertPass("Call to SDL_EnableScreenSaver()");
98 SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
99 SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
100
101 /* Disable screensaver and check */
103 SDLTest_AssertPass("Call to SDL_DisableScreenSaver()");
105 SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
106 SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);
107 }
108
109 return TEST_COMPLETED;
110}
#define SDL_DisableScreenSaver
#define SDL_EnableScreenSaver
#define SDL_IsScreenSaverEnabled
GLuint64EXT * result
@ SDL_TRUE
Definition: SDL_stdinc.h:164

References SDL_DisableScreenSaver, SDL_EnableScreenSaver, SDL_FALSE, SDL_IsScreenSaverEnabled, SDL_TRUE, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

◆ video_getClosestDisplayModeCurrentResolution()

int video_getClosestDisplayModeCurrentResolution ( void arg)

Tests the functionality of the SDL_GetClosestDisplayMode function against current resolution.

Definition at line 417 of file testautomation_video.c.

418{
419 int result;
420 SDL_DisplayMode current;
422 SDL_DisplayMode closest;
423 SDL_DisplayMode* dResult;
424 int displayNum;
425 int i;
426 int variation;
427
428 /* Get number of displays */
429 displayNum = SDL_GetNumVideoDisplays();
430 SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()");
431
432 /* Make calls for each display */
433 for (i=0; i<displayNum; i++) {
434 SDLTest_Log("Testing against display: %d", i);
435
436 /* Get first display mode to get a sane resolution; this should always work */
437 result = SDL_GetDisplayMode(i, 0, &current);
438 SDLTest_AssertPass("Call to SDL_GetDisplayMode()");
439 SDLTest_AssertCheck(result == 0, "Verify return value, expected: 0, got: %d", result);
440 if (result != 0) {
441 return TEST_ABORTED;
442 }
443
444 /* Set the desired resolution equals to current resolution */
445 target.w = current.w;
446 target.h = current.h;
447 for (variation = 0; variation < 8; variation ++) {
448 /* Vary constraints on other query parameters */
449 target.format = (variation & 1) ? current.format : 0;
450 target.refresh_rate = (variation & 2) ? current.refresh_rate : 0;
451 target.driverdata = (variation & 4) ? current.driverdata : 0;
452
453 /* Make call */
454 dResult = SDL_GetClosestDisplayMode(i, &target, &closest);
455 SDLTest_AssertPass("Call to SDL_GetClosestDisplayMode(target=current/variation%d)", variation);
456 SDLTest_AssertCheck(dResult != NULL, "Verify returned value is not NULL");
457
458 /* Check that one gets the current resolution back again */
459 SDLTest_AssertCheck(closest.w == current.w, "Verify returned width matches current width; expected: %d, got: %d", current.w, closest.w);
460 SDLTest_AssertCheck(closest.h == current.h, "Verify returned height matches current height; expected: %d, got: %d", current.h, closest.h);
461 SDLTest_AssertCheck(closest.w == dResult->w, "Verify return value matches assigned value; expected: %d, got: %d", closest.w, dResult->w);
462 SDLTest_AssertCheck(closest.h == dResult->h, "Verify return value matches assigned value; expected: %d, got: %d", closest.h, dResult->h);
463 }
464 }
465
466 return TEST_COMPLETED;
467}
#define SDL_GetClosestDisplayMode
#define SDL_GetDisplayMode
#define SDL_GetNumVideoDisplays
GLenum target
#define TEST_ABORTED
void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(1)
Prints given message with a timestamp in the TEST category and INFO priority.
Definition: SDL_test_log.c:85
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
The structure that defines a display mode.
Definition: SDL_video.h:54
void * driverdata
Definition: SDL_video.h:59
Uint32 format
Definition: SDL_video.h:55

References SDL_DisplayMode::driverdata, SDL_DisplayMode::format, SDL_DisplayMode::h, i, NULL, SDL_DisplayMode::refresh_rate, SDL_GetClosestDisplayMode, SDL_GetDisplayMode, SDL_GetNumVideoDisplays, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_Log(), TEST_ABORTED, TEST_COMPLETED, and SDL_DisplayMode::w.

◆ video_getClosestDisplayModeRandomResolution()

int video_getClosestDisplayModeRandomResolution ( void arg)

Tests the functionality of the SDL_GetClosestDisplayMode function against random resolution.

Definition at line 473 of file testautomation_video.c.

474{
476 SDL_DisplayMode closest;
477 SDL_DisplayMode* dResult;
478 int displayNum;
479 int i;
480 int variation;
481
482 /* Get number of displays */
483 displayNum = SDL_GetNumVideoDisplays();
484 SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()");
485
486 /* Make calls for each display */
487 for (i=0; i<displayNum; i++) {
488 SDLTest_Log("Testing against display: %d", i);
489
490 for (variation = 0; variation < 16; variation ++) {
491
492 /* Set random constraints */
493 target.w = (variation & 1) ? SDLTest_RandomIntegerInRange(1, 4096) : 0;
494 target.h = (variation & 2) ? SDLTest_RandomIntegerInRange(1, 4096) : 0;
495 target.format = (variation & 4) ? SDLTest_RandomIntegerInRange(1, 10) : 0;
496 target.refresh_rate = (variation & 8) ? SDLTest_RandomIntegerInRange(25, 120) : 0;
497 target.driverdata = 0;
498
499 /* Make call; may or may not find anything, so don't validate any further */
500 dResult = SDL_GetClosestDisplayMode(i, &target, &closest);
501 SDLTest_AssertPass("Call to SDL_GetClosestDisplayMode(target=random/variation%d)", variation);
502 }
503 }
504
505 return TEST_COMPLETED;
506}

References i, SDL_GetClosestDisplayMode, SDL_GetNumVideoDisplays, SDLTest_AssertPass(), SDLTest_Log(), SDLTest_RandomIntegerInRange(), and TEST_COMPLETED.

◆ video_getNumDisplayModes()

int video_getNumDisplayModes ( void arg)

Tests the functionality of the SDL_GetNumDisplayModes function.

Definition at line 359 of file testautomation_video.c.

360{
361 int result;
362 int displayNum;
363 int i;
364
365 /* Get number of displays */
366 displayNum = SDL_GetNumVideoDisplays();
367 SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()");
368
369 /* Make call for each display */
370 for (i=0; i<displayNum; i++) {
372 SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d)", i);
373 SDLTest_AssertCheck(result >= 1, "Validate returned value from function; expected: >=1; got: %d", result);
374 }
375
376 return TEST_COMPLETED;
377}
#define SDL_GetNumDisplayModes

References i, SDL_GetNumDisplayModes, SDL_GetNumVideoDisplays, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

◆ video_getNumDisplayModesNegative()

int video_getNumDisplayModesNegative ( void arg)

Tests negative call to SDL_GetNumDisplayModes function.

Definition at line 383 of file testautomation_video.c.

384{
385 int result;
386 int displayNum;
387 int displayIndex;
388
389 /* Get number of displays */
390 displayNum = SDL_GetNumVideoDisplays();
391 SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()");
392
393 /* Invalid boundary values */
394 displayIndex = SDLTest_RandomSint32BoundaryValue(0, displayNum, SDL_FALSE);
395 result = SDL_GetNumDisplayModes(displayIndex);
396 SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/boundary)", displayIndex);
397 SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result);
398
399 /* Large (out-of-bounds) display index */
400 displayIndex = SDLTest_RandomIntegerInRange(-2000, -1000);
401 result = SDL_GetNumDisplayModes(displayIndex);
402 SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/large negative)", displayIndex);
403 SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result);
404
405 displayIndex = SDLTest_RandomIntegerInRange(1000, 2000);
406 result = SDL_GetNumDisplayModes(displayIndex);
407 SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/large positive)", displayIndex);
408 SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result);
409
410 return TEST_COMPLETED;
411}
Sint32 SDLTest_RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool validDomain)

References SDL_FALSE, SDL_GetNumDisplayModes, SDL_GetNumVideoDisplays, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_RandomIntegerInRange(), SDLTest_RandomSint32BoundaryValue(), and TEST_COMPLETED.

◆ video_getSetWindowData()

int video_getSetWindowData ( void arg)

Tests call to SDL_SetWindowData and SDL_GetWindowData.

See also
http://wiki.libsdl.org/moin.fcg/SDL_SetWindowData
http://wiki.libsdl.org/moin.fcg/SDL_GetWindowData

Definition at line 1515 of file testautomation_video.c.

1516{
1517 int returnValue = TEST_COMPLETED;
1518 const char* title = "video_setGetWindowData Test Window";
1520 const char *referenceName = "TestName";
1521 const char *name = "TestName";
1522 const char *referenceName2 = "TestName2";
1523 const char *name2 = "TestName2";
1524 int datasize;
1525 char *referenceUserdata = NULL;
1526 char *userdata = NULL;
1527 char *referenceUserdata2 = NULL;
1528 char *userdata2 = NULL;
1529 char *result;
1530 int iteration;
1531
1532 /* Call against new test window */
1534 if (window == NULL) return TEST_ABORTED;
1535
1536 /* Create testdata */
1537 datasize = SDLTest_RandomIntegerInRange(1, 32);
1538 referenceUserdata = SDLTest_RandomAsciiStringOfSize(datasize);
1539 if (referenceUserdata == NULL) {
1540 returnValue = TEST_ABORTED;
1541 goto cleanup;
1542 }
1543 userdata = SDL_strdup(referenceUserdata);
1544 if (userdata == NULL) {
1545 returnValue = TEST_ABORTED;
1546 goto cleanup;
1547 }
1548 datasize = SDLTest_RandomIntegerInRange(1, 32);
1549 referenceUserdata2 = SDLTest_RandomAsciiStringOfSize(datasize);
1550 if (referenceUserdata2 == NULL) {
1551 returnValue = TEST_ABORTED;
1552 goto cleanup;
1553 }
1554 userdata2 = (char *)SDL_strdup(referenceUserdata2);
1555 if (userdata2 == NULL) {
1556 returnValue = TEST_ABORTED;
1557 goto cleanup;
1558 }
1559
1560 /* Get non-existent data */
1561 result = (char *)SDL_GetWindowData(window, name);
1562 SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name);
1563 SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
1564 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1565
1566 /* Set data */
1567 result = (char *)SDL_SetWindowData(window, name, userdata);
1568 SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s)", name, userdata);
1569 SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
1570 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1571 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
1572
1573 /* Get data (twice) */
1574 for (iteration = 1; iteration <= 2; iteration++) {
1575 result = (char *)SDL_GetWindowData(window, name);
1576 SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [iteration %d]", name, iteration);
1577 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
1578 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1579 }
1580
1581 /* Set data again twice */
1582 for (iteration = 1; iteration <= 2; iteration++) {
1583 result = (char *)SDL_SetWindowData(window, name, userdata);
1584 SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [iteration %d]", name, userdata, iteration);
1585 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
1586 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1587 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
1588 }
1589
1590 /* Get data again */
1591 result = (char *)SDL_GetWindowData(window, name);
1592 SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [again]", name);
1593 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
1594 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1595
1596 /* Set data with new data */
1597 result = (char *)SDL_SetWindowData(window, name, userdata2);
1598 SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [new userdata]", name, userdata2);
1599 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
1600 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1601 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
1602 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
1603
1604 /* Set data with new data again */
1605 result = (char *)SDL_SetWindowData(window, name, userdata2);
1606 SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [new userdata again]", name, userdata2);
1607 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result);
1608 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1609 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
1610 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
1611
1612 /* Get new data */
1613 result = (char *)SDL_GetWindowData(window, name);
1614 SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name);
1615 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result);
1616 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1617
1618 /* Set data with NULL to clear */
1620 SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,NULL)", name);
1621 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result);
1622 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1623 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
1624 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
1625
1626 /* Set data with NULL to clear again */
1628 SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,NULL) [again]", name);
1629 SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
1630 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1631 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
1632 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
1633
1634 /* Get non-existent data */
1635 result = (char *)SDL_GetWindowData(window, name);
1636 SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name);
1637 SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
1638 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1639
1640 /* Get non-existent data new name */
1641 result = (char *)SDL_GetWindowData(window, name2);
1642 SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name2);
1643 SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
1644 SDLTest_AssertCheck(SDL_strcmp(referenceName2, name2) == 0, "Validate that name2 was not changed, expected: %s, got: %s", referenceName2, name2);
1645
1646 /* Set data (again) */
1647 result = (char *)SDL_SetWindowData(window, name, userdata);
1648 SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [again, after clear]", name, userdata);
1649 SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
1650 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1651 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
1652
1653 /* Get data (again) */
1654 result = (char *)SDL_GetWindowData(window, name);
1655 SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [again, after clear]", name);
1656 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
1657 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1658
1659 /* Negative test */
1661 SDLTest_AssertPass("Call to SDL_ClearError()");
1662
1663 /* Set with invalid window */
1664 result = (char *)SDL_SetWindowData(NULL, name, userdata);
1665 SDLTest_AssertPass("Call to SDL_SetWindowData(window=NULL)");
1666 SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
1668
1669 /* Set data with NULL name, valid userdata */
1670 result = (char *)SDL_SetWindowData(window, NULL, userdata);
1671 SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL)");
1672 SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
1674
1675 /* Set data with empty name, valid userdata */
1676 result = (char *)SDL_SetWindowData(window, "", userdata);
1677 SDLTest_AssertPass("Call to SDL_SetWindowData(name='')");
1678 SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
1680
1681 /* Set data with NULL name, NULL userdata */
1683 SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL,userdata=NULL)");
1684 SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
1686
1687 /* Set data with empty name, NULL userdata */
1688 result = (char *)SDL_SetWindowData(window, "", NULL);
1689 SDLTest_AssertPass("Call to SDL_SetWindowData(name='',userdata=NULL)");
1690 SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
1692
1693 /* Get with invalid window */
1694 result = (char *)SDL_GetWindowData(NULL, name);
1695 SDLTest_AssertPass("Call to SDL_GetWindowData(window=NULL)");
1696 SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
1698
1699 /* Get data with NULL name */
1700 result = (char *)SDL_GetWindowData(window, NULL);
1701 SDLTest_AssertPass("Call to SDL_GetWindowData(name=NULL)");
1702 SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
1704
1705 /* Get data with empty name */
1706 result = (char *)SDL_GetWindowData(window, "");
1707 SDLTest_AssertPass("Call to SDL_GetWindowData(name='')");
1708 SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
1710
1711 /* Clean up */
1713
1714 cleanup:
1715 SDL_free(referenceUserdata);
1716 SDL_free(referenceUserdata2);
1717 SDL_free(userdata);
1718 SDL_free(userdata2);
1719
1720 return returnValue;
1721}
#define SDL_GetWindowData
#define SDL_free
#define SDL_strdup
#define SDL_SetWindowData
GLuint const GLchar * name
char * SDLTest_RandomAsciiStringOfSize(int size)
static void iteration()
void _checkInvalidParameterError()
SDL_Window * _createVideoSuiteTestWindow(const char *title)
void _checkInvalidWindowError()
static void cleanup(void)
Definition: testfile.c:44

References _checkInvalidParameterError(), _checkInvalidWindowError(), _createVideoSuiteTestWindow(), _destroyVideoSuiteTestWindow(), cleanup(), iteration(), NULL, SDL_ClearError, SDL_free, SDL_GetWindowData, SDL_SetWindowData, SDL_strcmp, SDL_strdup, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_RandomAsciiStringOfSize(), SDLTest_RandomIntegerInRange(), TEST_ABORTED, and TEST_COMPLETED.

◆ video_getSetWindowGrab()

int video_getSetWindowGrab ( void arg)

Tests call to SDL_GetWindowGrab and SDL_SetWindowGrab.

See also
http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGrab
http://wiki.libsdl.org/moin.fcg/SDL_SetWindowGrab

Definition at line 774 of file testautomation_video.c.

775{
776 const char* title = "video_getSetWindowGrab Test Window";
778 SDL_bool originalState, dummyState, currentState, desiredState;
779
780 /* Call against new test window */
782 if (window == NULL) return TEST_ABORTED;
783
784 /* Get state */
785 originalState = SDL_GetWindowGrab(window);
786 SDLTest_AssertPass("Call to SDL_GetWindowGrab()");
787
788 /* F */
790
791 /* F --> F */
793
794 /* F --> T */
796
797 /* T --> T */
799
800 /* T --> F */
802
803 /* Negative tests */
804 dummyState = SDL_GetWindowGrab(NULL);
805 SDLTest_AssertPass("Call to SDL_GetWindowGrab(window=NULL)");
807
809 SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
811
813 SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
815
816 /* State should still be F */
817 desiredState = SDL_FALSE;
818 currentState = SDL_GetWindowGrab(window);
819 SDLTest_AssertPass("Call to SDL_GetWindowGrab()");
821 currentState == desiredState,
822 "Validate returned state; expected: %s, got: %s",
823 (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE",
824 (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
825
826 /* Restore state */
827 _setAndCheckWindowGrabState(window, originalState);
828
829 /* Clean up */
831
832 return TEST_COMPLETED;
833}
void _setAndCheckWindowGrabState(SDL_Window *window, SDL_bool desiredState)

References _checkInvalidWindowError(), _createVideoSuiteTestWindow(), _destroyVideoSuiteTestWindow(), _setAndCheckWindowGrabState(), NULL, SDL_FALSE, SDL_GetWindowGrab, SDL_SetWindowGrab, SDL_TRUE, SDLTest_AssertCheck(), SDLTest_AssertPass(), TEST_ABORTED, and TEST_COMPLETED.

◆ video_getSetWindowMaximumSize()

int video_getSetWindowMaximumSize ( void arg)

Tests call to SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize.

Definition at line 1377 of file testautomation_video.c.

1378{
1379 const char* title = "video_getSetWindowMaximumSize Test Window";
1381 int result;
1382 SDL_Rect display;
1383 int wVariation, hVariation;
1384 int referenceW, referenceH;
1385 int currentW, currentH;
1386 int desiredW, desiredH;
1387
1388 /* Get display bounds for size range */
1389 result = SDL_GetDisplayBounds(0, &display);
1390 SDLTest_AssertPass("SDL_GetDisplayBounds()");
1391 SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
1392 if (result != 0) return TEST_ABORTED;
1393
1394 /* Call against new test window */
1396 if (window == NULL) return TEST_ABORTED;
1397
1398 for (wVariation = 0; wVariation < 3; wVariation++) {
1399 for (hVariation = 0; hVariation < 3; hVariation++) {
1400 switch(wVariation) {
1401 case 0:
1402 /* 1 Pixel Wide */
1403 desiredW = 1;
1404 break;
1405 case 1:
1406 /* Random width inside screen */
1407 desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1);
1408 break;
1409 case 2:
1410 /* Width at screen size */
1411 desiredW = display.w;
1412 break;
1413 }
1414
1415 switch(hVariation) {
1416 case 0:
1417 /* 1 Pixel High */
1418 desiredH = 1;
1419 break;
1420 case 1:
1421 /* Random height inside screen */
1422 desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1);
1423 break;
1424 case 2:
1425 /* Height at screen size */
1426 desiredH = display.h;
1427 break;
1428 }
1429
1430 /* Set size */
1431 SDL_SetWindowMaximumSize(window, desiredW, desiredH);
1432 SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH);
1433
1434 /* Get size */
1435 currentW = desiredW + 1;
1436 currentH = desiredH + 1;
1437 SDL_GetWindowMaximumSize(window, &currentW, &currentH);
1438 SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize()");
1439 SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
1440 SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
1441
1442 /* Get just width */
1443 currentW = desiredW + 1;
1445 SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&h=NULL)");
1446 SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
1447
1448 /* Get just height */
1449 currentH = desiredH + 1;
1451 SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL)");
1452 SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
1453 }
1454 }
1455
1456 /* Dummy call with both pointers NULL */
1458 SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL,&h=NULL)");
1459
1460 /* Negative tests for parameter input */
1462 SDLTest_AssertPass("Call to SDL_ClearError()");
1463 for (desiredH = -2; desiredH < 2; desiredH++) {
1464 for (desiredW = -2; desiredW < 2; desiredW++) {
1465 if (desiredW <= 0 || desiredH <= 0) {
1466 SDL_SetWindowMaximumSize(window, desiredW, desiredH);
1467 SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH);
1469 }
1470 }
1471 }
1472
1473 /* Clean up */
1475
1476 /* Set some 'magic' value for later check that nothing was changed */
1477 referenceW = SDLTest_RandomSint32();
1478 referenceH = SDLTest_RandomSint32();
1479 currentW = referenceW;
1480 currentH = referenceH;
1481 desiredW = SDLTest_RandomSint32();
1482 desiredH = SDLTest_RandomSint32();
1483
1484 /* Negative tests */
1486 SDLTest_AssertPass("Call to SDL_ClearError()");
1487 SDL_GetWindowMaximumSize(NULL, &currentW, &currentH);
1488 SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(window=NULL)");
1490 currentW == referenceW && currentH == referenceH,
1491 "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
1492 referenceW, referenceH,
1493 currentW, currentH);
1495
1497 SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(NULL, NULL, NULL)");
1499
1500 SDL_SetWindowMaximumSize(NULL, desiredW, desiredH);
1501 SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(window=NULL)");
1503
1504 return TEST_COMPLETED;
1505}
#define SDL_GetWindowMaximumSize
#define SDL_SetWindowMaximumSize
#define SDL_GetDisplayBounds
Sint32 SDLTest_RandomSint32(void)
A rectangle, with the origin at the upper left (integer).
Definition: SDL_rect.h:78
int h
Definition: SDL_rect.h:80
int w
Definition: SDL_rect.h:80

References _checkInvalidParameterError(), _checkInvalidWindowError(), _createVideoSuiteTestWindow(), _destroyVideoSuiteTestWindow(), SDL_Rect::h, NULL, SDL_ClearError, SDL_GetDisplayBounds, SDL_GetWindowMaximumSize, SDL_SetWindowMaximumSize, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_RandomIntegerInRange(), SDLTest_RandomSint32(), TEST_ABORTED, TEST_COMPLETED, and SDL_Rect::w.

◆ video_getSetWindowMinimumSize()

int video_getSetWindowMinimumSize ( void arg)

Tests call to SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize.

Definition at line 1238 of file testautomation_video.c.

1239{
1240 const char* title = "video_getSetWindowMinimumSize Test Window";
1242 int result;
1243 SDL_Rect display;
1244 int wVariation, hVariation;
1245 int referenceW, referenceH;
1246 int currentW, currentH;
1247 int desiredW, desiredH;
1248
1249 /* Get display bounds for size range */
1250 result = SDL_GetDisplayBounds(0, &display);
1251 SDLTest_AssertPass("SDL_GetDisplayBounds()");
1252 SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
1253 if (result != 0) return TEST_ABORTED;
1254
1255 /* Call against new test window */
1257 if (window == NULL) return TEST_ABORTED;
1258
1259 for (wVariation = 0; wVariation < 5; wVariation++) {
1260 for (hVariation = 0; hVariation < 5; hVariation++) {
1261 switch(wVariation) {
1262 case 0:
1263 /* 1 Pixel Wide */
1264 desiredW = 1;
1265 break;
1266 case 1:
1267 /* Random width inside screen */
1268 desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1);
1269 break;
1270 case 2:
1271 /* Width at screen size */
1272 desiredW = display.w;
1273 break;
1274 }
1275
1276 switch(hVariation) {
1277 case 0:
1278 /* 1 Pixel High */
1279 desiredH = 1;
1280 break;
1281 case 1:
1282 /* Random height inside screen */
1283 desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1);
1284 break;
1285 case 2:
1286 /* Height at screen size */
1287 desiredH = display.h;
1288 break;
1289 case 4:
1290 /* Height 1 pixel larger than screen */
1291 desiredH = display.h + 1;
1292 break;
1293 }
1294
1295 /* Set size */
1296 SDL_SetWindowMinimumSize(window, desiredW, desiredH);
1297 SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH);
1298
1299 /* Get size */
1300 currentW = desiredW + 1;
1301 currentH = desiredH + 1;
1302 SDL_GetWindowMinimumSize(window, &currentW, &currentH);
1303 SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize()");
1304 SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
1305 SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
1306
1307 /* Get just width */
1308 currentW = desiredW + 1;
1310 SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&h=NULL)");
1311 SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
1312
1313 /* Get just height */
1314 currentH = desiredH + 1;
1316 SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL)");
1317 SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
1318 }
1319 }
1320
1321 /* Dummy call with both pointers NULL */
1323 SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL,&h=NULL)");
1324
1325 /* Negative tests for parameter input */
1327 SDLTest_AssertPass("Call to SDL_ClearError()");
1328 for (desiredH = -2; desiredH < 2; desiredH++) {
1329 for (desiredW = -2; desiredW < 2; desiredW++) {
1330 if (desiredW <= 0 || desiredH <= 0) {
1331 SDL_SetWindowMinimumSize(window, desiredW, desiredH);
1332 SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH);
1334 }
1335 }
1336 }
1337
1338 /* Clean up */
1340
1341 /* Set some 'magic' value for later check that nothing was changed */
1342 referenceW = SDLTest_RandomSint32();
1343 referenceH = SDLTest_RandomSint32();
1344 currentW = referenceW;
1345 currentH = referenceH;
1346 desiredW = SDLTest_RandomSint32();
1347 desiredH = SDLTest_RandomSint32();
1348
1349 /* Negative tests for window input */
1351 SDLTest_AssertPass("Call to SDL_ClearError()");
1352 SDL_GetWindowMinimumSize(NULL, &currentW, &currentH);
1353 SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(window=NULL)");
1355 currentW == referenceW && currentH == referenceH,
1356 "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
1357 referenceW, referenceH,
1358 currentW, currentH);
1360
1362 SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(NULL, NULL, NULL)");
1364
1365 SDL_SetWindowMinimumSize(NULL, desiredW, desiredH);
1366 SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(window=NULL)");
1368
1369 return TEST_COMPLETED;
1370}
#define SDL_SetWindowMinimumSize
#define SDL_GetWindowMinimumSize

References _checkInvalidParameterError(), _checkInvalidWindowError(), _createVideoSuiteTestWindow(), _destroyVideoSuiteTestWindow(), SDL_Rect::h, NULL, SDL_ClearError, SDL_GetDisplayBounds, SDL_GetWindowMinimumSize, SDL_SetWindowMinimumSize, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_RandomIntegerInRange(), SDLTest_RandomSint32(), TEST_ABORTED, TEST_COMPLETED, and SDL_Rect::w.

◆ video_getSetWindowPosition()

int video_getSetWindowPosition ( void arg)

Tests call to SDL_GetWindowPosition and SDL_SetWindowPosition.

See also
http://wiki.libsdl.org/moin.fcg/SDL_GetWindowPosition
http://wiki.libsdl.org/moin.fcg/SDL_SetWindowPosition

Definition at line 933 of file testautomation_video.c.

934{
935 const char* title = "video_getSetWindowPosition Test Window";
937 int xVariation, yVariation;
938 int referenceX, referenceY;
939 int currentX, currentY;
940 int desiredX, desiredY;
941
942 /* Call against new test window */
944 if (window == NULL) return TEST_ABORTED;
945
946 for (xVariation = 0; xVariation < 4; xVariation++) {
947 for (yVariation = 0; yVariation < 4; yVariation++) {
948 switch(xVariation) {
949 case 0:
950 /* Zero X Position */
951 desiredX = 0;
952 break;
953 case 1:
954 /* Random X position inside screen */
955 desiredX = SDLTest_RandomIntegerInRange(1, 100);
956 break;
957 case 2:
958 /* Random X position outside screen (positive) */
959 desiredX = SDLTest_RandomIntegerInRange(10000, 11000);
960 break;
961 case 3:
962 /* Random X position outside screen (negative) */
963 desiredX = SDLTest_RandomIntegerInRange(-1000, -100);
964 break;
965 }
966
967 switch(yVariation) {
968 case 0:
969 /* Zero X Position */
970 desiredY = 0;
971 break;
972 case 1:
973 /* Random X position inside screen */
974 desiredY = SDLTest_RandomIntegerInRange(1, 100);
975 break;
976 case 2:
977 /* Random X position outside screen (positive) */
978 desiredY = SDLTest_RandomIntegerInRange(10000, 11000);
979 break;
980 case 3:
981 /* Random Y position outside screen (negative) */
982 desiredY = SDLTest_RandomIntegerInRange(-1000, -100);
983 break;
984 }
985
986 /* Set position */
987 SDL_SetWindowPosition(window, desiredX, desiredY);
988 SDLTest_AssertPass("Call to SDL_SetWindowPosition(...,%d,%d)", desiredX, desiredY);
989
990 /* Get position */
991 currentX = desiredX + 1;
992 currentY = desiredY + 1;
993 SDL_GetWindowPosition(window, &currentX, &currentY);
994 SDLTest_AssertPass("Call to SDL_GetWindowPosition()");
995 SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX);
996 SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY);
997
998 /* Get position X */
999 currentX = desiredX + 1;
1000 SDL_GetWindowPosition(window, &currentX, NULL);
1001 SDLTest_AssertPass("Call to SDL_GetWindowPosition(&y=NULL)");
1002 SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX);
1003
1004 /* Get position Y */
1005 currentY = desiredY + 1;
1006 SDL_GetWindowPosition(window, NULL, &currentY);
1007 SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL)");
1008 SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY);
1009 }
1010 }
1011
1012 /* Dummy call with both pointers NULL */
1014 SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL,&y=NULL)");
1015
1016 /* Clean up */
1018
1019 /* Set some 'magic' value for later check that nothing was changed */
1020 referenceX = SDLTest_RandomSint32();
1021 referenceY = SDLTest_RandomSint32();
1022 currentX = referenceX;
1023 currentY = referenceY;
1024 desiredX = SDLTest_RandomSint32();
1025 desiredY = SDLTest_RandomSint32();
1026
1027 /* Negative tests */
1029 SDLTest_AssertPass("Call to SDL_ClearError()");
1030 SDL_GetWindowPosition(NULL, &currentX, &currentY);
1031 SDLTest_AssertPass("Call to SDL_GetWindowPosition(window=NULL)");
1033 currentX == referenceX && currentY == referenceY,
1034 "Verify that content of X and Y pointers has not been modified; expected: %d,%d; got: %d,%d",
1035 referenceX, referenceY,
1036 currentX, currentY);
1038
1040 SDLTest_AssertPass("Call to SDL_GetWindowPosition(NULL, NULL, NULL)");
1042
1043 SDL_SetWindowPosition(NULL, desiredX, desiredY);
1044 SDLTest_AssertPass("Call to SDL_SetWindowPosition(window=NULL)");
1046
1047 return TEST_COMPLETED;
1048}
#define SDL_SetWindowPosition
#define SDL_GetWindowPosition

References _checkInvalidWindowError(), _createVideoSuiteTestWindow(), _destroyVideoSuiteTestWindow(), NULL, SDL_ClearError, SDL_GetWindowPosition, SDL_SetWindowPosition, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_RandomIntegerInRange(), SDLTest_RandomSint32(), TEST_ABORTED, and TEST_COMPLETED.

◆ video_getSetWindowSize()

int video_getSetWindowSize ( void arg)

Tests call to SDL_GetWindowSize and SDL_SetWindowSize.

See also
http://wiki.libsdl.org/moin.fcg/SDL_GetWindowSize
http://wiki.libsdl.org/moin.fcg/SDL_SetWindowSize

Definition at line 1076 of file testautomation_video.c.

1077{
1078 const char* title = "video_getSetWindowSize Test Window";
1080 int result;
1081 SDL_Rect display;
1082 int maxwVariation, maxhVariation;
1083 int wVariation, hVariation;
1084 int referenceW, referenceH;
1085 int currentW, currentH;
1086 int desiredW, desiredH;
1087
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;
1093
1094 /* Call against new test window */
1096 if (window == NULL) return TEST_ABORTED;
1097
1098#ifdef __WIN32__
1099 /* Platform clips window size to screen size */
1100 maxwVariation = 4;
1101 maxhVariation = 4;
1102#else
1103 /* Platform allows window size >= screen size */
1104 maxwVariation = 5;
1105 maxhVariation = 5;
1106#endif
1107
1108 for (wVariation = 0; wVariation < maxwVariation; wVariation++) {
1109 for (hVariation = 0; hVariation < maxhVariation; hVariation++) {
1110 switch(wVariation) {
1111 case 0:
1112 /* 1 Pixel Wide */
1113 desiredW = 1;
1114 break;
1115 case 1:
1116 /* Random width inside screen */
1117 desiredW = SDLTest_RandomIntegerInRange(1, 100);
1118 break;
1119 case 2:
1120 /* Width 1 pixel smaller than screen */
1121 desiredW = display.w - 1;
1122 break;
1123 case 3:
1124 /* Width at screen size */
1125 desiredW = display.w;
1126 break;
1127 case 4:
1128 /* Width 1 pixel larger than screen */
1129 desiredW = display.w + 1;
1130 break;
1131 }
1132
1133 switch(hVariation) {
1134 case 0:
1135 /* 1 Pixel High */
1136 desiredH = 1;
1137 break;
1138 case 1:
1139 /* Random height inside screen */
1140 desiredH = SDLTest_RandomIntegerInRange(1, 100);
1141 break;
1142 case 2:
1143 /* Height 1 pixel smaller than screen */
1144 desiredH = display.h - 1;
1145 break;
1146 case 3:
1147 /* Height at screen size */
1148 desiredH = display.h;
1149 break;
1150 case 4:
1151 /* Height 1 pixel larger than screen */
1152 desiredH = display.h + 1;
1153 break;
1154 }
1155
1156 /* Set size */
1157 SDL_SetWindowSize(window, desiredW, desiredH);
1158 SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH);
1159
1160 /* Get size */
1161 currentW = desiredW + 1;
1162 currentH = desiredH + 1;
1163 SDL_GetWindowSize(window, &currentW, &currentH);
1164 SDLTest_AssertPass("Call to SDL_GetWindowSize()");
1165 SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
1166 SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
1167
1168 /* Get just width */
1169 currentW = desiredW + 1;
1170 SDL_GetWindowSize(window, &currentW, NULL);
1171 SDLTest_AssertPass("Call to SDL_GetWindowSize(&h=NULL)");
1172 SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
1173
1174 /* Get just height */
1175 currentH = desiredH + 1;
1176 SDL_GetWindowSize(window, NULL, &currentH);
1177 SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL)");
1178 SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
1179 }
1180 }
1181
1182 /* Dummy call with both pointers NULL */
1184 SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL,&h=NULL)");
1185
1186 /* Negative tests for parameter input */
1188 SDLTest_AssertPass("Call to SDL_ClearError()");
1189 for (desiredH = -2; desiredH < 2; desiredH++) {
1190 for (desiredW = -2; desiredW < 2; desiredW++) {
1191 if (desiredW <= 0 || desiredH <= 0) {
1192 SDL_SetWindowSize(window, desiredW, desiredH);
1193 SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH);
1195 }
1196 }
1197 }
1198
1199 /* Clean up */
1201
1202 /* Set some 'magic' value for later check that nothing was changed */
1203 referenceW = SDLTest_RandomSint32();
1204 referenceH = SDLTest_RandomSint32();
1205 currentW = referenceW;
1206 currentH = referenceH;
1207 desiredW = SDLTest_RandomSint32();
1208 desiredH = SDLTest_RandomSint32();
1209
1210 /* Negative tests for window input */
1212 SDLTest_AssertPass("Call to SDL_ClearError()");
1213 SDL_GetWindowSize(NULL, &currentW, &currentH);
1214 SDLTest_AssertPass("Call to SDL_GetWindowSize(window=NULL)");
1216 currentW == referenceW && currentH == referenceH,
1217 "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
1218 referenceW, referenceH,
1219 currentW, currentH);
1221
1223 SDLTest_AssertPass("Call to SDL_GetWindowSize(NULL, NULL, NULL)");
1225
1226 SDL_SetWindowSize(NULL, desiredW, desiredH);
1227 SDLTest_AssertPass("Call to SDL_SetWindowSize(window=NULL)");
1229
1230 return TEST_COMPLETED;
1231}
#define SDL_GetWindowSize
#define SDL_SetWindowSize

References _checkInvalidParameterError(), _checkInvalidWindowError(), _createVideoSuiteTestWindow(), _destroyVideoSuiteTestWindow(), SDL_Rect::h, NULL, SDL_ClearError, SDL_GetDisplayBounds, SDL_GetWindowSize, SDL_SetWindowSize, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_RandomIntegerInRange(), SDLTest_RandomSint32(), TEST_ABORTED, TEST_COMPLETED, and SDL_Rect::w.

◆ video_getWindowBrightness()

int video_getWindowBrightness ( void arg)

Tests call to SDL_GetWindowBrightness.

See also
http://wiki.libsdl.org/moin.fcg/SDL_GetWindowBrightness

Definition at line 514 of file testautomation_video.c.

515{
517 const char* title = "video_getWindowBrightness Test Window";
518 float result;
519
520 /* Call against new test window */
522 if (window != NULL) {
524 SDLTest_AssertPass("Call to SDL_GetWindowBrightness()");
525 SDLTest_AssertCheck(result >= 0.0 && result <= 1.0, "Validate range of result value; expected: [0.0, 1.0], got: %f", result);
526 }
527
528 /* Clean up */
530
531 return TEST_COMPLETED;
532}
#define SDL_GetWindowBrightness

References _createVideoSuiteTestWindow(), _destroyVideoSuiteTestWindow(), NULL, SDL_GetWindowBrightness, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

◆ video_getWindowBrightnessNegative()

int video_getWindowBrightnessNegative ( void arg)

Tests call to SDL_GetWindowBrightness with invalid input.

See also
http://wiki.libsdl.org/moin.fcg/SDL_GetWindowBrightness

Definition at line 540 of file testautomation_video.c.

541{
542 const char *invalidWindowError = "Invalid window";
543 char *lastError;
544 float result;
545
546 /* Call against invalid window */
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'",
556 invalidWindowError,
557 lastError);
558 }
559
560 return TEST_COMPLETED;
561}

References NULL, SDL_GetError, SDL_GetWindowBrightness, SDL_strcmp, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

◆ video_getWindowDisplayMode()

int video_getWindowDisplayMode ( void arg)

Tests call to SDL_GetWindowDisplayMode.

See also
http://wiki.libsdl.org/moin.fcg/SDL_GetWindowDisplayMode

Definition at line 569 of file testautomation_video.c.

570{
572 const char* title = "video_getWindowDisplayMode Test Window";
574 int result;
575
576 /* Invalidate part of the mode content so we can check values later */
577 mode.w = -1;
578 mode.h = -1;
579 mode.refresh_rate = -1;
580
581 /* Call against new test window */
583 if (window != NULL) {
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);
590 }
591
592 /* Clean up */
594
595 return TEST_COMPLETED;
596}
#define SDL_GetWindowDisplayMode
GLenum mode

References _createVideoSuiteTestWindow(), _destroyVideoSuiteTestWindow(), NULL, SDL_GetWindowDisplayMode, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

◆ video_getWindowDisplayModeNegative()

int video_getWindowDisplayModeNegative ( void arg)

Tests call to SDL_GetWindowDisplayMode with invalid input.

See also
http://wiki.libsdl.org/moin.fcg/SDL_GetWindowDisplayMode

Definition at line 623 of file testautomation_video.c.

624{
625 const char *expectedError = "Parameter 'mode' is invalid";
626 char *lastError;
628 const char* title = "video_getWindowDisplayModeNegative Test Window";
630 int result;
631
632 /* Call against new test window */
634 if (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'",
644 expectedError,
645 lastError);
646 }
647 }
648
649 /* Clean up */
651
652 /* Call against invalid window */
654 SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(window=NULL,...)");
655 SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result);
657
658 return TEST_COMPLETED;
659}

References _checkInvalidWindowError(), _createVideoSuiteTestWindow(), _destroyVideoSuiteTestWindow(), NULL, SDL_GetError, SDL_GetWindowDisplayMode, SDL_strcmp, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

◆ video_getWindowFlags()

int video_getWindowFlags ( void arg)

Tests the functionality of the SDL_GetWindowFlags function.

Definition at line 331 of file testautomation_video.c.

332{
334 const char* title = "video_getWindowFlags Test Window";
336 Uint32 actualFlags;
337
338 /* Reliable flag set always set in test window */
340
341 /* Call against new test window */
343 if (window != NULL) {
344 actualFlags = SDL_GetWindowFlags(window);
345 SDLTest_AssertPass("Call to SDL_GetWindowFlags()");
346 SDLTest_AssertCheck((flags & actualFlags) == flags, "Verify returned value has flags %d set, got: %d", flags, actualFlags);
347 }
348
349 /* Clean up */
351
352 return TEST_COMPLETED;
353}
#define SDL_GetWindowFlags
uint32_t Uint32
Definition: SDL_stdinc.h:203

References _createVideoSuiteTestWindow(), _destroyVideoSuiteTestWindow(), NULL, SDL_GetWindowFlags, SDL_WINDOW_SHOWN, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

◆ video_getWindowGammaRamp()

int video_getWindowGammaRamp ( void arg)

Tests call to SDL_GetWindowGammaRamp.

See also
http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGammaRamp

Definition at line 667 of file testautomation_video.c.

668{
670 const char* title = "video_getWindowGammaRamp Test Window";
671 Uint16 red[256];
672 Uint16 green[256];
673 Uint16 blue[256];
674 int result;
675
676 /* Call against new test window */
678 if (window == NULL) return TEST_ABORTED;
679
680 /* Retrieve no channel */
682 SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(all NULL)");
683 SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
684
685 /* Retrieve single channel */
687 SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r)");
688 SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
689
691 SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(g)");
692 SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
693
695 SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(b)");
696 SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
697
698 /* Retrieve two channels */
700 SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r, g)");
701 SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
702
704 SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(g,b)");
705 SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
706
708 SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r,b)");
709 SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
710
711 /* Retrieve all channels */
713 SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r,g,b)");
714 SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
715
716 /* Clean up */
718
719 return TEST_COMPLETED;
720}
#define SDL_GetWindowGammaRamp
const GLubyte GLuint red
Definition: SDL_glfuncs.h:80
GLbyte GLbyte blue
GLbyte green
uint16_t Uint16
Definition: SDL_stdinc.h:191

References _createVideoSuiteTestWindow(), _destroyVideoSuiteTestWindow(), NULL, red, SDL_GetWindowGammaRamp, SDLTest_AssertCheck(), SDLTest_AssertPass(), TEST_ABORTED, and TEST_COMPLETED.

◆ video_getWindowGammaRampNegative()

int video_getWindowGammaRampNegative ( void arg)

Tests call to SDL_GetWindowGammaRamp with invalid input.

See also
http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGammaRamp

Definition at line 728 of file testautomation_video.c.

729{
730 Uint16 red[256];
731 Uint16 green[256];
732 Uint16 blue[256];
733 int result;
734
736 SDLTest_AssertPass("Call to SDL_ClearError()");
737
738 /* Call against invalid window */
740 SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(window=NULL,r,g,b)");
741 SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %i", result);
743
744 return TEST_COMPLETED;
745}

References _checkInvalidWindowError(), NULL, red, SDL_ClearError, SDL_GetWindowGammaRamp, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

◆ video_getWindowId()

int video_getWindowId ( void arg)

Tests call to SDL_GetWindowID and SDL_GetWindowFromID.

See also
http://wiki.libsdl.org/moin.fcg/SDL_GetWindowID
http://wiki.libsdl.org/moin.fcg/SDL_SetWindowFromID

Definition at line 843 of file testautomation_video.c.

844{
845 const char* title = "video_getWindowId Test Window";
848 Uint32 id, randomId;
849
850 /* Call against new test window */
852 if (window == NULL) return TEST_ABORTED;
853
854 /* Get ID */
856 SDLTest_AssertPass("Call to SDL_GetWindowID()");
857
858 /* Get window from ID */
860 SDLTest_AssertPass("Call to SDL_GetWindowID(%d)", id);
861 SDLTest_AssertCheck(result == window, "Verify result matches window pointer");
862
863 /* Get window from random large ID, no result check */
864 randomId = SDLTest_RandomIntegerInRange(UINT8_MAX,UINT16_MAX);
865 result = SDL_GetWindowFromID(randomId);
866 SDLTest_AssertPass("Call to SDL_GetWindowID(%d/random_large)", randomId);
867
868 /* Get window from 0 and Uint32 max ID, no result check */
870 SDLTest_AssertPass("Call to SDL_GetWindowID(0)");
871 result = SDL_GetWindowFromID(UINT32_MAX);
872 SDLTest_AssertPass("Call to SDL_GetWindowID(UINT32_MAX)");
873
874 /* Clean up */
876
877 /* Get window from ID for closed window */
879 SDLTest_AssertPass("Call to SDL_GetWindowID(%d/closed_window)", id);
880 SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
881
882 /* Negative test */
884 SDLTest_AssertPass("Call to SDL_ClearError()");
885 id = SDL_GetWindowID(NULL);
886 SDLTest_AssertPass("Call to SDL_GetWindowID(window=NULL)");
888
889 return TEST_COMPLETED;
890}
#define SDL_GetWindowID
#define SDL_GetWindowFromID
GLuint id

References _checkInvalidWindowError(), _createVideoSuiteTestWindow(), _destroyVideoSuiteTestWindow(), NULL, SDL_ClearError, SDL_GetWindowFromID, SDL_GetWindowID, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_RandomIntegerInRange(), TEST_ABORTED, and TEST_COMPLETED.

◆ video_getWindowPixelFormat()

int video_getWindowPixelFormat ( void arg)

Tests call to SDL_GetWindowPixelFormat.

See also
http://wiki.libsdl.org/moin.fcg/SDL_GetWindowPixelFormat

Definition at line 898 of file testautomation_video.c.

899{
900 const char* title = "video_getWindowPixelFormat Test Window";
903
904 /* Call against new test window */
906 if (window == NULL) return TEST_ABORTED;
907
908 /* Get format */
910 SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat()");
911 SDLTest_AssertCheck(format != SDL_PIXELFORMAT_UNKNOWN, "Verify that returned format is valid; expected: != %d, got: %d", SDL_PIXELFORMAT_UNKNOWN, format);
912
913 /* Clean up */
915
916 /* Negative test */
918 SDLTest_AssertPass("Call to SDL_ClearError()");
920 SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat(window=NULL)");
922
923 return TEST_COMPLETED;
924}
#define SDL_GetWindowPixelFormat
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1572
@ SDL_PIXELFORMAT_UNKNOWN
Definition: SDL_pixels.h:173

References _checkInvalidWindowError(), _createVideoSuiteTestWindow(), _destroyVideoSuiteTestWindow(), NULL, SDL_ClearError, SDL_GetWindowPixelFormat, SDL_PIXELFORMAT_UNKNOWN, SDLTest_AssertCheck(), SDLTest_AssertPass(), TEST_ABORTED, and TEST_COMPLETED.

Variable Documentation

◆ videoTest1

const SDLTest_TestCaseReference videoTest1
static
Initial value:
=
{ (SDLTest_TestCaseFp)video_enableDisableScreensaver, "video_enableDisableScreensaver", "Enable and disable screenaver while checking state", TEST_ENABLED }
#define TEST_ENABLED
int(* SDLTest_TestCaseFp)(void *arg)
int video_enableDisableScreensaver(void *arg)
Enable and disable screensaver while checking state.

Definition at line 1727 of file testautomation_video.c.

◆ videoTest10

const SDLTest_TestCaseReference videoTest10
static
Initial value:
=
{ (SDLTest_TestCaseFp)video_getWindowBrightness, "video_getWindowBrightness", "Get window brightness", TEST_ENABLED }
int video_getWindowBrightness(void *arg)
Tests call to SDL_GetWindowBrightness.

Definition at line 1754 of file testautomation_video.c.

◆ videoTest11

const SDLTest_TestCaseReference videoTest11
static
Initial value:
=
{ (SDLTest_TestCaseFp)video_getWindowBrightnessNegative, "video_getWindowBrightnessNegative", "Get window brightness with invalid input", TEST_ENABLED }
int video_getWindowBrightnessNegative(void *arg)
Tests call to SDL_GetWindowBrightness with invalid input.

Definition at line 1757 of file testautomation_video.c.

◆ videoTest12

const SDLTest_TestCaseReference videoTest12
static
Initial value:
=
{ (SDLTest_TestCaseFp)video_getWindowDisplayMode, "video_getWindowDisplayMode", "Get window display mode", TEST_ENABLED }
int video_getWindowDisplayMode(void *arg)
Tests call to SDL_GetWindowDisplayMode.

Definition at line 1760 of file testautomation_video.c.

◆ videoTest13

const SDLTest_TestCaseReference videoTest13
static
Initial value:
=
{ (SDLTest_TestCaseFp)video_getWindowDisplayModeNegative, "video_getWindowDisplayModeNegative", "Get window display mode with invalid input", TEST_ENABLED }
int video_getWindowDisplayModeNegative(void *arg)
Tests call to SDL_GetWindowDisplayMode with invalid input.

Definition at line 1763 of file testautomation_video.c.

◆ videoTest14

const SDLTest_TestCaseReference videoTest14
static
Initial value:
=
{ (SDLTest_TestCaseFp)video_getWindowGammaRamp, "video_getWindowGammaRamp", "Get window gamma ramp", TEST_ENABLED }
int video_getWindowGammaRamp(void *arg)
Tests call to SDL_GetWindowGammaRamp.

Definition at line 1766 of file testautomation_video.c.

◆ videoTest15

const SDLTest_TestCaseReference videoTest15
static
Initial value:
=
{ (SDLTest_TestCaseFp)video_getWindowGammaRampNegative, "video_getWindowGammaRampNegative", "Get window gamma ramp against invalid input", TEST_ENABLED }
int video_getWindowGammaRampNegative(void *arg)
Tests call to SDL_GetWindowGammaRamp with invalid input.

Definition at line 1769 of file testautomation_video.c.

◆ videoTest16

const SDLTest_TestCaseReference videoTest16
static
Initial value:
=
{ (SDLTest_TestCaseFp)video_getSetWindowGrab, "video_getSetWindowGrab", "Checks SDL_GetWindowGrab and SDL_SetWindowGrab positive and negative cases", TEST_ENABLED }
int video_getSetWindowGrab(void *arg)
Tests call to SDL_GetWindowGrab and SDL_SetWindowGrab.

Definition at line 1772 of file testautomation_video.c.

◆ videoTest17

const SDLTest_TestCaseReference videoTest17
static
Initial value:
=
{ (SDLTest_TestCaseFp)video_getWindowId, "video_getWindowId", "Checks SDL_GetWindowID and SDL_GetWindowFromID", TEST_ENABLED }
int video_getWindowId(void *arg)
Tests call to SDL_GetWindowID and SDL_GetWindowFromID.

Definition at line 1775 of file testautomation_video.c.

◆ videoTest18

const SDLTest_TestCaseReference videoTest18
static
Initial value:
=
{ (SDLTest_TestCaseFp)video_getWindowPixelFormat, "video_getWindowPixelFormat", "Checks SDL_GetWindowPixelFormat", TEST_ENABLED }
int video_getWindowPixelFormat(void *arg)
Tests call to SDL_GetWindowPixelFormat.

Definition at line 1778 of file testautomation_video.c.

◆ videoTest19

const SDLTest_TestCaseReference videoTest19
static
Initial value:
=
{ (SDLTest_TestCaseFp)video_getSetWindowPosition, "video_getSetWindowPosition", "Checks SDL_GetWindowPosition and SDL_SetWindowPosition positive and negative cases", TEST_ENABLED }
int video_getSetWindowPosition(void *arg)
Tests call to SDL_GetWindowPosition and SDL_SetWindowPosition.

Definition at line 1781 of file testautomation_video.c.

◆ videoTest2

const SDLTest_TestCaseReference videoTest2
static
Initial value:
=
{ (SDLTest_TestCaseFp)video_createWindowVariousPositions, "video_createWindowVariousPositions", "Create windows at various locations", TEST_ENABLED }
int video_createWindowVariousPositions(void *arg)
Tests the functionality of the SDL_CreateWindow function using different positions.

Definition at line 1730 of file testautomation_video.c.

◆ videoTest20

const SDLTest_TestCaseReference videoTest20
static
Initial value:
=
{ (SDLTest_TestCaseFp)video_getSetWindowSize, "video_getSetWindowSize", "Checks SDL_GetWindowSize and SDL_SetWindowSize positive and negative cases", TEST_ENABLED }
int video_getSetWindowSize(void *arg)
Tests call to SDL_GetWindowSize and SDL_SetWindowSize.

Definition at line 1784 of file testautomation_video.c.

◆ videoTest21

const SDLTest_TestCaseReference videoTest21
static
Initial value:
=
{ (SDLTest_TestCaseFp)video_getSetWindowMinimumSize, "video_getSetWindowMinimumSize", "Checks SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize positive and negative cases", TEST_ENABLED }
int video_getSetWindowMinimumSize(void *arg)
Tests call to SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize.

Definition at line 1787 of file testautomation_video.c.

◆ videoTest22

const SDLTest_TestCaseReference videoTest22
static
Initial value:
=
{ (SDLTest_TestCaseFp)video_getSetWindowMaximumSize, "video_getSetWindowMaximumSize", "Checks SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize positive and negative cases", TEST_ENABLED }
int video_getSetWindowMaximumSize(void *arg)
Tests call to SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize.

Definition at line 1790 of file testautomation_video.c.

◆ videoTest23

const SDLTest_TestCaseReference videoTest23
static
Initial value:
=
{ (SDLTest_TestCaseFp)video_getSetWindowData, "video_getSetWindowData", "Checks SDL_SetWindowData and SDL_GetWindowData positive and negative cases", TEST_ENABLED }
int video_getSetWindowData(void *arg)
Tests call to SDL_SetWindowData and SDL_GetWindowData.

Definition at line 1793 of file testautomation_video.c.

◆ videoTest3

const SDLTest_TestCaseReference videoTest3
static
Initial value:
=
{ (SDLTest_TestCaseFp)video_createWindowVariousSizes, "video_createWindowVariousSizes", "Create windows with various sizes", TEST_ENABLED }
int video_createWindowVariousSizes(void *arg)
Tests the functionality of the SDL_CreateWindow function using different sizes.

Definition at line 1733 of file testautomation_video.c.

◆ videoTest4

const SDLTest_TestCaseReference videoTest4
static
Initial value:
=
{ (SDLTest_TestCaseFp)video_createWindowVariousFlags, "video_createWindowVariousFlags", "Create windows using various flags", TEST_ENABLED }
int video_createWindowVariousFlags(void *arg)
Tests the functionality of the SDL_CreateWindow function using different flags.

Definition at line 1736 of file testautomation_video.c.

◆ videoTest5

const SDLTest_TestCaseReference videoTest5
static
Initial value:
=
{ (SDLTest_TestCaseFp)video_getWindowFlags, "video_getWindowFlags", "Get window flags set during SDL_CreateWindow", TEST_ENABLED }
int video_getWindowFlags(void *arg)
Tests the functionality of the SDL_GetWindowFlags function.

Definition at line 1739 of file testautomation_video.c.

◆ videoTest6

const SDLTest_TestCaseReference videoTest6
static
Initial value:
=
{ (SDLTest_TestCaseFp)video_getNumDisplayModes, "video_getNumDisplayModes", "Use SDL_GetNumDisplayModes function to get number of display modes", TEST_ENABLED }
int video_getNumDisplayModes(void *arg)
Tests the functionality of the SDL_GetNumDisplayModes function.

Definition at line 1742 of file testautomation_video.c.

◆ videoTest7

const SDLTest_TestCaseReference videoTest7
static
Initial value:
=
{ (SDLTest_TestCaseFp)video_getNumDisplayModesNegative, "video_getNumDisplayModesNegative", "Negative tests for SDL_GetNumDisplayModes", TEST_ENABLED }
int video_getNumDisplayModesNegative(void *arg)
Tests negative call to SDL_GetNumDisplayModes function.

Definition at line 1745 of file testautomation_video.c.

◆ videoTest8

const SDLTest_TestCaseReference videoTest8
static
Initial value:
=
{ (SDLTest_TestCaseFp)video_getClosestDisplayModeCurrentResolution, "video_getClosestDisplayModeCurrentResolution", "Use function to get closes match to requested display mode for current resolution", TEST_ENABLED }
int video_getClosestDisplayModeCurrentResolution(void *arg)
Tests the functionality of the SDL_GetClosestDisplayMode function against current resolution.

Definition at line 1748 of file testautomation_video.c.

◆ videoTest9

const SDLTest_TestCaseReference videoTest9
static
Initial value:
=
{ (SDLTest_TestCaseFp)video_getClosestDisplayModeRandomResolution, "video_getClosestDisplayModeRandomResolution", "Use function to get closes match to requested display mode for random resolution", TEST_ENABLED }
int video_getClosestDisplayModeRandomResolution(void *arg)
Tests the functionality of the SDL_GetClosestDisplayMode function against random resolution.

Definition at line 1751 of file testautomation_video.c.

◆ videoTests

const SDLTest_TestCaseReference* videoTests[]
static
Initial value:
= {
}
static const SDLTest_TestCaseReference videoTest20
static const SDLTest_TestCaseReference videoTest1
static const SDLTest_TestCaseReference videoTest10
static const SDLTest_TestCaseReference videoTest2
static const SDLTest_TestCaseReference videoTest5
static const SDLTest_TestCaseReference videoTest8
static const SDLTest_TestCaseReference videoTest16
static const SDLTest_TestCaseReference videoTest13
static const SDLTest_TestCaseReference videoTest19
static const SDLTest_TestCaseReference videoTest14
static const SDLTest_TestCaseReference videoTest7
static const SDLTest_TestCaseReference videoTest17
static const SDLTest_TestCaseReference videoTest3
static const SDLTest_TestCaseReference videoTest9
static const SDLTest_TestCaseReference videoTest21
static const SDLTest_TestCaseReference videoTest12
static const SDLTest_TestCaseReference videoTest23
static const SDLTest_TestCaseReference videoTest11
static const SDLTest_TestCaseReference videoTest4
static const SDLTest_TestCaseReference videoTest22
static const SDLTest_TestCaseReference videoTest18
static const SDLTest_TestCaseReference videoTest15
static const SDLTest_TestCaseReference videoTest6

Definition at line 1797 of file testautomation_video.c.

◆ videoTestSuite

Initial value:
= {
"Video",
}
static const SDLTest_TestCaseReference * videoTests[]

Definition at line 1806 of file testautomation_video.c.