Atlas - testautomation_video.c

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