SDL

Форк
0
/
testautomation_video.c 
2532 строки · 105.2 Кб
1
/**
2
 * Video test suite
3
 */
4
#include <SDL3/SDL.h>
5
#include <SDL3/SDL_test.h>
6
#include "testautomation_suites.h"
7

8
/* Private helpers */
9

10
/**
11
 * Create a test window
12
 */
13
static SDL_Window *createVideoSuiteTestWindow(const char *title)
14
{
15
    SDL_Window *window;
16
    SDL_Window **windows;
17
    SDL_Event event;
18
    int w, h;
19
    int count;
20
    SDL_WindowFlags flags;
21
    SDL_bool needs_renderer = SDL_FALSE;
22
    SDL_bool needs_events_pumped = SDL_FALSE;
23

24
    /* Standard window */
25
    w = SDLTest_RandomIntegerInRange(320, 1024);
26
    h = SDLTest_RandomIntegerInRange(320, 768);
27
    flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS;
28

29
    window = SDL_CreateWindow(title, w, h, flags);
30
    SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%" SDL_PRIu64 ")", w, h, flags);
31
    SDLTest_AssertCheck(window != NULL, "Validate that returned window is not NULL");
32

33
    /* Check the window is available in the window list */
34
    windows = SDL_GetWindows(&count);
35
    SDLTest_AssertCheck(windows != NULL, "Validate that returned window list is not NULL");
36
    SDLTest_AssertCheck(windows[0] == window, "Validate that the window is first in the window list");
37
    SDL_free(windows);
38

39
    /* Wayland and XWayland windows require that a frame be presented before they are fully mapped and visible onscreen.
40
     * This is required for the mouse/keyboard grab tests to pass.
41
     */
42
    if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "wayland") == 0) {
43
        needs_renderer = SDL_TRUE;
44
    } else if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0) {
45
        /* Try to detect if the x11 driver is running under XWayland */
46
        const char *session_type = SDL_getenv("XDG_SESSION_TYPE");
47
        if (session_type && SDL_strcasecmp(session_type, "wayland") == 0) {
48
            needs_renderer = SDL_TRUE;
49
        }
50

51
        /* X11 needs the initial events pumped, or it can erroneously deliver old configuration events at a later time. */
52
        needs_events_pumped = SDL_TRUE;
53
    }
54

55
    if (needs_renderer) {
56
        SDL_Renderer *renderer = SDL_CreateRenderer(window, NULL);
57
        if (renderer) {
58
            SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
59
            SDL_RenderClear(renderer);
60
            SDL_RenderPresent(renderer);
61

62
            /* Some desktops don't display the window immediately after presentation,
63
             * so delay to give the window time to actually appear on the desktop.
64
             */
65
            SDL_Delay(100);
66
        } else {
67
            SDLTest_Log("Unable to create a renderer, some tests may fail on Wayland/XWayland");
68
        }
69
    }
70

71
    if (needs_events_pumped) {
72
        /* Pump out the event queue */
73
        while (SDL_PollEvent(&event)) {
74
        }
75
    }
76

77
    return window;
78
}
79

80
/**
81
 * Destroy test window
82
 */
83
static void destroyVideoSuiteTestWindow(SDL_Window *window)
84
{
85
    if (window != NULL) {
86
        SDL_Renderer *renderer = SDL_GetRenderer(window);
87
        if (renderer) {
88
            SDL_DestroyRenderer(renderer);
89
        }
90
        SDL_DestroyWindow(window);
91
        window = NULL;
92
        SDLTest_AssertPass("Call to SDL_DestroyWindow()");
93
    }
94
}
95

96
/* Test case functions */
97

98
/**
99
 * Enable and disable screensaver while checking state
100
 */
101
static int video_enableDisableScreensaver(void *arg)
102
{
103
    SDL_bool initialResult;
104
    SDL_bool result;
105

106
    /* Get current state and proceed according to current state */
107
    initialResult = SDL_ScreenSaverEnabled();
108
    SDLTest_AssertPass("Call to SDL_ScreenSaverEnabled()");
109
    if (initialResult == SDL_TRUE) {
110

111
        /* Currently enabled: disable first, then enable again */
112

113
        /* Disable screensaver and check */
114
        SDL_DisableScreenSaver();
115
        SDLTest_AssertPass("Call to SDL_DisableScreenSaver()");
116
        result = SDL_ScreenSaverEnabled();
117
        SDLTest_AssertPass("Call to SDL_ScreenSaverEnabled()");
118
        SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_ScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);
119

120
        /* Enable screensaver and check */
121
        SDL_EnableScreenSaver();
122
        SDLTest_AssertPass("Call to SDL_EnableScreenSaver()");
123
        result = SDL_ScreenSaverEnabled();
124
        SDLTest_AssertPass("Call to SDL_ScreenSaverEnabled()");
125
        SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_ScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
126

127
    } else {
128

129
        /* Currently disabled: enable first, then disable again */
130

131
        /* Enable screensaver and check */
132
        SDL_EnableScreenSaver();
133
        SDLTest_AssertPass("Call to SDL_EnableScreenSaver()");
134
        result = SDL_ScreenSaverEnabled();
135
        SDLTest_AssertPass("Call to SDL_ScreenSaverEnabled()");
136
        SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_ScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
137

138
        /* Disable screensaver and check */
139
        SDL_DisableScreenSaver();
140
        SDLTest_AssertPass("Call to SDL_DisableScreenSaver()");
141
        result = SDL_ScreenSaverEnabled();
142
        SDLTest_AssertPass("Call to SDL_ScreenSaverEnabled()");
143
        SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_ScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);
144
    }
145

146
    return TEST_COMPLETED;
147
}
148

149
/**
150
 * Tests the functionality of the SDL_CreateWindow function using different sizes
151
 */
152
static int video_createWindowVariousSizes(void *arg)
153
{
154
    SDL_Window *window;
155
    const char *title = "video_createWindowVariousSizes Test Window";
156
    int w = 0, h = 0;
157
    int wVariation, hVariation;
158

159
    for (wVariation = 0; wVariation < 3; wVariation++) {
160
        for (hVariation = 0; hVariation < 3; hVariation++) {
161
            switch (wVariation) {
162
            case 0:
163
                /* Width of 1 */
164
                w = 1;
165
                break;
166
            case 1:
167
                /* Random "normal" width */
168
                w = SDLTest_RandomIntegerInRange(320, 1920);
169
                break;
170
            case 2:
171
                /* Random "large" width */
172
                w = SDLTest_RandomIntegerInRange(2048, 4095);
173
                break;
174
            }
175

176
            switch (hVariation) {
177
            case 0:
178
                /* Height of 1 */
179
                h = 1;
180
                break;
181
            case 1:
182
                /* Random "normal" height */
183
                h = SDLTest_RandomIntegerInRange(320, 1080);
184
                break;
185
            case 2:
186
                /* Random "large" height */
187
                h = SDLTest_RandomIntegerInRange(2048, 4095);
188
                break;
189
            }
190

191
            window = SDL_CreateWindow(title, w, h, 0);
192
            SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,SHOWN)", w, h);
193
            SDLTest_AssertCheck(window != NULL, "Validate that returned window is not NULL");
194

195
            /* Clean up */
196
            destroyVideoSuiteTestWindow(window);
197
        }
198
    }
199

200
    return TEST_COMPLETED;
201
}
202

203
/**
204
 * Tests the functionality of the SDL_CreateWindow function using different flags
205
 */
206
static int video_createWindowVariousFlags(void *arg)
207
{
208
    SDL_Window *window;
209
    const char *title = "video_createWindowVariousFlags Test Window";
210
    int w, h;
211
    int fVariation;
212
    SDL_WindowFlags flags;
213

214
    /* Standard window */
215
    w = SDLTest_RandomIntegerInRange(320, 1024);
216
    h = SDLTest_RandomIntegerInRange(320, 768);
217

218
    for (fVariation = 1; fVariation < 14; fVariation++) {
219
        switch (fVariation) {
220
        default:
221
        case 1:
222
            flags = SDL_WINDOW_FULLSCREEN;
223
            /* Skip - blanks screen; comment out next line to run test */
224
            continue;
225
            break;
226
        case 2:
227
            flags = SDL_WINDOW_OPENGL;
228
            /* Skip - not every video driver supports OpenGL; comment out next line to run test */
229
            continue;
230
            break;
231
        case 3:
232
            flags = 0;
233
            break;
234
        case 4:
235
            flags = SDL_WINDOW_HIDDEN;
236
            break;
237
        case 5:
238
            flags = SDL_WINDOW_BORDERLESS;
239
            break;
240
        case 6:
241
            flags = SDL_WINDOW_RESIZABLE;
242
            break;
243
        case 7:
244
            flags = SDL_WINDOW_MINIMIZED;
245
            break;
246
        case 8:
247
            flags = SDL_WINDOW_MAXIMIZED;
248
            break;
249
        case 9:
250
            flags = SDL_WINDOW_MOUSE_GRABBED;
251
            break;
252
        case 10:
253
            flags = SDL_WINDOW_INPUT_FOCUS;
254
            break;
255
        case 11:
256
            flags = SDL_WINDOW_MOUSE_FOCUS;
257
            break;
258
        case 12:
259
            flags = SDL_WINDOW_EXTERNAL;
260
            break;
261
        case 13:
262
            flags = SDL_WINDOW_KEYBOARD_GRABBED;
263
            break;
264
        }
265

266
        window = SDL_CreateWindow(title, w, h, flags);
267
        SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%" SDL_PRIu64 ")", w, h, flags);
268
        SDLTest_AssertCheck(window != NULL, "Validate that returned window is not NULL");
269

270
        /* Clean up */
271
        destroyVideoSuiteTestWindow(window);
272
    }
273

274
    return TEST_COMPLETED;
275
}
276

277
/**
278
 * Tests the functionality of the SDL_GetWindowFlags function
279
 */
280
static int video_getWindowFlags(void *arg)
281
{
282
    SDL_Window *window;
283
    const char *title = "video_getWindowFlags Test Window";
284
    SDL_WindowFlags flags;
285
    SDL_WindowFlags actualFlags;
286

287
    /* Reliable flag set always set in test window */
288
    flags = 0;
289

290
    /* Call against new test window */
291
    window = createVideoSuiteTestWindow(title);
292
    if (window != NULL) {
293
        actualFlags = SDL_GetWindowFlags(window);
294
        SDLTest_AssertPass("Call to SDL_GetWindowFlags()");
295
        SDLTest_AssertCheck((flags & actualFlags) == flags, "Verify returned value has flags %" SDL_PRIu64 " set, got: %" SDL_PRIu64, flags, actualFlags);
296
    }
297

298
    /* Clean up */
299
    destroyVideoSuiteTestWindow(window);
300

301
    return TEST_COMPLETED;
302
}
303

304
/**
305
 * Tests the functionality of the SDL_GetFullscreenDisplayModes function
306
 */
307
static int video_getFullscreenDisplayModes(void *arg)
308
{
309
    SDL_DisplayID *displays;
310
    SDL_DisplayMode **modes;
311
    int count;
312
    int i;
313

314
    /* Get number of displays */
315
    displays = SDL_GetDisplays(NULL);
316
    if (displays) {
317
        SDLTest_AssertPass("Call to SDL_GetDisplays()");
318

319
        /* Make call for each display */
320
        for (i = 0; displays[i]; ++i) {
321
            modes = SDL_GetFullscreenDisplayModes(displays[i], &count);
322
            SDLTest_AssertPass("Call to SDL_GetFullscreenDisplayModes(%" SDL_PRIu32 ")", displays[i]);
323
            SDLTest_AssertCheck(modes != NULL, "Validate returned value from function; expected != NULL; got: %p", modes);
324
            SDLTest_AssertCheck(count >= 0, "Validate number of modes; expected: >= 0; got: %d", count);
325
            SDL_free(modes);
326
        }
327
        SDL_free(displays);
328
    }
329

330
    return TEST_COMPLETED;
331
}
332

333
/**
334
 * Tests the functionality of the SDL_GetClosestFullscreenDisplayMode function against current resolution
335
 */
336
static int video_getClosestDisplayModeCurrentResolution(void *arg)
337
{
338
    SDL_DisplayID *displays;
339
    SDL_DisplayMode **modes;
340
    SDL_DisplayMode current;
341
    SDL_DisplayMode closest;
342
    int i, result, num_modes;
343

344
    /* Get number of displays */
345
    displays = SDL_GetDisplays(NULL);
346
    if (displays) {
347
        SDLTest_AssertPass("Call to SDL_GetDisplays()");
348

349
        /* Make calls for each display */
350
        for (i = 0; displays[i]; ++i) {
351
            SDLTest_Log("Testing against display: %" SDL_PRIu32, displays[i]);
352

353
            /* Get first display mode to get a sane resolution; this should always work */
354
            modes = SDL_GetFullscreenDisplayModes(displays[i], &num_modes);
355
            SDLTest_AssertPass("Call to SDL_GetDisplayModes()");
356
            SDLTest_Assert(modes != NULL, "Verify returned value is not NULL");
357
            if (num_modes > 0) {
358
                SDL_memcpy(&current, modes[0], sizeof(current));
359

360
                /* Make call */
361
                result = SDL_GetClosestFullscreenDisplayMode(displays[i], current.w, current.h, current.refresh_rate, SDL_FALSE, &closest);
362
                SDLTest_AssertPass("Call to SDL_GetClosestFullscreenDisplayMode(target=current)");
363
                SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
364

365
                /* Check that one gets the current resolution back again */
366
                if (result == 0) {
367
                    SDLTest_AssertCheck(closest.w == current.w,
368
                                        "Verify returned width matches current width; expected: %d, got: %d",
369
                                        current.w, closest.w);
370
                    SDLTest_AssertCheck(closest.h == current.h,
371
                                        "Verify returned height matches current height; expected: %d, got: %d",
372
                                        current.h, closest.h);
373
                }
374
            }
375
            SDL_free(modes);
376
        }
377
        SDL_free(displays);
378
    }
379

380
    return TEST_COMPLETED;
381
}
382

383
/**
384
 * Tests the functionality of the SDL_GetClosestFullscreenDisplayMode function against random resolution
385
 */
386
static int video_getClosestDisplayModeRandomResolution(void *arg)
387
{
388
    SDL_DisplayID *displays;
389
    SDL_DisplayMode target;
390
    SDL_DisplayMode closest;
391
    int i;
392
    int variation;
393

394
    /* Get number of displays */
395
    displays = SDL_GetDisplays(NULL);
396
    if (displays) {
397
        SDLTest_AssertPass("Call to SDL_GetDisplays()");
398

399
        /* Make calls for each display */
400
        for (i = 0; displays[i]; ++i) {
401
            SDLTest_Log("Testing against display: %" SDL_PRIu32, displays[i]);
402

403
            for (variation = 0; variation < 16; variation++) {
404

405
                /* Set random constraints */
406
                SDL_zero(target);
407
                target.w = (variation & 1) ? SDLTest_RandomIntegerInRange(1, 4096) : 0;
408
                target.h = (variation & 2) ? SDLTest_RandomIntegerInRange(1, 4096) : 0;
409
                target.refresh_rate = (variation & 8) ? (float)SDLTest_RandomIntegerInRange(25, 120) : 0.0f;
410

411
                /* Make call; may or may not find anything, so don't validate any further */
412
                SDL_GetClosestFullscreenDisplayMode(displays[i], target.w, target.h, target.refresh_rate, SDL_FALSE, &closest);
413
                SDLTest_AssertPass("Call to SDL_GetClosestFullscreenDisplayMode(target=random/variation%d)", variation);
414
            }
415
        }
416
        SDL_free(displays);
417
    }
418

419
    return TEST_COMPLETED;
420
}
421

422
/**
423
 * Tests call to SDL_GetWindowFullscreenMode
424
 *
425
 * \sa SDL_GetWindowFullscreenMode
426
 */
427
static int video_getWindowDisplayMode(void *arg)
428
{
429
    SDL_Window *window;
430
    const char *title = "video_getWindowDisplayMode Test Window";
431
    const SDL_DisplayMode *mode;
432

433
    /* Call against new test window */
434
    window = createVideoSuiteTestWindow(title);
435
    if (window != NULL) {
436
        mode = SDL_GetWindowFullscreenMode(window);
437
        SDLTest_AssertPass("Call to SDL_GetWindowFullscreenMode()");
438
        SDLTest_AssertCheck(mode == NULL, "Validate result value; expected: NULL, got: %p", mode);
439
    }
440

441
    /* Clean up */
442
    destroyVideoSuiteTestWindow(window);
443

444
    return TEST_COMPLETED;
445
}
446

447
/* Helper function that checks for an 'Invalid window' error */
448
static void checkInvalidWindowError(void)
449
{
450
    const char *invalidWindowError = "Invalid window";
451
    const char *lastError;
452

453
    lastError = SDL_GetError();
454
    SDLTest_AssertPass("SDL_GetError()");
455
    SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
456
    if (lastError != NULL) {
457
        SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
458
                            "SDL_GetError(): expected message '%s', was message: '%s'",
459
                            invalidWindowError,
460
                            lastError);
461
        SDL_ClearError();
462
        SDLTest_AssertPass("Call to SDL_ClearError()");
463
    }
464
}
465

466
/**
467
 * Tests call to SDL_GetWindowFullscreenMode with invalid input
468
 *
469
 * \sa SDL_GetWindowFullscreenMode
470
 */
471
static int video_getWindowDisplayModeNegative(void *arg)
472
{
473
    const SDL_DisplayMode *mode;
474

475
    /* Call against invalid window */
476
    mode = SDL_GetWindowFullscreenMode(NULL);
477
    SDLTest_AssertPass("Call to SDL_GetWindowFullscreenMode(window=NULL)");
478
    SDLTest_AssertCheck(mode == NULL, "Validate result value; expected: NULL, got: %p", mode);
479
    checkInvalidWindowError();
480

481
    return TEST_COMPLETED;
482
}
483

484
/* Helper for setting and checking the window mouse grab state */
485
static void setAndCheckWindowMouseGrabState(SDL_Window *window, SDL_bool desiredState)
486
{
487
    SDL_bool currentState;
488

489
    /* Set state */
490
    SDL_SetWindowMouseGrab(window, desiredState);
491
    SDLTest_AssertPass("Call to SDL_SetWindowMouseGrab(%s)", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
492

493
    /* Get and check state */
494
    currentState = SDL_GetWindowMouseGrab(window);
495
    SDLTest_AssertPass("Call to SDL_GetWindowMouseGrab()");
496
    SDLTest_AssertCheck(
497
        currentState == desiredState,
498
        "Validate returned state; expected: %s, got: %s",
499
        (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE",
500
        (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
501

502
    if (desiredState) {
503
        SDLTest_AssertCheck(
504
            SDL_GetGrabbedWindow() == window,
505
            "Grabbed window should be to our window");
506
        SDLTest_AssertCheck(
507
            SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_GRABBED,
508
            "SDL_WINDOW_MOUSE_GRABBED should be set");
509
    } else {
510
        SDLTest_AssertCheck(
511
            !(SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_GRABBED),
512
            "SDL_WINDOW_MOUSE_GRABBED should be unset");
513
    }
514
}
515

516
/* Helper for setting and checking the window keyboard grab state */
517
static void setAndCheckWindowKeyboardGrabState(SDL_Window *window, SDL_bool desiredState)
518
{
519
    SDL_bool currentState;
520

521
    /* Set state */
522
    SDL_SetWindowKeyboardGrab(window, desiredState);
523
    SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(%s)", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
524

525
    /* Get and check state */
526
    currentState = SDL_GetWindowKeyboardGrab(window);
527
    SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab()");
528
    SDLTest_AssertCheck(
529
        currentState == desiredState,
530
        "Validate returned state; expected: %s, got: %s",
531
        (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE",
532
        (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
533

534
    if (desiredState) {
535
        SDLTest_AssertCheck(
536
            SDL_GetGrabbedWindow() == window,
537
            "Grabbed window should be set to our window");
538
        SDLTest_AssertCheck(
539
            SDL_GetWindowFlags(window) & SDL_WINDOW_KEYBOARD_GRABBED,
540
            "SDL_WINDOW_KEYBOARD_GRABBED should be set");
541
    } else {
542
        SDLTest_AssertCheck(
543
            !(SDL_GetWindowFlags(window) & SDL_WINDOW_KEYBOARD_GRABBED),
544
            "SDL_WINDOW_KEYBOARD_GRABBED should be unset");
545
    }
546
}
547

548
/**
549
 * Tests keyboard and mouse grab support
550
 *
551
 * \sa SDL_GetWindowMouseGrab
552
 * \sa SDL_GetWindowKeyboardGrab
553
 * \sa SDL_SetWindowMouseGrab
554
 * \sa SDL_SetWindowKeyboardGrab
555
 */
556
static int video_getSetWindowGrab(void *arg)
557
{
558
    const char *title = "video_getSetWindowGrab Test Window";
559
    SDL_Window *window;
560
    SDL_bool originalMouseState, originalKeyboardState;
561
    SDL_bool hasFocusGained = SDL_FALSE;
562

563
    /* Call against new test window */
564
    window = createVideoSuiteTestWindow(title);
565
    if (!window) {
566
        return TEST_ABORTED;
567
    }
568

569
    /* Need to raise the window to have and SDL_EVENT_WINDOW_FOCUS_GAINED,
570
     * so that the window gets the flags SDL_WINDOW_INPUT_FOCUS,
571
     * so that it can be "grabbed" */
572
    SDL_RaiseWindow(window);
573

574
    if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_INPUT_FOCUS)) {
575
        int count = 0;
576
        SDL_Event evt;
577
        SDL_zero(evt);
578
        while (!hasFocusGained && count++ < 3) {
579
            while (SDL_PollEvent(&evt)) {
580
                if (evt.type == SDL_EVENT_WINDOW_FOCUS_GAINED) {
581
                    hasFocusGained = SDL_TRUE;
582
                }
583
            }
584
        }
585
    } else {
586
        hasFocusGained = SDL_TRUE;
587
    }
588

589
    SDLTest_AssertCheck(hasFocusGained == SDL_TRUE, "Expectded window with focus");
590

591
    /* Get state */
592
    originalMouseState = SDL_GetWindowMouseGrab(window);
593
    SDLTest_AssertPass("Call to SDL_GetWindowMouseGrab()");
594
    originalKeyboardState = SDL_GetWindowKeyboardGrab(window);
595
    SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab()");
596

597
    /* F */
598
    setAndCheckWindowKeyboardGrabState(window, SDL_FALSE);
599
    setAndCheckWindowMouseGrabState(window, SDL_FALSE);
600
    SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL,
601
                        "Expected NULL grabbed window");
602

603
    /* F --> F */
604
    setAndCheckWindowMouseGrabState(window, SDL_FALSE);
605
    setAndCheckWindowKeyboardGrabState(window, SDL_FALSE);
606
    SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL,
607
                        "Expected NULL grabbed window");
608

609
    /* F --> T */
610
    setAndCheckWindowMouseGrabState(window, SDL_TRUE);
611
    setAndCheckWindowKeyboardGrabState(window, SDL_TRUE);
612

613
    /* T --> T */
614
    setAndCheckWindowKeyboardGrabState(window, SDL_TRUE);
615
    setAndCheckWindowMouseGrabState(window, SDL_TRUE);
616

617
    /* M: T --> F */
618
    /* K: T --> T */
619
    setAndCheckWindowKeyboardGrabState(window, SDL_TRUE);
620
    setAndCheckWindowMouseGrabState(window, SDL_FALSE);
621

622
    /* M: F --> T */
623
    /* K: T --> F */
624
    setAndCheckWindowMouseGrabState(window, SDL_TRUE);
625
    setAndCheckWindowKeyboardGrabState(window, SDL_FALSE);
626

627
    /* M: T --> F */
628
    /* K: F --> F */
629
    setAndCheckWindowMouseGrabState(window, SDL_FALSE);
630
    setAndCheckWindowKeyboardGrabState(window, SDL_FALSE);
631
    SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL,
632
                        "Expected NULL grabbed window");
633

634
    /* Negative tests */
635
    SDL_GetWindowMouseGrab(NULL);
636
    SDLTest_AssertPass("Call to SDL_GetWindowMouseGrab(window=NULL)");
637
    checkInvalidWindowError();
638

639
    SDL_GetWindowKeyboardGrab(NULL);
640
    SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab(window=NULL)");
641
    checkInvalidWindowError();
642

643
    SDL_SetWindowMouseGrab(NULL, SDL_FALSE);
644
    SDLTest_AssertPass("Call to SDL_SetWindowMouseGrab(window=NULL,SDL_FALSE)");
645
    checkInvalidWindowError();
646

647
    SDL_SetWindowKeyboardGrab(NULL, SDL_FALSE);
648
    SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(window=NULL,SDL_FALSE)");
649
    checkInvalidWindowError();
650

651
    SDL_SetWindowMouseGrab(NULL, SDL_TRUE);
652
    SDLTest_AssertPass("Call to SDL_SetWindowMouseGrab(window=NULL,SDL_TRUE)");
653
    checkInvalidWindowError();
654

655
    SDL_SetWindowKeyboardGrab(NULL, SDL_TRUE);
656
    SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(window=NULL,SDL_TRUE)");
657
    checkInvalidWindowError();
658

659
    /* Restore state */
660
    setAndCheckWindowMouseGrabState(window, originalMouseState);
661
    setAndCheckWindowKeyboardGrabState(window, originalKeyboardState);
662

663
    /* Clean up */
664
    destroyVideoSuiteTestWindow(window);
665

666
    return TEST_COMPLETED;
667
}
668

669
/**
670
 * Tests call to SDL_GetWindowID and SDL_GetWindowFromID
671
 *
672
 * \sa SDL_GetWindowID
673
 * \sa SDL_SetWindowFromID
674
 */
675
static int video_getWindowId(void *arg)
676
{
677
    const char *title = "video_getWindowId Test Window";
678
    SDL_Window *window;
679
    SDL_Window *result;
680
    Uint32 id, randomId;
681

682
    /* Call against new test window */
683
    window = createVideoSuiteTestWindow(title);
684
    if (!window) {
685
        return TEST_ABORTED;
686
    }
687

688
    /* Get ID */
689
    id = SDL_GetWindowID(window);
690
    SDLTest_AssertPass("Call to SDL_GetWindowID()");
691

692
    /* Get window from ID */
693
    result = SDL_GetWindowFromID(id);
694
    SDLTest_AssertPass("Call to SDL_GetWindowID(%" SDL_PRIu32 ")", id);
695
    SDLTest_AssertCheck(result == window, "Verify result matches window pointer");
696

697
    /* Get window from random large ID, no result check */
698
    randomId = SDLTest_RandomIntegerInRange(UINT8_MAX, UINT16_MAX);
699
    result = SDL_GetWindowFromID(randomId);
700
    SDLTest_AssertPass("Call to SDL_GetWindowID(%" SDL_PRIu32 "/random_large)", randomId);
701

702
    /* Get window from 0 and Uint32 max ID, no result check */
703
    result = SDL_GetWindowFromID(0);
704
    SDLTest_AssertPass("Call to SDL_GetWindowID(0)");
705
    result = SDL_GetWindowFromID(UINT32_MAX);
706
    SDLTest_AssertPass("Call to SDL_GetWindowID(UINT32_MAX)");
707

708
    /* Clean up */
709
    destroyVideoSuiteTestWindow(window);
710

711
    /* Get window from ID for closed window */
712
    result = SDL_GetWindowFromID(id);
713
    SDLTest_AssertPass("Call to SDL_GetWindowID(%" SDL_PRIu32 "/closed_window)", id);
714
    SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
715

716
    /* Negative test */
717
    SDL_ClearError();
718
    SDLTest_AssertPass("Call to SDL_ClearError()");
719
    id = SDL_GetWindowID(NULL);
720
    SDLTest_AssertPass("Call to SDL_GetWindowID(window=NULL)");
721
    checkInvalidWindowError();
722

723
    return TEST_COMPLETED;
724
}
725

726
/**
727
 * Tests call to SDL_GetWindowPixelFormat
728
 *
729
 * \sa SDL_GetWindowPixelFormat
730
 */
731
static int video_getWindowPixelFormat(void *arg)
732
{
733
    const char *title = "video_getWindowPixelFormat Test Window";
734
    SDL_Window *window;
735
    SDL_PixelFormat format;
736

737
    /* Call against new test window */
738
    window = createVideoSuiteTestWindow(title);
739
    if (!window) {
740
        return TEST_ABORTED;
741
    }
742

743
    /* Get format */
744
    format = SDL_GetWindowPixelFormat(window);
745
    SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat()");
746
    SDLTest_AssertCheck(format != SDL_PIXELFORMAT_UNKNOWN, "Verify that returned format is valid; expected: != SDL_PIXELFORMAT_UNKNOWN, got: SDL_PIXELFORMAT_UNKNOWN");
747

748
    /* Clean up */
749
    destroyVideoSuiteTestWindow(window);
750

751
    /* Negative test */
752
    SDL_ClearError();
753
    SDLTest_AssertPass("Call to SDL_ClearError()");
754
    format = SDL_GetWindowPixelFormat(NULL);
755
    SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat(window=NULL)");
756
    checkInvalidWindowError();
757

758
    return TEST_COMPLETED;
759
}
760

761

762
static SDL_bool getPositionFromEvent(int *x, int *y)
763
{
764
    SDL_bool ret = SDL_FALSE;
765
    SDL_Event evt;
766
    SDL_zero(evt);
767
    while (SDL_PollEvent(&evt)) {
768
        if (evt.type == SDL_EVENT_WINDOW_MOVED) {
769
            *x = evt.window.data1;
770
            *y = evt.window.data2;
771
            ret = SDL_TRUE;
772
        }
773
    }
774
    return ret;
775
}
776

777
static SDL_bool getSizeFromEvent(int *w, int *h)
778
{
779
    SDL_bool ret = SDL_FALSE;
780
    SDL_Event evt;
781
    SDL_zero(evt);
782
    while (SDL_PollEvent(&evt)) {
783
        if (evt.type == SDL_EVENT_WINDOW_RESIZED) {
784
            *w = evt.window.data1;
785
            *h = evt.window.data2;
786
            ret = SDL_TRUE;
787
        }
788
    }
789
    return ret;
790
}
791

792
/**
793
 * Tests call to SDL_GetWindowPosition and SDL_SetWindowPosition
794
 *
795
 * \sa SDL_GetWindowPosition
796
 * \sa SDL_SetWindowPosition
797
 */
798
static int video_getSetWindowPosition(void *arg)
799
{
800
    const char *title = "video_getSetWindowPosition Test Window";
801
    SDL_Window *window;
802
    int result;
803
    int maxxVariation, maxyVariation;
804
    int xVariation, yVariation;
805
    int referenceX, referenceY;
806
    int currentX, currentY;
807
    int desiredX, desiredY;
808
    SDL_Rect display_bounds;
809

810
    /* Call against new test window */
811
    window = createVideoSuiteTestWindow(title);
812
    if (!window) {
813
        return TEST_ABORTED;
814
    }
815

816
    /* Sanity check */
817
    SDL_GetWindowPosition(window, &currentX, &currentY);
818
    if (SDL_SetWindowPosition(window, currentX, currentY) < 0) {
819
        SDLTest_Log("Skipping window positioning tests: %s reports window positioning as unsupported", SDL_GetCurrentVideoDriver());
820
        goto null_tests;
821
    }
822

823
    if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0) {
824
        /* The X11 server allows arbitrary window placement, but compositing
825
         * window managers such as GNOME and KDE force windows to be within
826
         * desktop bounds.
827
         */
828
        maxxVariation = 2;
829
        maxyVariation = 2;
830

831
        SDL_GetDisplayUsableBounds(SDL_GetPrimaryDisplay(), &display_bounds);
832
    } else if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "cocoa") == 0) {
833
        /* Platform doesn't allow windows with negative Y desktop bounds */
834
        maxxVariation = 4;
835
        maxyVariation = 3;
836

837
        SDL_GetDisplayUsableBounds(SDL_GetPrimaryDisplay(), &display_bounds);
838
    } else {
839
        /* Platform allows windows to be placed out of bounds */
840
        maxxVariation = 4;
841
        maxyVariation = 4;
842

843
        SDL_GetDisplayBounds(SDL_GetPrimaryDisplay(), &display_bounds);
844
    }
845

846
    for (xVariation = 0; xVariation < maxxVariation; xVariation++) {
847
        for (yVariation = 0; yVariation < maxyVariation; yVariation++) {
848
            switch (xVariation) {
849
            default:
850
            case 0:
851
                /* Zero X Position */
852
                desiredX = display_bounds.x > 0 ? display_bounds.x : 0;
853
                break;
854
            case 1:
855
                /* Random X position inside screen */
856
                desiredX = SDLTest_RandomIntegerInRange(display_bounds.x + 1, display_bounds.x + 100);
857
                break;
858
            case 2:
859
                /* Random X position outside screen (positive) */
860
                desiredX = SDLTest_RandomIntegerInRange(10000, 11000);
861
                break;
862
            case 3:
863
                /* Random X position outside screen (negative) */
864
                desiredX = SDLTest_RandomIntegerInRange(-1000, -100);
865
                break;
866
            }
867

868
            switch (yVariation) {
869
            default:
870
            case 0:
871
                /* Zero Y Position */
872
                desiredY = display_bounds.y > 0 ? display_bounds.y : 0;
873
                break;
874
            case 1:
875
                /* Random Y position inside screen */
876
                desiredY = SDLTest_RandomIntegerInRange(display_bounds.y + 1, display_bounds.y + 100);
877
                break;
878
            case 2:
879
                /* Random Y position outside screen (positive) */
880
                desiredY = SDLTest_RandomIntegerInRange(10000, 11000);
881
                break;
882
            case 3:
883
                /* Random Y position outside screen (negative) */
884
                desiredY = SDLTest_RandomIntegerInRange(-1000, -100);
885
                break;
886
            }
887

888
            /* Set position */
889
            SDL_SetWindowPosition(window, desiredX, desiredY);
890
            SDLTest_AssertPass("Call to SDL_SetWindowPosition(...,%d,%d)", desiredX, desiredY);
891

892
            result = SDL_SyncWindow(window);
893
            SDLTest_AssertPass("SDL_SyncWindow()");
894
            SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
895

896
            /* Get position */
897
            currentX = desiredX + 1;
898
            currentY = desiredY + 1;
899
            SDL_GetWindowPosition(window, &currentX, &currentY);
900
            SDLTest_AssertPass("Call to SDL_GetWindowPosition()");
901

902
            if (desiredX == currentX && desiredY == currentY) {
903
                SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX);
904
                SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY);
905
            } else {
906
                SDL_bool hasEvent;
907
                /* SDL_SetWindowPosition() and SDL_SetWindowSize() will make requests of the window manager and set the internal position and size,
908
                 * and then we get events signaling what actually happened, and they get passed on to the application if they're not what we expect. */
909
                currentX = desiredX + 1;
910
                currentY = desiredY + 1;
911
                hasEvent = getPositionFromEvent(&currentX, &currentY);
912
                SDLTest_AssertCheck(hasEvent == SDL_TRUE, "Changing position was not honored by WM, checking present of SDL_EVENT_WINDOW_MOVED");
913
                if (hasEvent) {
914
                    SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position is the position from SDL event; expected: %d, got: %d", desiredX, currentX);
915
                    SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position is the position from SDL event; expected: %d, got: %d", desiredY, currentY);
916
                }
917
            }
918

919
            /* Get position X */
920
            currentX = desiredX + 1;
921
            SDL_GetWindowPosition(window, &currentX, NULL);
922
            SDLTest_AssertPass("Call to SDL_GetWindowPosition(&y=NULL)");
923
            SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX);
924

925
            /* Get position Y */
926
            currentY = desiredY + 1;
927
            SDL_GetWindowPosition(window, NULL, &currentY);
928
            SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL)");
929
            SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY);
930
        }
931
    }
932

933
null_tests:
934

935
    /* Dummy call with both pointers NULL */
936
    SDL_GetWindowPosition(window, NULL, NULL);
937
    SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL,&y=NULL)");
938

939
    /* Clean up */
940
    destroyVideoSuiteTestWindow(window);
941

942
    /* Set some 'magic' value for later check that nothing was changed */
943
    referenceX = SDLTest_RandomSint32();
944
    referenceY = SDLTest_RandomSint32();
945
    currentX = referenceX;
946
    currentY = referenceY;
947
    desiredX = SDLTest_RandomSint32();
948
    desiredY = SDLTest_RandomSint32();
949

950
    /* Negative tests */
951
    SDL_ClearError();
952
    SDLTest_AssertPass("Call to SDL_ClearError()");
953
    SDL_GetWindowPosition(NULL, &currentX, &currentY);
954
    SDLTest_AssertPass("Call to SDL_GetWindowPosition(window=NULL)");
955
    SDLTest_AssertCheck(
956
        currentX == referenceX && currentY == referenceY,
957
        "Verify that content of X and Y pointers has not been modified; expected: %d,%d; got: %d,%d",
958
        referenceX, referenceY,
959
        currentX, currentY);
960
    checkInvalidWindowError();
961

962
    SDL_GetWindowPosition(NULL, NULL, NULL);
963
    SDLTest_AssertPass("Call to SDL_GetWindowPosition(NULL, NULL, NULL)");
964
    checkInvalidWindowError();
965

966
    SDL_SetWindowPosition(NULL, desiredX, desiredY);
967
    SDLTest_AssertPass("Call to SDL_SetWindowPosition(window=NULL)");
968
    checkInvalidWindowError();
969

970
    return TEST_COMPLETED;
971
}
972

973
/* Helper function that checks for an 'Invalid parameter' error */
974
static void checkInvalidParameterError(void)
975
{
976
    const char *invalidParameterError = "Parameter";
977
    const char *lastError;
978

979
    lastError = SDL_GetError();
980
    SDLTest_AssertPass("SDL_GetError()");
981
    SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
982
    if (lastError != NULL) {
983
        SDLTest_AssertCheck(SDL_strncmp(lastError, invalidParameterError, SDL_strlen(invalidParameterError)) == 0,
984
                            "SDL_GetError(): expected message starts with '%s', was message: '%s'",
985
                            invalidParameterError,
986
                            lastError);
987
        SDL_ClearError();
988
        SDLTest_AssertPass("Call to SDL_ClearError()");
989
    }
990
}
991

992
/**
993
 * Tests call to SDL_GetWindowSize and SDL_SetWindowSize
994
 *
995
 * \sa SDL_GetWindowSize
996
 * \sa SDL_SetWindowSize
997
 */
998
static int video_getSetWindowSize(void *arg)
999
{
1000
    const char *title = "video_getSetWindowSize Test Window";
1001
    SDL_Window *window;
1002
    int result;
1003
    SDL_Rect display;
1004
    int maxwVariation, maxhVariation;
1005
    int wVariation, hVariation;
1006
    int referenceW, referenceH;
1007
    int currentW, currentH;
1008
    int desiredW, desiredH;
1009
    const SDL_bool restoreHint = SDL_GetHintBoolean("SDL_BORDERLESS_RESIZABLE_STYLE", SDL_TRUE);
1010

1011
    /* Win32 borderless windows are not resizable by default and need this undocumented hint */
1012
    SDL_SetHint("SDL_BORDERLESS_RESIZABLE_STYLE", "1");
1013

1014
    /* Get display bounds for size range */
1015
    result = SDL_GetDisplayUsableBounds(SDL_GetPrimaryDisplay(), &display);
1016
    SDLTest_AssertPass("SDL_GetDisplayBounds()");
1017
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
1018
    if (result != 0) {
1019
        return TEST_ABORTED;
1020
    }
1021

1022
    /* Call against new test window */
1023
    window = createVideoSuiteTestWindow(title);
1024
    if (!window) {
1025
        return TEST_ABORTED;
1026
    }
1027

1028
    SDL_GetWindowSize(window, &currentW, &currentH);
1029
    if (SDL_SetWindowSize(window, currentW, currentH)) {
1030
        SDLTest_Log("Skipping window resize tests: %s reports window resizing as unsupported", SDL_GetCurrentVideoDriver());
1031
        goto null_tests;
1032
    }
1033

1034
    if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "windows") == 0 ||
1035
        SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0) {
1036
        /* Platform clips window size to screen size */
1037
        maxwVariation = 4;
1038
        maxhVariation = 4;
1039
    } else {
1040
        /* Platform allows window size >= screen size */
1041
        maxwVariation = 5;
1042
        maxhVariation = 5;
1043
    }
1044

1045
    for (wVariation = 0; wVariation < maxwVariation; wVariation++) {
1046
        for (hVariation = 0; hVariation < maxhVariation; hVariation++) {
1047
            switch (wVariation) {
1048
            default:
1049
            case 0:
1050
                /* 1 Pixel Wide */
1051
                desiredW = 1;
1052
                break;
1053
            case 1:
1054
                /* Random width inside screen */
1055
                desiredW = SDLTest_RandomIntegerInRange(1, 100);
1056
                break;
1057
            case 2:
1058
                /* Width 1 pixel smaller than screen */
1059
                desiredW = display.w - 1;
1060
                break;
1061
            case 3:
1062
                /* Width at screen size */
1063
                desiredW = display.w;
1064
                break;
1065
            case 4:
1066
                /* Width 1 pixel larger than screen */
1067
                desiredW = display.w + 1;
1068
                break;
1069
            }
1070

1071
            switch (hVariation) {
1072
            default:
1073
            case 0:
1074
                /* 1 Pixel High */
1075
                desiredH = 1;
1076
                break;
1077
            case 1:
1078
                /* Random height inside screen */
1079
                desiredH = SDLTest_RandomIntegerInRange(1, 100);
1080
                break;
1081
            case 2:
1082
                /* Height 1 pixel smaller than screen */
1083
                desiredH = display.h - 1;
1084
                break;
1085
            case 3:
1086
                /* Height at screen size */
1087
                desiredH = display.h;
1088
                break;
1089
            case 4:
1090
                /* Height 1 pixel larger than screen */
1091
                desiredH = display.h + 1;
1092
                break;
1093
            }
1094

1095
            /* Set size */
1096
            SDL_SetWindowSize(window, desiredW, desiredH);
1097
            SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH);
1098

1099
            result = SDL_SyncWindow(window);
1100
            SDLTest_AssertPass("SDL_SyncWindow()");
1101
            SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
1102

1103
            /* Get size */
1104
            currentW = desiredW + 1;
1105
            currentH = desiredH + 1;
1106
            SDL_GetWindowSize(window, &currentW, &currentH);
1107
            SDLTest_AssertPass("Call to SDL_GetWindowSize()");
1108

1109
            if (desiredW == currentW && desiredH == currentH) {
1110
                SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
1111
                SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
1112
            } else {
1113
                SDL_bool hasEvent;
1114
                /* SDL_SetWindowPosition() and SDL_SetWindowSize() will make requests of the window manager and set the internal position and size,
1115
                 * and then we get events signaling what actually happened, and they get passed on to the application if they're not what we expect. */
1116
                currentW = desiredW + 1;
1117
                currentH = desiredH + 1;
1118
                hasEvent = getSizeFromEvent(&currentW, &currentH);
1119
                SDLTest_AssertCheck(hasEvent == SDL_TRUE, "Changing size was not honored by WM, checking presence of SDL_EVENT_WINDOW_RESIZED");
1120
                if (hasEvent) {
1121
                    SDLTest_AssertCheck(desiredW == currentW, "Verify returned width is the one from SDL event; expected: %d, got: %d", desiredW, currentW);
1122
                    SDLTest_AssertCheck(desiredH == currentH, "Verify returned height is the one from SDL event; expected: %d, got: %d", desiredH, currentH);
1123
                }
1124
            }
1125

1126

1127
            /* Get just width */
1128
            currentW = desiredW + 1;
1129
            SDL_GetWindowSize(window, &currentW, NULL);
1130
            SDLTest_AssertPass("Call to SDL_GetWindowSize(&h=NULL)");
1131
            SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
1132

1133
            /* Get just height */
1134
            currentH = desiredH + 1;
1135
            SDL_GetWindowSize(window, NULL, &currentH);
1136
            SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL)");
1137
            SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
1138
        }
1139
    }
1140

1141
null_tests:
1142

1143
    /* Dummy call with both pointers NULL */
1144
    SDL_GetWindowSize(window, NULL, NULL);
1145
    SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL,&h=NULL)");
1146

1147
    /* Negative tests for parameter input */
1148
    SDL_ClearError();
1149
    SDLTest_AssertPass("Call to SDL_ClearError()");
1150
    for (desiredH = -2; desiredH < 2; desiredH++) {
1151
        for (desiredW = -2; desiredW < 2; desiredW++) {
1152
            if (desiredW <= 0 || desiredH <= 0) {
1153
                SDL_SetWindowSize(window, desiredW, desiredH);
1154
                SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH);
1155
                checkInvalidParameterError();
1156
            }
1157
        }
1158
    }
1159

1160
    /* Clean up */
1161
    destroyVideoSuiteTestWindow(window);
1162

1163
    /* Set some 'magic' value for later check that nothing was changed */
1164
    referenceW = SDLTest_RandomSint32();
1165
    referenceH = SDLTest_RandomSint32();
1166
    currentW = referenceW;
1167
    currentH = referenceH;
1168
    desiredW = SDLTest_RandomSint32();
1169
    desiredH = SDLTest_RandomSint32();
1170

1171
    /* Negative tests for window input */
1172
    SDL_ClearError();
1173
    SDLTest_AssertPass("Call to SDL_ClearError()");
1174
    SDL_GetWindowSize(NULL, &currentW, &currentH);
1175
    SDLTest_AssertPass("Call to SDL_GetWindowSize(window=NULL)");
1176
    SDLTest_AssertCheck(
1177
        currentW == referenceW && currentH == referenceH,
1178
        "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
1179
        referenceW, referenceH,
1180
        currentW, currentH);
1181
    checkInvalidWindowError();
1182

1183
    SDL_GetWindowSize(NULL, NULL, NULL);
1184
    SDLTest_AssertPass("Call to SDL_GetWindowSize(NULL, NULL, NULL)");
1185
    checkInvalidWindowError();
1186

1187
    SDL_SetWindowSize(NULL, desiredW, desiredH);
1188
    SDLTest_AssertPass("Call to SDL_SetWindowSize(window=NULL)");
1189
    checkInvalidWindowError();
1190

1191
    /* Restore the hint to the previous value */
1192
    SDL_SetHint("SDL_BORDERLESS_RESIZABLE_STYLE", restoreHint ? "1" : "0");
1193

1194
    return TEST_COMPLETED;
1195
}
1196

1197
/**
1198
 * Tests call to SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize
1199
 *
1200
 */
1201
static int video_getSetWindowMinimumSize(void *arg)
1202
{
1203
    const char *title = "video_getSetWindowMinimumSize Test Window";
1204
    SDL_Window *window;
1205
    int result;
1206
    SDL_Rect display;
1207
    int wVariation, hVariation;
1208
    int referenceW, referenceH;
1209
    int currentW, currentH;
1210
    int desiredW = 1;
1211
    int desiredH = 1;
1212

1213
    /* Get display bounds for size range */
1214
    result = SDL_GetDisplayBounds(SDL_GetPrimaryDisplay(), &display);
1215
    SDLTest_AssertPass("SDL_GetDisplayBounds()");
1216
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
1217
    if (result != 0) {
1218
        return TEST_ABORTED;
1219
    }
1220

1221
    /* Call against new test window */
1222
    window = createVideoSuiteTestWindow(title);
1223
    if (!window) {
1224
        return TEST_ABORTED;
1225
    }
1226

1227
    for (wVariation = 0; wVariation < 5; wVariation++) {
1228
        for (hVariation = 0; hVariation < 5; hVariation++) {
1229
            switch (wVariation) {
1230
            case 0:
1231
                /* 1 Pixel Wide */
1232
                desiredW = 1;
1233
                break;
1234
            case 1:
1235
                /* Random width inside screen */
1236
                desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1);
1237
                break;
1238
            case 2:
1239
                /* Width at screen size */
1240
                desiredW = display.w;
1241
                break;
1242
            }
1243

1244
            switch (hVariation) {
1245
            case 0:
1246
                /* 1 Pixel High */
1247
                desiredH = 1;
1248
                break;
1249
            case 1:
1250
                /* Random height inside screen */
1251
                desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1);
1252
                break;
1253
            case 2:
1254
                /* Height at screen size */
1255
                desiredH = display.h;
1256
                break;
1257
            case 4:
1258
                /* Height 1 pixel larger than screen */
1259
                desiredH = display.h + 1;
1260
                break;
1261
            }
1262

1263
            /* Set size */
1264
            SDL_SetWindowMinimumSize(window, desiredW, desiredH);
1265
            SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH);
1266

1267
            /* Get size */
1268
            currentW = desiredW + 1;
1269
            currentH = desiredH + 1;
1270
            SDL_GetWindowMinimumSize(window, &currentW, &currentH);
1271
            SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize()");
1272
            SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
1273
            SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
1274

1275
            /* Get just width */
1276
            currentW = desiredW + 1;
1277
            SDL_GetWindowMinimumSize(window, &currentW, NULL);
1278
            SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&h=NULL)");
1279
            SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
1280

1281
            /* Get just height */
1282
            currentH = desiredH + 1;
1283
            SDL_GetWindowMinimumSize(window, NULL, &currentH);
1284
            SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL)");
1285
            SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
1286
        }
1287
    }
1288

1289
    /* Dummy call with both pointers NULL */
1290
    SDL_GetWindowMinimumSize(window, NULL, NULL);
1291
    SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL,&h=NULL)");
1292

1293
    /* Negative tests for parameter input */
1294
    SDL_ClearError();
1295
    SDLTest_AssertPass("Call to SDL_ClearError()");
1296
    for (desiredH = -2; desiredH < 2; desiredH++) {
1297
        for (desiredW = -2; desiredW < 2; desiredW++) {
1298
            if (desiredW < 0 || desiredH < 0) {
1299
                SDL_SetWindowMinimumSize(window, desiredW, desiredH);
1300
                SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH);
1301
                checkInvalidParameterError();
1302
            }
1303
        }
1304
    }
1305

1306
    /* Clean up */
1307
    destroyVideoSuiteTestWindow(window);
1308

1309
    /* Set some 'magic' value for later check that nothing was changed */
1310
    referenceW = SDLTest_RandomSint32();
1311
    referenceH = SDLTest_RandomSint32();
1312
    currentW = referenceW;
1313
    currentH = referenceH;
1314
    desiredW = SDLTest_RandomSint32();
1315
    desiredH = SDLTest_RandomSint32();
1316

1317
    /* Negative tests for window input */
1318
    SDL_ClearError();
1319
    SDLTest_AssertPass("Call to SDL_ClearError()");
1320
    SDL_GetWindowMinimumSize(NULL, &currentW, &currentH);
1321
    SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(window=NULL)");
1322
    SDLTest_AssertCheck(
1323
        currentW == referenceW && currentH == referenceH,
1324
        "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
1325
        referenceW, referenceH,
1326
        currentW, currentH);
1327
    checkInvalidWindowError();
1328

1329
    SDL_GetWindowMinimumSize(NULL, NULL, NULL);
1330
    SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(NULL, NULL, NULL)");
1331
    checkInvalidWindowError();
1332

1333
    SDL_SetWindowMinimumSize(NULL, desiredW, desiredH);
1334
    SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(window=NULL)");
1335
    checkInvalidWindowError();
1336

1337
    return TEST_COMPLETED;
1338
}
1339

1340
/**
1341
 * Tests call to SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize
1342
 *
1343
 */
1344
static int video_getSetWindowMaximumSize(void *arg)
1345
{
1346
    const char *title = "video_getSetWindowMaximumSize Test Window";
1347
    SDL_Window *window;
1348
    int result;
1349
    SDL_Rect display;
1350
    int wVariation, hVariation;
1351
    int referenceW, referenceH;
1352
    int currentW, currentH;
1353
    int desiredW = 0, desiredH = 0;
1354

1355
    /* Get display bounds for size range */
1356
    result = SDL_GetDisplayBounds(SDL_GetPrimaryDisplay(), &display);
1357
    SDLTest_AssertPass("SDL_GetDisplayBounds()");
1358
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
1359
    if (result != 0) {
1360
        return TEST_ABORTED;
1361
    }
1362

1363
    /* Call against new test window */
1364
    window = createVideoSuiteTestWindow(title);
1365
    if (!window) {
1366
        return TEST_ABORTED;
1367
    }
1368

1369
    for (wVariation = 0; wVariation < 3; wVariation++) {
1370
        for (hVariation = 0; hVariation < 3; hVariation++) {
1371
            switch (wVariation) {
1372
            case 0:
1373
                /* 1 Pixel Wide */
1374
                desiredW = 1;
1375
                break;
1376
            case 1:
1377
                /* Random width inside screen */
1378
                desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1);
1379
                break;
1380
            case 2:
1381
                /* Width at screen size */
1382
                desiredW = display.w;
1383
                break;
1384
            }
1385

1386
            switch (hVariation) {
1387
            case 0:
1388
                /* 1 Pixel High */
1389
                desiredH = 1;
1390
                break;
1391
            case 1:
1392
                /* Random height inside screen */
1393
                desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1);
1394
                break;
1395
            case 2:
1396
                /* Height at screen size */
1397
                desiredH = display.h;
1398
                break;
1399
            }
1400

1401
            /* Set size */
1402
            SDL_SetWindowMaximumSize(window, desiredW, desiredH);
1403
            SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH);
1404

1405
            /* Get size */
1406
            currentW = desiredW + 1;
1407
            currentH = desiredH + 1;
1408
            SDL_GetWindowMaximumSize(window, &currentW, &currentH);
1409
            SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize()");
1410
            SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
1411
            SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
1412

1413
            /* Get just width */
1414
            currentW = desiredW + 1;
1415
            SDL_GetWindowMaximumSize(window, &currentW, NULL);
1416
            SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&h=NULL)");
1417
            SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
1418

1419
            /* Get just height */
1420
            currentH = desiredH + 1;
1421
            SDL_GetWindowMaximumSize(window, NULL, &currentH);
1422
            SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL)");
1423
            SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
1424
        }
1425
    }
1426

1427
    /* Dummy call with both pointers NULL */
1428
    SDL_GetWindowMaximumSize(window, NULL, NULL);
1429
    SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL,&h=NULL)");
1430

1431
    /* Negative tests for parameter input */
1432
    SDL_ClearError();
1433
    SDLTest_AssertPass("Call to SDL_ClearError()");
1434
    for (desiredH = -2; desiredH < 2; desiredH++) {
1435
        for (desiredW = -2; desiredW < 2; desiredW++) {
1436
            if (desiredW < 0 || desiredH < 0) {
1437
                SDL_SetWindowMaximumSize(window, desiredW, desiredH);
1438
                SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH);
1439
                checkInvalidParameterError();
1440
            }
1441
        }
1442
    }
1443

1444
    /* Clean up */
1445
    destroyVideoSuiteTestWindow(window);
1446

1447
    /* Set some 'magic' value for later check that nothing was changed */
1448
    referenceW = SDLTest_RandomSint32();
1449
    referenceH = SDLTest_RandomSint32();
1450
    currentW = referenceW;
1451
    currentH = referenceH;
1452
    desiredW = SDLTest_RandomSint32();
1453
    desiredH = SDLTest_RandomSint32();
1454

1455
    /* Negative tests */
1456
    SDL_ClearError();
1457
    SDLTest_AssertPass("Call to SDL_ClearError()");
1458
    SDL_GetWindowMaximumSize(NULL, &currentW, &currentH);
1459
    SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(window=NULL)");
1460
    SDLTest_AssertCheck(
1461
        currentW == referenceW && currentH == referenceH,
1462
        "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
1463
        referenceW, referenceH,
1464
        currentW, currentH);
1465
    checkInvalidWindowError();
1466

1467
    SDL_GetWindowMaximumSize(NULL, NULL, NULL);
1468
    SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(NULL, NULL, NULL)");
1469
    checkInvalidWindowError();
1470

1471
    SDL_SetWindowMaximumSize(NULL, desiredW, desiredH);
1472
    SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(window=NULL)");
1473
    checkInvalidWindowError();
1474

1475
    return TEST_COMPLETED;
1476
}
1477

1478
/**
1479
 * Tests call to SDL_SetWindowData and SDL_GetWindowData
1480
 *
1481
 * \sa SDL_SetWindowData
1482
 * \sa SDL_GetWindowData
1483
 */
1484
static int video_getSetWindowData(void *arg)
1485
{
1486
    int returnValue = TEST_COMPLETED;
1487
    const char *title = "video_setGetWindowData Test Window";
1488
    SDL_Window *window;
1489
    const char *referenceName = "TestName";
1490
    const char *name = "TestName";
1491
    const char *referenceName2 = "TestName2";
1492
    const char *name2 = "TestName2";
1493
    int datasize;
1494
    char *referenceUserdata = NULL;
1495
    char *userdata = NULL;
1496
    char *referenceUserdata2 = NULL;
1497
    char *userdata2 = NULL;
1498
    char *result;
1499
    int iteration;
1500

1501
    /* Call against new test window */
1502
    window = createVideoSuiteTestWindow(title);
1503
    if (!window) {
1504
        return TEST_ABORTED;
1505
    }
1506

1507
    /* Create testdata */
1508
    datasize = SDLTest_RandomIntegerInRange(1, 32);
1509
    referenceUserdata = SDLTest_RandomAsciiStringOfSize(datasize);
1510
    if (!referenceUserdata) {
1511
        returnValue = TEST_ABORTED;
1512
        goto cleanup;
1513
    }
1514
    userdata = SDL_strdup(referenceUserdata);
1515
    if (!userdata) {
1516
        returnValue = TEST_ABORTED;
1517
        goto cleanup;
1518
    }
1519
    datasize = SDLTest_RandomIntegerInRange(1, 32);
1520
    referenceUserdata2 = SDLTest_RandomAsciiStringOfSize(datasize);
1521
    if (!referenceUserdata2) {
1522
        returnValue = TEST_ABORTED;
1523
        goto cleanup;
1524
    }
1525
    userdata2 = SDL_strdup(referenceUserdata2);
1526
    if (!userdata2) {
1527
        returnValue = TEST_ABORTED;
1528
        goto cleanup;
1529
    }
1530

1531
    /* Get non-existent data */
1532
    result = (char *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), name, NULL);
1533
    SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name);
1534
    SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
1535
    SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1536

1537
    /* Set data */
1538
    SDL_SetPointerProperty(SDL_GetWindowProperties(window), name, userdata);
1539
    SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s)", name, userdata);
1540
    SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1541
    SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
1542

1543
    /* Get data (twice) */
1544
    for (iteration = 1; iteration <= 2; iteration++) {
1545
        result = (char *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), name, NULL);
1546
        SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [iteration %d]", name, iteration);
1547
        SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
1548
        SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1549
    }
1550

1551
    /* Set data again twice */
1552
    for (iteration = 1; iteration <= 2; iteration++) {
1553
        SDL_SetPointerProperty(SDL_GetWindowProperties(window), name, userdata);
1554
        SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [iteration %d]", name, userdata, iteration);
1555
        SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1556
        SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
1557
    }
1558

1559
    /* Get data again */
1560
    result = (char *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), name, NULL);
1561
    SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [again]", name);
1562
    SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
1563
    SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1564

1565
    /* Set data with new data */
1566
    SDL_SetPointerProperty(SDL_GetWindowProperties(window), name, userdata2);
1567
    SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [new userdata]", name, userdata2);
1568
    SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1569
    SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
1570
    SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
1571

1572
    /* Set data with new data again */
1573
    SDL_SetPointerProperty(SDL_GetWindowProperties(window), name, userdata2);
1574
    SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [new userdata again]", name, userdata2);
1575
    SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1576
    SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
1577
    SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
1578

1579
    /* Get new data */
1580
    result = (char *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), name, NULL);
1581
    SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name);
1582
    SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result);
1583
    SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1584

1585
    /* Set data with NULL to clear */
1586
    SDL_SetPointerProperty(SDL_GetWindowProperties(window), name, NULL);
1587
    SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,NULL)", name);
1588
    SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1589
    SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
1590
    SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
1591

1592
    /* Set data with NULL to clear again */
1593
    SDL_SetPointerProperty(SDL_GetWindowProperties(window), name, NULL);
1594
    SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,NULL) [again]", name);
1595
    SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1596
    SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
1597
    SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
1598

1599
    /* Get non-existent data */
1600
    result = (char *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), name, NULL);
1601
    SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name);
1602
    SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
1603
    SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1604

1605
    /* Get non-existent data new name */
1606
    result = (char *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), name2, NULL);
1607
    SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name2);
1608
    SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
1609
    SDLTest_AssertCheck(SDL_strcmp(referenceName2, name2) == 0, "Validate that name2 was not changed, expected: %s, got: %s", referenceName2, name2);
1610

1611
    /* Set data (again) */
1612
    SDL_SetPointerProperty(SDL_GetWindowProperties(window), name, userdata);
1613
    SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [again, after clear]", name, userdata);
1614
    SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1615
    SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
1616

1617
    /* Get data (again) */
1618
    result = (char *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), name, NULL);
1619
    SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [again, after clear]", name);
1620
    SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
1621
    SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
1622

1623
    /* Set data with NULL name, valid userdata */
1624
    SDL_SetPointerProperty(SDL_GetWindowProperties(window), NULL, userdata);
1625
    SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL)");
1626
    checkInvalidParameterError();
1627

1628
    /* Set data with empty name, valid userdata */
1629
    SDL_SetPointerProperty(SDL_GetWindowProperties(window), "", userdata);
1630
    SDLTest_AssertPass("Call to SDL_SetWindowData(name='')");
1631
    checkInvalidParameterError();
1632

1633
    /* Set data with NULL name, NULL userdata */
1634
    SDL_SetPointerProperty(SDL_GetWindowProperties(window), NULL, NULL);
1635
    SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL,userdata=NULL)");
1636
    checkInvalidParameterError();
1637

1638
    /* Set data with empty name, NULL userdata */
1639
    SDL_SetPointerProperty(SDL_GetWindowProperties(window), "", NULL);
1640
    SDLTest_AssertPass("Call to SDL_SetWindowData(name='',userdata=NULL)");
1641
    checkInvalidParameterError();
1642

1643
    /* Get data with NULL name */
1644
    result = (char *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), NULL, NULL);
1645
    SDLTest_AssertPass("Call to SDL_GetWindowData(name=NULL)");
1646
    SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
1647

1648
    /* Get data with empty name */
1649
    result = (char *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), "", NULL);
1650
    SDLTest_AssertPass("Call to SDL_GetWindowData(name='')");
1651
    SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
1652

1653
    /* Clean up */
1654
    destroyVideoSuiteTestWindow(window);
1655

1656
cleanup:
1657
    SDL_free(referenceUserdata);
1658
    SDL_free(referenceUserdata2);
1659
    SDL_free(userdata);
1660
    SDL_free(userdata2);
1661

1662
    return returnValue;
1663
}
1664

1665
/**
1666
 * Tests the functionality of the SDL_WINDOWPOS_CENTERED_DISPLAY along with SDL_WINDOW_FULLSCREEN.
1667
 *
1668
 * Especially useful when run on a multi-monitor system with different DPI scales per monitor,
1669
 * to test that the window size is maintained when moving between monitors.
1670
 *
1671
 * As the Wayland windowing protocol does not allow application windows to control their position in the
1672
 * desktop space, coupled with the general asynchronous nature of Wayland compositors, the positioning
1673
 * tests don't work in windowed mode and are unreliable in fullscreen mode, thus are disabled when using
1674
 * the Wayland video driver. All that can be done is check that the windows are the expected size.
1675
 */
1676
static int video_setWindowCenteredOnDisplay(void *arg)
1677
{
1678
    SDL_DisplayID *displays;
1679
    SDL_Window *window;
1680
    const char *title = "video_setWindowCenteredOnDisplay Test Window";
1681
    int x, y, w, h;
1682
    int xVariation, yVariation;
1683
    int displayNum;
1684
    int result;
1685
    SDL_Rect display0, display1;
1686
    const char *video_driver = SDL_GetCurrentVideoDriver();
1687
    SDL_bool video_driver_is_wayland = SDL_strcmp(video_driver, "wayland") == 0;
1688
    SDL_bool video_driver_is_emscripten = SDL_strcmp(video_driver, "emscripten") == 0;
1689

1690
    displays = SDL_GetDisplays(&displayNum);
1691
    if (displays) {
1692

1693
        /* Get display bounds */
1694
        result = SDL_GetDisplayUsableBounds(displays[0 % displayNum], &display0);
1695
        SDLTest_AssertPass("SDL_GetDisplayUsableBounds()");
1696
        SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
1697
        if (result != 0) {
1698
            return TEST_ABORTED;
1699
        }
1700

1701
        result = SDL_GetDisplayUsableBounds(displays[1 % displayNum], &display1);
1702
        SDLTest_AssertPass("SDL_GetDisplayUsableBounds()");
1703
        SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
1704
        if (result != 0) {
1705
            return TEST_ABORTED;
1706
        }
1707

1708
        for (xVariation = 0; xVariation < 2; xVariation++) {
1709
            for (yVariation = 0; yVariation < 2; yVariation++) {
1710
                int currentX = 0, currentY = 0;
1711
                int currentW = 0, currentH = 0;
1712
                int expectedX = 0, expectedY = 0;
1713
                int currentDisplay;
1714
                int expectedDisplay;
1715
                SDL_Rect expectedDisplayRect, expectedFullscreenRect;
1716
                SDL_PropertiesID props;
1717

1718
                /* xVariation is the display we start on */
1719
                expectedDisplay = displays[xVariation % displayNum];
1720
                x = SDL_WINDOWPOS_CENTERED_DISPLAY(expectedDisplay);
1721
                y = SDL_WINDOWPOS_CENTERED_DISPLAY(expectedDisplay);
1722
                w = SDLTest_RandomIntegerInRange(640, 800);
1723
                h = SDLTest_RandomIntegerInRange(400, 600);
1724
                expectedDisplayRect = (xVariation == 0) ? display0 : display1;
1725
                expectedX = (expectedDisplayRect.x + ((expectedDisplayRect.w - w) / 2));
1726
                expectedY = (expectedDisplayRect.y + ((expectedDisplayRect.h - h) / 2));
1727

1728
                props = SDL_CreateProperties();
1729
                SDL_SetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, title);
1730
                SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_X_NUMBER, x);
1731
                SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_Y_NUMBER, y);
1732
                SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, w);
1733
                SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, h);
1734
                SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_BORDERLESS_BOOLEAN, SDL_TRUE);
1735
                window = SDL_CreateWindowWithProperties(props);
1736
                SDL_DestroyProperties(props);
1737
                SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h);
1738
                SDLTest_AssertCheck(window != NULL, "Validate that returned window is not NULL");
1739

1740
                /* Wayland windows require that a frame be presented before they are fully mapped and visible onscreen. */
1741
                if (video_driver_is_wayland) {
1742
                    SDL_Renderer *renderer = SDL_CreateRenderer(window, NULL);
1743

1744
                    if (renderer) {
1745
                        SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
1746
                        SDL_RenderClear(renderer);
1747
                        SDL_RenderPresent(renderer);
1748

1749
                        /* Some desktops don't display the window immediately after presentation,
1750
                         * so delay to give the window time to actually appear on the desktop.
1751
                         */
1752
                        SDL_Delay(100);
1753
                    } else {
1754
                        SDLTest_Log("Unable to create a renderer, tests may fail under Wayland");
1755
                    }
1756
                }
1757

1758
                /* Check the window is centered on the requested display */
1759
                currentDisplay = SDL_GetDisplayForWindow(window);
1760
                SDL_GetWindowSize(window, &currentW, &currentH);
1761
                SDL_GetWindowPosition(window, &currentX, &currentY);
1762

1763
                if (video_driver_is_wayland) {
1764
                    SDLTest_Log("Skipping display ID validation: %s driver does not support window positioning", video_driver);
1765
                } else {
1766
                    SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display ID (current: %d, expected: %d)", currentDisplay, expectedDisplay);
1767
                }
1768
                if (video_driver_is_emscripten) {
1769
                    SDLTest_Log("Skipping window size validation: %s driver does not support window resizing", video_driver);
1770
                } else {
1771
                    SDLTest_AssertCheck(currentW == w, "Validate width (current: %d, expected: %d)", currentW, w);
1772
                    SDLTest_AssertCheck(currentH == h, "Validate height (current: %d, expected: %d)", currentH, h);
1773
                }
1774
                if (video_driver_is_emscripten || video_driver_is_wayland) {
1775
                    SDLTest_Log("Skipping window position validation: %s driver does not support window positioning", video_driver);
1776
                } else {
1777
                    SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX);
1778
                    SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY);
1779
                }
1780

1781
                /* Enter fullscreen desktop */
1782
                SDL_SetWindowPosition(window, x, y);
1783
                result = SDL_SetWindowFullscreen(window, SDL_TRUE);
1784
                SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
1785

1786
                result = SDL_SyncWindow(window);
1787
                SDLTest_AssertPass("SDL_SyncWindow()");
1788
                SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
1789

1790
                /* Check we are filling the full display */
1791
                currentDisplay = SDL_GetDisplayForWindow(window);
1792
                SDL_GetWindowSize(window, &currentW, &currentH);
1793
                SDL_GetWindowPosition(window, &currentX, &currentY);
1794

1795
                /* Get the expected fullscreen rect.
1796
                 * This needs to be queried after window creation and positioning as some drivers can alter the
1797
                 * usable bounds based on the window scaling mode.
1798
                 */
1799
                result = SDL_GetDisplayBounds(expectedDisplay, &expectedFullscreenRect);
1800
                SDLTest_AssertPass("SDL_GetDisplayBounds()");
1801
                SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
1802

1803
                if (video_driver_is_wayland) {
1804
                    SDLTest_Log("Skipping display ID validation: Wayland driver does not support window positioning");
1805
                } else {
1806
                    SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display ID (current: %d, expected: %d)", currentDisplay, expectedDisplay);
1807
                }
1808

1809
                if (video_driver_is_emscripten) {
1810
                    SDLTest_Log("Skipping window position validation: %s driver does not support window resizing", video_driver);
1811
                } else {
1812
                    SDLTest_AssertCheck(currentW == expectedFullscreenRect.w, "Validate width (current: %d, expected: %d)", currentW, expectedFullscreenRect.w);
1813
                    SDLTest_AssertCheck(currentH == expectedFullscreenRect.h, "Validate height (current: %d, expected: %d)", currentH, expectedFullscreenRect.h);
1814
                }
1815
                if (video_driver_is_emscripten || video_driver_is_wayland) {
1816
                    SDLTest_Log("Skipping window position validation: %s driver does not support window positioning", video_driver);
1817
                } else {
1818
                    SDLTest_AssertCheck(currentX == expectedFullscreenRect.x, "Validate x (current: %d, expected: %d)", currentX, expectedFullscreenRect.x);
1819
                    SDLTest_AssertCheck(currentY == expectedFullscreenRect.y, "Validate y (current: %d, expected: %d)", currentY, expectedFullscreenRect.y);
1820
                }
1821

1822
                /* Leave fullscreen desktop */
1823
                result = SDL_SetWindowFullscreen(window, SDL_FALSE);
1824
                SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
1825

1826
                result = SDL_SyncWindow(window);
1827
                SDLTest_AssertPass("SDL_SyncWindow()");
1828
                SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
1829

1830
                /* Check window was restored correctly */
1831
                currentDisplay = SDL_GetDisplayForWindow(window);
1832
                SDL_GetWindowSize(window, &currentW, &currentH);
1833
                SDL_GetWindowPosition(window, &currentX, &currentY);
1834

1835
                if (video_driver_is_wayland) {
1836
                    SDLTest_Log("Skipping display ID validation: %s driver does not support window positioning", video_driver);
1837
                } else {
1838
                    SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay);
1839
                }
1840
                if (video_driver_is_emscripten) {
1841
                    SDLTest_Log("Skipping window position validation: %s driver does not support window resizing", video_driver);
1842
                } else {
1843
                    SDLTest_AssertCheck(currentW == w, "Validate width (current: %d, expected: %d)", currentW, w);
1844
                    SDLTest_AssertCheck(currentH == h, "Validate height (current: %d, expected: %d)", currentH, h);
1845
                }
1846
                if (video_driver_is_wayland) {
1847
                    SDLTest_Log("Skipping window position validation: %s driver does not support window positioning", video_driver);
1848
                } else {
1849
                    SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX);
1850
                    SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY);
1851
                }
1852

1853
                /* Center on display yVariation, and check window properties */
1854

1855
                expectedDisplay = displays[yVariation % displayNum];
1856
                x = SDL_WINDOWPOS_CENTERED_DISPLAY(expectedDisplay);
1857
                y = SDL_WINDOWPOS_CENTERED_DISPLAY(expectedDisplay);
1858
                expectedDisplayRect = (yVariation == 0) ? display0 : display1;
1859
                expectedX = (expectedDisplayRect.x + ((expectedDisplayRect.w - w) / 2));
1860
                expectedY = (expectedDisplayRect.y + ((expectedDisplayRect.h - h) / 2));
1861
                SDL_SetWindowPosition(window, x, y);
1862

1863
                result = SDL_SyncWindow(window);
1864
                SDLTest_AssertPass("SDL_SyncWindow()");
1865
                SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
1866

1867
                currentDisplay = SDL_GetDisplayForWindow(window);
1868
                SDL_GetWindowSize(window, &currentW, &currentH);
1869
                SDL_GetWindowPosition(window, &currentX, &currentY);
1870

1871
                if (video_driver_is_wayland) {
1872
                    SDLTest_Log("Skipping display ID validation: %s driver does not support window positioning", video_driver);
1873
                } else {
1874
                    SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display ID (current: %d, expected: %d)", currentDisplay, expectedDisplay);
1875
                }
1876
                if (video_driver_is_emscripten) {
1877
                    SDLTest_Log("Skipping window position validation: %s driver does not support window resizing", video_driver);
1878
                } else {
1879
                    SDLTest_AssertCheck(currentW == w, "Validate width (current: %d, expected: %d)", currentW, w);
1880
                    SDLTest_AssertCheck(currentH == h, "Validate height (current: %d, expected: %d)", currentH, h);
1881
                }
1882
                if (video_driver_is_wayland) {
1883
                    SDLTest_Log("Skipping window position validation: %s driver does not support window positioning", video_driver);
1884
                } else {
1885
                    SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX);
1886
                    SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY);
1887
                }
1888

1889
                /* Clean up */
1890
                destroyVideoSuiteTestWindow(window);
1891
            }
1892
        }
1893
        SDL_free(displays);
1894
    }
1895

1896
    return TEST_COMPLETED;
1897
}
1898

1899
/**
1900
 * Tests calls to SDL_MaximizeWindow(), SDL_RestoreWindow(), and SDL_SetWindowFullscreen(),
1901
 * interspersed with calls to set the window size and position, and verifies the flags,
1902
 * sizes, and positions of maximized, fullscreen, and restored windows.
1903
 *
1904
 * NOTE: This test is good on Mac, Win32, GNOME, and KDE (Wayland and X11). Other *nix
1905
 *       desktops, particularly tiling desktops, may not support the expected behavior,
1906
 *       so don't be surprised if this fails.
1907
 */
1908
static int video_getSetWindowState(void *arg)
1909
{
1910
    const char *title = "video_getSetWindowState Test Window";
1911
    SDL_Window *window;
1912
    int result;
1913
    SDL_Rect display;
1914
    SDL_WindowFlags flags;
1915
    int windowedX, windowedY;
1916
    int currentX, currentY;
1917
    int desiredX = 0, desiredY = 0;
1918
    int windowedW, windowedH;
1919
    int currentW, currentH;
1920
    int desiredW = 0, desiredH = 0;
1921
    SDL_WindowFlags skipFlags = 0;
1922
    const SDL_bool restoreHint = SDL_GetHintBoolean("SDL_BORDERLESS_RESIZABLE_STYLE", SDL_TRUE);
1923
    const SDL_bool skipPos = SDL_strcmp(SDL_GetCurrentVideoDriver(), "wayland") == 0;
1924

1925
    /* This test is known to be good only on GNOME and KDE. At the time of writing, Weston seems to have maximize related bugs
1926
     * that prevent it from running correctly (no configure events are received when unsetting maximize), and tiling window
1927
     * managers such as Sway have fundamental behavioral differences that conflict with it.
1928
     *
1929
     * Other desktops can be enabled in the future as required.
1930
     */
1931
    if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "wayland") == 0 || SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0) {
1932
        const char *desktop = SDL_getenv("XDG_CURRENT_DESKTOP");
1933
        if (SDL_strcmp(desktop, "GNOME") != 0 && SDL_strcmp(desktop, "KDE") != 0) {
1934
            SDLTest_Log("Skipping test video_getSetWindowState: desktop environment %s not supported", desktop);
1935
            return TEST_SKIPPED;
1936
        }
1937
    }
1938

1939
    /* Win32 borderless windows are not resizable by default and need this undocumented hint */
1940
    SDL_SetHint("SDL_BORDERLESS_RESIZABLE_STYLE", "1");
1941

1942
    /* Call against new test window */
1943
    window = createVideoSuiteTestWindow(title);
1944
    if (!window) {
1945
        return TEST_ABORTED;
1946
    }
1947

1948
    SDL_GetWindowSize(window, &windowedW, &windowedH);
1949
    SDLTest_AssertPass("SDL_GetWindowSize()");
1950

1951
    SDL_GetWindowPosition(window, &windowedX, &windowedY);
1952
    SDLTest_AssertPass("SDL_GetWindowPosition()");
1953

1954
    if (skipPos) {
1955
        SDLTest_Log("Skipping positioning tests: %s reports window positioning as unsupported", SDL_GetCurrentVideoDriver());
1956
    }
1957

1958
    /* Maximize and check the dimensions */
1959
    result = SDL_MaximizeWindow(window);
1960
    SDLTest_AssertPass("SDL_MaximizeWindow()");
1961
    if (result < 0) {
1962
        SDLTest_Log("Skipping state transition tests: %s reports window maximizing as unsupported", SDL_GetCurrentVideoDriver());
1963
        skipFlags |= SDL_WINDOW_MAXIMIZED;
1964
        goto minimize_test;
1965
    }
1966
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
1967

1968
    result = SDL_SyncWindow(window);
1969
    SDLTest_AssertPass("SDL_SyncWindow()");
1970
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
1971

1972
    flags = SDL_GetWindowFlags(window);
1973
    SDLTest_AssertPass("SDL_GetWindowFlags()");
1974
    SDLTest_AssertCheck(flags & SDL_WINDOW_MAXIMIZED, "Verify the `SDL_WINDOW_MAXIMIZED` flag is set: %s", (flags & SDL_WINDOW_MAXIMIZED) ? "true" : "false");
1975

1976
    /* Check that the maximized window doesn't extend beyond the usable display bounds.
1977
     * FIXME: Maximizing Win32 borderless windows is broken, so this always fails.
1978
     *        Skip it for now.
1979
     */
1980
    if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "windows") != 0) {
1981
        result = SDL_GetDisplayUsableBounds(SDL_GetDisplayForWindow(window), &display);
1982
        SDLTest_AssertPass("SDL_GetDisplayUsableBounds()");
1983
        SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
1984

1985
        desiredW = display.w;
1986
        desiredH = display.h;
1987
        currentW = windowedW + 1;
1988
        currentH = windowedH + 1;
1989
        SDL_GetWindowSize(window, &currentW, &currentH);
1990
        SDLTest_AssertPass("Call to SDL_GetWindowSize()");
1991
        SDLTest_AssertCheck(currentW <= desiredW, "Verify returned width; expected: <= %d, got: %d", desiredW,
1992
                            currentW);
1993
        SDLTest_AssertCheck(currentH <= desiredH, "Verify returned height; expected: <= %d, got: %d", desiredH,
1994
                            currentH);
1995
    }
1996

1997
    /* Restore and check the dimensions */
1998
    result = SDL_RestoreWindow(window);
1999
    SDLTest_AssertPass("SDL_RestoreWindow()");
2000
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2001

2002
    result = SDL_SyncWindow(window);
2003
    SDLTest_AssertPass("SDL_SyncWindow()");
2004
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2005

2006
    flags = SDL_GetWindowFlags(window);
2007
    SDLTest_AssertPass("SDL_GetWindowFlags()");
2008
    SDLTest_AssertCheck(!(flags & SDL_WINDOW_MAXIMIZED), "Verify that the `SDL_WINDOW_MAXIMIZED` flag is cleared: %s", !(flags & SDL_WINDOW_MAXIMIZED) ? "true" : "false");
2009

2010
    if (!skipPos) {
2011
        currentX = windowedX + 1;
2012
        currentY = windowedY + 1;
2013
        SDL_GetWindowPosition(window, &currentX, &currentY);
2014
        SDLTest_AssertPass("Call to SDL_GetWindowPosition()");
2015
        SDLTest_AssertCheck(windowedX == currentX, "Verify returned X coordinate; expected: %d, got: %d", windowedX, currentX);
2016
        SDLTest_AssertCheck(windowedY == currentY, "Verify returned Y coordinate; expected: %d, got: %d", windowedY, currentY);
2017
    }
2018

2019
    currentW = windowedW + 1;
2020
    currentH = windowedH + 1;
2021
    SDL_GetWindowSize(window, &currentW, &currentH);
2022
    SDLTest_AssertPass("Call to SDL_GetWindowSize()");
2023
    SDLTest_AssertCheck(windowedW == currentW, "Verify returned width; expected: %d, got: %d", windowedW, currentW);
2024
    SDLTest_AssertCheck(windowedH == currentH, "Verify returned height; expected: %d, got: %d", windowedH, currentH);
2025

2026
    /* Maximize, then immediately restore */
2027
    result = SDL_MaximizeWindow(window);
2028
    SDLTest_AssertPass("SDL_MaximizeWindow()");
2029
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2030

2031
    result = SDL_RestoreWindow(window);
2032
    SDLTest_AssertPass("SDL_RestoreWindow()");
2033
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2034

2035
    result = SDL_SyncWindow(window);
2036
    SDLTest_AssertPass("SDL_SyncWindow()");
2037
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2038

2039
    flags = SDL_GetWindowFlags(window);
2040
    SDLTest_AssertPass("SDL_GetWindowFlags()");
2041
    SDLTest_AssertCheck(!(flags & SDL_WINDOW_MAXIMIZED), "Verify that the `SDL_WINDOW_MAXIMIZED` flag is cleared: %s", !(flags & SDL_WINDOW_MAXIMIZED) ? "true" : "false");
2042

2043
    /* Make sure the restored size and position matches the original windowed size and position. */
2044
    if (!skipPos) {
2045
        currentX = windowedX + 1;
2046
        currentY = windowedY + 1;
2047
        SDL_GetWindowPosition(window, &currentX, &currentY);
2048
        SDLTest_AssertPass("Call to SDL_GetWindowPosition()");
2049
        SDLTest_AssertCheck(windowedX == currentX, "Verify returned X coordinate; expected: %d, got: %d", windowedX, currentX);
2050
        SDLTest_AssertCheck(windowedY == currentY, "Verify returned Y coordinate; expected: %d, got: %d", windowedY, currentY);
2051
    }
2052

2053
    currentW = windowedW + 1;
2054
    currentH = windowedH + 1;
2055
    SDL_GetWindowSize(window, &currentW, &currentH);
2056
    SDLTest_AssertPass("Call to SDL_GetWindowSize()");
2057
    SDLTest_AssertCheck(windowedW == currentW, "Verify returned width; expected: %d, got: %d", windowedW, currentW);
2058
    SDLTest_AssertCheck(windowedH == currentH, "Verify returned height; expected: %d, got: %d", windowedH, currentH);
2059

2060
    /* Maximize, then enter fullscreen */
2061
    result = SDL_MaximizeWindow(window);
2062
    SDLTest_AssertPass("SDL_MaximizeWindow()");
2063
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2064

2065
    result = SDL_SetWindowFullscreen(window, SDL_TRUE);
2066
    SDLTest_AssertPass("SDL_SetWindowFullscreen(SDL_TRUE)");
2067
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2068

2069
    result = SDL_SyncWindow(window);
2070
    SDLTest_AssertPass("SDL_SyncWindow()");
2071
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2072

2073
    flags = SDL_GetWindowFlags(window);
2074
    SDLTest_AssertPass("SDL_GetWindowFlags()");
2075
    SDLTest_AssertCheck(flags & SDL_WINDOW_FULLSCREEN, "Verify the `SDL_WINDOW_FULLSCREEN` flag is set: %s", (flags & SDL_WINDOW_FULLSCREEN) ? "true" : "false");
2076
    SDLTest_AssertCheck(!(flags & SDL_WINDOW_MAXIMIZED), "Verify the `SDL_WINDOW_MAXIMIZED` flag is cleared: %s", !(flags & SDL_WINDOW_MAXIMIZED) ? "true" : "false");
2077

2078
    /* Verify the fullscreen size and position */
2079
    result = SDL_GetDisplayBounds(SDL_GetDisplayForWindow(window), &display);
2080
    SDLTest_AssertPass("SDL_GetDisplayBounds()");
2081
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2082

2083
    if (!skipPos) {
2084
        desiredX = display.x;
2085
        desiredY = display.y;
2086
        currentX = windowedX + 1;
2087
        currentY = windowedY + 1;
2088
        SDL_GetWindowPosition(window, &currentX, &currentY);
2089
        SDLTest_AssertPass("Call to SDL_GetWindowPosition()");
2090
        SDLTest_AssertCheck(desiredX == currentX, "Verify returned X coordinate; expected: %d, got: %d", desiredX, currentX);
2091
        SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y coordinate; expected: %d, got: %d", desiredY, currentY);
2092
    }
2093

2094
    desiredW = display.w;
2095
    desiredH = display.h;
2096
    currentW = windowedW + 1;
2097
    currentH = windowedH + 1;
2098
    SDL_GetWindowSize(window, &currentW, &currentH);
2099
    SDLTest_AssertPass("Call to SDL_GetWindowSize()");
2100
    SDLTest_AssertCheck(currentW == desiredW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
2101
    SDLTest_AssertCheck(currentH == desiredH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
2102

2103
    /* Leave fullscreen and restore the window */
2104
    result = SDL_SetWindowFullscreen(window, SDL_FALSE);
2105
    SDLTest_AssertPass("SDL_SetWindowFullscreen(SDL_FALSE)");
2106
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2107

2108
    result = SDL_RestoreWindow(window);
2109
    SDLTest_AssertPass("SDL_RestoreWindow()");
2110
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2111

2112
    result = SDL_SyncWindow(window);
2113
    SDLTest_AssertPass("SDL_SyncWindow()");
2114
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2115

2116
    flags = SDL_GetWindowFlags(window);
2117
    SDLTest_AssertPass("SDL_GetWindowFlags()");
2118
    SDLTest_AssertCheck(!(flags & SDL_WINDOW_MAXIMIZED), "Verify that the `SDL_WINDOW_MAXIMIZED` flag is cleared: %s", !(flags & SDL_WINDOW_MAXIMIZED) ? "true" : "false");
2119

2120
    /* Make sure the restored size and position matches the original windowed size and position. */
2121
    if (!skipPos) {
2122
        currentX = windowedX + 1;
2123
        currentY = windowedY + 1;
2124
        SDL_GetWindowPosition(window, &currentX, &currentY);
2125
        SDLTest_AssertPass("Call to SDL_GetWindowPosition()");
2126
        SDLTest_AssertCheck(windowedX == currentX, "Verify returned X coordinate; expected: %d, got: %d", windowedX, currentX);
2127
        SDLTest_AssertCheck(windowedY == currentY, "Verify returned Y coordinate; expected: %d, got: %d", windowedY, currentY);
2128
    }
2129

2130
    currentW = windowedW + 1;
2131
    currentH = windowedH + 1;
2132
    SDL_GetWindowSize(window, &currentW, &currentH);
2133
    SDLTest_AssertPass("Call to SDL_GetWindowSize()");
2134
    SDLTest_AssertCheck(windowedW == currentW, "Verify returned width; expected: %d, got: %d", windowedW, currentW);
2135
    SDLTest_AssertCheck(windowedH == currentH, "Verify returned height; expected: %d, got: %d", windowedH, currentH);
2136

2137
    /* Maximize, change size, and restore */
2138
    result = SDL_MaximizeWindow(window);
2139
    SDLTest_AssertPass("SDL_MaximizeWindow()");
2140
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2141

2142
    desiredW = windowedW + 10;
2143
    desiredH = windowedH + 10;
2144
    result = SDL_SetWindowSize(window, desiredW, desiredH);
2145
    SDLTest_AssertPass("SDL_SetWindowSize()");
2146
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2147

2148
    if (!skipPos) {
2149
        desiredX = windowedX + 10;
2150
        desiredY = windowedY + 10;
2151
        result = SDL_SetWindowPosition(window, desiredX, desiredY);
2152
        SDLTest_AssertPass("SDL_SetWindowPosition()");
2153
        SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2154
    }
2155

2156
    result = SDL_RestoreWindow(window);
2157
    SDLTest_AssertPass("SDL_RestoreWindow()");
2158
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2159

2160
    result = SDL_SyncWindow(window);
2161
    SDLTest_AssertPass("SDL_SyncWindow()");
2162
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2163

2164
    flags = SDL_GetWindowFlags(window);
2165
    SDLTest_AssertPass("SDL_GetWindowFlags()");
2166
    SDLTest_AssertCheck(!(flags & SDL_WINDOW_MAXIMIZED), "Verify that the `SDL_WINDOW_MAXIMIZED` flag is cleared: %s", !(flags & SDL_WINDOW_MAXIMIZED) ? "true" : "false");
2167

2168
    if (!skipPos) {
2169
        currentX = desiredX + 1;
2170
        currentY = desiredY + 1;
2171
        SDL_GetWindowPosition(window, &currentX, &currentY);
2172
        SDLTest_AssertPass("Call to SDL_GetWindowPosition()");
2173
        SDLTest_AssertCheck(desiredX == currentX, "Verify returned X coordinate; expected: %d, got: %d", desiredX, currentX);
2174
        SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y coordinate; expected: %d, got: %d", desiredY, currentY);
2175
    }
2176

2177
    currentW = desiredW + 1;
2178
    currentH = desiredH + 1;
2179
    SDL_GetWindowSize(window, &currentW, &currentH);
2180
    SDLTest_AssertPass("Call to SDL_GetWindowSize()");
2181
    SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
2182
    SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
2183

2184
    /* Change size and position, maximize and restore */
2185
    desiredW = windowedW - 5;
2186
    desiredH = windowedH - 5;
2187
    result = SDL_SetWindowSize(window, desiredW, desiredH);
2188
    SDLTest_AssertPass("SDL_SetWindowSize()");
2189
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2190

2191
    if (!skipPos) {
2192
        desiredX = windowedX + 5;
2193
        desiredY = windowedY + 5;
2194
        result = SDL_SetWindowPosition(window, desiredX, desiredY);
2195
        SDLTest_AssertPass("SDL_SetWindowPosition()");
2196
        SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2197
    }
2198

2199
    result = SDL_MaximizeWindow(window);
2200
    SDLTest_AssertPass("SDL_MaximizeWindow()");
2201
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2202

2203
    result = SDL_RestoreWindow(window);
2204
    SDLTest_AssertPass("SDL_RestoreWindow()");
2205
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2206

2207
    result = SDL_SyncWindow(window);
2208
    SDLTest_AssertPass("SDL_SyncWindow()");
2209
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2210

2211
    flags = SDL_GetWindowFlags(window);
2212
    SDLTest_AssertPass("SDL_GetWindowFlags()");
2213
    SDLTest_AssertCheck(!(flags & SDL_WINDOW_MAXIMIZED), "Verify that the `SDL_WINDOW_MAXIMIZED` flag is cleared: %s", !(flags & SDL_WINDOW_MAXIMIZED) ? "true" : "false");
2214

2215
    if (!skipPos) {
2216
        currentX = desiredX + 1;
2217
        currentY = desiredY + 1;
2218
        SDL_GetWindowPosition(window, &currentX, &currentY);
2219
        SDLTest_AssertPass("Call to SDL_GetWindowPosition()");
2220
        SDLTest_AssertCheck(desiredX == currentX, "Verify returned X coordinate; expected: %d, got: %d", desiredX, currentX);
2221
        SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y coordinate; expected: %d, got: %d", desiredY, currentY);
2222
    }
2223

2224
    currentW = desiredW + 1;
2225
    currentH = desiredH + 1;
2226
    SDL_GetWindowSize(window, &currentW, &currentH);
2227
    SDLTest_AssertPass("Call to SDL_GetWindowSize()");
2228
    SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
2229
    SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
2230

2231
minimize_test:
2232

2233
    /* Minimize */
2234
    result = SDL_MinimizeWindow(window);
2235
    if (result == 0) {
2236
        SDLTest_AssertPass("SDL_MinimizeWindow()");
2237
        SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2238

2239
        result = SDL_SyncWindow(window);
2240
        SDLTest_AssertPass("SDL_SyncWindow()");
2241
        SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2242

2243
        flags = SDL_GetWindowFlags(window);
2244
        SDLTest_AssertPass("SDL_GetWindowFlags()");
2245
        SDLTest_AssertCheck(flags & SDL_WINDOW_MINIMIZED, "Verify that the `SDL_WINDOW_MINIMIZED` flag is set: %s", (flags & SDL_WINDOW_MINIMIZED) ? "true" : "false");
2246
    } else {
2247
        SDLTest_Log("Skipping minimize test: %s reports window minimizing as unsupported", SDL_GetCurrentVideoDriver());
2248
        skipFlags |= SDL_WINDOW_MINIMIZED;
2249
    }
2250

2251
    /* Clean up */
2252
    destroyVideoSuiteTestWindow(window);
2253

2254
    /* Restore the hint to the previous value */
2255
    SDL_SetHint("SDL_BORDERLESS_RESIZABLE_STYLE", restoreHint ? "1" : "0");
2256

2257
    return skipFlags != (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED)  ? TEST_COMPLETED : TEST_SKIPPED;
2258
}
2259

2260
static int video_createMinimized(void *arg)
2261
{
2262
    const char *title = "video_createMinimized Test Window";
2263
    int result;
2264
    SDL_Window *window;
2265
    int windowedX, windowedY;
2266
    int windowedW, windowedH;
2267

2268
    /* Call against new test window */
2269
    window = SDL_CreateWindow(title, 320, 200, SDL_WINDOW_MINIMIZED);
2270
    if (!window) {
2271
        return TEST_ABORTED;
2272
    }
2273

2274
    SDL_GetWindowSize(window, &windowedW, &windowedH);
2275
    SDLTest_AssertPass("SDL_GetWindowSize()");
2276
    SDLTest_AssertCheck(windowedW > 0 && windowedH > 0, "Verify return value; expected: 320x200, got: %dx%d", windowedW, windowedH);
2277

2278
    SDL_GetWindowSizeInPixels(window, &windowedW, &windowedH);
2279
    SDLTest_AssertPass("SDL_GetWindowSizeInPixels()");
2280
    SDLTest_AssertCheck(windowedW > 0 && windowedH > 0, "Verify return value; expected: > 0, got: %dx%d", windowedW, windowedH);
2281

2282
    SDL_GetWindowPosition(window, &windowedX, &windowedY);
2283
    SDLTest_AssertPass("SDL_GetWindowPosition()");
2284
    SDLTest_AssertCheck(windowedX >= 0 && windowedY >= 0, "Verify return value; expected: >= 0, got: %d,%d", windowedX, windowedY);
2285

2286
    if (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED) {
2287
        result = SDL_RestoreWindow(window);
2288
        SDLTest_AssertPass("SDL_RestoreWindow()");
2289
        SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2290
    } else {
2291
        SDLTest_Log("Requested minimized window on creation, but that isn't supported on this platform.");
2292
    }
2293

2294
    SDL_DestroyWindow(window);
2295

2296
    return TEST_COMPLETED;
2297
}
2298

2299
static int video_createMaximized(void *arg)
2300
{
2301
    const char *title = "video_createMaximized Test Window";
2302
    int result;
2303
    SDL_Window *window;
2304
    int windowedX, windowedY;
2305
    int windowedW, windowedH;
2306

2307
    /* Call against new test window */
2308
    window = SDL_CreateWindow(title, 320, 200, SDL_WINDOW_MAXIMIZED);
2309
    if (!window) {
2310
        return TEST_ABORTED;
2311
    }
2312

2313
    SDL_GetWindowSize(window, &windowedW, &windowedH);
2314
    SDLTest_AssertPass("SDL_GetWindowSize()");
2315
    SDLTest_AssertCheck(windowedW > 0 && windowedH > 0, "Verify return value; expected: 320x200, got: %dx%d", windowedW, windowedH);
2316

2317
    SDL_GetWindowSizeInPixels(window, &windowedW, &windowedH);
2318
    SDLTest_AssertPass("SDL_GetWindowSizeInPixels()");
2319
    SDLTest_AssertCheck(windowedW > 0 && windowedH > 0, "Verify return value; expected: > 0, got: %dx%d", windowedW, windowedH);
2320

2321
    SDL_GetWindowPosition(window, &windowedX, &windowedY);
2322
    SDLTest_AssertPass("SDL_GetWindowPosition()");
2323
    SDLTest_AssertCheck(windowedX >= 0 && windowedY >= 0, "Verify return value; expected: >= 0, got: %d,%d", windowedX, windowedY);
2324

2325
    if (SDL_GetWindowFlags(window) & SDL_WINDOW_MAXIMIZED) {
2326
        result = SDL_RestoreWindow(window);
2327
        SDLTest_AssertPass("SDL_RestoreWindow()");
2328
        SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2329
    } else {
2330
        SDLTest_Log("Requested maximized window on creation, but that isn't supported on this platform.");
2331
    }
2332

2333
    SDL_DestroyWindow(window);
2334

2335
    return TEST_COMPLETED;
2336
}
2337

2338
/**
2339
 * Tests window surface functionality
2340
 */
2341
static int video_getWindowSurface(void *arg)
2342
{
2343
    const char *title = "video_getWindowSurface Test Window";
2344
    SDL_Window *window;
2345
    SDL_Surface *surface;
2346
    SDL_Renderer *renderer;
2347
    const char *renderer_name = NULL;
2348
    int result;
2349

2350
    if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "dummy") == 0) {
2351
        renderer_name = SDL_SOFTWARE_RENDERER;
2352
    }
2353

2354
    /* Make sure we're testing interaction with an accelerated renderer */
2355
    SDL_SetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION, "1");
2356

2357
    window = SDL_CreateWindow(title, 320, 320, 0);
2358
    SDLTest_AssertPass("Call to SDL_CreateWindow('Title',320,320,0)");
2359
    SDLTest_AssertCheck(window != NULL, "Validate that returned window is not NULL");
2360

2361
    surface = SDL_GetWindowSurface(window);
2362
    SDLTest_AssertPass("Call to SDL_GetWindowSurface(window)");
2363
    SDLTest_AssertCheck(surface != NULL, "Validate that returned surface is not NULL");
2364
    SDLTest_AssertCheck(SDL_WindowHasSurface(window), "Validate that window has a surface");
2365

2366
    result = SDL_UpdateWindowSurface(window);
2367
    SDLTest_AssertPass("Call to SDL_UpdateWindowSurface(window)");
2368
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2369

2370
    /* We shouldn't be able to create a renderer on a window with a surface */
2371
    renderer = SDL_CreateRenderer(window, renderer_name);
2372
    SDLTest_AssertPass("Call to SDL_CreateRenderer(window, %s)", renderer_name);
2373
    SDLTest_AssertCheck(renderer == NULL, "Validate that returned renderer is NULL");
2374

2375
    result = SDL_DestroyWindowSurface(window);
2376
    SDLTest_AssertPass("Call to SDL_DestroyWindowSurface(window)");
2377
    SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
2378
    SDLTest_AssertCheck(!SDL_WindowHasSurface(window), "Validate that window does not have a surface");
2379

2380
    /* We should be able to create a renderer on the window now */
2381
    renderer = SDL_CreateRenderer(window, renderer_name);
2382
    SDLTest_AssertPass("Call to SDL_CreateRenderer(window, %s)", renderer_name);
2383
    SDLTest_AssertCheck(renderer != NULL, "Validate that returned renderer is not NULL");
2384

2385
    /* We should not be able to create a window surface now, unless it was created by the renderer */
2386
    if (!SDL_WindowHasSurface(window)) {
2387
        surface = SDL_GetWindowSurface(window);
2388
        SDLTest_AssertPass("Call to SDL_GetWindowSurface(window)");
2389
        SDLTest_AssertCheck(surface == NULL, "Validate that returned surface is NULL");
2390
    }
2391

2392
    SDL_DestroyRenderer(renderer);
2393
    SDLTest_AssertPass("Call to SDL_DestroyRenderer(renderer)");
2394
    SDLTest_AssertCheck(!SDL_WindowHasSurface(window), "Validate that window does not have a surface");
2395

2396
    /* We should be able to create a window surface again */
2397
    surface = SDL_GetWindowSurface(window);
2398
    SDLTest_AssertPass("Call to SDL_GetWindowSurface(window)");
2399
    SDLTest_AssertCheck(surface != NULL, "Validate that returned surface is not NULL");
2400
    SDLTest_AssertCheck(SDL_WindowHasSurface(window), "Validate that window has a surface");
2401

2402
    /* Clean up */
2403
    SDL_DestroyWindow(window);
2404

2405
    return TEST_COMPLETED;
2406
}
2407

2408
/* ================= Test References ================== */
2409

2410
/* Video test cases */
2411
static const SDLTest_TestCaseReference videoTestEnableDisableScreensaver = {
2412
    video_enableDisableScreensaver, "video_enableDisableScreensaver", "Enable and disable screenaver while checking state", TEST_ENABLED
2413
};
2414

2415
static const SDLTest_TestCaseReference videoTestCreateWindowVariousSizes = {
2416
    video_createWindowVariousSizes, "video_createWindowVariousSizes", "Create windows with various sizes", TEST_ENABLED
2417
};
2418

2419
static const SDLTest_TestCaseReference videoTestCreateWindowVariousFlags = {
2420
    video_createWindowVariousFlags, "video_createWindowVariousFlags", "Create windows using various flags", TEST_ENABLED
2421
};
2422

2423
static const SDLTest_TestCaseReference videoTestGetWindowFlags = {
2424
    video_getWindowFlags, "video_getWindowFlags", "Get window flags set during SDL_CreateWindow", TEST_ENABLED
2425
};
2426

2427
static const SDLTest_TestCaseReference videoTestGetFullscreenDisplayModes = {
2428
    video_getFullscreenDisplayModes, "video_getFullscreenDisplayModes", "Use SDL_GetFullscreenDisplayModes function to get number of display modes", TEST_ENABLED
2429
};
2430

2431
static const SDLTest_TestCaseReference videoTestGetClosestDisplayModeCurrentResolution = {
2432
    video_getClosestDisplayModeCurrentResolution, "video_getClosestDisplayModeCurrentResolution", "Use function to get closes match to requested display mode for current resolution", TEST_ENABLED
2433
};
2434

2435
static const SDLTest_TestCaseReference videoTestGetClosestDisplayModeRandomResolution = {
2436
    video_getClosestDisplayModeRandomResolution, "video_getClosestDisplayModeRandomResolution", "Use function to get closes match to requested display mode for random resolution", TEST_ENABLED
2437
};
2438

2439
static const SDLTest_TestCaseReference videoTestGetWindowDisplayMode = {
2440
    video_getWindowDisplayMode, "video_getWindowDisplayMode", "Get window display mode", TEST_ENABLED
2441
};
2442

2443
static const SDLTest_TestCaseReference videoTestGetWindowDisplayModeNegative = {
2444
    video_getWindowDisplayModeNegative, "video_getWindowDisplayModeNegative", "Get window display mode with invalid input", TEST_ENABLED
2445
};
2446

2447
static const SDLTest_TestCaseReference videoTestGetSetWindowGrab = {
2448
    video_getSetWindowGrab, "video_getSetWindowGrab", "Checks input grab positive and negative cases", TEST_ENABLED
2449
};
2450

2451
static const SDLTest_TestCaseReference videoTestGetWindowID = {
2452
    video_getWindowId, "video_getWindowId", "Checks SDL_GetWindowID and SDL_GetWindowFromID", TEST_ENABLED
2453
};
2454

2455
static const SDLTest_TestCaseReference videoTestGetWindowPixelFormat = {
2456
    video_getWindowPixelFormat, "video_getWindowPixelFormat", "Checks SDL_GetWindowPixelFormat", TEST_ENABLED
2457
};
2458

2459
static const SDLTest_TestCaseReference videoTestGetSetWindowPosition = {
2460
    video_getSetWindowPosition, "video_getSetWindowPosition", "Checks SDL_GetWindowPosition and SDL_SetWindowPosition positive and negative cases", TEST_ENABLED
2461
};
2462

2463
static const SDLTest_TestCaseReference videoTestGetSetWindowSize = {
2464
    video_getSetWindowSize, "video_getSetWindowSize", "Checks SDL_GetWindowSize and SDL_SetWindowSize positive and negative cases", TEST_ENABLED
2465
};
2466

2467
static const SDLTest_TestCaseReference videoTestGetSetWindowMinimumSize = {
2468
    video_getSetWindowMinimumSize, "video_getSetWindowMinimumSize", "Checks SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize positive and negative cases", TEST_ENABLED
2469
};
2470

2471
static const SDLTest_TestCaseReference videoTestGetSetWindowMaximumSize = {
2472
    video_getSetWindowMaximumSize, "video_getSetWindowMaximumSize", "Checks SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize positive and negative cases", TEST_ENABLED
2473
};
2474

2475
static const SDLTest_TestCaseReference videoTestGetSetWindowData = {
2476
    video_getSetWindowData, "video_getSetWindowData", "Checks SDL_SetWindowData and SDL_GetWindowData positive and negative cases", TEST_ENABLED
2477
};
2478

2479
static const SDLTest_TestCaseReference videoTestSetWindowCenteredOnDisplay = {
2480
    video_setWindowCenteredOnDisplay, "video_setWindowCenteredOnDisplay", "Checks using SDL_WINDOWPOS_CENTERED_DISPLAY centers the window on a display", TEST_ENABLED
2481
};
2482

2483
static const SDLTest_TestCaseReference videoTestGetSetWindowState = {
2484
    video_getSetWindowState, "video_getSetWindowState", "Checks transitioning between windowed, minimized, maximized, and fullscreen states", TEST_ENABLED
2485
};
2486

2487
static const SDLTest_TestCaseReference videoTestCreateMinimized = {
2488
    video_createMinimized, "video_createMinimized", "Checks window state for windows created minimized", TEST_ENABLED
2489
};
2490

2491
static const SDLTest_TestCaseReference videoTestCreateMaximized = {
2492
    video_createMaximized, "video_createMaximized", "Checks window state for windows created maximized", TEST_ENABLED
2493
};
2494

2495
static const SDLTest_TestCaseReference videoTestGetWindowSurface = {
2496
    video_getWindowSurface, "video_getWindowSurface", "Checks window surface functionality", TEST_ENABLED
2497
};
2498

2499
/* Sequence of Video test cases */
2500
static const SDLTest_TestCaseReference *videoTests[] = {
2501
    &videoTestEnableDisableScreensaver,
2502
    &videoTestCreateWindowVariousSizes,
2503
    &videoTestCreateWindowVariousFlags,
2504
    &videoTestGetWindowFlags,
2505
    &videoTestGetFullscreenDisplayModes,
2506
    &videoTestGetClosestDisplayModeCurrentResolution,
2507
    &videoTestGetClosestDisplayModeRandomResolution,
2508
    &videoTestGetWindowDisplayMode,
2509
    &videoTestGetWindowDisplayModeNegative,
2510
    &videoTestGetSetWindowGrab,
2511
    &videoTestGetWindowID,
2512
    &videoTestGetWindowPixelFormat,
2513
    &videoTestGetSetWindowPosition,
2514
    &videoTestGetSetWindowSize,
2515
    &videoTestGetSetWindowMinimumSize,
2516
    &videoTestGetSetWindowMaximumSize,
2517
    &videoTestGetSetWindowData,
2518
    &videoTestSetWindowCenteredOnDisplay,
2519
    &videoTestGetSetWindowState,
2520
    &videoTestCreateMinimized,
2521
    &videoTestCreateMaximized,
2522
    &videoTestGetWindowSurface,
2523
    NULL
2524
};
2525

2526
/* Video test suite (global) */
2527
SDLTest_TestSuiteReference videoTestSuite = {
2528
    "Video",
2529
    NULL,
2530
    videoTests,
2531
    NULL
2532
};
2533

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.