SDL  2.0
testautomation_hints.c
Go to the documentation of this file.
1 /**
2  * Hints test suite
3  */
4 
5 #include <stdio.h>
6 
7 #include "SDL.h"
8 #include "SDL_test.h"
9 
10 
11 const int _numHintsEnum = 25;
12 char* _HintsEnum[] =
13  {
39  };
40 char* _HintsVerbose[] =
41  {
42  "SDL_HINT_ACCELEROMETER_AS_JOYSTICK",
43  "SDL_HINT_FRAMEBUFFER_ACCELERATION",
44  "SDL_HINT_GAMECONTROLLERCONFIG",
45  "SDL_HINT_GRAB_KEYBOARD",
46  "SDL_HINT_IDLE_TIMER_DISABLED",
47  "SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS",
48  "SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK",
49  "SDL_HINT_MOUSE_RELATIVE_MODE_WARP",
50  "SDL_HINT_ORIENTATIONS",
51  "SDL_HINT_RENDER_DIRECT3D_THREADSAFE",
52  "SDL_HINT_RENDER_DRIVER",
53  "SDL_HINT_RENDER_OPENGL_SHADERS",
54  "SDL_HINT_RENDER_SCALE_QUALITY",
55  "SDL_HINT_RENDER_VSYNC",
56  "SDL_HINT_TIMER_RESOLUTION",
57  "SDL_HINT_VIDEO_ALLOW_SCREENSAVER",
58  "SDL_HINT_VIDEO_HIGHDPI_DISABLED",
59  "SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES",
60  "SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS",
61  "SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT",
62  "SDL_HINT_VIDEO_WIN_D3DCOMPILER",
63  "SDL_HINT_VIDEO_X11_XINERAMA",
64  "SDL_HINT_VIDEO_X11_XRANDR",
65  "SDL_HINT_VIDEO_X11_XVIDMODE",
66  "SDL_HINT_XINPUT_ENABLED"
67  };
68 
69 
70 /* Test case functions */
71 
72 /**
73  * @brief Call to SDL_GetHint
74  */
75 int
76 hints_getHint(void *arg)
77 {
78  char *result1;
79  char *result2;
80  int i;
81 
82  for (i=0; i<_numHintsEnum; i++) {
83  result1 = (char *)SDL_GetHint((char*)_HintsEnum[i]);
84  SDLTest_AssertPass("Call to SDL_GetHint(%s) - using define definition", (char*)_HintsEnum[i]);
85  result2 = (char *)SDL_GetHint((char *)_HintsVerbose[i]);
86  SDLTest_AssertPass("Call to SDL_GetHint(%s) - using string definition", (char*)_HintsVerbose[i]);
88  (result1 == NULL && result2 == NULL) || (SDL_strcmp(result1, result2) == 0),
89  "Verify returned values are equal; got: result1='%s' result2='%s",
90  (result1 == NULL) ? "null" : result1,
91  (result2 == NULL) ? "null" : result2);
92  }
93 
94  return TEST_COMPLETED;
95 }
96 
97 /**
98  * @brief Call to SDL_SetHint
99  */
100 int
101 hints_setHint(void *arg)
102 {
103  char *originalValue;
104  char *value;
105  char *testValue;
107  int i, j;
108 
109  /* Create random values to set */
111 
112  for (i=0; i<_numHintsEnum; i++) {
113  /* Capture current value */
114  originalValue = (char *)SDL_GetHint((char*)_HintsEnum[i]);
115  SDLTest_AssertPass("Call to SDL_GetHint(%s)", (char*)_HintsEnum[i]);
116 
117  /* Set value (twice) */
118  for (j=1; j<=2; j++) {
119  result = SDL_SetHint((char*)_HintsEnum[i], value);
120  SDLTest_AssertPass("Call to SDL_SetHint(%s, %s) (iteration %i)", (char*)_HintsEnum[i], value, j);
122  result == SDL_TRUE || result == SDL_FALSE,
123  "Verify valid result was returned, got: %i",
124  (int)result);
125  testValue = (char *)SDL_GetHint((char*)_HintsEnum[i]);
126  SDLTest_AssertPass("Call to SDL_GetHint(%s) - using string definition", (char*)_HintsVerbose[i]);
128  (SDL_strcmp(value, testValue) == 0),
129  "Verify returned value equals set value; got: testValue='%s' value='%s",
130  (testValue == NULL) ? "null" : testValue,
131  value);
132  }
133 
134  /* Reset original value */
135  result = SDL_SetHint((char*)_HintsEnum[i], originalValue);
136  SDLTest_AssertPass("Call to SDL_SetHint(%s, originalValue)", (char*)_HintsEnum[i]);
138  result == SDL_TRUE || result == SDL_FALSE,
139  "Verify valid result was returned, got: %i",
140  (int)result);
141  }
142 
143  SDL_free(value);
144 
145  return TEST_COMPLETED;
146 }
147 
148 /* ================= Test References ================== */
149 
150 /* Hints test cases */
152  { (SDLTest_TestCaseFp)hints_getHint, "hints_getHint", "Call to SDL_GetHint", TEST_ENABLED };
153 
155  { (SDLTest_TestCaseFp)hints_setHint, "hints_setHint", "Call to SDL_SetHint", TEST_ENABLED };
156 
157 /* Sequence of Hints test cases */
160 };
161 
162 /* Hints test suite (global) */
164  "Hints",
165  NULL,
166  hintsTests,
167  NULL
168 };
SDL.h
SDL_HINT_RENDER_VSYNC
#define SDL_HINT_RENDER_VSYNC
A variable controlling whether updates to the SDL screen surface should be synchronized with the vert...
Definition: SDL_hints.h:154
SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
#define SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
A variable that lets you enable joystick (and gamecontroller) events even when your app is in the bac...
Definition: SDL_hints.h:476
hintsTest2
static const SDLTest_TestCaseReference hintsTest2
Definition: testautomation_hints.c:154
SDL_test.h
NULL
#define NULL
Definition: begin_code.h:164
SDL_HINT_VIDEO_HIGHDPI_DISABLED
#define SDL_HINT_VIDEO_HIGHDPI_DISABLED
If set to 1, then do not allow high-DPI windows. ("Retina" on Mac and iOS)
Definition: SDL_hints.h:632
SDL_HINT_VIDEO_ALLOW_SCREENSAVER
#define SDL_HINT_VIDEO_ALLOW_SCREENSAVER
A variable controlling whether the screensaver is enabled.
Definition: SDL_hints.h:165
SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS
#define SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS
Minimize your SDL_Window if it loses key focus when in fullscreen mode. Defaults to true.
Definition: SDL_hints.h:322
SDL_HINT_RENDER_OPENGL_SHADERS
#define SDL_HINT_RENDER_OPENGL_SHADERS
A variable controlling whether the OpenGL render driver uses shaders if they are available.
Definition: SDL_hints.h:96
SDL_HINT_RENDER_SCALE_QUALITY
#define SDL_HINT_RENDER_SCALE_QUALITY
A variable controlling the scaling quality.
Definition: SDL_hints.h:143
TEST_ENABLED
#define TEST_ENABLED
Definition: SDL_test_harness.h:47
hintsTestSuite
SDLTest_TestSuiteReference hintsTestSuite
Definition: testautomation_hints.c:163
SDL_GetHint
#define SDL_GetHint
Definition: SDL_dynapi_overrides.h:191
SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK
#define SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK
A variable that determines whether ctrl+click should generate a right-click event on Mac.
Definition: SDL_hints.h:640
result
GLuint64EXT * result
Definition: SDL_opengl_glext.h:9432
SDL_HINT_TIMER_RESOLUTION
#define SDL_HINT_TIMER_RESOLUTION
A variable that controls the timer resolution, in milliseconds.
Definition: SDL_hints.h:584
SDL_HINT_VIDEO_WIN_D3DCOMPILER
#define SDL_HINT_VIDEO_WIN_D3DCOMPILER
A variable specifying which shader compiler to preload when using the Chrome ANGLE binaries.
Definition: SDL_hints.h:656
SDLTest_RandomAsciiStringOfSize
char * SDLTest_RandomAsciiStringOfSize(int size)
Definition: SDL_test_fuzzer.c:507
SDL_HINT_ACCELEROMETER_AS_JOYSTICK
#define SDL_HINT_ACCELEROMETER_AS_JOYSTICK
A variable controlling whether the Android / iOS built-in accelerometer should be listed as a joystic...
Definition: SDL_hints.h:399
SDL_HINT_XINPUT_ENABLED
#define SDL_HINT_XINPUT_ENABLED
A variable that lets you disable the detection and use of Xinput gamepad devices.
Definition: SDL_hints.h:418
SDL_HINT_GRAB_KEYBOARD
#define SDL_HINT_GRAB_KEYBOARD
A variable controlling whether grabbing input grabs the keyboard.
Definition: SDL_hints.h:263
SDLTest_TestCaseFp
int(* SDLTest_TestCaseFp)(void *arg)
Definition: SDL_test_harness.h:67
SDLTest_AssertPass
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.
Definition: SDL_test_assert.c:94
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
_HintsVerbose
char * _HintsVerbose[]
Definition: testautomation_hints.c:40
hints_getHint
int hints_getHint(void *arg)
Call to SDL_GetHint.
Definition: testautomation_hints.c:76
SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES
#define SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES
A variable that dictates policy for fullscreen Spaces on Mac OS X.
Definition: SDL_hints.h:793
SDLTest_AssertCheck
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...
Definition: SDL_test_assert.c:65
SDLTest_TestCaseReference
Definition: SDL_test_harness.h:75
TEST_COMPLETED
#define TEST_COMPLETED
Definition: SDL_test_harness.h:53
SDL_HINT_RENDER_DIRECT3D_THREADSAFE
#define SDL_HINT_RENDER_DIRECT3D_THREADSAFE
A variable controlling whether the Direct3D device is initialized for thread-safe operations.
Definition: SDL_hints.h:107
_numHintsEnum
const int _numHintsEnum
Definition: testautomation_hints.c:11
SDL_TRUE
@ SDL_TRUE
Definition: SDL_stdinc.h:164
_HintsEnum
char * _HintsEnum[]
Definition: testautomation_hints.c:12
SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT
#define SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT
A variable that is the address of another SDL_Window* (as a hex string formatted with "%p").
Definition: SDL_hints.h:675
SDL_HINT_IDLE_TIMER_DISABLED
#define SDL_HINT_IDLE_TIMER_DISABLED
A variable controlling whether the idle timer is disabled on iOS.
Definition: SDL_hints.h:339
SDL_HINT_VIDEO_X11_XRANDR
#define SDL_HINT_VIDEO_X11_XRANDR
A variable controlling whether the X11 XRandR extension should be used.
Definition: SDL_hints.h:198
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
SDL_HINT_ORIENTATIONS
#define SDL_HINT_ORIENTATIONS
A variable controlling which orientations are allowed on iOS/Android.
Definition: SDL_hints.h:350
hintsTests
static const SDLTest_TestCaseReference * hintsTests[]
Definition: testautomation_hints.c:158
j
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 int in j)
Definition: SDL_x11sym.h:50
SDL_SetHint
#define SDL_SetHint
Definition: SDL_dynapi_overrides.h:190
SDL_HINT_GAMECONTROLLERCONFIG
#define SDL_HINT_GAMECONTROLLERCONFIG
A variable that lets you manually hint extra gamecontroller db entries.
Definition: SDL_hints.h:437
SDL_HINT_FRAMEBUFFER_ACCELERATION
#define SDL_HINT_FRAMEBUFFER_ACCELERATION
A variable controlling how 3D acceleration is used to accelerate the SDL screen surface.
Definition: SDL_hints.h:65
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:162
hints_setHint
int hints_setHint(void *arg)
Call to SDL_SetHint.
Definition: testautomation_hints.c:101
SDL_HINT_RENDER_DRIVER
#define SDL_HINT_RENDER_DRIVER
A variable specifying which render driver to use.
Definition: SDL_hints.h:85
SDL_FALSE
@ SDL_FALSE
Definition: SDL_stdinc.h:163
hintsTest1
static const SDLTest_TestCaseReference hintsTest1
Definition: testautomation_hints.c:151
SDL_HINT_VIDEO_X11_XINERAMA
#define SDL_HINT_VIDEO_X11_XINERAMA
A variable controlling whether the X11 Xinerama extension should be used.
Definition: SDL_hints.h:187
SDL_strcmp
#define SDL_strcmp
Definition: SDL_dynapi_overrides.h:417
SDL_HINT_MOUSE_RELATIVE_MODE_WARP
#define SDL_HINT_MOUSE_RELATIVE_MODE_WARP
A variable controlling whether relative mouse mode is implemented using mouse warping.
Definition: SDL_hints.h:294
SDL_HINT_VIDEO_X11_XVIDMODE
#define SDL_HINT_VIDEO_X11_XVIDMODE
A variable controlling whether the X11 VidMode extension should be used.
Definition: SDL_hints.h:176
SDLTest_TestSuiteReference
Definition: SDL_test_harness.h:89
i
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