Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
1813 lines (1548 loc) · 64.3 KB

testautomation_video.c

File metadata and controls

1813 lines (1548 loc) · 64.3 KB
 
1
2
3
4
5
/**
* Video test suite
*/
#include <stdio.h>
Apr 16, 2013
Apr 16, 2013
6
#include <string.h>
Mar 4, 2013
Mar 4, 2013
8
9
10
11
12
13
14
15
16
17
/* Visual Studio 2008 doesn't have stdint.h */
#if defined(_MSC_VER) && _MSC_VER <= 1500
#define UINT8_MAX ~(Uint8)0
#define UINT16_MAX ~(Uint16)0
#define UINT32_MAX ~(Uint32)0
#define UINT64_MAX ~(Uint64)0
#else
#include <stdint.h>
#endif
18
19
20
#include "SDL.h"
#include "SDL_test.h"
Feb 25, 2013
Feb 25, 2013
21
22
/* Private helpers */
May 18, 2013
May 18, 2013
23
/*
Feb 25, 2013
Feb 25, 2013
24
25
26
27
28
29
30
31
32
33
34
35
36
* Create a test window
*/
SDL_Window *_createVideoSuiteTestWindow(const char *title)
{
SDL_Window* window;
int x, y, w, h;
SDL_WindowFlags flags;
/* Standard window */
x = SDLTest_RandomIntegerInRange(1, 100);
y = SDLTest_RandomIntegerInRange(1, 100);
w = SDLTest_RandomIntegerInRange(320, 1024);
h = SDLTest_RandomIntegerInRange(320, 768);
Mar 9, 2013
Mar 9, 2013
37
flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS;
May 18, 2013
May 18, 2013
38
Feb 25, 2013
Feb 25, 2013
39
40
41
42
43
44
45
46
window = SDL_CreateWindow(title, x, y, w, h, flags);
SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
return window;
}
/*
May 18, 2013
May 18, 2013
47
* Destroy test window
Feb 25, 2013
Feb 25, 2013
48
49
50
*/
void _destroyVideoSuiteTestWindow(SDL_Window *window)
{
May 18, 2013
May 18, 2013
51
if (window != NULL) {
Feb 25, 2013
Feb 25, 2013
52
53
54
55
56
57
SDL_DestroyWindow(window);
window = NULL;
SDLTest_AssertPass("Call to SDL_DestroyWindow");
}
}
58
59
60
61
62
63
64
65
/* Test case functions */
/**
* @brief Enable and disable screensaver while checking state
*/
int
video_enableDisableScreensaver(void *arg)
{
May 18, 2013
May 18, 2013
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
SDL_bool initialResult;
SDL_bool result;
/* Get current state and proceed according to current state */
initialResult = SDL_IsScreenSaverEnabled();
SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
if (initialResult == SDL_TRUE) {
/* Currently enabled: disable first, then enable again */
/* Disable screensaver and check */
SDL_DisableScreenSaver();
SDLTest_AssertPass("Call to SDL_DisableScreenSaver()");
result = SDL_IsScreenSaverEnabled();
SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);
/* Enable screensaver and check */
SDL_EnableScreenSaver();
SDLTest_AssertPass("Call to SDL_EnableScreenSaver()");
result = SDL_IsScreenSaverEnabled();
SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
} else {
/* Currently disabled: enable first, then disable again */
/* Enable screensaver and check */
SDL_EnableScreenSaver();
SDLTest_AssertPass("Call to SDL_EnableScreenSaver()");
result = SDL_IsScreenSaverEnabled();
SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
/* Disable screensaver and check */
SDL_DisableScreenSaver();
SDLTest_AssertPass("Call to SDL_DisableScreenSaver()");
result = SDL_IsScreenSaverEnabled();
SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);
}
return TEST_COMPLETED;
Feb 17, 2013
Feb 17, 2013
112
113
114
115
116
117
118
119
120
121
/**
* @brief Tests the functionality of the SDL_CreateWindow function using different positions
*/
int
video_createWindowVariousPositions(void *arg)
{
SDL_Window* window;
const char* title = "video_createWindowVariousPositions Test Window";
int x, y, w, h;
int xVariation, yVariation;
May 18, 2013
May 18, 2013
122
Feb 17, 2013
Feb 17, 2013
123
124
125
126
for (xVariation = 0; xVariation < 6; xVariation++) {
for (yVariation = 0; yVariation < 6; yVariation++) {
switch(xVariation) {
case 0:
May 18, 2013
May 18, 2013
127
/* Zero X Position */
Feb 17, 2013
Feb 17, 2013
128
129
130
x = 0;
break;
case 1:
May 18, 2013
May 18, 2013
131
/* Random X position inside screen */
Feb 17, 2013
Feb 17, 2013
132
133
134
x = SDLTest_RandomIntegerInRange(1, 100);
break;
case 2:
May 18, 2013
May 18, 2013
135
/* Random X position outside screen (positive) */
Feb 17, 2013
Feb 17, 2013
136
137
138
x = SDLTest_RandomIntegerInRange(10000, 11000);
break;
case 3:
May 18, 2013
May 18, 2013
139
/* Random X position outside screen (negative) */
Feb 17, 2013
Feb 17, 2013
140
141
142
x = SDLTest_RandomIntegerInRange(-1000, -100);
break;
case 4:
May 18, 2013
May 18, 2013
143
/* Centered X position */
Feb 17, 2013
Feb 17, 2013
144
145
146
x = SDL_WINDOWPOS_CENTERED;
break;
case 5:
May 18, 2013
May 18, 2013
147
/* Undefined X position */
Feb 17, 2013
Feb 17, 2013
148
149
150
151
152
153
x = SDL_WINDOWPOS_UNDEFINED;
break;
}
switch(yVariation) {
case 0:
May 18, 2013
May 18, 2013
154
/* Zero X Position */
Feb 17, 2013
Feb 17, 2013
155
156
157
y = 0;
break;
case 1:
May 18, 2013
May 18, 2013
158
/* Random X position inside screen */
Feb 17, 2013
Feb 17, 2013
159
160
161
y = SDLTest_RandomIntegerInRange(1, 100);
break;
case 2:
May 18, 2013
May 18, 2013
162
/* Random X position outside screen (positive) */
Feb 17, 2013
Feb 17, 2013
163
164
165
y = SDLTest_RandomIntegerInRange(10000, 11000);
break;
case 3:
May 18, 2013
May 18, 2013
166
/* Random Y position outside screen (negative) */
Feb 17, 2013
Feb 17, 2013
167
168
169
y = SDLTest_RandomIntegerInRange(-1000, -100);
break;
case 4:
May 18, 2013
May 18, 2013
170
/* Centered Y position */
Feb 17, 2013
Feb 17, 2013
171
172
173
y = SDL_WINDOWPOS_CENTERED;
break;
case 5:
May 18, 2013
May 18, 2013
174
/* Undefined Y position */
Feb 17, 2013
Feb 17, 2013
175
176
177
y = SDL_WINDOWPOS_UNDEFINED;
break;
}
May 18, 2013
May 18, 2013
178
Feb 17, 2013
Feb 17, 2013
179
180
181
182
183
w = SDLTest_RandomIntegerInRange(32, 96);
h = SDLTest_RandomIntegerInRange(32, 96);
window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN);
SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h);
SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
Feb 25, 2013
Feb 25, 2013
184
May 18, 2013
May 18, 2013
185
/* Clean up */
Feb 25, 2013
Feb 25, 2013
186
_destroyVideoSuiteTestWindow(window);
Feb 17, 2013
Feb 17, 2013
187
}
May 18, 2013
May 18, 2013
188
}
Feb 17, 2013
Feb 17, 2013
189
190
191
192
193
194
195
196
197
198
199
200
201
202
return TEST_COMPLETED;
}
/**
* @brief Tests the functionality of the SDL_CreateWindow function using different sizes
*/
int
video_createWindowVariousSizes(void *arg)
{
SDL_Window* window;
const char* title = "video_createWindowVariousSizes Test Window";
int x, y, w, h;
int wVariation, hVariation;
May 18, 2013
May 18, 2013
203
Feb 17, 2013
Feb 17, 2013
204
205
206
207
208
209
x = SDLTest_RandomIntegerInRange(1, 100);
y = SDLTest_RandomIntegerInRange(1, 100);
for (wVariation = 0; wVariation < 3; wVariation++) {
for (hVariation = 0; hVariation < 3; hVariation++) {
switch(wVariation) {
case 0:
May 18, 2013
May 18, 2013
210
/* Width of 1 */
Feb 17, 2013
Feb 17, 2013
211
212
213
w = 1;
break;
case 1:
May 18, 2013
May 18, 2013
214
/* Random "normal" width */
Feb 17, 2013
Feb 17, 2013
215
216
217
w = SDLTest_RandomIntegerInRange(320, 1920);
break;
case 2:
May 18, 2013
May 18, 2013
218
/* Random "large" width */
Feb 17, 2013
Feb 17, 2013
219
220
221
222
223
224
w = SDLTest_RandomIntegerInRange(2048, 4095);
break;
}
switch(hVariation) {
case 0:
May 18, 2013
May 18, 2013
225
/* Height of 1 */
Feb 17, 2013
Feb 17, 2013
226
227
228
h = 1;
break;
case 1:
May 18, 2013
May 18, 2013
229
/* Random "normal" height */
Feb 17, 2013
Feb 17, 2013
230
231
232
h = SDLTest_RandomIntegerInRange(320, 1080);
break;
case 2:
May 18, 2013
May 18, 2013
233
/* Random "large" height */
Feb 17, 2013
Feb 17, 2013
234
235
236
h = SDLTest_RandomIntegerInRange(2048, 4095);
break;
}
May 18, 2013
May 18, 2013
237
Feb 17, 2013
Feb 17, 2013
238
239
240
window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN);
SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h);
SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
Feb 25, 2013
Feb 25, 2013
241
May 18, 2013
May 18, 2013
242
/* Clean up */
Feb 25, 2013
Feb 25, 2013
243
_destroyVideoSuiteTestWindow(window);
Feb 17, 2013
Feb 17, 2013
244
}
May 18, 2013
May 18, 2013
245
}
Feb 17, 2013
Feb 17, 2013
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
return TEST_COMPLETED;
}
/**
* @brief Tests the functionality of the SDL_CreateWindow function using different flags
*/
int
video_createWindowVariousFlags(void *arg)
{
SDL_Window* window;
const char* title = "video_createWindowVariousFlags Test Window";
int x, y, w, h;
int fVariation;
SDL_WindowFlags flags;
May 18, 2013
May 18, 2013
261
Feb 17, 2013
Feb 17, 2013
262
263
264
265
266
267
268
269
270
271
272
/* Standard window */
x = SDLTest_RandomIntegerInRange(1, 100);
y = SDLTest_RandomIntegerInRange(1, 100);
w = SDLTest_RandomIntegerInRange(320, 1024);
h = SDLTest_RandomIntegerInRange(320, 768);
for (fVariation = 0; fVariation < 13; fVariation++) {
switch(fVariation) {
case 0:
flags = SDL_WINDOW_FULLSCREEN;
/* Skip - blanks screen; comment out next line to run test */
May 18, 2013
May 18, 2013
273
continue;
Feb 17, 2013
Feb 17, 2013
274
275
276
277
break;
case 1:
flags = SDL_WINDOW_FULLSCREEN_DESKTOP;
/* Skip - blanks screen; comment out next line to run test */
May 18, 2013
May 18, 2013
278
continue;
Feb 17, 2013
Feb 17, 2013
279
280
281
break;
case 2:
flags = SDL_WINDOW_OPENGL;
May 18, 2013
May 18, 2013
282
break;
Feb 17, 2013
Feb 17, 2013
283
284
case 3:
flags = SDL_WINDOW_SHOWN;
May 18, 2013
May 18, 2013
285
286
break;
case 4:
Feb 17, 2013
Feb 17, 2013
287
flags = SDL_WINDOW_HIDDEN;
May 18, 2013
May 18, 2013
288
break;
Feb 17, 2013
Feb 17, 2013
289
290
case 5:
flags = SDL_WINDOW_BORDERLESS;
May 18, 2013
May 18, 2013
291
break;
Feb 17, 2013
Feb 17, 2013
292
293
case 6:
flags = SDL_WINDOW_RESIZABLE;
May 18, 2013
May 18, 2013
294
break;
Feb 17, 2013
Feb 17, 2013
295
296
case 7:
flags = SDL_WINDOW_MINIMIZED;
May 18, 2013
May 18, 2013
297
break;
Feb 17, 2013
Feb 17, 2013
298
299
300
case 8:
flags = SDL_WINDOW_MAXIMIZED;
break;
May 18, 2013
May 18, 2013
301
case 9:
Feb 17, 2013
Feb 17, 2013
302
303
flags = SDL_WINDOW_INPUT_GRABBED;
break;
May 18, 2013
May 18, 2013
304
case 10:
Feb 17, 2013
Feb 17, 2013
305
flags = SDL_WINDOW_INPUT_FOCUS;
May 18, 2013
May 18, 2013
306
307
break;
case 11:
Feb 17, 2013
Feb 17, 2013
308
309
flags = SDL_WINDOW_MOUSE_FOCUS;
break;
May 18, 2013
May 18, 2013
310
case 12:
Feb 17, 2013
Feb 17, 2013
311
312
313
flags = SDL_WINDOW_FOREIGN;
break;
}
May 18, 2013
May 18, 2013
314
Feb 17, 2013
Feb 17, 2013
315
316
317
window = SDL_CreateWindow(title, x, y, w, h, flags);
SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
Feb 25, 2013
Feb 25, 2013
318
May 18, 2013
May 18, 2013
319
320
/* Clean up */
_destroyVideoSuiteTestWindow(window);
Feb 17, 2013
Feb 17, 2013
321
322
323
324
325
}
return TEST_COMPLETED;
}
Feb 25, 2013
Feb 25, 2013
326
Feb 17, 2013
Feb 17, 2013
327
328
329
330
331
332
333
334
335
336
/**
* @brief Tests the functionality of the SDL_GetWindowFlags function
*/
int
video_getWindowFlags(void *arg)
{
SDL_Window* window;
const char* title = "video_getWindowFlags Test Window";
SDL_WindowFlags flags;
Uint32 actualFlags;
May 18, 2013
May 18, 2013
337
Feb 25, 2013
Feb 25, 2013
338
/* Reliable flag set always set in test window */
Feb 17, 2013
Feb 17, 2013
339
flags = SDL_WINDOW_SHOWN;
May 18, 2013
May 18, 2013
340
341
/* Call against new test window */
Feb 25, 2013
Feb 25, 2013
342
window = _createVideoSuiteTestWindow(title);
Feb 17, 2013
Feb 17, 2013
343
344
345
346
if (window != NULL) {
actualFlags = SDL_GetWindowFlags(window);
SDLTest_AssertPass("Call to SDL_GetWindowFlags");
SDLTest_AssertCheck((flags & actualFlags) == flags, "Verify returned value has flags %d set, got: %d", flags, actualFlags);
Feb 25, 2013
Feb 25, 2013
347
348
}
May 18, 2013
May 18, 2013
349
/* Clean up */
Feb 25, 2013
Feb 25, 2013
350
_destroyVideoSuiteTestWindow(window);
May 18, 2013
May 18, 2013
351
Feb 25, 2013
Feb 25, 2013
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
return TEST_COMPLETED;
}
/**
* @brief Tests the functionality of the SDL_GetNumDisplayModes function
*/
int
video_getNumDisplayModes(void *arg)
{
int result;
int displayNum;
int i;
/* Get number of displays */
displayNum = SDL_GetNumVideoDisplays();
SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays");
May 18, 2013
May 18, 2013
369
/* Make call for each display */
Feb 25, 2013
Feb 25, 2013
370
371
372
373
for (i=0; i<displayNum; i++) {
result = SDL_GetNumDisplayModes(i);
SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d)", i);
SDLTest_AssertCheck(result >= 1, "Validate returned value from function; expected: >=1; got: %d", result);
Feb 17, 2013
Feb 17, 2013
374
375
376
377
378
}
return TEST_COMPLETED;
}
Feb 25, 2013
Feb 25, 2013
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
/**
* @brief Tests negative call to SDL_GetNumDisplayModes function
*/
int
video_getNumDisplayModesNegative(void *arg)
{
int result;
int displayNum;
int displayIndex;
/* Get number of displays */
displayNum = SDL_GetNumVideoDisplays();
SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays");
/* Invalid boundary values */
displayIndex = SDLTest_RandomSint32BoundaryValue(0, displayNum, SDL_FALSE);
result = SDL_GetNumDisplayModes(displayIndex);
SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/boundary)", displayIndex);
May 18, 2013
May 18, 2013
397
398
SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result);
Feb 25, 2013
Feb 25, 2013
399
400
401
402
/* Large (out-of-bounds) display index */
displayIndex = SDLTest_RandomIntegerInRange(-2000, -1000);
result = SDL_GetNumDisplayModes(displayIndex);
SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/large negative)", displayIndex);
May 18, 2013
May 18, 2013
403
SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result);
Feb 25, 2013
Feb 25, 2013
404
405
406
407
displayIndex = SDLTest_RandomIntegerInRange(1000, 2000);
result = SDL_GetNumDisplayModes(displayIndex);
SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/large positive)", displayIndex);
May 18, 2013
May 18, 2013
408
SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result);
Feb 25, 2013
Feb 25, 2013
409
410
411
412
413
414
415
416
417
418
419
return TEST_COMPLETED;
}
/**
* @brief Tests the functionality of the SDL_GetClosestDisplayMode function against current resolution
*/
int
video_getClosestDisplayModeCurrentResolution(void *arg)
{
int result;
May 18, 2013
May 18, 2013
420
421
SDL_DisplayMode current;
SDL_DisplayMode target;
Feb 25, 2013
Feb 25, 2013
422
423
424
425
426
427
428
429
430
431
SDL_DisplayMode closest;
SDL_DisplayMode* dResult;
int displayNum;
int i;
int variation;
/* Get number of displays */
displayNum = SDL_GetNumVideoDisplays();
SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays");
May 18, 2013
May 18, 2013
432
/* Make calls for each display */
Feb 25, 2013
Feb 25, 2013
433
434
for (i=0; i<displayNum; i++) {
SDLTest_Log("Testing against display: %d", i);
May 18, 2013
May 18, 2013
435
Feb 25, 2013
Feb 25, 2013
436
437
438
439
440
441
442
/* Get first display mode to get a sane resolution; this should always work */
result = SDL_GetDisplayMode(i, 0, &current);
SDLTest_AssertPass("Call to SDL_GetDisplayMode");
SDLTest_AssertCheck(result == 0, "Verify return value, expected: 0, got: %d", result);
if (result != 0) {
return TEST_ABORTED;
}
May 18, 2013
May 18, 2013
443
Feb 25, 2013
Feb 25, 2013
444
445
/* Set the desired resolution equals to current resolution */
target.w = current.w;
May 18, 2013
May 18, 2013
446
target.h = current.h;
Feb 25, 2013
Feb 25, 2013
447
448
449
450
451
for (variation = 0; variation < 8; variation ++) {
/* Vary constraints on other query parameters */
target.format = (variation & 1) ? current.format : 0;
target.refresh_rate = (variation & 2) ? current.refresh_rate : 0;
target.driverdata = (variation & 4) ? current.driverdata : 0;
May 18, 2013
May 18, 2013
452
Feb 25, 2013
Feb 25, 2013
453
454
455
456
/* Make call */
dResult = SDL_GetClosestDisplayMode(i, &target, &closest);
SDLTest_AssertPass("Call to SDL_GetClosestDisplayMode(target=current/variation%d)", variation);
SDLTest_AssertCheck(dResult != NULL, "Verify returned value is not NULL");
May 18, 2013
May 18, 2013
457
Feb 25, 2013
Feb 25, 2013
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
/* Check that one gets the current resolution back again */
SDLTest_AssertCheck(closest.w == current.w, "Verify returned width matches current width; expected: %d, got: %d", current.w, closest.w);
SDLTest_AssertCheck(closest.h == current.h, "Verify returned height matches current height; expected: %d, got: %d", current.h, closest.h);
SDLTest_AssertCheck(closest.w == dResult->w, "Verify return value matches assigned value; expected: %d, got: %d", closest.w, dResult->w);
SDLTest_AssertCheck(closest.h == dResult->h, "Verify return value matches assigned value; expected: %d, got: %d", closest.h, dResult->h);
}
}
return TEST_COMPLETED;
}
/**
* @brief Tests the functionality of the SDL_GetClosestDisplayMode function against random resolution
*/
int
video_getClosestDisplayModeRandomResolution(void *arg)
{
May 18, 2013
May 18, 2013
475
SDL_DisplayMode target;
Feb 25, 2013
Feb 25, 2013
476
477
478
479
480
481
482
483
484
485
SDL_DisplayMode closest;
SDL_DisplayMode* dResult;
int displayNum;
int i;
int variation;
/* Get number of displays */
displayNum = SDL_GetNumVideoDisplays();
SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays");
May 18, 2013
May 18, 2013
486
/* Make calls for each display */
Feb 25, 2013
Feb 25, 2013
487
488
for (i=0; i<displayNum; i++) {
SDLTest_Log("Testing against display: %d", i);
May 18, 2013
May 18, 2013
489
Feb 25, 2013
Feb 25, 2013
490
for (variation = 0; variation < 16; variation ++) {
May 18, 2013
May 18, 2013
491
Feb 25, 2013
Feb 25, 2013
492
493
/* Set random constraints */
target.w = (variation & 1) ? SDLTest_RandomIntegerInRange(1, 4096) : 0;
May 18, 2013
May 18, 2013
494
target.h = (variation & 2) ? SDLTest_RandomIntegerInRange(1, 4096) : 0;
Feb 25, 2013
Feb 25, 2013
495
496
497
target.format = (variation & 4) ? SDLTest_RandomIntegerInRange(1, 10) : 0;
target.refresh_rate = (variation & 8) ? SDLTest_RandomIntegerInRange(25, 120) : 0;
target.driverdata = 0;
May 18, 2013
May 18, 2013
498
Feb 25, 2013
Feb 25, 2013
499
500
/* Make call; may or may not find anything, so don't validate any further */
dResult = SDL_GetClosestDisplayMode(i, &target, &closest);
May 18, 2013
May 18, 2013
501
SDLTest_AssertPass("Call to SDL_GetClosestDisplayMode(target=random/variation%d)", variation);
Feb 25, 2013
Feb 25, 2013
502
503
504
505
506
507
508
509
}
}
return TEST_COMPLETED;
}
/**
* @brief Tests call to SDL_GetWindowBrightness
Feb 28, 2013
Feb 28, 2013
510
511
*
* @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowBrightness
Feb 25, 2013
Feb 25, 2013
512
513
514
515
516
517
518
519
*/
int
video_getWindowBrightness(void *arg)
{
SDL_Window* window;
const char* title = "video_getWindowBrightness Test Window";
float result;
May 18, 2013
May 18, 2013
520
/* Call against new test window */
Feb 25, 2013
Feb 25, 2013
521
522
523
524
525
526
527
window = _createVideoSuiteTestWindow(title);
if (window != NULL) {
result = SDL_GetWindowBrightness(window);
SDLTest_AssertPass("Call to SDL_GetWindowBrightness");
SDLTest_AssertCheck(result >= 0.0 && result <= 1.0, "Validate range of result value; expected: [0.0, 1.0], got: %f", result);
}
May 18, 2013
May 18, 2013
528
/* Clean up */
Feb 25, 2013
Feb 25, 2013
529
_destroyVideoSuiteTestWindow(window);
May 18, 2013
May 18, 2013
530
Feb 25, 2013
Feb 25, 2013
531
532
533
return TEST_COMPLETED;
}
Feb 28, 2013
Feb 28, 2013
534
535
536
537
538
539
540
541
542
543
544
545
546
/**
* @brief Tests call to SDL_GetWindowBrightness with invalid input
*
* @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowBrightness
*/
int
video_getWindowBrightnessNegative(void *arg)
{
const char *invalidWindowError = "Invalid window";
char *lastError;
const char* title = "video_getWindowBrightnessNegative Test Window";
float result;
May 18, 2013
May 18, 2013
547
/* Call against invalid window */
Feb 28, 2013
Feb 28, 2013
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
result = SDL_GetWindowBrightness(NULL);
SDLTest_AssertPass("Call to SDL_GetWindowBrightness(window=NULL)");
SDLTest_AssertCheck(result == 1.0, "Validate result value; expected: 1.0, got: %f", result);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
if (lastError != NULL) {
SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
"SDL_GetError(): expected message '%s', was message: '%s'",
invalidWindowError,
lastError);
}
return TEST_COMPLETED;
}
/**
* @brief Tests call to SDL_GetWindowDisplayMode
*
* @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowDisplayMode
*/
int
video_getWindowDisplayMode(void *arg)
{
SDL_Window* window;
const char* title = "video_getWindowDisplayMode Test Window";
SDL_DisplayMode mode;
int result;
/* Invalidate part of the mode content so we can check values later */
mode.w = -1;
mode.h = -1;
mode.refresh_rate = -1;
May 18, 2013
May 18, 2013
582
/* Call against new test window */
Feb 28, 2013
Feb 28, 2013
583
584
585
586
587
588
589
590
591
592
window = _createVideoSuiteTestWindow(title);
if (window != NULL) {
result = SDL_GetWindowDisplayMode(window, &mode);
SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode");
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
SDLTest_AssertCheck(mode.w > 0, "Validate mode.w content; expected: >0, got: %d", mode.w);
SDLTest_AssertCheck(mode.h > 0, "Validate mode.h content; expected: >0, got: %d", mode.h);
SDLTest_AssertCheck(mode.refresh_rate > 0, "Validate mode.refresh_rate content; expected: >0, got: %d", mode.refresh_rate);
}
May 18, 2013
May 18, 2013
593
/* Clean up */
Feb 28, 2013
Feb 28, 2013
594
_destroyVideoSuiteTestWindow(window);
May 18, 2013
May 18, 2013
595
Feb 28, 2013
Feb 28, 2013
596
597
598
return TEST_COMPLETED;
}
Mar 9, 2013
Mar 9, 2013
599
600
601
602
603
604
/* Helper function that checks for an 'Invalid window' error */
void _checkInvalidWindowError()
{
const char *invalidWindowError = "Invalid window";
char *lastError;
Apr 13, 2013
Apr 13, 2013
605
lastError = (char *)SDL_GetError();
Mar 9, 2013
Mar 9, 2013
606
607
608
609
610
611
612
613
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
if (lastError != NULL) {
SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
"SDL_GetError(): expected message '%s', was message: '%s'",
invalidWindowError,
lastError);
SDL_ClearError();
May 18, 2013
May 18, 2013
614
SDLTest_AssertPass("Call to SDL_ClearError()");
Mar 9, 2013
Mar 9, 2013
615
616
617
}
}
Feb 28, 2013
Feb 28, 2013
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
/**
* @brief Tests call to SDL_GetWindowDisplayMode with invalid input
*
* @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowDisplayMode
*/
int
video_getWindowDisplayModeNegative(void *arg)
{
const char *expectedError = "Parameter 'mode' is invalid";
char *lastError;
SDL_Window* window;
const char* title = "video_getWindowDisplayModeNegative Test Window";
SDL_DisplayMode mode;
int result;
May 18, 2013
May 18, 2013
633
/* Call against new test window */
Feb 28, 2013
Feb 28, 2013
634
635
636
637
638
639
640
641
642
window = _createVideoSuiteTestWindow(title);
if (window != NULL) {
result = SDL_GetWindowDisplayMode(window, NULL);
SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(...,mode=NULL)");
SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
if (lastError != NULL) {
May 18, 2013
May 18, 2013
643
SDLTest_AssertCheck(SDL_strcmp(lastError, expectedError) == 0,
Feb 28, 2013
Feb 28, 2013
644
645
646
647
648
649
"SDL_GetError(): expected message '%s', was message: '%s'",
expectedError,
lastError);
}
}
May 18, 2013
May 18, 2013
650
/* Clean up */
Feb 28, 2013
Feb 28, 2013
651
_destroyVideoSuiteTestWindow(window);
May 18, 2013
May 18, 2013
652
Feb 28, 2013
Feb 28, 2013
653
654
655
656
/* Call against invalid window */
result = SDL_GetWindowDisplayMode(NULL, &mode);
SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(window=NULL,...)");
SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result);
Mar 9, 2013
Mar 9, 2013
657
658
_checkInvalidWindowError();
Feb 28, 2013
Feb 28, 2013
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
return TEST_COMPLETED;
}
/**
* @brief Tests call to SDL_GetWindowGammaRamp
*
* @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGammaRamp
*/
int
video_getWindowGammaRamp(void *arg)
{
SDL_Window* window;
const char* title = "video_getWindowGammaRamp Test Window";
Uint16 red[256];
Uint16 green[256];
Uint16 blue[256];
int result;
May 18, 2013
May 18, 2013
677
/* Call against new test window */
Feb 28, 2013
Feb 28, 2013
678
window = _createVideoSuiteTestWindow(title);
Mar 4, 2013
Mar 4, 2013
679
if (window == NULL) return TEST_ABORTED;
May 18, 2013
May 18, 2013
680
Mar 4, 2013
Mar 4, 2013
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
/* Retrieve no channel */
result = SDL_GetWindowGammaRamp(window, NULL, NULL, NULL);
SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(all NULL)");
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
/* Retrieve single channel */
result = SDL_GetWindowGammaRamp(window, red, NULL, NULL);
SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r)");
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
result = SDL_GetWindowGammaRamp(window, NULL, green, NULL);
SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(g)");
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
result = SDL_GetWindowGammaRamp(window, NULL, NULL, blue);
SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(b)");
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
/* Retrieve two channels */
result = SDL_GetWindowGammaRamp(window, red, green, NULL);
SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r, g)");
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
result = SDL_GetWindowGammaRamp(window, NULL, green, blue);
SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(g,b)");
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
result = SDL_GetWindowGammaRamp(window, red, NULL, blue);
SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r,b)");
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
/* Retrieve all channels */
result = SDL_GetWindowGammaRamp(window, red, green, blue);
SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r,g,b)");
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
Feb 28, 2013
Feb 28, 2013
716
May 18, 2013
May 18, 2013
717
/* Clean up */
Feb 28, 2013
Feb 28, 2013
718
_destroyVideoSuiteTestWindow(window);
May 18, 2013
May 18, 2013
719
Feb 28, 2013
Feb 28, 2013
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
return TEST_COMPLETED;
}
/**
* @brief Tests call to SDL_GetWindowGammaRamp with invalid input
*
* @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGammaRamp
*/
int
video_getWindowGammaRampNegative(void *arg)
{
const char* title = "video_getWindowGammaRampNegative Test Window";
Uint16 red[256];
Uint16 green[256];
Uint16 blue[256];
int result;
Mar 9, 2013
Mar 9, 2013
737
738
739
SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()");
May 18, 2013
May 18, 2013
740
/* Call against invalid window */
Feb 28, 2013
Feb 28, 2013
741
742
743
result = SDL_GetWindowGammaRamp(NULL, red, green, blue);
SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(window=NULL,r,g,b)");
SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %f", result);
Mar 9, 2013
Mar 9, 2013
744
_checkInvalidWindowError();
May 18, 2013
May 18, 2013
745
Feb 28, 2013
Feb 28, 2013
746
747
748
return TEST_COMPLETED;
}
Mar 4, 2013
Mar 4, 2013
749
/* Helper for setting and checking the window grab state */
May 18, 2013
May 18, 2013
750
void
Mar 4, 2013
Mar 4, 2013
751
752
753
_setAndCheckWindowGrabState(SDL_Window* window, SDL_bool desiredState)
{
SDL_bool currentState;
May 18, 2013
May 18, 2013
754
Mar 4, 2013
Mar 4, 2013
755
756
757
758
759
760
761
762
/* Set state */
SDL_SetWindowGrab(window, desiredState);
SDLTest_AssertPass("Call to SDL_SetWindowGrab(%s)", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
/* Get and check state */
currentState = SDL_GetWindowGrab(window);
SDLTest_AssertPass("Call to SDL_GetWindowGrab()");
SDLTest_AssertCheck(
May 18, 2013
May 18, 2013
763
764
currentState == desiredState,
"Validate returned state; expected: %s, got: %s",
Mar 4, 2013
Mar 4, 2013
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
(desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE",
(currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
}
/**
* @brief Tests call to SDL_GetWindowGrab and SDL_SetWindowGrab
*
* @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGrab
* @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowGrab
*/
int
video_getSetWindowGrab(void *arg)
{
const char* title = "video_getSetWindowGrab Test Window";
SDL_Window* window;
SDL_bool originalState, dummyState, currentState, desiredState;
May 18, 2013
May 18, 2013
782
/* Call against new test window */
Mar 4, 2013
Mar 4, 2013
783
784
785
window = _createVideoSuiteTestWindow(title);
if (window == NULL) return TEST_ABORTED;
May 18, 2013
May 18, 2013
786
/* Get state */
Mar 4, 2013
Mar 4, 2013
787
788
789
790
791
792
793
794
originalState = SDL_GetWindowGrab(window);
SDLTest_AssertPass("Call to SDL_GetWindowGrab()");
/* F */
_setAndCheckWindowGrabState(window, SDL_FALSE);
/* F --> F */
_setAndCheckWindowGrabState(window, SDL_FALSE);
May 18, 2013
May 18, 2013
795
Mar 4, 2013
Mar 4, 2013
796
797
798
799
800
801
802
803
/* F --> T */
_setAndCheckWindowGrabState(window, SDL_TRUE);
/* T --> T */
_setAndCheckWindowGrabState(window, SDL_TRUE);
/* T --> F */
_setAndCheckWindowGrabState(window, SDL_FALSE);
May 18, 2013
May 18, 2013
804
Mar 4, 2013
Mar 4, 2013
805
806
807
/* Negative tests */
dummyState = SDL_GetWindowGrab(NULL);
SDLTest_AssertPass("Call to SDL_GetWindowGrab(window=NULL)");
Mar 9, 2013
Mar 9, 2013
808
_checkInvalidWindowError();
Mar 4, 2013
Mar 4, 2013
809
810
811
SDL_SetWindowGrab(NULL, SDL_FALSE);
SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
Mar 9, 2013
Mar 9, 2013
812
_checkInvalidWindowError();
Mar 4, 2013
Mar 4, 2013
813
814
815
SDL_SetWindowGrab(NULL, SDL_TRUE);
SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
Mar 9, 2013
Mar 9, 2013
816
_checkInvalidWindowError();
May 18, 2013
May 18, 2013
817
Mar 4, 2013
Mar 4, 2013
818
819
820
821
822
/* State should still be F */
desiredState = SDL_FALSE;
currentState = SDL_GetWindowGrab(window);
SDLTest_AssertPass("Call to SDL_GetWindowGrab()");
SDLTest_AssertCheck(
May 18, 2013
May 18, 2013
823
824
currentState == desiredState,
"Validate returned state; expected: %s, got: %s",
Mar 4, 2013
Mar 4, 2013
825
826
(desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE",
(currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
May 18, 2013
May 18, 2013
827
828
/* Restore state */
Mar 4, 2013
Mar 4, 2013
829
830
_setAndCheckWindowGrabState(window, originalState);
May 18, 2013
May 18, 2013
831
/* Clean up */
Mar 4, 2013
Mar 4, 2013
832
833
834
835
836
_destroyVideoSuiteTestWindow(window);
return TEST_COMPLETED;
}
Mar 9, 2013
Mar 9, 2013
837
Mar 4, 2013
Mar 4, 2013
838
839
840
841
842
843
844
845
846
847
848
849
850
851
/**
* @brief Tests call to SDL_GetWindowID and SDL_GetWindowFromID
*
* @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowID
* @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowFromID
*/
int
video_getWindowId(void *arg)
{
const char* title = "video_getWindowId Test Window";
SDL_Window* window;
SDL_Window* result;
Uint32 id, randomId;
May 18, 2013
May 18, 2013
852
/* Call against new test window */
Mar 4, 2013
Mar 4, 2013
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
window = _createVideoSuiteTestWindow(title);
if (window == NULL) return TEST_ABORTED;
/* Get ID */
id = SDL_GetWindowID(window);
SDLTest_AssertPass("Call to SDL_GetWindowID()");
/* Get window from ID */
result = SDL_GetWindowFromID(id);
SDLTest_AssertPass("Call to SDL_GetWindowID(%d)", id);
SDLTest_AssertCheck(result == window, "Verify result matches window pointer");
/* Get window from random large ID, no result check */
randomId = SDLTest_RandomIntegerInRange(UINT8_MAX,UINT16_MAX);
result = SDL_GetWindowFromID(randomId);
SDLTest_AssertPass("Call to SDL_GetWindowID(%d/random_large)", randomId);
/* Get window from 0 and Uint32 max ID, no result check */
result = SDL_GetWindowFromID(0);
SDLTest_AssertPass("Call to SDL_GetWindowID(0)");
result = SDL_GetWindowFromID(UINT32_MAX);
SDLTest_AssertPass("Call to SDL_GetWindowID(UINT32_MAX)");
May 18, 2013
May 18, 2013
876
/* Clean up */
Mar 4, 2013
Mar 4, 2013
877
_destroyVideoSuiteTestWindow(window);
May 18, 2013
May 18, 2013
878
Mar 4, 2013
Mar 4, 2013
879
880
881
882
883
884
/* Get window from ID for closed window*/
result = SDL_GetWindowFromID(id);
SDLTest_AssertPass("Call to SDL_GetWindowID(%d/closed_window)", id);
SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
/* Negative test */
Mar 9, 2013
Mar 9, 2013
885
886
SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()");
Mar 4, 2013
Mar 4, 2013
887
888
id = SDL_GetWindowID(NULL);
SDLTest_AssertPass("Call to SDL_GetWindowID(window=NULL)");
Mar 9, 2013
Mar 9, 2013
889
_checkInvalidWindowError();
May 18, 2013
May 18, 2013
890
Mar 4, 2013
Mar 4, 2013
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
return TEST_COMPLETED;
}
/**
* @brief Tests call to SDL_GetWindowPixelFormat
*
* @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowPixelFormat
*/
int
video_getWindowPixelFormat(void *arg)
{
const char* title = "video_getWindowPixelFormat Test Window";
SDL_Window* window;
Uint32 format;
May 18, 2013
May 18, 2013
906
/* Call against new test window */
Mar 4, 2013
Mar 4, 2013
907
908
909
910
911
912
913
window = _createVideoSuiteTestWindow(title);
if (window == NULL) return TEST_ABORTED;
/* Get format */
format = SDL_GetWindowPixelFormat(window);
SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat()");
SDLTest_AssertCheck(format != SDL_PIXELFORMAT_UNKNOWN, "Verify that returned format is valid; expected: != %d, got: %d", SDL_PIXELFORMAT_UNKNOWN, format);
May 18, 2013
May 18, 2013
914
915
/* Clean up */
Mar 4, 2013
Mar 4, 2013
916
_destroyVideoSuiteTestWindow(window);
May 18, 2013
May 18, 2013
917
Mar 4, 2013
Mar 4, 2013
918
/* Negative test */
Mar 9, 2013
Mar 9, 2013
919
920
SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()");
Mar 4, 2013
Mar 4, 2013
921
922
format = SDL_GetWindowPixelFormat(NULL);
SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat(window=NULL)");
Mar 9, 2013
Mar 9, 2013
923
_checkInvalidWindowError();
Mar 4, 2013
Mar 4, 2013
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
return TEST_COMPLETED;
}
/**
* @brief Tests call to SDL_GetWindowPosition and SDL_SetWindowPosition
*
* @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowPosition
* @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowPosition
*/
int
video_getSetWindowPosition(void *arg)
{
const char* title = "video_getSetWindowPosition Test Window";
SDL_Window* window;
int xVariation, yVariation;
int referenceX, referenceY;
int currentX, currentY;
int desiredX, desiredY;
May 18, 2013
May 18, 2013
944
/* Call against new test window */
Mar 4, 2013
Mar 4, 2013
945
946
window = _createVideoSuiteTestWindow(title);
if (window == NULL) return TEST_ABORTED;
May 18, 2013
May 18, 2013
947
Mar 4, 2013
Mar 4, 2013
948
949
950
951
for (xVariation = 0; xVariation < 4; xVariation++) {
for (yVariation = 0; yVariation < 4; yVariation++) {
switch(xVariation) {
case 0:
May 18, 2013
May 18, 2013
952
/* Zero X Position */
Mar 4, 2013
Mar 4, 2013
953
954
955
desiredX = 0;
break;
case 1:
May 18, 2013
May 18, 2013
956
/* Random X position inside screen */
Mar 4, 2013
Mar 4, 2013
957
958
959
desiredX = SDLTest_RandomIntegerInRange(1, 100);
break;
case 2:
May 18, 2013
May 18, 2013
960
/* Random X position outside screen (positive) */
Mar 4, 2013
Mar 4, 2013
961
962
963
desiredX = SDLTest_RandomIntegerInRange(10000, 11000);
break;
case 3:
May 18, 2013
May 18, 2013
964
/* Random X position outside screen (negative) */
Mar 4, 2013
Mar 4, 2013
965
966
967
968
969
970
desiredX = SDLTest_RandomIntegerInRange(-1000, -100);
break;
}
switch(yVariation) {
case 0:
May 18, 2013
May 18, 2013
971
/* Zero X Position */
Mar 4, 2013
Mar 4, 2013
972
973
974
desiredY = 0;
break;
case 1:
May 18, 2013
May 18, 2013
975
/* Random X position inside screen */
Mar 4, 2013
Mar 4, 2013
976
977
978
desiredY = SDLTest_RandomIntegerInRange(1, 100);
break;
case 2:
May 18, 2013
May 18, 2013
979
/* Random X position outside screen (positive) */
Mar 4, 2013
Mar 4, 2013
980
981
982
desiredY = SDLTest_RandomIntegerInRange(10000, 11000);
break;
case 3:
May 18, 2013
May 18, 2013
983
/* Random Y position outside screen (negative) */
Mar 4, 2013
Mar 4, 2013
984
985
986
987
988
989
990
desiredY = SDLTest_RandomIntegerInRange(-1000, -100);
break;
}
/* Set position */
SDL_SetWindowPosition(window, desiredX, desiredY);
SDLTest_AssertPass("Call to SDL_SetWindowPosition(...,%d,%d)", desiredX, desiredY);
May 18, 2013
May 18, 2013
991
Mar 4, 2013
Mar 4, 2013
992
993
994
995
996
997
998
999
1000
/* Get position */
currentX = desiredX + 1;
currentY = desiredY + 1;
SDL_GetWindowPosition(window, &currentX, &currentY);
SDLTest_AssertPass("Call to SDL_GetWindowPosition()");
SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX);
SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY);
/* Get position X */