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 };
#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:466
SDLTest_TestSuiteReference hintsTestSuite
GLuint64EXT * result
int hints_setHint(void *arg)
Call to SDL_SetHint.
static const SDLTest_TestCaseReference hintsTest1
#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
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.
#define SDL_HINT_RENDER_SCALE_QUALITY
A variable controlling the scaling quality.
Definition: SDL_hints.h:143
#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:312
#define SDL_HINT_VIDEO_ALLOW_SCREENSAVER
A variable controlling whether the screensaver is enabled.
Definition: SDL_hints.h:165
#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:536
#define SDL_GetHint
#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
#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:544
#define SDL_HINT_TIMER_RESOLUTION
A variable that controls the timer resolution, in milliseconds.
Definition: SDL_hints.h:492
#define SDL_HINT_GRAB_KEYBOARD
A variable controlling whether grabbing input grabs the keyboard.
Definition: SDL_hints.h:263
#define SDL_HINT_XINPUT_ENABLED
A variable that lets you disable the detection and use of Xinput gamepad devices. ...
Definition: SDL_hints.h:408
#define SDL_HINT_VIDEO_WIN_D3DCOMPILER
A variable specifying which shader compiler to preload when using the Chrome ANGLE binaries...
Definition: SDL_hints.h:560
int(* SDLTest_TestCaseFp)(void *arg)
char * SDLTest_RandomAsciiStringOfSize(int size)
#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:389
char * _HintsVerbose[]
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 SDL_free
#define SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES
A variable that dictates policy for fullscreen Spaces on Mac OS X.
Definition: SDL_hints.h:697
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
GLsizei const GLfloat * value
#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:579
#define TEST_COMPLETED
#define SDL_HINT_IDLE_TIMER_DISABLED
A variable controlling whether the idle timer is disabled on iOS.
Definition: SDL_hints.h:329
#define TEST_ENABLED
#define SDL_HINT_RENDER_DIRECT3D_THREADSAFE
A variable controlling whether the Direct3D device is initialized for thread-safe operations...
Definition: SDL_hints.h:107
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
#define SDL_HINT_ORIENTATIONS
A variable controlling which orientations are allowed on iOS.
Definition: SDL_hints.h:340
#define NULL
Definition: begin_code.h:164
SDL_bool
Definition: SDL_stdinc.h:139
#define SDL_HINT_VIDEO_X11_XRANDR
A variable controlling whether the X11 XRandR extension should be used.
Definition: SDL_hints.h:198
int hints_getHint(void *arg)
Call to SDL_GetHint.
#define SDL_SetHint
#define SDL_HINT_FRAMEBUFFER_ACCELERATION
A variable controlling how 3D acceleration is used to accelerate the SDL screen surface.
Definition: SDL_hints.h:65
#define SDL_HINT_RENDER_DRIVER
A variable specifying which render driver to use.
Definition: SDL_hints.h:85
const int _numHintsEnum
#define SDL_HINT_GAMECONTROLLERCONFIG
A variable that lets you manually hint extra gamecontroller db entries.
Definition: SDL_hints.h:427
char * _HintsEnum[]
static const SDLTest_TestCaseReference hintsTest2
#define SDL_strcmp
#define SDL_HINT_VIDEO_X11_XVIDMODE
A variable controlling whether the X11 VidMode extension should be used.
Definition: SDL_hints.h:176
#define SDL_HINT_MOUSE_RELATIVE_MODE_WARP
A variable controlling whether relative mouse mode is implemented using mouse warping.
Definition: SDL_hints.h:284
#define SDL_HINT_VIDEO_X11_XINERAMA
A variable controlling whether the X11 Xinerama extension should be used.
Definition: SDL_hints.h:187
static const SDLTest_TestCaseReference * hintsTests[]