Atlas - testautomation_video.c

Home / ext / SDL / test Lines: 1 | Size: 112406 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
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 10static bool VideoSupportsWindowPositioning(void) 11{ 12 const char *video_driver = SDL_GetCurrentVideoDriver(); 13 14 if (SDL_strcmp(video_driver, "android") == 0) { 15 return false; 16 } 17 if (SDL_strcmp(video_driver, "emscripten") == 0) { 18 return false; 19 } 20 if (SDL_strcmp(video_driver, "uikit") == 0) { 21 return false; 22 } 23 if (SDL_strcmp(video_driver, "wayland") == 0) { 24 return false; 25 } 26 return true; 27} 28 29static bool VideoSupportsWindowResizing(void) 30{ 31 const char *video_driver = SDL_GetCurrentVideoDriver(); 32 33 if (SDL_strcmp(video_driver, "android") == 0) { 34 return false; 35 } 36 if (SDL_strcmp(video_driver, "emscripten") == 0) { 37 return false; 38 } 39 if (SDL_strcmp(video_driver, "uikit") == 0) { 40 return false; 41 } 42 return true; 43} 44 45static bool VideoSupportsWindowMinimizing(void) 46{ 47 const char *video_driver = SDL_GetCurrentVideoDriver(); 48 49 if (SDL_strcmp(video_driver, "android") == 0) { 50 // Technically it's supported, but minimizing backgrounds the application and stops processing 51 return false; 52 } 53 return true; 54} 55 56/** 57 * Create a test window 58 */ 59static SDL_Window *createVideoSuiteTestWindow(const char *title) 60{ 61 SDL_Window *window; 62 SDL_Window **windows; 63 SDL_Event event; 64 int w, h; 65 int count; 66 SDL_WindowFlags flags; 67 bool needs_renderer = false; 68 bool needs_events_pumped = false; 69 70 /* Standard window */ 71 w = SDLTest_RandomIntegerInRange(320, 1024); 72 h = SDLTest_RandomIntegerInRange(320, 768); 73 flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS; 74 75 window = SDL_CreateWindow(title, w, h, flags); 76 SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%" SDL_PRIu64 ")", w, h, flags); 77 SDLTest_AssertCheck(window != NULL, "Validate that returned window is not NULL"); 78 79 /* Check the window is available in the window list */ 80 windows = SDL_GetWindows(&count); 81 SDLTest_AssertCheck(windows != NULL, "Validate that returned window list is not NULL"); 82 SDLTest_AssertCheck(windows[0] == window, "Validate that the window is first in the window list"); 83 SDL_free(windows); 84 85 /* Wayland and XWayland windows require that a frame be presented before they are fully mapped and visible onscreen. 86 * This is required for the mouse/keyboard grab tests to pass. 87 */ 88 if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "wayland") == 0) { 89 needs_renderer = true; 90 } else if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0) { 91 /* Try to detect if the x11 driver is running under XWayland */ 92 const char *session_type = SDL_GetEnvironmentVariable(SDL_GetEnvironment(), "XDG_SESSION_TYPE"); 93 if (session_type && SDL_strcasecmp(session_type, "wayland") == 0) { 94 needs_renderer = true; 95 } 96 97 /* X11 needs the initial events pumped, or it can erroneously deliver old configuration events at a later time. */ 98 needs_events_pumped = true; 99 } 100 101 if (needs_renderer) { 102 SDL_Renderer *renderer = SDL_CreateRenderer(window, NULL); 103 if (renderer) { 104 SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF); 105 SDL_RenderClear(renderer); 106 SDL_RenderPresent(renderer); 107 108 /* Some desktops don't display the window immediately after presentation, 109 * so delay to give the window time to actually appear on the desktop. 110 */ 111 SDL_Delay(100); 112 } else { 113 SDLTest_Log("Unable to create a renderer, some tests may fail on Wayland/XWayland"); 114 } 115 } 116 117 if (needs_events_pumped) { 118 /* Pump out the event queue */ 119 while (SDL_PollEvent(&event)) { 120 } 121 } 122 123 return window; 124} 125 126/** 127 * Destroy test window 128 */ 129static void destroyVideoSuiteTestWindow(SDL_Window *window) 130{ 131 if (window != NULL) { 132 SDL_Renderer *renderer = SDL_GetRenderer(window); 133 if (renderer) { 134 SDL_DestroyRenderer(renderer); 135 } 136 SDL_DestroyWindow(window); 137 window = NULL; 138 SDLTest_AssertPass("Call to SDL_DestroyWindow()"); 139 } 140} 141 142/* Test case functions */ 143 144/** 145 * Enable and disable screensaver while checking state 146 */ 147static int SDLCALL video_enableDisableScreensaver(void *arg) 148{ 149 bool initialResult; 150 bool result; 151 152 /* Get current state and proceed according to current state */ 153 initialResult = SDL_ScreenSaverEnabled(); 154 SDLTest_AssertPass("Call to SDL_ScreenSaverEnabled()"); 155 if (initialResult == true) { 156 157 /* Currently enabled: disable first, then enable again */ 158 159 /* Disable screensaver and check */ 160 SDL_DisableScreenSaver(); 161 SDLTest_AssertPass("Call to SDL_DisableScreenSaver()"); 162 result = SDL_ScreenSaverEnabled(); 163 SDLTest_AssertPass("Call to SDL_ScreenSaverEnabled()"); 164 SDLTest_AssertCheck(result == false, "Verify result from SDL_ScreenSaverEnabled, expected: %i, got: %i", false, result); 165 166 /* Enable screensaver and check */ 167 SDL_EnableScreenSaver(); 168 SDLTest_AssertPass("Call to SDL_EnableScreenSaver()"); 169 result = SDL_ScreenSaverEnabled(); 170 SDLTest_AssertPass("Call to SDL_ScreenSaverEnabled()"); 171 SDLTest_AssertCheck(result == true, "Verify result from SDL_ScreenSaverEnabled, expected: %i, got: %i", true, result); 172 173 } else { 174 175 /* Currently disabled: enable first, then disable again */ 176 177 /* Enable screensaver and check */ 178 SDL_EnableScreenSaver(); 179 SDLTest_AssertPass("Call to SDL_EnableScreenSaver()"); 180 result = SDL_ScreenSaverEnabled(); 181 SDLTest_AssertPass("Call to SDL_ScreenSaverEnabled()"); 182 SDLTest_AssertCheck(result == true, "Verify result from SDL_ScreenSaverEnabled, expected: %i, got: %i", true, result); 183 184 /* Disable screensaver and check */ 185 SDL_DisableScreenSaver(); 186 SDLTest_AssertPass("Call to SDL_DisableScreenSaver()"); 187 result = SDL_ScreenSaverEnabled(); 188 SDLTest_AssertPass("Call to SDL_ScreenSaverEnabled()"); 189 SDLTest_AssertCheck(result == false, "Verify result from SDL_ScreenSaverEnabled, expected: %i, got: %i", false, result); 190 } 191 192 return TEST_COMPLETED; 193} 194 195/** 196 * Tests the functionality of the SDL_CreateWindow function using different sizes 197 */ 198static int SDLCALL video_createWindowVariousSizes(void *arg) 199{ 200 SDL_Window *window; 201 const char *title = "video_createWindowVariousSizes Test Window"; 202 int w = 0, h = 0; 203 int wVariation, hVariation; 204 205 for (wVariation = 0; wVariation < 3; wVariation++) { 206 for (hVariation = 0; hVariation < 3; hVariation++) { 207 switch (wVariation) { 208 case 0: 209 /* Width of 1 */ 210 w = 1; 211 break; 212 case 1: 213 /* Random "normal" width */ 214 w = SDLTest_RandomIntegerInRange(320, 1920); 215 break; 216 case 2: 217 /* Random "large" width */ 218 w = SDLTest_RandomIntegerInRange(2048, 4095); 219 break; 220 } 221 222 switch (hVariation) { 223 case 0: 224 /* Height of 1 */ 225 h = 1; 226 break; 227 case 1: 228 /* Random "normal" height */ 229 h = SDLTest_RandomIntegerInRange(320, 1080); 230 break; 231 case 2: 232 /* Random "large" height */ 233 h = SDLTest_RandomIntegerInRange(2048, 4095); 234 break; 235 } 236 237 window = SDL_CreateWindow(title, w, h, 0); 238 SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,SHOWN)", w, h); 239 SDLTest_AssertCheck(window != NULL, "Validate that returned window is not NULL"); 240 241 /* Clean up */ 242 destroyVideoSuiteTestWindow(window); 243 } 244 } 245 246 return TEST_COMPLETED; 247} 248 249/** 250 * Tests the functionality of the SDL_CreateWindow function using different flags 251 */ 252static int SDLCALL video_createWindowVariousFlags(void *arg) 253{ 254 SDL_Window *window; 255 const char *title = "video_createWindowVariousFlags Test Window"; 256 int w, h; 257 int fVariation; 258 SDL_WindowFlags flags; 259 260 /* Standard window */ 261 w = SDLTest_RandomIntegerInRange(320, 1024); 262 h = SDLTest_RandomIntegerInRange(320, 768); 263 264 for (fVariation = 1; fVariation < 14; fVariation++) { 265 switch (fVariation) { 266 default: 267 case 1: 268 flags = SDL_WINDOW_FULLSCREEN; 269 /* Skip - blanks screen; comment out next line to run test */ 270 continue; 271 case 2: 272 flags = SDL_WINDOW_OPENGL; 273 /* Skip - not every video driver supports OpenGL; comment out next line to run test */ 274 continue; 275 case 3: 276 flags = 0; 277 break; 278 case 4: 279 flags = SDL_WINDOW_HIDDEN; 280 break; 281 case 5: 282 flags = SDL_WINDOW_BORDERLESS; 283 break; 284 case 6: 285 flags = SDL_WINDOW_RESIZABLE; 286 break; 287 case 7: 288 flags = SDL_WINDOW_MINIMIZED; 289 break; 290 case 8: 291 flags = SDL_WINDOW_MAXIMIZED; 292 break; 293 case 9: 294 flags = SDL_WINDOW_MOUSE_GRABBED; 295 break; 296 case 10: 297 flags = SDL_WINDOW_INPUT_FOCUS; 298 break; 299 case 11: 300 flags = SDL_WINDOW_MOUSE_FOCUS; 301 break; 302 case 12: 303 flags = SDL_WINDOW_EXTERNAL; 304 break; 305 case 13: 306 flags = SDL_WINDOW_KEYBOARD_GRABBED; 307 break; 308 } 309 310 window = SDL_CreateWindow(title, w, h, flags); 311 SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%" SDL_PRIu64 ")", w, h, flags); 312 SDLTest_AssertCheck(window != NULL, "Validate that returned window is not NULL"); 313 314 /* Clean up */ 315 destroyVideoSuiteTestWindow(window); 316 } 317 318 return TEST_COMPLETED; 319} 320 321/** 322 * Tests the functionality of the SDL_GetWindowFlags function 323 */ 324static int SDLCALL video_getWindowFlags(void *arg) 325{ 326 SDL_Window *window; 327 const char *title = "video_getWindowFlags Test Window"; 328 SDL_WindowFlags flags; 329 SDL_WindowFlags actualFlags; 330 331 /* Reliable flag set always set in test window */ 332 flags = 0; 333 334 /* Call against new test window */ 335 window = createVideoSuiteTestWindow(title); 336 if (window != NULL) { 337 actualFlags = SDL_GetWindowFlags(window); 338 SDLTest_AssertPass("Call to SDL_GetWindowFlags()"); 339 SDLTest_AssertCheck((flags & actualFlags) == flags, "Verify returned value has flags %" SDL_PRIu64 " set, got: %" SDL_PRIu64, flags, actualFlags); 340 } 341 342 /* Clean up */ 343 destroyVideoSuiteTestWindow(window); 344 345 return TEST_COMPLETED; 346} 347 348/** 349 * Tests the functionality of the SDL_GetFullscreenDisplayModes function 350 */ 351static int SDLCALL video_getFullscreenDisplayModes(void *arg) 352{ 353 SDL_DisplayID *displays; 354 SDL_DisplayMode **modes; 355 int count; 356 int i; 357 358 /* Get number of displays */ 359 displays = SDL_GetDisplays(NULL); 360 if (displays) { 361 SDLTest_AssertPass("Call to SDL_GetDisplays()"); 362 363 /* Make call for each display */ 364 for (i = 0; displays[i]; ++i) { 365 modes = SDL_GetFullscreenDisplayModes(displays[i], &count); 366 SDLTest_AssertPass("Call to SDL_GetFullscreenDisplayModes(%" SDL_PRIu32 ")", displays[i]); 367 SDLTest_AssertCheck(modes != NULL, "Validate returned value from function; expected != NULL; got: %p", modes); 368 SDLTest_AssertCheck(count >= 0, "Validate number of modes; expected: >= 0; got: %d", count); 369 SDL_free(modes); 370 } 371 SDL_free(displays); 372 } 373 374 return TEST_COMPLETED; 375} 376 377/** 378 * Tests the functionality of the SDL_GetClosestFullscreenDisplayMode function against current resolution 379 */ 380static int SDLCALL video_getClosestDisplayModeCurrentResolution(void *arg) 381{ 382 SDL_DisplayID *displays; 383 SDL_DisplayMode **modes; 384 SDL_DisplayMode current; 385 SDL_DisplayMode closest; 386 int i, result, num_modes; 387 388 /* Get number of displays */ 389 displays = SDL_GetDisplays(NULL); 390 if (displays) { 391 SDLTest_AssertPass("Call to SDL_GetDisplays()"); 392 393 /* Make calls for each display */ 394 for (i = 0; displays[i]; ++i) { 395 SDLTest_Log("Testing against display: %" SDL_PRIu32, displays[i]); 396 397 /* Get first display mode to get a sane resolution; this should always work */ 398 modes = SDL_GetFullscreenDisplayModes(displays[i], &num_modes); 399 SDLTest_AssertPass("Call to SDL_GetDisplayModes()"); 400 SDLTest_Assert(modes != NULL, "Verify returned value is not NULL"); 401 if (num_modes > 0) { 402 SDL_memcpy(&current, modes[0], sizeof(current)); 403 404 /* Make call */ 405 result = SDL_GetClosestFullscreenDisplayMode(displays[i], current.w, current.h, current.refresh_rate, (current.pixel_density > 1.0f), &closest); 406 SDLTest_AssertPass("Call to SDL_GetClosestFullscreenDisplayMode(target=current)"); 407 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 408 409 /* Check that one gets the current resolution back again */ 410 if (result == 0) { 411 SDLTest_AssertCheck(closest.w == current.w, 412 "Verify returned width matches current width; expected: %d, got: %d", 413 current.w, closest.w); 414 SDLTest_AssertCheck(closest.h == current.h, 415 "Verify returned height matches current height; expected: %d, got: %d", 416 current.h, closest.h); 417 } 418 } 419 SDL_free(modes); 420 } 421 SDL_free(displays); 422 } 423 424 return TEST_COMPLETED; 425} 426 427/** 428 * Tests the functionality of the SDL_GetClosestFullscreenDisplayMode function against random resolution 429 */ 430static int SDLCALL video_getClosestDisplayModeRandomResolution(void *arg) 431{ 432 SDL_DisplayID *displays; 433 SDL_DisplayMode target; 434 SDL_DisplayMode closest; 435 int i; 436 int variation; 437 438 /* Get number of displays */ 439 displays = SDL_GetDisplays(NULL); 440 if (displays) { 441 SDLTest_AssertPass("Call to SDL_GetDisplays()"); 442 443 /* Make calls for each display */ 444 for (i = 0; displays[i]; ++i) { 445 SDLTest_Log("Testing against display: %" SDL_PRIu32, displays[i]); 446 447 for (variation = 0; variation < 16; variation++) { 448 449 /* Set random constraints */ 450 SDL_zero(target); 451 target.w = (variation & 1) ? SDLTest_RandomIntegerInRange(1, 4096) : 0; 452 target.h = (variation & 2) ? SDLTest_RandomIntegerInRange(1, 4096) : 0; 453 target.refresh_rate = (variation & 8) ? (float)SDLTest_RandomIntegerInRange(25, 120) : 0.0f; 454 455 /* Make call; may or may not find anything, so don't validate any further */ 456 SDL_GetClosestFullscreenDisplayMode(displays[i], target.w, target.h, target.refresh_rate, false, &closest); 457 SDLTest_AssertPass("Call to SDL_GetClosestFullscreenDisplayMode(target=random/variation%d)", variation); 458 } 459 } 460 SDL_free(displays); 461 } 462 463 return TEST_COMPLETED; 464} 465 466/** 467 * Tests call to SDL_GetWindowFullscreenMode 468 * 469 * \sa SDL_GetWindowFullscreenMode 470 */ 471static int SDLCALL video_getWindowDisplayMode(void *arg) 472{ 473 SDL_Window *window; 474 const char *title = "video_getWindowDisplayMode Test Window"; 475 const SDL_DisplayMode *mode; 476 477 /* Call against new test window */ 478 window = createVideoSuiteTestWindow(title); 479 if (window != NULL) { 480 mode = SDL_GetWindowFullscreenMode(window); 481 SDLTest_AssertPass("Call to SDL_GetWindowFullscreenMode()"); 482 SDLTest_AssertCheck(mode == NULL, "Validate result value; expected: NULL, got: %p", mode); 483 } 484 485 /* Clean up */ 486 destroyVideoSuiteTestWindow(window); 487 488 return TEST_COMPLETED; 489} 490 491/* Helper function that checks for an 'Invalid window' error */ 492static void checkInvalidWindowError(void) 493{ 494 const char *invalidWindowError = "Invalid window"; 495 const char *lastError; 496 497 lastError = SDL_GetError(); 498 SDLTest_AssertPass("SDL_GetError()"); 499 SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL"); 500 if (lastError != NULL) { 501 SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0, 502 "SDL_GetError(): expected message '%s', was message: '%s'", 503 invalidWindowError, 504 lastError); 505 SDL_ClearError(); 506 SDLTest_AssertPass("Call to SDL_ClearError()"); 507 } 508} 509 510/** 511 * Tests call to SDL_GetWindowFullscreenMode with invalid input 512 * 513 * \sa SDL_GetWindowFullscreenMode 514 */ 515static int SDLCALL video_getWindowDisplayModeNegative(void *arg) 516{ 517 const SDL_DisplayMode *mode; 518 519 /* Call against invalid window */ 520 mode = SDL_GetWindowFullscreenMode(NULL); 521 SDLTest_AssertPass("Call to SDL_GetWindowFullscreenMode(window=NULL)"); 522 SDLTest_AssertCheck(mode == NULL, "Validate result value; expected: NULL, got: %p", mode); 523 checkInvalidWindowError(); 524 525 return TEST_COMPLETED; 526} 527 528/* Helper for setting and checking the window mouse grab state */ 529static void setAndCheckWindowMouseGrabState(SDL_Window *window, bool desiredState) 530{ 531 bool currentState; 532 533 /* Set state */ 534 SDL_SetWindowMouseGrab(window, desiredState); 535 SDLTest_AssertPass("Call to SDL_SetWindowMouseGrab(%s)", (desiredState == false) ? "false" : "true"); 536 537 /* Get and check state */ 538 currentState = SDL_GetWindowMouseGrab(window); 539 SDLTest_AssertPass("Call to SDL_GetWindowMouseGrab()"); 540 SDLTest_AssertCheck( 541 currentState == desiredState, 542 "Validate returned state; expected: %s, got: %s", 543 (desiredState == false) ? "false" : "true", 544 (currentState == false) ? "false" : "true"); 545 546 if (desiredState) { 547 SDLTest_AssertCheck( 548 SDL_GetGrabbedWindow() == window, 549 "Grabbed window should be to our window"); 550 SDLTest_AssertCheck( 551 SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_GRABBED, 552 "SDL_WINDOW_MOUSE_GRABBED should be set"); 553 } else { 554 SDLTest_AssertCheck( 555 !(SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_GRABBED), 556 "SDL_WINDOW_MOUSE_GRABBED should be unset"); 557 } 558} 559 560/* Helper for setting and checking the window keyboard grab state */ 561static void setAndCheckWindowKeyboardGrabState(SDL_Window *window, bool desiredState) 562{ 563 bool currentState; 564 565 /* Set state */ 566 SDL_SetWindowKeyboardGrab(window, desiredState); 567 SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(%s)", (desiredState == false) ? "false" : "true"); 568 569 /* Get and check state */ 570 currentState = SDL_GetWindowKeyboardGrab(window); 571 SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab()"); 572 SDLTest_AssertCheck( 573 currentState == desiredState, 574 "Validate returned state; expected: %s, got: %s", 575 (desiredState == false) ? "false" : "true", 576 (currentState == false) ? "false" : "true"); 577 578 if (desiredState) { 579 SDLTest_AssertCheck( 580 SDL_GetGrabbedWindow() == window, 581 "Grabbed window should be set to our window"); 582 SDLTest_AssertCheck( 583 SDL_GetWindowFlags(window) & SDL_WINDOW_KEYBOARD_GRABBED, 584 "SDL_WINDOW_KEYBOARD_GRABBED should be set"); 585 } else { 586 SDLTest_AssertCheck( 587 !(SDL_GetWindowFlags(window) & SDL_WINDOW_KEYBOARD_GRABBED), 588 "SDL_WINDOW_KEYBOARD_GRABBED should be unset"); 589 } 590} 591 592/** 593 * Tests keyboard and mouse grab support 594 * 595 * \sa SDL_GetWindowMouseGrab 596 * \sa SDL_GetWindowKeyboardGrab 597 * \sa SDL_SetWindowMouseGrab 598 * \sa SDL_SetWindowKeyboardGrab 599 */ 600static int SDLCALL video_getSetWindowGrab(void *arg) 601{ 602 const char *title = "video_getSetWindowGrab Test Window"; 603 SDL_Window *window; 604 bool originalMouseState, originalKeyboardState; 605 bool hasFocusGained = false; 606 607 /* Call against new test window */ 608 window = createVideoSuiteTestWindow(title); 609 if (!window) { 610 return TEST_ABORTED; 611 } 612 613 /* Need to raise the window to have and SDL_EVENT_WINDOW_FOCUS_GAINED, 614 * so that the window gets the flags SDL_WINDOW_INPUT_FOCUS, 615 * so that it can be "grabbed" */ 616 SDL_RaiseWindow(window); 617 618 if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_INPUT_FOCUS)) { 619 int count = 0; 620 SDL_Event evt; 621 SDL_zero(evt); 622 while (!hasFocusGained && count++ < 3) { 623 while (SDL_PollEvent(&evt)) { 624 if (evt.type == SDL_EVENT_WINDOW_FOCUS_GAINED) { 625 hasFocusGained = true; 626 } 627 } 628 } 629 } else { 630 hasFocusGained = true; 631 } 632 633 SDLTest_AssertCheck(hasFocusGained == true, "Expectded window with focus"); 634 635 /* Get state */ 636 originalMouseState = SDL_GetWindowMouseGrab(window); 637 SDLTest_AssertPass("Call to SDL_GetWindowMouseGrab()"); 638 originalKeyboardState = SDL_GetWindowKeyboardGrab(window); 639 SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab()"); 640 641 /* F */ 642 setAndCheckWindowKeyboardGrabState(window, false); 643 setAndCheckWindowMouseGrabState(window, false); 644 SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL, 645 "Expected NULL grabbed window"); 646 647 /* F --> F */ 648 setAndCheckWindowMouseGrabState(window, false); 649 setAndCheckWindowKeyboardGrabState(window, false); 650 SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL, 651 "Expected NULL grabbed window"); 652 653 /* F --> T */ 654 setAndCheckWindowMouseGrabState(window, true); 655 setAndCheckWindowKeyboardGrabState(window, true); 656 657 /* T --> T */ 658 setAndCheckWindowKeyboardGrabState(window, true); 659 setAndCheckWindowMouseGrabState(window, true); 660 661 /* M: T --> F */ 662 /* K: T --> T */ 663 setAndCheckWindowKeyboardGrabState(window, true); 664 setAndCheckWindowMouseGrabState(window, false); 665 666 /* M: F --> T */ 667 /* K: T --> F */ 668 setAndCheckWindowMouseGrabState(window, true); 669 setAndCheckWindowKeyboardGrabState(window, false); 670 671 /* M: T --> F */ 672 /* K: F --> F */ 673 setAndCheckWindowMouseGrabState(window, false); 674 setAndCheckWindowKeyboardGrabState(window, false); 675 SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL, 676 "Expected NULL grabbed window"); 677 678 /* Negative tests */ 679 SDL_GetWindowMouseGrab(NULL); 680 SDLTest_AssertPass("Call to SDL_GetWindowMouseGrab(window=NULL)"); 681 checkInvalidWindowError(); 682 683 SDL_GetWindowKeyboardGrab(NULL); 684 SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab(window=NULL)"); 685 checkInvalidWindowError(); 686 687 SDL_SetWindowMouseGrab(NULL, false); 688 SDLTest_AssertPass("Call to SDL_SetWindowMouseGrab(window=NULL,false)"); 689 checkInvalidWindowError(); 690 691 SDL_SetWindowKeyboardGrab(NULL, false); 692 SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(window=NULL,false)"); 693 checkInvalidWindowError(); 694 695 SDL_SetWindowMouseGrab(NULL, true); 696 SDLTest_AssertPass("Call to SDL_SetWindowMouseGrab(window=NULL,true)"); 697 checkInvalidWindowError(); 698 699 SDL_SetWindowKeyboardGrab(NULL, true); 700 SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(window=NULL,true)"); 701 checkInvalidWindowError(); 702 703 /* Restore state */ 704 setAndCheckWindowMouseGrabState(window, originalMouseState); 705 setAndCheckWindowKeyboardGrabState(window, originalKeyboardState); 706 707 /* Clean up */ 708 destroyVideoSuiteTestWindow(window); 709 710 return TEST_COMPLETED; 711} 712 713/** 714 * Tests call to SDL_GetWindowID and SDL_GetWindowFromID 715 * 716 * \sa SDL_GetWindowID 717 * \sa SDL_SetWindowFromID 718 */ 719static int SDLCALL video_getWindowId(void *arg) 720{ 721 const char *title = "video_getWindowId Test Window"; 722 SDL_Window *window; 723 SDL_Window *result; 724 Uint32 id, randomId; 725 726 /* Call against new test window */ 727 window = createVideoSuiteTestWindow(title); 728 if (!window) { 729 return TEST_ABORTED; 730 } 731 732 /* Get ID */ 733 id = SDL_GetWindowID(window); 734 SDLTest_AssertPass("Call to SDL_GetWindowID()"); 735 736 /* Get window from ID */ 737 result = SDL_GetWindowFromID(id); 738 SDLTest_AssertPass("Call to SDL_GetWindowID(%" SDL_PRIu32 ")", id); 739 SDLTest_AssertCheck(result == window, "Verify result matches window pointer"); 740 741 /* Get window from random large ID, no result check */ 742 randomId = SDLTest_RandomIntegerInRange(UINT8_MAX, UINT16_MAX); 743 result = SDL_GetWindowFromID(randomId); 744 SDLTest_AssertPass("Call to SDL_GetWindowID(%" SDL_PRIu32 "/random_large)", randomId); 745 746 /* Get window from 0 and Uint32 max ID, no result check */ 747 result = SDL_GetWindowFromID(0); 748 SDLTest_AssertPass("Call to SDL_GetWindowID(0)"); 749 result = SDL_GetWindowFromID(UINT32_MAX); 750 SDLTest_AssertPass("Call to SDL_GetWindowID(UINT32_MAX)"); 751 752 /* Clean up */ 753 destroyVideoSuiteTestWindow(window); 754 755 /* Get window from ID for closed window */ 756 result = SDL_GetWindowFromID(id); 757 SDLTest_AssertPass("Call to SDL_GetWindowID(%" SDL_PRIu32 "/closed_window)", id); 758 SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); 759 760 /* Negative test */ 761 SDL_ClearError(); 762 SDLTest_AssertPass("Call to SDL_ClearError()"); 763 id = SDL_GetWindowID(NULL); 764 SDLTest_AssertPass("Call to SDL_GetWindowID(window=NULL)"); 765 checkInvalidWindowError(); 766 767 return TEST_COMPLETED; 768} 769 770/** 771 * Tests call to SDL_GetWindowPixelFormat 772 * 773 * \sa SDL_GetWindowPixelFormat 774 */ 775static int SDLCALL video_getWindowPixelFormat(void *arg) 776{ 777 const char *title = "video_getWindowPixelFormat Test Window"; 778 SDL_Window *window; 779 SDL_PixelFormat format; 780 781 /* Call against new test window */ 782 window = createVideoSuiteTestWindow(title); 783 if (!window) { 784 return TEST_ABORTED; 785 } 786 787 /* Get format */ 788 format = SDL_GetWindowPixelFormat(window); 789 SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat()"); 790 SDLTest_AssertCheck(format != SDL_PIXELFORMAT_UNKNOWN, "Verify that returned format is valid; expected: != SDL_PIXELFORMAT_UNKNOWN, got: SDL_PIXELFORMAT_UNKNOWN"); 791 792 /* Clean up */ 793 destroyVideoSuiteTestWindow(window); 794 795 /* Negative test */ 796 SDL_ClearError(); 797 SDLTest_AssertPass("Call to SDL_ClearError()"); 798 format = SDL_GetWindowPixelFormat(NULL); 799 SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat(window=NULL)"); 800 checkInvalidWindowError(); 801 802 return TEST_COMPLETED; 803} 804 805 806static bool getPositionFromEvent(int *x, int *y) 807{ 808 bool ret = false; 809 SDL_Event evt; 810 SDL_zero(evt); 811 while (SDL_PollEvent(&evt)) { 812 if (evt.type == SDL_EVENT_WINDOW_MOVED) { 813 *x = evt.window.data1; 814 *y = evt.window.data2; 815 ret = true; 816 } 817 } 818 return ret; 819} 820 821static bool getSizeFromEvent(int *w, int *h) 822{ 823 bool ret = false; 824 SDL_Event evt; 825 SDL_zero(evt); 826 while (SDL_PollEvent(&evt)) { 827 if (evt.type == SDL_EVENT_WINDOW_RESIZED) { 828 *w = evt.window.data1; 829 *h = evt.window.data2; 830 ret = true; 831 } 832 } 833 return ret; 834} 835 836/** 837 * Tests call to SDL_GetWindowPosition and SDL_SetWindowPosition 838 * 839 * \sa SDL_GetWindowPosition 840 * \sa SDL_SetWindowPosition 841 */ 842static int SDLCALL video_getSetWindowPosition(void *arg) 843{ 844 const char *title = "video_getSetWindowPosition Test Window"; 845 SDL_Window *window; 846 int result; 847 int maxxVariation, maxyVariation; 848 int xVariation, yVariation; 849 int referenceX, referenceY; 850 int currentX, currentY; 851 int desiredX, desiredY; 852 SDL_Rect display_bounds; 853 854 /* Call against new test window */ 855 window = createVideoSuiteTestWindow(title); 856 if (!window) { 857 return TEST_ABORTED; 858 } 859 860 /* Sanity check */ 861 SDL_GetWindowPosition(window, &currentX, &currentY); 862 if (!SDL_SetWindowPosition(window, currentX, currentY)) { 863 SDLTest_Log("Skipping window positioning tests: %s reports window positioning as unsupported", SDL_GetCurrentVideoDriver()); 864 goto null_tests; 865 } 866 867 if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0) { 868 /* The X11 server allows arbitrary window placement, but compositing 869 * window managers such as GNOME and KDE force windows to be within 870 * desktop bounds. 871 */ 872 maxxVariation = 2; 873 maxyVariation = 2; 874 875 SDL_GetDisplayUsableBounds(SDL_GetPrimaryDisplay(), &display_bounds); 876 } else if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "cocoa") == 0) { 877 /* Platform doesn't allow windows with negative Y desktop bounds */ 878 maxxVariation = 4; 879 maxyVariation = 3; 880 881 SDL_GetDisplayUsableBounds(SDL_GetPrimaryDisplay(), &display_bounds); 882 } else { 883 /* Platform allows windows to be placed out of bounds */ 884 maxxVariation = 4; 885 maxyVariation = 4; 886 887 SDL_GetDisplayBounds(SDL_GetPrimaryDisplay(), &display_bounds); 888 } 889 890 for (xVariation = 0; xVariation < maxxVariation; xVariation++) { 891 for (yVariation = 0; yVariation < maxyVariation; yVariation++) { 892 switch (xVariation) { 893 default: 894 case 0: 895 /* Zero X Position */ 896 desiredX = display_bounds.x > 0 ? display_bounds.x : 0; 897 break; 898 case 1: 899 /* Random X position inside screen */ 900 desiredX = SDLTest_RandomIntegerInRange(display_bounds.x + 1, display_bounds.x + 100); 901 break; 902 case 2: 903 /* Random X position outside screen (positive) */ 904 desiredX = SDLTest_RandomIntegerInRange(10000, 11000); 905 break; 906 case 3: 907 /* Random X position outside screen (negative) */ 908 desiredX = SDLTest_RandomIntegerInRange(-1000, -100); 909 break; 910 } 911 912 switch (yVariation) { 913 default: 914 case 0: 915 /* Zero Y Position */ 916 desiredY = display_bounds.y > 0 ? display_bounds.y : 0; 917 break; 918 case 1: 919 /* Random Y position inside screen */ 920 desiredY = SDLTest_RandomIntegerInRange(display_bounds.y + 1, display_bounds.y + 100); 921 break; 922 case 2: 923 /* Random Y position outside screen (positive) */ 924 desiredY = SDLTest_RandomIntegerInRange(10000, 11000); 925 break; 926 case 3: 927 /* Random Y position outside screen (negative) */ 928 desiredY = SDLTest_RandomIntegerInRange(-1000, -100); 929 break; 930 } 931 932 /* Set position */ 933 SDL_SetWindowPosition(window, desiredX, desiredY); 934 SDLTest_AssertPass("Call to SDL_SetWindowPosition(...,%d,%d)", desiredX, desiredY); 935 936 result = SDL_SyncWindow(window); 937 SDLTest_AssertPass("SDL_SyncWindow()"); 938 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 939 940 /* Get position */ 941 currentX = desiredX + 1; 942 currentY = desiredY + 1; 943 SDL_GetWindowPosition(window, &currentX, &currentY); 944 SDLTest_AssertPass("Call to SDL_GetWindowPosition()"); 945 946 if (desiredX == currentX && desiredY == currentY) { 947 SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX); 948 SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY); 949 } else { 950 bool hasEvent; 951 /* SDL_SetWindowPosition() and SDL_SetWindowSize() will make requests of the window manager and set the internal position and size, 952 * and then we get events signaling what actually happened, and they get passed on to the application if they're not what we expect. */ 953 currentX = desiredX + 1; 954 currentY = desiredY + 1; 955 hasEvent = getPositionFromEvent(&currentX, &currentY); 956 SDLTest_AssertCheck(hasEvent == true, "Changing position was not honored by WM, checking present of SDL_EVENT_WINDOW_MOVED"); 957 if (hasEvent) { 958 SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position is the position from SDL event; expected: %d, got: %d", desiredX, currentX); 959 SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position is the position from SDL event; expected: %d, got: %d", desiredY, currentY); 960 } 961 } 962 963 /* Get position X */ 964 currentX = desiredX + 1; 965 SDL_GetWindowPosition(window, &currentX, NULL); 966 SDLTest_AssertPass("Call to SDL_GetWindowPosition(&y=NULL)"); 967 SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX); 968 969 /* Get position Y */ 970 currentY = desiredY + 1; 971 SDL_GetWindowPosition(window, NULL, &currentY); 972 SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL)"); 973 SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY); 974 } 975 } 976 977null_tests: 978 979 /* Dummy call with both pointers NULL */ 980 SDL_GetWindowPosition(window, NULL, NULL); 981 SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL,&y=NULL)"); 982 983 /* Clean up */ 984 destroyVideoSuiteTestWindow(window); 985 986 /* Set some 'magic' value for later check that nothing was changed */ 987 referenceX = SDLTest_RandomSint32(); 988 referenceY = SDLTest_RandomSint32(); 989 currentX = referenceX; 990 currentY = referenceY; 991 desiredX = SDLTest_RandomSint32(); 992 desiredY = SDLTest_RandomSint32(); 993 994 /* Negative tests */ 995 SDL_ClearError(); 996 SDLTest_AssertPass("Call to SDL_ClearError()"); 997 SDL_GetWindowPosition(NULL, &currentX, &currentY); 998 SDLTest_AssertPass("Call to SDL_GetWindowPosition(window=NULL)"); 999 SDLTest_AssertCheck( 1000 currentX == referenceX && currentY == referenceY, 1001 "Verify that content of X and Y pointers has not been modified; expected: %d,%d; got: %d,%d", 1002 referenceX, referenceY, 1003 currentX, currentY); 1004 checkInvalidWindowError(); 1005 1006 SDL_GetWindowPosition(NULL, NULL, NULL); 1007 SDLTest_AssertPass("Call to SDL_GetWindowPosition(NULL, NULL, NULL)"); 1008 checkInvalidWindowError(); 1009 1010 SDL_SetWindowPosition(NULL, desiredX, desiredY); 1011 SDLTest_AssertPass("Call to SDL_SetWindowPosition(window=NULL)"); 1012 checkInvalidWindowError(); 1013 1014 return TEST_COMPLETED; 1015} 1016 1017/* Helper function that checks for an 'Invalid parameter' error */ 1018static void checkInvalidParameterError(void) 1019{ 1020 const char *invalidParameterError = "Parameter"; 1021 const char *lastError; 1022 1023 lastError = SDL_GetError(); 1024 SDLTest_AssertPass("SDL_GetError()"); 1025 SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL"); 1026 if (lastError != NULL) { 1027 SDLTest_AssertCheck(SDL_strncmp(lastError, invalidParameterError, SDL_strlen(invalidParameterError)) == 0, 1028 "SDL_GetError(): expected message starts with '%s', was message: '%s'", 1029 invalidParameterError, 1030 lastError); 1031 SDL_ClearError(); 1032 SDLTest_AssertPass("Call to SDL_ClearError()"); 1033 } 1034} 1035 1036/** 1037 * Tests call to SDL_GetWindowSize and SDL_SetWindowSize 1038 * 1039 * \sa SDL_GetWindowSize 1040 * \sa SDL_SetWindowSize 1041 */ 1042static int SDLCALL video_getSetWindowSize(void *arg) 1043{ 1044 const char *title = "video_getSetWindowSize Test Window"; 1045 SDL_Window *window; 1046 int result; 1047 SDL_Rect display; 1048 int maxwVariation, maxhVariation; 1049 int wVariation, hVariation; 1050 int referenceW, referenceH; 1051 int currentW, currentH; 1052 int desiredW, desiredH; 1053 1054 /* Get display bounds for size range */ 1055 result = SDL_GetDisplayUsableBounds(SDL_GetPrimaryDisplay(), &display); 1056 SDLTest_AssertPass("SDL_GetDisplayUsableBounds()"); 1057 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 1058 if (!result) { 1059 return TEST_ABORTED; 1060 } 1061 1062 /* Call against new test window */ 1063 window = createVideoSuiteTestWindow(title); 1064 if (!window) { 1065 return TEST_ABORTED; 1066 } 1067 1068 SDL_GetWindowSize(window, &currentW, &currentH); 1069 if (!SDL_SetWindowSize(window, currentW, currentH)) { 1070 SDLTest_Log("Skipping window resize tests: %s reports window resizing as unsupported", SDL_GetCurrentVideoDriver()); 1071 goto null_tests; 1072 } 1073 1074 if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "windows") == 0 || 1075 SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0) { 1076 /* Platform clips window size to screen size */ 1077 maxwVariation = 4; 1078 maxhVariation = 4; 1079 } else { 1080 /* Platform allows window size >= screen size */ 1081 maxwVariation = 5; 1082 maxhVariation = 5; 1083 } 1084 1085 for (wVariation = 0; wVariation < maxwVariation; wVariation++) { 1086 for (hVariation = 0; hVariation < maxhVariation; hVariation++) { 1087 switch (wVariation) { 1088 default: 1089 case 0: 1090 /* 1 Pixel Wide */ 1091 desiredW = 1; 1092 break; 1093 case 1: 1094 /* Random width inside screen */ 1095 desiredW = SDLTest_RandomIntegerInRange(1, 100); 1096 break; 1097 case 2: 1098 /* Width 1 pixel smaller than screen */ 1099 desiredW = display.w - 1; 1100 break; 1101 case 3: 1102 /* Width at screen size */ 1103 desiredW = display.w; 1104 break; 1105 case 4: 1106 /* Width 1 pixel larger than screen */ 1107 desiredW = display.w + 1; 1108 break; 1109 } 1110 1111 switch (hVariation) { 1112 default: 1113 case 0: 1114 /* 1 Pixel High */ 1115 desiredH = 1; 1116 break; 1117 case 1: 1118 /* Random height inside screen */ 1119 desiredH = SDLTest_RandomIntegerInRange(1, 100); 1120 break; 1121 case 2: 1122 /* Height 1 pixel smaller than screen */ 1123 desiredH = display.h - 1; 1124 break; 1125 case 3: 1126 /* Height at screen size */ 1127 desiredH = display.h; 1128 break; 1129 case 4: 1130 /* Height 1 pixel larger than screen */ 1131 desiredH = display.h + 1; 1132 break; 1133 } 1134 1135 /* Set size */ 1136 SDL_SetWindowSize(window, desiredW, desiredH); 1137 SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH); 1138 1139 result = SDL_SyncWindow(window); 1140 SDLTest_AssertPass("SDL_SyncWindow()"); 1141 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 1142 1143 /* Get size */ 1144 currentW = desiredW + 1; 1145 currentH = desiredH + 1; 1146 SDL_GetWindowSize(window, &currentW, &currentH); 1147 SDLTest_AssertPass("Call to SDL_GetWindowSize()"); 1148 1149 if (desiredW == currentW && desiredH == currentH) { 1150 SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW); 1151 SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH); 1152 } else { 1153 bool hasEvent; 1154 /* SDL_SetWindowPosition() and SDL_SetWindowSize() will make requests of the window manager and set the internal position and size, 1155 * and then we get events signaling what actually happened, and they get passed on to the application if they're not what we expect. */ 1156 currentW = desiredW + 1; 1157 currentH = desiredH + 1; 1158 hasEvent = getSizeFromEvent(&currentW, &currentH); 1159 SDLTest_AssertCheck(hasEvent == true, "Changing size was not honored by WM, checking presence of SDL_EVENT_WINDOW_RESIZED"); 1160 if (hasEvent) { 1161 SDLTest_AssertCheck(desiredW == currentW, "Verify returned width is the one from SDL event; expected: %d, got: %d", desiredW, currentW); 1162 SDLTest_AssertCheck(desiredH == currentH, "Verify returned height is the one from SDL event; expected: %d, got: %d", desiredH, currentH); 1163 } 1164 } 1165 1166 1167 /* Get just width */ 1168 currentW = desiredW + 1; 1169 SDL_GetWindowSize(window, &currentW, NULL); 1170 SDLTest_AssertPass("Call to SDL_GetWindowSize(&h=NULL)"); 1171 SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW); 1172 1173 /* Get just height */ 1174 currentH = desiredH + 1; 1175 SDL_GetWindowSize(window, NULL, &currentH); 1176 SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL)"); 1177 SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH); 1178 } 1179 } 1180 1181null_tests: 1182 1183 /* Dummy call with both pointers NULL */ 1184 SDL_GetWindowSize(window, NULL, NULL); 1185 SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL,&h=NULL)"); 1186 1187 /* Negative tests for parameter input */ 1188 SDL_ClearError(); 1189 SDLTest_AssertPass("Call to SDL_ClearError()"); 1190 for (desiredH = -2; desiredH < 2; desiredH++) { 1191 for (desiredW = -2; desiredW < 2; desiredW++) { 1192 if (desiredW <= 0 || desiredH <= 0) { 1193 SDL_SetWindowSize(window, desiredW, desiredH); 1194 SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH); 1195 checkInvalidParameterError(); 1196 } 1197 } 1198 } 1199 1200 /* Clean up */ 1201 destroyVideoSuiteTestWindow(window); 1202 1203 /* Set some 'magic' value for later check that nothing was changed */ 1204 referenceW = SDLTest_RandomSint32(); 1205 referenceH = SDLTest_RandomSint32(); 1206 currentW = referenceW; 1207 currentH = referenceH; 1208 desiredW = SDLTest_RandomSint32(); 1209 desiredH = SDLTest_RandomSint32(); 1210 1211 /* Negative tests for window input */ 1212 SDL_ClearError(); 1213 SDLTest_AssertPass("Call to SDL_ClearError()"); 1214 SDL_GetWindowSize(NULL, &currentW, &currentH); 1215 SDLTest_AssertPass("Call to SDL_GetWindowSize(window=NULL)"); 1216 SDLTest_AssertCheck( 1217 currentW == referenceW && currentH == referenceH, 1218 "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d", 1219 referenceW, referenceH, 1220 currentW, currentH); 1221 checkInvalidWindowError(); 1222 1223 SDL_GetWindowSize(NULL, NULL, NULL); 1224 SDLTest_AssertPass("Call to SDL_GetWindowSize(NULL, NULL, NULL)"); 1225 checkInvalidWindowError(); 1226 1227 SDL_SetWindowSize(NULL, desiredW, desiredH); 1228 SDLTest_AssertPass("Call to SDL_SetWindowSize(window=NULL)"); 1229 checkInvalidWindowError(); 1230 1231 return TEST_COMPLETED; 1232} 1233 1234/** 1235 * Tests call to SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize 1236 * 1237 */ 1238static int SDLCALL video_getSetWindowMinimumSize(void *arg) 1239{ 1240 const char *title = "video_getSetWindowMinimumSize Test Window"; 1241 SDL_Window *window; 1242 int result; 1243 SDL_Rect display; 1244 int wVariation, hVariation; 1245 int referenceW, referenceH; 1246 int currentW, currentH; 1247 int desiredW = 1; 1248 int desiredH = 1; 1249 1250 /* Get display bounds for size range */ 1251 result = SDL_GetDisplayBounds(SDL_GetPrimaryDisplay(), &display); 1252 SDLTest_AssertPass("SDL_GetDisplayBounds()"); 1253 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 1254 if (!result) { 1255 return TEST_ABORTED; 1256 } 1257 1258 /* Call against new test window */ 1259 window = createVideoSuiteTestWindow(title); 1260 if (!window) { 1261 return TEST_ABORTED; 1262 } 1263 1264 for (wVariation = 0; wVariation < 5; wVariation++) { 1265 for (hVariation = 0; hVariation < 5; hVariation++) { 1266 switch (wVariation) { 1267 case 0: 1268 /* 1 Pixel Wide */ 1269 desiredW = 1; 1270 break; 1271 case 1: 1272 /* Random width inside screen */ 1273 desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1); 1274 break; 1275 case 2: 1276 /* Width at screen size */ 1277 desiredW = display.w; 1278 break; 1279 } 1280 1281 switch (hVariation) { 1282 case 0: 1283 /* 1 Pixel High */ 1284 desiredH = 1; 1285 break; 1286 case 1: 1287 /* Random height inside screen */ 1288 desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1); 1289 break; 1290 case 2: 1291 /* Height at screen size */ 1292 desiredH = display.h; 1293 break; 1294 case 4: 1295 /* Height 1 pixel larger than screen */ 1296 desiredH = display.h + 1; 1297 break; 1298 } 1299 1300 /* Set size */ 1301 SDL_SetWindowMinimumSize(window, desiredW, desiredH); 1302 SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH); 1303 1304 /* Get size */ 1305 currentW = desiredW + 1; 1306 currentH = desiredH + 1; 1307 SDL_GetWindowMinimumSize(window, &currentW, &currentH); 1308 SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize()"); 1309 SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW); 1310 SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH); 1311 1312 /* Get just width */ 1313 currentW = desiredW + 1; 1314 SDL_GetWindowMinimumSize(window, &currentW, NULL); 1315 SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&h=NULL)"); 1316 SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH); 1317 1318 /* Get just height */ 1319 currentH = desiredH + 1; 1320 SDL_GetWindowMinimumSize(window, NULL, &currentH); 1321 SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL)"); 1322 SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH); 1323 } 1324 } 1325 1326 /* Dummy call with both pointers NULL */ 1327 SDL_GetWindowMinimumSize(window, NULL, NULL); 1328 SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL,&h=NULL)"); 1329 1330 /* Negative tests for parameter input */ 1331 SDL_ClearError(); 1332 SDLTest_AssertPass("Call to SDL_ClearError()"); 1333 for (desiredH = -2; desiredH < 2; desiredH++) { 1334 for (desiredW = -2; desiredW < 2; desiredW++) { 1335 if (desiredW < 0 || desiredH < 0) { 1336 SDL_SetWindowMinimumSize(window, desiredW, desiredH); 1337 SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH); 1338 checkInvalidParameterError(); 1339 } 1340 } 1341 } 1342 1343 /* Clean up */ 1344 destroyVideoSuiteTestWindow(window); 1345 1346 /* Set some 'magic' value for later check that nothing was changed */ 1347 referenceW = SDLTest_RandomSint32(); 1348 referenceH = SDLTest_RandomSint32(); 1349 currentW = referenceW; 1350 currentH = referenceH; 1351 desiredW = SDLTest_RandomSint32(); 1352 desiredH = SDLTest_RandomSint32(); 1353 1354 /* Negative tests for window input */ 1355 SDL_ClearError(); 1356 SDLTest_AssertPass("Call to SDL_ClearError()"); 1357 SDL_GetWindowMinimumSize(NULL, &currentW, &currentH); 1358 SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(window=NULL)"); 1359 SDLTest_AssertCheck( 1360 currentW == referenceW && currentH == referenceH, 1361 "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d", 1362 referenceW, referenceH, 1363 currentW, currentH); 1364 checkInvalidWindowError(); 1365 1366 SDL_GetWindowMinimumSize(NULL, NULL, NULL); 1367 SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(NULL, NULL, NULL)"); 1368 checkInvalidWindowError(); 1369 1370 SDL_SetWindowMinimumSize(NULL, desiredW, desiredH); 1371 SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(window=NULL)"); 1372 checkInvalidWindowError(); 1373 1374 return TEST_COMPLETED; 1375} 1376 1377/** 1378 * Tests call to SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize 1379 * 1380 */ 1381static int SDLCALL video_getSetWindowMaximumSize(void *arg) 1382{ 1383 const char *title = "video_getSetWindowMaximumSize Test Window"; 1384 SDL_Window *window; 1385 int result; 1386 SDL_Rect display; 1387 int wVariation, hVariation; 1388 int referenceW, referenceH; 1389 int currentW, currentH; 1390 int desiredW = 0, desiredH = 0; 1391 1392 /* Get display bounds for size range */ 1393 result = SDL_GetDisplayBounds(SDL_GetPrimaryDisplay(), &display); 1394 SDLTest_AssertPass("SDL_GetDisplayBounds()"); 1395 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 1396 if (!result) { 1397 return TEST_ABORTED; 1398 } 1399 1400 /* Call against new test window */ 1401 window = createVideoSuiteTestWindow(title); 1402 if (!window) { 1403 return TEST_ABORTED; 1404 } 1405 1406 for (wVariation = 0; wVariation < 3; wVariation++) { 1407 for (hVariation = 0; hVariation < 3; hVariation++) { 1408 switch (wVariation) { 1409 case 0: 1410 /* 1 Pixel Wide */ 1411 desiredW = 1; 1412 break; 1413 case 1: 1414 /* Random width inside screen */ 1415 desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1); 1416 break; 1417 case 2: 1418 /* Width at screen size */ 1419 desiredW = display.w; 1420 break; 1421 } 1422 1423 switch (hVariation) { 1424 case 0: 1425 /* 1 Pixel High */ 1426 desiredH = 1; 1427 break; 1428 case 1: 1429 /* Random height inside screen */ 1430 desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1); 1431 break; 1432 case 2: 1433 /* Height at screen size */ 1434 desiredH = display.h; 1435 break; 1436 } 1437 1438 /* Set size */ 1439 SDL_SetWindowMaximumSize(window, desiredW, desiredH); 1440 SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH); 1441 1442 /* Get size */ 1443 currentW = desiredW + 1; 1444 currentH = desiredH + 1; 1445 SDL_GetWindowMaximumSize(window, &currentW, &currentH); 1446 SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize()"); 1447 SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW); 1448 SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH); 1449 1450 /* Get just width */ 1451 currentW = desiredW + 1; 1452 SDL_GetWindowMaximumSize(window, &currentW, NULL); 1453 SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&h=NULL)"); 1454 SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH); 1455 1456 /* Get just height */ 1457 currentH = desiredH + 1; 1458 SDL_GetWindowMaximumSize(window, NULL, &currentH); 1459 SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL)"); 1460 SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH); 1461 } 1462 } 1463 1464 /* Dummy call with both pointers NULL */ 1465 SDL_GetWindowMaximumSize(window, NULL, NULL); 1466 SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL,&h=NULL)"); 1467 1468 /* Negative tests for parameter input */ 1469 SDL_ClearError(); 1470 SDLTest_AssertPass("Call to SDL_ClearError()"); 1471 for (desiredH = -2; desiredH < 2; desiredH++) { 1472 for (desiredW = -2; desiredW < 2; desiredW++) { 1473 if (desiredW < 0 || desiredH < 0) { 1474 SDL_SetWindowMaximumSize(window, desiredW, desiredH); 1475 SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH); 1476 checkInvalidParameterError(); 1477 } 1478 } 1479 } 1480 1481 /* Clean up */ 1482 destroyVideoSuiteTestWindow(window); 1483 1484 /* Set some 'magic' value for later check that nothing was changed */ 1485 referenceW = SDLTest_RandomSint32(); 1486 referenceH = SDLTest_RandomSint32(); 1487 currentW = referenceW; 1488 currentH = referenceH; 1489 desiredW = SDLTest_RandomSint32(); 1490 desiredH = SDLTest_RandomSint32(); 1491 1492 /* Negative tests */ 1493 SDL_ClearError(); 1494 SDLTest_AssertPass("Call to SDL_ClearError()"); 1495 SDL_GetWindowMaximumSize(NULL, &currentW, &currentH); 1496 SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(window=NULL)"); 1497 SDLTest_AssertCheck( 1498 currentW == referenceW && currentH == referenceH, 1499 "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d", 1500 referenceW, referenceH, 1501 currentW, currentH); 1502 checkInvalidWindowError(); 1503 1504 SDL_GetWindowMaximumSize(NULL, NULL, NULL); 1505 SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(NULL, NULL, NULL)"); 1506 checkInvalidWindowError(); 1507 1508 SDL_SetWindowMaximumSize(NULL, desiredW, desiredH); 1509 SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(window=NULL)"); 1510 checkInvalidWindowError(); 1511 1512 return TEST_COMPLETED; 1513} 1514 1515/** 1516 * Tests call to SDL_SetWindowData and SDL_GetWindowData 1517 * 1518 * \sa SDL_SetWindowData 1519 * \sa SDL_GetWindowData 1520 */ 1521static int SDLCALL video_getSetWindowData(void *arg) 1522{ 1523 int returnValue = TEST_COMPLETED; 1524 const char *title = "video_setGetWindowData Test Window"; 1525 SDL_Window *window; 1526 const char *referenceName = "TestName"; 1527 const char *name = "TestName"; 1528 const char *referenceName2 = "TestName2"; 1529 const char *name2 = "TestName2"; 1530 int datasize; 1531 char *referenceUserdata = NULL; 1532 char *userdata = NULL; 1533 char *referenceUserdata2 = NULL; 1534 char *userdata2 = NULL; 1535 char *result; 1536 int iteration; 1537 1538 /* Call against new test window */ 1539 window = createVideoSuiteTestWindow(title); 1540 if (!window) { 1541 return TEST_ABORTED; 1542 } 1543 1544 /* Create testdata */ 1545 datasize = SDLTest_RandomIntegerInRange(1, 32); 1546 referenceUserdata = SDLTest_RandomAsciiStringOfSize(datasize); 1547 if (!referenceUserdata) { 1548 returnValue = TEST_ABORTED; 1549 goto cleanup; 1550 } 1551 userdata = SDL_strdup(referenceUserdata); 1552 if (!userdata) { 1553 returnValue = TEST_ABORTED; 1554 goto cleanup; 1555 } 1556 datasize = SDLTest_RandomIntegerInRange(1, 32); 1557 referenceUserdata2 = SDLTest_RandomAsciiStringOfSize(datasize); 1558 if (!referenceUserdata2) { 1559 returnValue = TEST_ABORTED; 1560 goto cleanup; 1561 } 1562 userdata2 = SDL_strdup(referenceUserdata2); 1563 if (!userdata2) { 1564 returnValue = TEST_ABORTED; 1565 goto cleanup; 1566 } 1567 1568 /* Get non-existent data */ 1569 result = (char *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), name, NULL); 1570 SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name); 1571 SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); 1572 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); 1573 1574 /* Set data */ 1575 SDL_SetPointerProperty(SDL_GetWindowProperties(window), name, userdata); 1576 SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s)", name, userdata); 1577 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); 1578 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); 1579 1580 /* Get data (twice) */ 1581 for (iteration = 1; iteration <= 2; iteration++) { 1582 result = (char *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), name, NULL); 1583 SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [iteration %d]", name, iteration); 1584 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result); 1585 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); 1586 } 1587 1588 /* Set data again twice */ 1589 for (iteration = 1; iteration <= 2; iteration++) { 1590 SDL_SetPointerProperty(SDL_GetWindowProperties(window), name, userdata); 1591 SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [iteration %d]", name, userdata, iteration); 1592 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); 1593 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); 1594 } 1595 1596 /* Get data again */ 1597 result = (char *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), name, NULL); 1598 SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [again]", name); 1599 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result); 1600 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); 1601 1602 /* Set data with new data */ 1603 SDL_SetPointerProperty(SDL_GetWindowProperties(window), name, userdata2); 1604 SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [new userdata]", name, userdata2); 1605 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); 1606 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); 1607 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2); 1608 1609 /* Set data with new data again */ 1610 SDL_SetPointerProperty(SDL_GetWindowProperties(window), name, userdata2); 1611 SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [new userdata again]", name, userdata2); 1612 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); 1613 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); 1614 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2); 1615 1616 /* Get new data */ 1617 result = (char *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), name, NULL); 1618 SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name); 1619 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result); 1620 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); 1621 1622 /* Set data with NULL to clear */ 1623 SDL_SetPointerProperty(SDL_GetWindowProperties(window), name, NULL); 1624 SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,NULL)", name); 1625 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); 1626 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); 1627 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2); 1628 1629 /* Set data with NULL to clear again */ 1630 SDL_SetPointerProperty(SDL_GetWindowProperties(window), name, NULL); 1631 SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,NULL) [again]", name); 1632 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); 1633 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); 1634 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2); 1635 1636 /* Get non-existent data */ 1637 result = (char *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), name, NULL); 1638 SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name); 1639 SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); 1640 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); 1641 1642 /* Get non-existent data new name */ 1643 result = (char *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), name2, NULL); 1644 SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name2); 1645 SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); 1646 SDLTest_AssertCheck(SDL_strcmp(referenceName2, name2) == 0, "Validate that name2 was not changed, expected: %s, got: %s", referenceName2, name2); 1647 1648 /* Set data (again) */ 1649 SDL_SetPointerProperty(SDL_GetWindowProperties(window), name, userdata); 1650 SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [again, after clear]", name, userdata); 1651 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); 1652 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); 1653 1654 /* Get data (again) */ 1655 result = (char *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), name, NULL); 1656 SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [again, after clear]", name); 1657 SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result); 1658 SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); 1659 1660 /* Set data with NULL name, valid userdata */ 1661 SDL_SetPointerProperty(SDL_GetWindowProperties(window), NULL, userdata); 1662 SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL)"); 1663 checkInvalidParameterError(); 1664 1665 /* Set data with empty name, valid userdata */ 1666 SDL_SetPointerProperty(SDL_GetWindowProperties(window), "", userdata); 1667 SDLTest_AssertPass("Call to SDL_SetWindowData(name='')"); 1668 checkInvalidParameterError(); 1669 1670 /* Set data with NULL name, NULL userdata */ 1671 SDL_SetPointerProperty(SDL_GetWindowProperties(window), NULL, NULL); 1672 SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL,userdata=NULL)"); 1673 checkInvalidParameterError(); 1674 1675 /* Set data with empty name, NULL userdata */ 1676 SDL_SetPointerProperty(SDL_GetWindowProperties(window), "", NULL); 1677 SDLTest_AssertPass("Call to SDL_SetWindowData(name='',userdata=NULL)"); 1678 checkInvalidParameterError(); 1679 1680 /* Get data with NULL name */ 1681 result = (char *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), NULL, NULL); 1682 SDLTest_AssertPass("Call to SDL_GetWindowData(name=NULL)"); 1683 SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); 1684 1685 /* Get data with empty name */ 1686 result = (char *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), "", NULL); 1687 SDLTest_AssertPass("Call to SDL_GetWindowData(name='')"); 1688 SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); 1689 1690 /* Clean up */ 1691 destroyVideoSuiteTestWindow(window); 1692 1693cleanup: 1694 SDL_free(referenceUserdata); 1695 SDL_free(referenceUserdata2); 1696 SDL_free(userdata); 1697 SDL_free(userdata2); 1698 1699 return returnValue; 1700} 1701 1702/** 1703 * Tests the functionality of the SDL_WINDOWPOS_CENTERED_DISPLAY along with SDL_WINDOW_FULLSCREEN. 1704 * 1705 * Especially useful when run on a multi-monitor system with different DPI scales per monitor, 1706 * to test that the window size is maintained when moving between monitors. 1707 * 1708 * As the Wayland windowing protocol does not allow application windows to control their position in the 1709 * desktop space, coupled with the general asynchronous nature of Wayland compositors, the positioning 1710 * tests don't work in windowed mode and are unreliable in fullscreen mode, thus are disabled when using 1711 * the Wayland video driver. All that can be done is check that the windows are the expected size. 1712 */ 1713static int SDLCALL video_setWindowCenteredOnDisplay(void *arg) 1714{ 1715 SDL_DisplayID *displays; 1716 SDL_Window *window; 1717 const char *title = "video_setWindowCenteredOnDisplay Test Window"; 1718 int x, y, w, h; 1719 int xVariation, yVariation; 1720 int displayNum; 1721 int result; 1722 SDL_Rect display0, display1; 1723 const char *video_driver = SDL_GetCurrentVideoDriver(); 1724 const bool video_driver_is_wayland = SDL_strcmp(video_driver, "wayland") == 0; 1725 const bool video_driver_is_emscripten = SDL_strcmp(video_driver, "emscripten") == 0; 1726 1727 displays = SDL_GetDisplays(&displayNum); 1728 if (displays) { 1729 1730 /* Get display bounds */ 1731 result = SDL_GetDisplayUsableBounds(displays[0 % displayNum], &display0); 1732 SDLTest_AssertPass("SDL_GetDisplayUsableBounds()"); 1733 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 1734 if (!result) { 1735 return TEST_ABORTED; 1736 } 1737 1738 result = SDL_GetDisplayUsableBounds(displays[1 % displayNum], &display1); 1739 SDLTest_AssertPass("SDL_GetDisplayUsableBounds()"); 1740 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 1741 if (!result) { 1742 return TEST_ABORTED; 1743 } 1744 1745 for (xVariation = 0; xVariation < 2; xVariation++) { 1746 for (yVariation = 0; yVariation < 2; yVariation++) { 1747 int currentX = 0, currentY = 0; 1748 int currentW = 0, currentH = 0; 1749 int expectedX = 0, expectedY = 0; 1750 int currentDisplay; 1751 int expectedDisplay; 1752 SDL_Rect expectedDisplayRect, expectedFullscreenRect; 1753 SDL_PropertiesID props; 1754 1755 /* xVariation is the display we start on */ 1756 expectedDisplay = displays[xVariation % displayNum]; 1757 x = SDL_WINDOWPOS_CENTERED_DISPLAY(expectedDisplay); 1758 y = SDL_WINDOWPOS_CENTERED_DISPLAY(expectedDisplay); 1759 w = SDLTest_RandomIntegerInRange(640, 800); 1760 h = SDLTest_RandomIntegerInRange(400, 600); 1761 expectedDisplayRect = (xVariation == 0) ? display0 : display1; 1762 expectedX = (expectedDisplayRect.x + ((expectedDisplayRect.w - w) / 2)); 1763 expectedY = (expectedDisplayRect.y + ((expectedDisplayRect.h - h) / 2)); 1764 1765 props = SDL_CreateProperties(); 1766 SDL_SetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, title); 1767 SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_X_NUMBER, x); 1768 SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_Y_NUMBER, y); 1769 SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, w); 1770 SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, h); 1771 SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_BORDERLESS_BOOLEAN, true); 1772 window = SDL_CreateWindowWithProperties(props); 1773 SDL_DestroyProperties(props); 1774 SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h); 1775 SDLTest_AssertCheck(window != NULL, "Validate that returned window is not NULL"); 1776 1777 /* Wayland windows require that a frame be presented before they are fully mapped and visible onscreen. */ 1778 if (video_driver_is_wayland) { 1779 SDL_Renderer *renderer = SDL_CreateRenderer(window, NULL); 1780 1781 if (renderer) { 1782 SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF); 1783 SDL_RenderClear(renderer); 1784 SDL_RenderPresent(renderer); 1785 1786 /* Some desktops don't display the window immediately after presentation, 1787 * so delay to give the window time to actually appear on the desktop. 1788 */ 1789 SDL_Delay(100); 1790 } else { 1791 SDLTest_Log("Unable to create a renderer, tests may fail under Wayland"); 1792 } 1793 } 1794 1795 /* Check the window is centered on the requested display */ 1796 currentDisplay = SDL_GetDisplayForWindow(window); 1797 SDL_GetWindowSize(window, &currentW, &currentH); 1798 SDL_GetWindowPosition(window, &currentX, &currentY); 1799 1800 if (video_driver_is_wayland) { 1801 SDLTest_Log("Skipping display ID validation: %s driver does not support window positioning", video_driver); 1802 } else { 1803 SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display ID (current: %d, expected: %d)", currentDisplay, expectedDisplay); 1804 } 1805 if (VideoSupportsWindowResizing()) { 1806 SDLTest_AssertCheck(currentW == w, "Validate width (current: %d, expected: %d)", currentW, w); 1807 SDLTest_AssertCheck(currentH == h, "Validate height (current: %d, expected: %d)", currentH, h); 1808 } else { 1809 SDLTest_Log("Skipping window size validation: %s driver does not support window resizing", video_driver); 1810 } 1811 if (VideoSupportsWindowPositioning()) { 1812 SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX); 1813 SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY); 1814 } else { 1815 SDLTest_Log("Skipping window position validation: %s driver does not support window positioning", video_driver); 1816 } 1817 1818 if (video_driver_is_emscripten) { 1819 SDLTest_Log("Skipping fullscreen checks on Emscripten: can't toggle fullscreen without returning to mainloop."); 1820 } else { 1821 /* Enter fullscreen desktop */ 1822 SDL_SetWindowPosition(window, x, y); 1823 result = SDL_SetWindowFullscreen(window, true); 1824 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 1825 1826 result = SDL_SyncWindow(window); 1827 SDLTest_AssertPass("SDL_SyncWindow()"); 1828 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 1829 1830 /* Check we are filling the full display */ 1831 currentDisplay = SDL_GetDisplayForWindow(window); 1832 SDL_GetWindowSize(window, &currentW, &currentH); 1833 SDL_GetWindowPosition(window, &currentX, &currentY); 1834 1835 /* Get the expected fullscreen rect. 1836 * This needs to be queried after window creation and positioning as some drivers can alter the 1837 * usable bounds based on the window scaling mode. 1838 */ 1839 result = SDL_GetDisplayBounds(expectedDisplay, &expectedFullscreenRect); 1840 SDLTest_AssertPass("SDL_GetDisplayBounds()"); 1841 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 1842 1843 if (video_driver_is_wayland) { 1844 SDLTest_Log("Skipping display ID validation: Wayland driver does not support window positioning"); 1845 } else { 1846 SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display ID (current: %d, expected: %d)", currentDisplay, expectedDisplay); 1847 } 1848 1849 if (VideoSupportsWindowResizing()) { 1850 SDLTest_AssertCheck(currentW == expectedFullscreenRect.w, "Validate width (current: %d, expected: %d)", currentW, expectedFullscreenRect.w); 1851 SDLTest_AssertCheck(currentH == expectedFullscreenRect.h, "Validate height (current: %d, expected: %d)", currentH, expectedFullscreenRect.h); 1852 } else { 1853 SDLTest_Log("Skipping window size validation: %s driver does not support window resizing", video_driver); 1854 } 1855 if (VideoSupportsWindowPositioning()) { 1856 SDLTest_AssertCheck(currentX == expectedFullscreenRect.x, "Validate x (current: %d, expected: %d)", currentX, expectedFullscreenRect.x); 1857 SDLTest_AssertCheck(currentY == expectedFullscreenRect.y, "Validate y (current: %d, expected: %d)", currentY, expectedFullscreenRect.y); 1858 } else { 1859 SDLTest_Log("Skipping window position validation: %s driver does not support window positioning", video_driver); 1860 } 1861 1862 /* Leave fullscreen desktop */ 1863 1864 result = SDL_SetWindowFullscreen(window, false); 1865 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 1866 1867 result = SDL_SyncWindow(window); 1868 SDLTest_AssertPass("SDL_SyncWindow()"); 1869 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 1870 1871 /* Check window was restored correctly */ 1872 currentDisplay = SDL_GetDisplayForWindow(window); 1873 SDL_GetWindowSize(window, &currentW, &currentH); 1874 SDL_GetWindowPosition(window, &currentX, &currentY); 1875 1876 if (video_driver_is_wayland) { 1877 SDLTest_Log("Skipping display ID validation: %s driver does not support window positioning", video_driver); 1878 } else { 1879 SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay); 1880 } 1881 if (VideoSupportsWindowResizing()) { 1882 SDLTest_AssertCheck(currentW == w, "Validate width (current: %d, expected: %d)", currentW, w); 1883 SDLTest_AssertCheck(currentH == h, "Validate height (current: %d, expected: %d)", currentH, h); 1884 } else { 1885 SDLTest_Log("Skipping window size validation: %s driver does not support window resizing", video_driver); 1886 } 1887 if (VideoSupportsWindowPositioning()) { 1888 SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX); 1889 SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY); 1890 } else { 1891 SDLTest_Log("Skipping window position validation: %s driver does not support window positioning", video_driver); 1892 } 1893 } 1894 1895 /* Center on display yVariation, and check window properties */ 1896 1897 expectedDisplay = displays[yVariation % displayNum]; 1898 x = SDL_WINDOWPOS_CENTERED_DISPLAY(expectedDisplay); 1899 y = SDL_WINDOWPOS_CENTERED_DISPLAY(expectedDisplay); 1900 expectedDisplayRect = (yVariation == 0) ? display0 : display1; 1901 expectedX = (expectedDisplayRect.x + ((expectedDisplayRect.w - w) / 2)); 1902 expectedY = (expectedDisplayRect.y + ((expectedDisplayRect.h - h) / 2)); 1903 SDL_SetWindowPosition(window, x, y); 1904 1905 result = SDL_SyncWindow(window); 1906 SDLTest_AssertPass("SDL_SyncWindow()"); 1907 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 1908 1909 currentDisplay = SDL_GetDisplayForWindow(window); 1910 SDL_GetWindowSize(window, &currentW, &currentH); 1911 SDL_GetWindowPosition(window, &currentX, &currentY); 1912 1913 if (video_driver_is_wayland) { 1914 SDLTest_Log("Skipping display ID validation: %s driver does not support window positioning", video_driver); 1915 } else { 1916 SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display ID (current: %d, expected: %d)", currentDisplay, expectedDisplay); 1917 } 1918 if (VideoSupportsWindowResizing()) { 1919 SDLTest_AssertCheck(currentW == w, "Validate width (current: %d, expected: %d)", currentW, w); 1920 SDLTest_AssertCheck(currentH == h, "Validate height (current: %d, expected: %d)", currentH, h); 1921 } else { 1922 SDLTest_Log("Skipping window size validation: %s driver does not support window resizing", video_driver); 1923 } 1924 if (VideoSupportsWindowPositioning()) { 1925 SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX); 1926 SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY); 1927 } else { 1928 SDLTest_Log("Skipping window position validation: %s driver does not support window positioning", video_driver); 1929 } 1930 1931 /* Clean up */ 1932 destroyVideoSuiteTestWindow(window); 1933 } 1934 } 1935 SDL_free(displays); 1936 } 1937 1938 return TEST_COMPLETED; 1939} 1940 1941/** 1942 * Tests calls to SDL_MaximizeWindow(), SDL_RestoreWindow(), and SDL_SetWindowFullscreen(), 1943 * interspersed with calls to set the window size and position, and verifies the flags, 1944 * sizes, and positions of maximized, fullscreen, and restored windows. 1945 * 1946 * NOTE: This test is good on Mac, Win32, GNOME, and KDE (Wayland and X11). Other *nix 1947 * desktops, particularly tiling desktops, may not support the expected behavior, 1948 * so don't be surprised if this fails. 1949 */ 1950static int SDLCALL video_getSetWindowState(void *arg) 1951{ 1952 const char *title = "video_getSetWindowState Test Window"; 1953 SDL_Window *window; 1954 int result; 1955 SDL_Rect display; 1956 SDL_WindowFlags flags; 1957 int windowedX, windowedY; 1958 int currentX = 0, currentY = 0; 1959 int desiredX = 0, desiredY = 0; 1960 int windowedW, windowedH; 1961 int currentW, currentH; 1962 int desiredW = 0, desiredH = 0; 1963 SDL_WindowFlags skipFlags = 0; 1964 const bool restoreHint = SDL_GetHintBoolean("SDL_BORDERLESS_RESIZABLE_STYLE", true); 1965 const bool skipPos = SDL_strcmp(SDL_GetCurrentVideoDriver(), "wayland") == 0; 1966 1967 /* This test is known to be good only on GNOME and KDE. At the time of writing, Weston seems to have maximize related bugs 1968 * that prevent it from running correctly (no configure events are received when unsetting maximize), and tiling window 1969 * managers such as Sway have fundamental behavioral differences that conflict with it. 1970 * 1971 * Other desktops can be enabled in the future as required. 1972 */ 1973 if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "wayland") == 0 || SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0) { 1974 const char *desktop = SDL_GetEnvironmentVariable(SDL_GetEnvironment(), "XDG_CURRENT_DESKTOP"); 1975 if (SDL_strcmp(desktop, "GNOME") != 0 && SDL_strcmp(desktop, "KDE") != 0) { 1976 SDLTest_Log("Skipping test video_getSetWindowState: desktop environment %s not supported", desktop); 1977 return TEST_SKIPPED; 1978 } 1979 } 1980 1981 /* Win32 borderless windows are not resizable by default and need this undocumented hint */ 1982 SDL_SetHint("SDL_BORDERLESS_RESIZABLE_STYLE", "1"); 1983 1984 /* Call against new test window */ 1985 window = createVideoSuiteTestWindow(title); 1986 if (!window) { 1987 return TEST_ABORTED; 1988 } 1989 1990 SDL_GetWindowSize(window, &windowedW, &windowedH); 1991 SDLTest_AssertPass("SDL_GetWindowSize()"); 1992 1993 SDL_GetWindowPosition(window, &windowedX, &windowedY); 1994 SDLTest_AssertPass("SDL_GetWindowPosition()"); 1995 1996 if (skipPos) { 1997 SDLTest_Log("Skipping positioning tests: %s reports window positioning as unsupported", SDL_GetCurrentVideoDriver()); 1998 } 1999 2000 /* Maximize and check the dimensions */ 2001 result = SDL_MaximizeWindow(window); 2002 SDLTest_AssertPass("SDL_MaximizeWindow()"); 2003 if (!result) { 2004 SDLTest_Log("Skipping state transition tests: %s reports window maximizing as unsupported", SDL_GetCurrentVideoDriver()); 2005 skipFlags |= SDL_WINDOW_MAXIMIZED; 2006 goto minimize_test; 2007 } 2008 2009 result = SDL_SyncWindow(window); 2010 SDLTest_AssertPass("SDL_SyncWindow()"); 2011 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2012 2013 flags = SDL_GetWindowFlags(window); 2014 SDLTest_AssertPass("SDL_GetWindowFlags()"); 2015 SDLTest_AssertCheck(flags & SDL_WINDOW_MAXIMIZED, "Verify the `SDL_WINDOW_MAXIMIZED` flag is set: %s", (flags & SDL_WINDOW_MAXIMIZED) ? "true" : "false"); 2016 2017 /* Check that the maximized window doesn't extend beyond the usable display bounds. 2018 * FIXME: Maximizing Win32 borderless windows is broken, so this always fails. 2019 * Skip it for now. 2020 */ 2021 if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "windows") != 0) { 2022 result = SDL_GetDisplayUsableBounds(SDL_GetDisplayForWindow(window), &display); 2023 SDLTest_AssertPass("SDL_GetDisplayUsableBounds()"); 2024 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2025 2026 desiredW = display.w; 2027 desiredH = display.h; 2028 currentW = windowedW + 1; 2029 currentH = windowedH + 1; 2030 SDL_GetWindowSize(window, &currentW, &currentH); 2031 SDLTest_AssertPass("Call to SDL_GetWindowSize()"); 2032 SDLTest_AssertCheck(currentW <= desiredW, "Verify returned width; expected: <= %d, got: %d", desiredW, 2033 currentW); 2034 SDLTest_AssertCheck(currentH <= desiredH, "Verify returned height; expected: <= %d, got: %d", desiredH, 2035 currentH); 2036 } 2037 2038 /* Restore and check the dimensions */ 2039 result = SDL_RestoreWindow(window); 2040 SDLTest_AssertPass("SDL_RestoreWindow()"); 2041 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2042 2043 result = SDL_SyncWindow(window); 2044 SDLTest_AssertPass("SDL_SyncWindow()"); 2045 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2046 2047 flags = SDL_GetWindowFlags(window); 2048 SDLTest_AssertPass("SDL_GetWindowFlags()"); 2049 SDLTest_AssertCheck(!(flags & SDL_WINDOW_MAXIMIZED), "Verify that the `SDL_WINDOW_MAXIMIZED` flag is cleared: %s", !(flags & SDL_WINDOW_MAXIMIZED) ? "true" : "false"); 2050 2051 if (!skipPos) { 2052 currentX = windowedX + 1; 2053 currentY = windowedY + 1; 2054 SDL_GetWindowPosition(window, &currentX, &currentY); 2055 SDLTest_AssertPass("Call to SDL_GetWindowPosition()"); 2056 SDLTest_AssertCheck(windowedX == currentX, "Verify returned X coordinate; expected: %d, got: %d", windowedX, currentX); 2057 SDLTest_AssertCheck(windowedY == currentY, "Verify returned Y coordinate; expected: %d, got: %d", windowedY, currentY); 2058 } 2059 2060 currentW = windowedW + 1; 2061 currentH = windowedH + 1; 2062 SDL_GetWindowSize(window, &currentW, &currentH); 2063 SDLTest_AssertPass("Call to SDL_GetWindowSize()"); 2064 SDLTest_AssertCheck(windowedW == currentW, "Verify returned width; expected: %d, got: %d", windowedW, currentW); 2065 SDLTest_AssertCheck(windowedH == currentH, "Verify returned height; expected: %d, got: %d", windowedH, currentH); 2066 2067 /* Maximize, then immediately restore */ 2068 result = SDL_MaximizeWindow(window); 2069 SDLTest_AssertPass("SDL_MaximizeWindow()"); 2070 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2071 2072 result = SDL_RestoreWindow(window); 2073 SDLTest_AssertPass("SDL_RestoreWindow()"); 2074 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2075 2076 result = SDL_SyncWindow(window); 2077 SDLTest_AssertPass("SDL_SyncWindow()"); 2078 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2079 2080 flags = SDL_GetWindowFlags(window); 2081 SDLTest_AssertPass("SDL_GetWindowFlags()"); 2082 SDLTest_AssertCheck(!(flags & SDL_WINDOW_MAXIMIZED), "Verify that the `SDL_WINDOW_MAXIMIZED` flag is cleared: %s", !(flags & SDL_WINDOW_MAXIMIZED) ? "true" : "false"); 2083 2084 /* Make sure the restored size and position matches the original windowed size and position. */ 2085 if (!skipPos) { 2086 currentX = windowedX + 1; 2087 currentY = windowedY + 1; 2088 SDL_GetWindowPosition(window, &currentX, &currentY); 2089 SDLTest_AssertPass("Call to SDL_GetWindowPosition()"); 2090 SDLTest_AssertCheck(windowedX == currentX, "Verify returned X coordinate; expected: %d, got: %d", windowedX, currentX); 2091 SDLTest_AssertCheck(windowedY == currentY, "Verify returned Y coordinate; expected: %d, got: %d", windowedY, currentY); 2092 } 2093 2094 currentW = windowedW + 1; 2095 currentH = windowedH + 1; 2096 SDL_GetWindowSize(window, &currentW, &currentH); 2097 SDLTest_AssertPass("Call to SDL_GetWindowSize()"); 2098 SDLTest_AssertCheck(windowedW == currentW, "Verify returned width; expected: %d, got: %d", windowedW, currentW); 2099 SDLTest_AssertCheck(windowedH == currentH, "Verify returned height; expected: %d, got: %d", windowedH, currentH); 2100 2101 /* Maximize, then enter fullscreen */ 2102 result = SDL_MaximizeWindow(window); 2103 SDLTest_AssertPass("SDL_MaximizeWindow()"); 2104 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2105 2106 result = SDL_SetWindowFullscreen(window, true); 2107 SDLTest_AssertPass("SDL_SetWindowFullscreen(true)"); 2108 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2109 2110 result = SDL_SyncWindow(window); 2111 SDLTest_AssertPass("SDL_SyncWindow()"); 2112 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2113 2114 flags = SDL_GetWindowFlags(window); 2115 SDLTest_AssertPass("SDL_GetWindowFlags()"); 2116 SDLTest_AssertCheck(flags & SDL_WINDOW_FULLSCREEN, "Verify the `SDL_WINDOW_FULLSCREEN` flag is set: %s", (flags & SDL_WINDOW_FULLSCREEN) ? "true" : "false"); 2117 SDLTest_AssertCheck(!(flags & SDL_WINDOW_MAXIMIZED), "Verify the `SDL_WINDOW_MAXIMIZED` flag is cleared: %s", !(flags & SDL_WINDOW_MAXIMIZED) ? "true" : "false"); 2118 2119 /* Verify the fullscreen size and position */ 2120 result = SDL_GetDisplayBounds(SDL_GetDisplayForWindow(window), &display); 2121 SDLTest_AssertPass("SDL_GetDisplayBounds()"); 2122 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2123 2124 if (!skipPos) { 2125 desiredX = display.x; 2126 desiredY = display.y; 2127 currentX = windowedX + 1; 2128 currentY = windowedY + 1; 2129 SDL_GetWindowPosition(window, &currentX, &currentY); 2130 SDLTest_AssertPass("Call to SDL_GetWindowPosition()"); 2131 SDLTest_AssertCheck(desiredX == currentX, "Verify returned X coordinate; expected: %d, got: %d", desiredX, currentX); 2132 SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y coordinate; expected: %d, got: %d", desiredY, currentY); 2133 } 2134 2135 desiredW = display.w; 2136 desiredH = display.h; 2137 currentW = windowedW + 1; 2138 currentH = windowedH + 1; 2139 SDL_GetWindowSize(window, &currentW, &currentH); 2140 SDLTest_AssertPass("Call to SDL_GetWindowSize()"); 2141 SDLTest_AssertCheck(currentW == desiredW, "Verify returned width; expected: %d, got: %d", desiredW, currentW); 2142 SDLTest_AssertCheck(currentH == desiredH, "Verify returned height; expected: %d, got: %d", desiredH, currentH); 2143 2144 /* Leave fullscreen and restore the window */ 2145 result = SDL_SetWindowFullscreen(window, false); 2146 SDLTest_AssertPass("SDL_SetWindowFullscreen(false)"); 2147 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2148 2149 result = SDL_RestoreWindow(window); 2150 SDLTest_AssertPass("SDL_RestoreWindow()"); 2151 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2152 2153 result = SDL_SyncWindow(window); 2154 SDLTest_AssertPass("SDL_SyncWindow()"); 2155 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2156 2157 flags = SDL_GetWindowFlags(window); 2158 SDLTest_AssertPass("SDL_GetWindowFlags()"); 2159 SDLTest_AssertCheck(!(flags & SDL_WINDOW_MAXIMIZED), "Verify that the `SDL_WINDOW_MAXIMIZED` flag is cleared: %s", !(flags & SDL_WINDOW_MAXIMIZED) ? "true" : "false"); 2160 2161 /* Make sure the restored size and position matches the original windowed size and position. */ 2162 if (!skipPos) { 2163 currentX = windowedX + 1; 2164 currentY = windowedY + 1; 2165 SDL_GetWindowPosition(window, &currentX, &currentY); 2166 SDLTest_AssertPass("Call to SDL_GetWindowPosition()"); 2167 SDLTest_AssertCheck(windowedX == currentX, "Verify returned X coordinate; expected: %d, got: %d", windowedX, currentX); 2168 SDLTest_AssertCheck(windowedY == currentY, "Verify returned Y coordinate; expected: %d, got: %d", windowedY, currentY); 2169 } 2170 2171 currentW = windowedW + 1; 2172 currentH = windowedH + 1; 2173 SDL_GetWindowSize(window, &currentW, &currentH); 2174 SDLTest_AssertPass("Call to SDL_GetWindowSize()"); 2175 SDLTest_AssertCheck(windowedW == currentW, "Verify returned width; expected: %d, got: %d", windowedW, currentW); 2176 SDLTest_AssertCheck(windowedH == currentH, "Verify returned height; expected: %d, got: %d", windowedH, currentH); 2177 2178 /* Maximize, restore, and change size */ 2179 result = SDL_MaximizeWindow(window); 2180 SDLTest_AssertPass("SDL_MaximizeWindow()"); 2181 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2182 2183 result = SDL_RestoreWindow(window); 2184 SDLTest_AssertPass("SDL_RestoreWindow()"); 2185 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2186 2187 desiredW = windowedW + 10; 2188 desiredH = windowedH + 10; 2189 result = SDL_SetWindowSize(window, desiredW, desiredH); 2190 SDLTest_AssertPass("SDL_SetWindowSize()"); 2191 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2192 2193 if (!skipPos) { 2194 desiredX = windowedX + 10; 2195 desiredY = windowedY + 10; 2196 result = SDL_SetWindowPosition(window, desiredX, desiredY); 2197 SDLTest_AssertPass("SDL_SetWindowPosition()"); 2198 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2199 } 2200 2201 result = SDL_SyncWindow(window); 2202 SDLTest_AssertPass("SDL_SyncWindow()"); 2203 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2204 2205 flags = SDL_GetWindowFlags(window); 2206 SDLTest_AssertPass("SDL_GetWindowFlags()"); 2207 SDLTest_AssertCheck(!(flags & SDL_WINDOW_MAXIMIZED), "Verify that the `SDL_WINDOW_MAXIMIZED` flag is cleared: %s", !(flags & SDL_WINDOW_MAXIMIZED) ? "true" : "false"); 2208 2209 if (!skipPos) { 2210 currentX = desiredX + 1; 2211 currentY = desiredY + 1; 2212 SDL_GetWindowPosition(window, &currentX, &currentY); 2213 SDLTest_AssertPass("Call to SDL_GetWindowPosition()"); 2214 SDLTest_AssertCheck(desiredX == currentX, "Verify returned X coordinate; expected: %d, got: %d", desiredX, currentX); 2215 SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y coordinate; expected: %d, got: %d", desiredY, currentY); 2216 } 2217 2218 currentW = desiredW + 1; 2219 currentH = desiredH + 1; 2220 SDL_GetWindowSize(window, &currentW, &currentH); 2221 SDLTest_AssertPass("Call to SDL_GetWindowSize()"); 2222 SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW); 2223 SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH); 2224 2225 /* Maximize, change size/position (should be ignored), and restore. */ 2226 result = SDL_MaximizeWindow(window); 2227 SDLTest_AssertPass("SDL_MaximizeWindow()"); 2228 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2229 2230 desiredW = windowedW + 10; 2231 desiredH = windowedH + 10; 2232 result = SDL_SetWindowSize(window, desiredW, desiredH); 2233 SDLTest_AssertPass("SDL_SetWindowSize()"); 2234 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2235 2236 if (!skipPos) { 2237 desiredX = windowedX + 10; 2238 desiredY = windowedY + 10; 2239 result = SDL_SetWindowPosition(window, desiredX, desiredY); 2240 SDLTest_AssertPass("SDL_SetWindowPosition()"); 2241 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2242 } 2243 2244 result = SDL_RestoreWindow(window); 2245 SDLTest_AssertPass("SDL_RestoreWindow()"); 2246 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2247 2248 result = SDL_SyncWindow(window); 2249 SDLTest_AssertPass("SDL_SyncWindow()"); 2250 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2251 2252 flags = SDL_GetWindowFlags(window); 2253 SDLTest_AssertPass("SDL_GetWindowFlags()"); 2254 SDLTest_AssertCheck(!(flags & SDL_WINDOW_MAXIMIZED), "Verify that the `SDL_WINDOW_MAXIMIZED` flag is cleared: %s", !(flags & SDL_WINDOW_MAXIMIZED) ? "true" : "false"); 2255 2256 if (!skipPos) { 2257 int previousX = desiredX + 1; 2258 int previousY = desiredY + 1; 2259 SDL_GetWindowPosition(window, &previousX, &previousY); 2260 SDLTest_AssertPass("Call to SDL_GetWindowPosition()"); 2261 SDLTest_AssertCheck(desiredX == currentX, "Verify returned X coordinate; expected: %d, got: %d", previousX, currentX); 2262 SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y coordinate; expected: %d, got: %d", previousY, currentY); 2263 } 2264 2265 int previousW = desiredW + 1; 2266 int previousH = desiredH + 1; 2267 SDL_GetWindowSize(window, &previousW, &previousH); 2268 SDLTest_AssertPass("Call to SDL_GetWindowSize()"); 2269 SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", previousW, currentW); 2270 SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", previousH, currentH); 2271 2272 /* Change size and position, maximize and restore */ 2273 desiredW = windowedW - 5; 2274 desiredH = windowedH - 5; 2275 result = SDL_SetWindowSize(window, desiredW, desiredH); 2276 SDLTest_AssertPass("SDL_SetWindowSize()"); 2277 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2278 2279 if (!skipPos) { 2280 desiredX = windowedX + 5; 2281 desiredY = windowedY + 5; 2282 result = SDL_SetWindowPosition(window, desiredX, desiredY); 2283 SDLTest_AssertPass("SDL_SetWindowPosition()"); 2284 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2285 } 2286 2287 result = SDL_MaximizeWindow(window); 2288 SDLTest_AssertPass("SDL_MaximizeWindow()"); 2289 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2290 2291 result = SDL_RestoreWindow(window); 2292 SDLTest_AssertPass("SDL_RestoreWindow()"); 2293 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2294 2295 result = SDL_SyncWindow(window); 2296 SDLTest_AssertPass("SDL_SyncWindow()"); 2297 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2298 2299 flags = SDL_GetWindowFlags(window); 2300 SDLTest_AssertPass("SDL_GetWindowFlags()"); 2301 SDLTest_AssertCheck(!(flags & SDL_WINDOW_MAXIMIZED), "Verify that the `SDL_WINDOW_MAXIMIZED` flag is cleared: %s", !(flags & SDL_WINDOW_MAXIMIZED) ? "true" : "false"); 2302 2303 if (!skipPos) { 2304 currentX = desiredX + 1; 2305 currentY = desiredY + 1; 2306 SDL_GetWindowPosition(window, &currentX, &currentY); 2307 SDLTest_AssertPass("Call to SDL_GetWindowPosition()"); 2308 SDLTest_AssertCheck(desiredX == currentX, "Verify returned X coordinate; expected: %d, got: %d", desiredX, currentX); 2309 SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y coordinate; expected: %d, got: %d", desiredY, currentY); 2310 } 2311 2312 currentW = desiredW + 1; 2313 currentH = desiredH + 1; 2314 SDL_GetWindowSize(window, &currentW, &currentH); 2315 SDLTest_AssertPass("Call to SDL_GetWindowSize()"); 2316 SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW); 2317 SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH); 2318 2319minimize_test: 2320 2321 /* Minimize */ 2322 if (VideoSupportsWindowMinimizing() && SDL_MinimizeWindow(window)) { 2323 SDLTest_AssertPass("SDL_MinimizeWindow()"); 2324 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2325 2326 result = SDL_SyncWindow(window); 2327 SDLTest_AssertPass("SDL_SyncWindow()"); 2328 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2329 2330 flags = SDL_GetWindowFlags(window); 2331 SDLTest_AssertPass("SDL_GetWindowFlags()"); 2332 SDLTest_AssertCheck(flags & SDL_WINDOW_MINIMIZED, "Verify that the `SDL_WINDOW_MINIMIZED` flag is set: %s", (flags & SDL_WINDOW_MINIMIZED) ? "true" : "false"); 2333 } else { 2334 SDLTest_Log("Skipping minimize test: %s reports window minimizing as unsupported", SDL_GetCurrentVideoDriver()); 2335 skipFlags |= SDL_WINDOW_MINIMIZED; 2336 } 2337 2338 /* Clean up */ 2339 destroyVideoSuiteTestWindow(window); 2340 2341 /* Restore the hint to the previous value */ 2342 SDL_SetHint("SDL_BORDERLESS_RESIZABLE_STYLE", restoreHint ? "1" : "0"); 2343 2344 return skipFlags != (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED) ? TEST_COMPLETED : TEST_SKIPPED; 2345} 2346 2347static int SDLCALL video_createMinimized(void *arg) 2348{ 2349 const char *title = "video_createMinimized Test Window"; 2350 int result; 2351 SDL_Window *window; 2352 int windowedX, windowedY; 2353 int windowedW, windowedH; 2354 2355 if (!VideoSupportsWindowMinimizing()) { 2356 SDLTest_Log("Skipping creating mimized window, %s reports window minimizing as unsupported", SDL_GetCurrentVideoDriver()); 2357 return TEST_SKIPPED; 2358 } 2359 2360 /* Call against new test window */ 2361 window = SDL_CreateWindow(title, 320, 200, SDL_WINDOW_MINIMIZED); 2362 if (!window) { 2363 return TEST_ABORTED; 2364 } 2365 2366 SDL_GetWindowSize(window, &windowedW, &windowedH); 2367 SDLTest_AssertPass("SDL_GetWindowSize()"); 2368 SDLTest_AssertCheck(windowedW > 0 && windowedH > 0, "Verify return value; expected: 320x200, got: %dx%d", windowedW, windowedH); 2369 2370 SDL_GetWindowSizeInPixels(window, &windowedW, &windowedH); 2371 SDLTest_AssertPass("SDL_GetWindowSizeInPixels()"); 2372 SDLTest_AssertCheck(windowedW > 0 && windowedH > 0, "Verify return value; expected: > 0, got: %dx%d", windowedW, windowedH); 2373 2374 SDL_GetWindowPosition(window, &windowedX, &windowedY); 2375 SDLTest_AssertPass("SDL_GetWindowPosition()"); 2376 SDLTest_AssertCheck(windowedX >= 0 && windowedY >= 0, "Verify return value; expected: >= 0, got: %d,%d", windowedX, windowedY); 2377 2378 if (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED) { 2379 result = SDL_RestoreWindow(window); 2380 SDLTest_AssertPass("SDL_RestoreWindow()"); 2381 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2382 } else { 2383 SDLTest_Log("Requested minimized window on creation, but that isn't supported on this platform."); 2384 } 2385 2386 SDL_DestroyWindow(window); 2387 2388 return TEST_COMPLETED; 2389} 2390 2391static int SDLCALL video_createMaximized(void *arg) 2392{ 2393 const char *title = "video_createMaximized Test Window"; 2394 int result; 2395 SDL_Window *window; 2396 int windowedX, windowedY; 2397 int windowedW, windowedH; 2398 2399 /* Call against new test window */ 2400 window = SDL_CreateWindow(title, 320, 200, SDL_WINDOW_MAXIMIZED); 2401 if (!window) { 2402 return TEST_ABORTED; 2403 } 2404 2405 SDL_GetWindowSize(window, &windowedW, &windowedH); 2406 SDLTest_AssertPass("SDL_GetWindowSize()"); 2407 SDLTest_AssertCheck(windowedW > 0 && windowedH > 0, "Verify return value; expected: 320x200, got: %dx%d", windowedW, windowedH); 2408 2409 SDL_GetWindowSizeInPixels(window, &windowedW, &windowedH); 2410 SDLTest_AssertPass("SDL_GetWindowSizeInPixels()"); 2411 SDLTest_AssertCheck(windowedW > 0 && windowedH > 0, "Verify return value; expected: > 0, got: %dx%d", windowedW, windowedH); 2412 2413 SDL_GetWindowPosition(window, &windowedX, &windowedY); 2414 SDLTest_AssertPass("SDL_GetWindowPosition()"); 2415 SDLTest_AssertCheck(windowedX >= 0 && windowedY >= 0, "Verify return value; expected: >= 0, got: %d,%d", windowedX, windowedY); 2416 2417 if (SDL_GetWindowFlags(window) & SDL_WINDOW_MAXIMIZED) { 2418 result = SDL_RestoreWindow(window); 2419 SDLTest_AssertPass("SDL_RestoreWindow()"); 2420 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2421 } else { 2422 SDLTest_Log("Requested maximized window on creation, but that isn't supported on this platform."); 2423 } 2424 2425 SDL_DestroyWindow(window); 2426 2427 return TEST_COMPLETED; 2428} 2429 2430/** 2431 * Tests window surface functionality 2432 */ 2433static int SDLCALL video_getWindowSurface(void *arg) 2434{ 2435 const char *title = "video_getWindowSurface Test Window"; 2436 SDL_Window *window; 2437 SDL_Surface *surface; 2438 SDL_Renderer *renderer; 2439 const char *renderer_name = NULL; 2440 int result; 2441 2442 if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "dummy") == 0) { 2443 renderer_name = SDL_SOFTWARE_RENDERER; 2444 } 2445 2446 /* Make sure we're testing interaction with an accelerated renderer */ 2447 SDL_SetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION, "1"); 2448 2449 window = SDL_CreateWindow(title, 320, 320, 0); 2450 SDLTest_AssertPass("Call to SDL_CreateWindow('Title',320,320,0)"); 2451 SDLTest_AssertCheck(window != NULL, "Validate that returned window is not NULL"); 2452 2453 surface = SDL_GetWindowSurface(window); 2454 SDLTest_AssertPass("Call to SDL_GetWindowSurface(window)"); 2455 SDLTest_AssertCheck(surface != NULL, "Validate that returned surface is not NULL"); 2456 SDLTest_AssertCheck(SDL_WindowHasSurface(window), "Validate that window has a surface"); 2457 2458 result = SDL_UpdateWindowSurface(window); 2459 SDLTest_AssertPass("Call to SDL_UpdateWindowSurface(window)"); 2460 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2461 2462 /* We shouldn't be able to create a renderer on a window with a surface */ 2463 renderer = SDL_CreateRenderer(window, renderer_name); 2464 SDLTest_AssertPass("Call to SDL_CreateRenderer(window, %s)", renderer_name); 2465 SDLTest_AssertCheck(renderer == NULL, "Validate that returned renderer is NULL"); 2466 2467 result = SDL_DestroyWindowSurface(window); 2468 SDLTest_AssertPass("Call to SDL_DestroyWindowSurface(window)"); 2469 SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result); 2470 SDLTest_AssertCheck(!SDL_WindowHasSurface(window), "Validate that window does not have a surface"); 2471 2472 /* We should be able to create a renderer on the window now */ 2473 renderer = SDL_CreateRenderer(window, renderer_name); 2474 SDLTest_AssertPass("Call to SDL_CreateRenderer(window, %s)", renderer_name); 2475 SDLTest_AssertCheck(renderer != NULL, "Validate that returned renderer is not NULL"); 2476 2477 /* We should not be able to create a window surface now, unless it was created by the renderer */ 2478 if (!SDL_WindowHasSurface(window)) { 2479 surface = SDL_GetWindowSurface(window); 2480 SDLTest_AssertPass("Call to SDL_GetWindowSurface(window)"); 2481 SDLTest_AssertCheck(surface == NULL, "Validate that returned surface is NULL"); 2482 } 2483 2484 SDL_DestroyRenderer(renderer); 2485 SDLTest_AssertPass("Call to SDL_DestroyRenderer(renderer)"); 2486 SDLTest_AssertCheck(!SDL_WindowHasSurface(window), "Validate that window does not have a surface"); 2487 2488 /* We should be able to create a window surface again */ 2489 surface = SDL_GetWindowSurface(window); 2490 SDLTest_AssertPass("Call to SDL_GetWindowSurface(window)"); 2491 SDLTest_AssertCheck(surface != NULL, "Validate that returned surface is not NULL"); 2492 SDLTest_AssertCheck(SDL_WindowHasSurface(window), "Validate that window has a surface"); 2493 2494 /* Clean up */ 2495 SDL_DestroyWindow(window); 2496 2497 return TEST_COMPLETED; 2498} 2499 2500/** 2501 * Tests SDL_RaiseWindow 2502 */ 2503static int SDLCALL video_raiseWindow(void *arg) 2504{ 2505 bool result; 2506 SDL_Window *window; 2507 2508 SDLTest_AssertPass("SDL_SetWindowInputFocus is not supported on dummy and SDL2 wayland driver"); 2509 if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "dummy") == 0 || SDL_strcmp(SDL_GetCurrentVideoDriver(), "wayland") == 0) { 2510 return TEST_SKIPPED; 2511 } 2512 2513 window = createVideoSuiteTestWindow("video_raiseWindow"); 2514 if (!window) { 2515 return TEST_ABORTED; 2516 } 2517 2518 SDLTest_AssertPass("About to call SDL_RaiseWindow(window)"); 2519 result = SDL_RaiseWindow(window); 2520 SDLTest_AssertCheck(result, "Result is %d, expected 1 (%s)", result, SDL_GetError()); 2521 2522 destroyVideoSuiteTestWindow(window); 2523 2524 return TEST_COMPLETED; 2525} 2526 2527/* ================= Test References ================== */ 2528 2529/* Video test cases */ 2530static const SDLTest_TestCaseReference videoTestEnableDisableScreensaver = { 2531 video_enableDisableScreensaver, "video_enableDisableScreensaver", "Enable and disable screenaver while checking state", TEST_ENABLED 2532}; 2533 2534static const SDLTest_TestCaseReference videoTestCreateWindowVariousSizes = { 2535 video_createWindowVariousSizes, "video_createWindowVariousSizes", "Create windows with various sizes", TEST_ENABLED 2536}; 2537 2538static const SDLTest_TestCaseReference videoTestCreateWindowVariousFlags = { 2539 video_createWindowVariousFlags, "video_createWindowVariousFlags", "Create windows using various flags", TEST_ENABLED 2540}; 2541 2542static const SDLTest_TestCaseReference videoTestGetWindowFlags = { 2543 video_getWindowFlags, "video_getWindowFlags", "Get window flags set during SDL_CreateWindow", TEST_ENABLED 2544}; 2545 2546static const SDLTest_TestCaseReference videoTestGetFullscreenDisplayModes = { 2547 video_getFullscreenDisplayModes, "video_getFullscreenDisplayModes", "Use SDL_GetFullscreenDisplayModes function to get number of display modes", TEST_ENABLED 2548}; 2549 2550static const SDLTest_TestCaseReference videoTestGetClosestDisplayModeCurrentResolution = { 2551 video_getClosestDisplayModeCurrentResolution, "video_getClosestDisplayModeCurrentResolution", "Use function to get closes match to requested display mode for current resolution", TEST_ENABLED 2552}; 2553 2554static const SDLTest_TestCaseReference videoTestGetClosestDisplayModeRandomResolution = { 2555 video_getClosestDisplayModeRandomResolution, "video_getClosestDisplayModeRandomResolution", "Use function to get closes match to requested display mode for random resolution", TEST_ENABLED 2556}; 2557 2558static const SDLTest_TestCaseReference videoTestGetWindowDisplayMode = { 2559 video_getWindowDisplayMode, "video_getWindowDisplayMode", "Get window display mode", TEST_ENABLED 2560}; 2561 2562static const SDLTest_TestCaseReference videoTestGetWindowDisplayModeNegative = { 2563 video_getWindowDisplayModeNegative, "video_getWindowDisplayModeNegative", "Get window display mode with invalid input", TEST_ENABLED 2564}; 2565 2566static const SDLTest_TestCaseReference videoTestGetSetWindowGrab = { 2567 video_getSetWindowGrab, "video_getSetWindowGrab", "Checks input grab positive and negative cases", TEST_ENABLED 2568}; 2569 2570static const SDLTest_TestCaseReference videoTestGetWindowID = { 2571 video_getWindowId, "video_getWindowId", "Checks SDL_GetWindowID and SDL_GetWindowFromID", TEST_ENABLED 2572}; 2573 2574static const SDLTest_TestCaseReference videoTestGetWindowPixelFormat = { 2575 video_getWindowPixelFormat, "video_getWindowPixelFormat", "Checks SDL_GetWindowPixelFormat", TEST_ENABLED 2576}; 2577 2578static const SDLTest_TestCaseReference videoTestGetSetWindowPosition = { 2579 video_getSetWindowPosition, "video_getSetWindowPosition", "Checks SDL_GetWindowPosition and SDL_SetWindowPosition positive and negative cases", TEST_ENABLED 2580}; 2581 2582static const SDLTest_TestCaseReference videoTestGetSetWindowSize = { 2583 video_getSetWindowSize, "video_getSetWindowSize", "Checks SDL_GetWindowSize and SDL_SetWindowSize positive and negative cases", TEST_ENABLED 2584}; 2585 2586static const SDLTest_TestCaseReference videoTestGetSetWindowMinimumSize = { 2587 video_getSetWindowMinimumSize, "video_getSetWindowMinimumSize", "Checks SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize positive and negative cases", TEST_ENABLED 2588}; 2589 2590static const SDLTest_TestCaseReference videoTestGetSetWindowMaximumSize = { 2591 video_getSetWindowMaximumSize, "video_getSetWindowMaximumSize", "Checks SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize positive and negative cases", TEST_ENABLED 2592}; 2593 2594static const SDLTest_TestCaseReference videoTestGetSetWindowData = { 2595 video_getSetWindowData, "video_getSetWindowData", "Checks SDL_SetWindowData and SDL_GetWindowData positive and negative cases", TEST_ENABLED 2596}; 2597 2598static const SDLTest_TestCaseReference videoTestSetWindowCenteredOnDisplay = { 2599 video_setWindowCenteredOnDisplay, "video_setWindowCenteredOnDisplay", "Checks using SDL_WINDOWPOS_CENTERED_DISPLAY centers the window on a display", TEST_ENABLED 2600}; 2601 2602static const SDLTest_TestCaseReference videoTestGetSetWindowState = { 2603 video_getSetWindowState, "video_getSetWindowState", "Checks transitioning between windowed, minimized, maximized, and fullscreen states", TEST_ENABLED 2604}; 2605 2606static const SDLTest_TestCaseReference videoTestCreateMinimized = { 2607 video_createMinimized, "video_createMinimized", "Checks window state for windows created minimized", TEST_ENABLED 2608}; 2609 2610static const SDLTest_TestCaseReference videoTestCreateMaximized = { 2611 video_createMaximized, "video_createMaximized", "Checks window state for windows created maximized", TEST_ENABLED 2612}; 2613 2614static const SDLTest_TestCaseReference videoTestGetWindowSurface = { 2615 video_getWindowSurface, "video_getWindowSurface", "Checks window surface functionality", TEST_ENABLED 2616}; 2617static const SDLTest_TestCaseReference videoTestRaiseWindow = { 2618 video_raiseWindow, "video_raiseWindow", "Checks window focus", TEST_ENABLED 2619}; 2620 2621/* Sequence of Video test cases */ 2622static const SDLTest_TestCaseReference *videoTests[] = { 2623 &videoTestEnableDisableScreensaver, 2624 &videoTestCreateWindowVariousSizes, 2625 &videoTestCreateWindowVariousFlags, 2626 &videoTestGetWindowFlags, 2627 &videoTestGetFullscreenDisplayModes, 2628 &videoTestGetClosestDisplayModeCurrentResolution, 2629 &videoTestGetClosestDisplayModeRandomResolution, 2630 &videoTestGetWindowDisplayMode, 2631 &videoTestGetWindowDisplayModeNegative, 2632 &videoTestGetSetWindowGrab, 2633 &videoTestGetWindowID, 2634 &videoTestGetWindowPixelFormat, 2635 &videoTestGetSetWindowPosition, 2636 &videoTestGetSetWindowSize, 2637 &videoTestGetSetWindowMinimumSize, 2638 &videoTestGetSetWindowMaximumSize, 2639 &videoTestGetSetWindowData, 2640 &videoTestSetWindowCenteredOnDisplay, 2641 &videoTestGetSetWindowState, 2642 &videoTestCreateMinimized, 2643 &videoTestCreateMaximized, 2644 &videoTestGetWindowSurface, 2645 &videoTestRaiseWindow, 2646 NULL 2647}; 2648 2649/* Video test suite (global) */ 2650SDLTest_TestSuiteReference videoTestSuite = { 2651 "Video", 2652 NULL, 2653 videoTests, 2654 NULL 2655}; 2656
[FILE END]
(C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.