test/testautomation_video.c
changeset 6984 ae9c4b12f3e2
parent 6956 afdc35fa58e9
child 7062 c0a739679bbd
     1.1 --- a/test/testautomation_video.c	Fri Mar 08 23:04:53 2013 -0800
     1.2 +++ b/test/testautomation_video.c	Fri Mar 08 23:33:07 2013 -0800
     1.3 @@ -33,7 +33,7 @@
     1.4    y = SDLTest_RandomIntegerInRange(1, 100);
     1.5    w = SDLTest_RandomIntegerInRange(320, 1024);
     1.6    h = SDLTest_RandomIntegerInRange(320, 768);
     1.7 -  flags = SDL_WINDOW_SHOWN;
     1.8 +  flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS;
     1.9    
    1.10    window = SDL_CreateWindow(title, x, y, w, h, flags);
    1.11    SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
    1.12 @@ -315,7 +315,6 @@
    1.13      SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
    1.14      SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
    1.15  
    1.16 -
    1.17      /* Clean up */    
    1.18      _destroyVideoSuiteTestWindow(window);  
    1.19    }
    1.20 @@ -596,6 +595,25 @@
    1.21    return TEST_COMPLETED;
    1.22  }
    1.23  
    1.24 +/* Helper function that checks for an 'Invalid window' error */
    1.25 +void _checkInvalidWindowError()
    1.26 +{
    1.27 +  const char *invalidWindowError = "Invalid window";
    1.28 +  char *lastError;
    1.29 +
    1.30 + lastError = (char *)SDL_GetError();
    1.31 +  SDLTest_AssertPass("SDL_GetError()");
    1.32 +  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
    1.33 +  if (lastError != NULL) {
    1.34 +      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
    1.35 +         "SDL_GetError(): expected message '%s', was message: '%s'",
    1.36 +         invalidWindowError,
    1.37 +         lastError);
    1.38 +      SDL_ClearError();
    1.39 +      SDLTest_AssertPass("Call to SDL_ClearError()");  
    1.40 +  }
    1.41 +}
    1.42 +
    1.43  /**
    1.44   * @brief Tests call to SDL_GetWindowDisplayMode with invalid input
    1.45   *
    1.46 @@ -605,7 +623,6 @@
    1.47  video_getWindowDisplayModeNegative(void *arg)
    1.48  {
    1.49    const char *expectedError = "Parameter 'mode' is invalid";
    1.50 -  const char *invalidWindowError = "Invalid window";
    1.51    char *lastError;
    1.52    SDL_Window* window;
    1.53    const char* title = "video_getWindowDisplayModeNegative Test Window";
    1.54 @@ -636,16 +653,8 @@
    1.55    result = SDL_GetWindowDisplayMode(NULL, &mode);
    1.56    SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(window=NULL,...)");
    1.57    SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result);
    1.58 -  lastError = (char *)SDL_GetError();
    1.59 -  SDLTest_AssertPass("SDL_GetError()");
    1.60 -  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
    1.61 -  if (lastError != NULL) {
    1.62 -      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
    1.63 -         "SDL_GetError(): expected message '%s', was message: '%s'",
    1.64 -         invalidWindowError,
    1.65 -         lastError);
    1.66 -  }
    1.67 -  
    1.68 +  _checkInvalidWindowError();
    1.69 +
    1.70    return TEST_COMPLETED;
    1.71  }
    1.72  
    1.73 @@ -718,28 +727,21 @@
    1.74  int
    1.75  video_getWindowGammaRampNegative(void *arg)
    1.76  {
    1.77 -  const char *invalidWindowError = "Invalid window";
    1.78 -  char *lastError;
    1.79    const char* title = "video_getWindowGammaRampNegative Test Window";
    1.80    Uint16 red[256];
    1.81    Uint16 green[256];
    1.82    Uint16 blue[256];
    1.83    int result;
    1.84  
    1.85 +  SDL_ClearError();
    1.86 +  SDLTest_AssertPass("Call to SDL_ClearError()");
    1.87 +
    1.88    /* Call against invalid window */ 
    1.89    result = SDL_GetWindowGammaRamp(NULL, red, green, blue);
    1.90    SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(window=NULL,r,g,b)");
    1.91    SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %f", result);
    1.92 -  lastError = (char *)SDL_GetError();
    1.93 -  SDLTest_AssertPass("SDL_GetError()");
    1.94 -  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
    1.95 -  if (lastError != NULL) {
    1.96 -      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
    1.97 -         "SDL_GetError(): expected message '%s', was message: '%s'",
    1.98 -         invalidWindowError,
    1.99 -         lastError);
   1.100 -  }
   1.101 -
   1.102 +  _checkInvalidWindowError();
   1.103 +  
   1.104    return TEST_COMPLETED;
   1.105  }
   1.106  
   1.107 @@ -772,8 +774,6 @@
   1.108  int
   1.109  video_getSetWindowGrab(void *arg)
   1.110  {
   1.111 -  const char *invalidWindowError = "Invalid window";
   1.112 -  char *lastError;
   1.113    const char* title = "video_getSetWindowGrab Test Window";
   1.114    SDL_Window* window;
   1.115    SDL_bool originalState, dummyState, currentState, desiredState;
   1.116 @@ -804,39 +804,15 @@
   1.117    /* Negative tests */
   1.118    dummyState = SDL_GetWindowGrab(NULL);
   1.119    SDLTest_AssertPass("Call to SDL_GetWindowGrab(window=NULL)");
   1.120 -  lastError = (char *)SDL_GetError();
   1.121 -  SDLTest_AssertPass("SDL_GetError()");
   1.122 -  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
   1.123 -  if (lastError != NULL) {
   1.124 -      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
   1.125 -         "SDL_GetError(): expected message '%s', was message: '%s'",
   1.126 -         invalidWindowError,
   1.127 -         lastError);
   1.128 -  }
   1.129 +  _checkInvalidWindowError();
   1.130  
   1.131    SDL_SetWindowGrab(NULL, SDL_FALSE);
   1.132    SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
   1.133 -  lastError = (char *)SDL_GetError();
   1.134 -  SDLTest_AssertPass("SDL_GetError()");
   1.135 -  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
   1.136 -  if (lastError != NULL) {
   1.137 -      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
   1.138 -         "SDL_GetError(): expected message '%s', was message: '%s'",
   1.139 -         invalidWindowError,
   1.140 -         lastError);
   1.141 -  }
   1.142 +  _checkInvalidWindowError();
   1.143  
   1.144    SDL_SetWindowGrab(NULL, SDL_TRUE);
   1.145    SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
   1.146 -  lastError = (char *)SDL_GetError();
   1.147 -  SDLTest_AssertPass("SDL_GetError()");
   1.148 -  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
   1.149 -  if (lastError != NULL) {
   1.150 -      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
   1.151 -         "SDL_GetError(): expected message '%s', was message: '%s'",
   1.152 -         invalidWindowError,
   1.153 -         lastError);
   1.154 -  }
   1.155 +  _checkInvalidWindowError();
   1.156    
   1.157    /* State should still be F */
   1.158    desiredState = SDL_FALSE;
   1.159 @@ -857,6 +833,7 @@
   1.160    return TEST_COMPLETED;
   1.161  }
   1.162  
   1.163 +
   1.164  /**
   1.165   * @brief Tests call to SDL_GetWindowID and SDL_GetWindowFromID
   1.166   *
   1.167 @@ -866,8 +843,6 @@
   1.168  int
   1.169  video_getWindowId(void *arg)
   1.170  {
   1.171 -  const char *invalidWindowError = "Invalid window";
   1.172 -  char *lastError;
   1.173    const char* title = "video_getWindowId Test Window";
   1.174    SDL_Window* window;
   1.175    SDL_Window* result;
   1.176 @@ -906,18 +881,12 @@
   1.177    SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
   1.178  
   1.179    /* Negative test */
   1.180 +  SDL_ClearError();
   1.181 +  SDLTest_AssertPass("Call to SDL_ClearError()");
   1.182    id = SDL_GetWindowID(NULL);
   1.183    SDLTest_AssertPass("Call to SDL_GetWindowID(window=NULL)");
   1.184 -  lastError = (char *)SDL_GetError();
   1.185 -  SDLTest_AssertPass("SDL_GetError()");
   1.186 -  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
   1.187 -  if (lastError != NULL) {
   1.188 -      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
   1.189 -         "SDL_GetError(): expected message '%s', was message: '%s'",
   1.190 -         invalidWindowError,
   1.191 -         lastError);
   1.192 -  }
   1.193 -
   1.194 +  _checkInvalidWindowError();
   1.195 +  
   1.196    return TEST_COMPLETED;
   1.197  }
   1.198  
   1.199 @@ -929,8 +898,6 @@
   1.200  int
   1.201  video_getWindowPixelFormat(void *arg)
   1.202  {
   1.203 -  const char *invalidWindowError = "Invalid window";
   1.204 -  char *lastError;
   1.205    const char* title = "video_getWindowPixelFormat Test Window";
   1.206    SDL_Window* window;
   1.207    Uint32 format;
   1.208 @@ -948,17 +915,11 @@
   1.209    _destroyVideoSuiteTestWindow(window);
   1.210      
   1.211    /* Negative test */
   1.212 +  SDL_ClearError();
   1.213 +  SDLTest_AssertPass("Call to SDL_ClearError()");
   1.214    format = SDL_GetWindowPixelFormat(NULL);
   1.215    SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat(window=NULL)");
   1.216 -  lastError = (char *)SDL_GetError();
   1.217 -  SDLTest_AssertPass("SDL_GetError()");
   1.218 -  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
   1.219 -  if (lastError != NULL) {
   1.220 -      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
   1.221 -         "SDL_GetError(): expected message '%s', was message: '%s'",
   1.222 -         invalidWindowError,
   1.223 -         lastError);
   1.224 -  }
   1.225 +  _checkInvalidWindowError();
   1.226  
   1.227    return TEST_COMPLETED;
   1.228  }
   1.229 @@ -972,8 +933,6 @@
   1.230  int
   1.231  video_getSetWindowPosition(void *arg)
   1.232  {
   1.233 -  const char *invalidWindowError = "Invalid window";
   1.234 -  char *lastError;
   1.235    const char* title = "video_getSetWindowPosition Test Window";
   1.236    SDL_Window* window;
   1.237    int xVariation, yVariation;
   1.238 @@ -1065,8 +1024,10 @@
   1.239    currentY = referenceY;
   1.240    desiredX = SDLTest_RandomSint32();
   1.241    desiredY = SDLTest_RandomSint32();
   1.242 -  
   1.243 +
   1.244    /* Negative tests */
   1.245 +  SDL_ClearError();
   1.246 +  SDLTest_AssertPass("Call to SDL_ClearError()");  
   1.247    SDL_GetWindowPosition(NULL, &currentX, &currentY);
   1.248    SDLTest_AssertPass("Call to SDL_GetWindowPosition(window=NULL)");
   1.249    SDLTest_AssertCheck(
   1.250 @@ -1074,39 +1035,453 @@
   1.251    	"Verify that content of X and Y pointers has not been modified; expected: %d,%d; got: %d,%d",
   1.252    	referenceX, referenceY,
   1.253    	currentX, currentY);
   1.254 +  _checkInvalidWindowError();
   1.255 +
   1.256 +  SDL_GetWindowPosition(NULL, NULL, NULL);
   1.257 +  SDLTest_AssertPass("Call to SDL_GetWindowPosition(NULL, NULL, NULL)");
   1.258 +  _checkInvalidWindowError();
   1.259 +
   1.260 +  SDL_SetWindowPosition(NULL, desiredX, desiredY);
   1.261 +  SDLTest_AssertPass("Call to SDL_SetWindowPosition(window=NULL)");
   1.262 +  _checkInvalidWindowError();
   1.263 +  
   1.264 +  return TEST_COMPLETED;
   1.265 +}
   1.266 +
   1.267 +/* Helper function that checks for an 'Invalid parameter' error */
   1.268 +void _checkInvalidParameterError()
   1.269 +{
   1.270 +  const char *invalidParameterError = "Parameter";
   1.271 +  char *lastError;
   1.272 +
   1.273    lastError = (char *)SDL_GetError();
   1.274    SDLTest_AssertPass("SDL_GetError()");
   1.275    SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
   1.276    if (lastError != NULL) {
   1.277 -      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
   1.278 -         "SDL_GetError(): expected message '%s', was message: '%s'",
   1.279 -         invalidWindowError,
   1.280 +      SDLTest_AssertCheck(SDL_strncmp(lastError, invalidParameterError, SDL_strlen(invalidParameterError)) == 0,
   1.281 +         "SDL_GetError(): expected message starts with '%s', was message: '%s'",
   1.282 +         invalidParameterError,
   1.283           lastError);
   1.284 +      SDL_ClearError();
   1.285 +      SDLTest_AssertPass("Call to SDL_ClearError()");  
   1.286 +  }
   1.287 +}
   1.288 +
   1.289 +/**
   1.290 + * @brief Tests call to SDL_GetWindowSize and SDL_SetWindowSize
   1.291 + *
   1.292 + * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowSize
   1.293 + * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowSize
   1.294 + */
   1.295 +int
   1.296 +video_getSetWindowSize(void *arg)
   1.297 +{
   1.298 +  const char* title = "video_getSetWindowSize Test Window";
   1.299 +  SDL_Window* window;
   1.300 +  int result;
   1.301 +  SDL_Rect display;
   1.302 +  int wVariation, hVariation;
   1.303 +  int referenceW, referenceH;
   1.304 +  int currentW, currentH;
   1.305 +  int desiredW, desiredH;
   1.306 +
   1.307 +  /* Get display bounds for size range */
   1.308 +  result = SDL_GetDisplayBounds(0, &display);
   1.309 +  SDLTest_AssertPass("SDL_GetDisplayBounds()");
   1.310 +  SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
   1.311 +  if (result != 0) return TEST_ABORTED;
   1.312 +  
   1.313 +  /* Call against new test window */ 
   1.314 +  window = _createVideoSuiteTestWindow(title);
   1.315 +  if (window == NULL) return TEST_ABORTED;
   1.316 +  
   1.317 +  for (wVariation = 0; wVariation < 4; wVariation++) {
   1.318 +   for (hVariation = 0; hVariation < 4; hVariation++) {
   1.319 +    switch(wVariation) {
   1.320 +     case 0:
   1.321 +      /* 1 Pixel Wide */  
   1.322 +      desiredW = 1;
   1.323 +      break;
   1.324 +     case 1:
   1.325 +      /* Random width inside screen */  
   1.326 +      desiredW = SDLTest_RandomIntegerInRange(1, 100);
   1.327 +      break;
   1.328 +     case 2:
   1.329 +      /* Width at screen size */  
   1.330 +      desiredW = display.w;
   1.331 +      break;
   1.332 +     case 3:
   1.333 +      /* Width 1 pixel larger than screen */  
   1.334 +      desiredW = display.w + 1;
   1.335 +      break;
   1.336 +    }
   1.337 +
   1.338 +    switch(hVariation) {
   1.339 +     case 0:
   1.340 +      /* 1 Pixel High */  
   1.341 +      desiredH = 1;
   1.342 +      break;
   1.343 +     case 1:
   1.344 +      /* Random height inside screen */  
   1.345 +      desiredH = SDLTest_RandomIntegerInRange(1, 100);
   1.346 +      break;
   1.347 +     case 2:
   1.348 +      /* Height at screen size */  
   1.349 +      desiredH = display.h;
   1.350 +      break;
   1.351 +     case 3:
   1.352 +      /* Height 1 pixel larger than screen */  
   1.353 +      desiredH = display.h + 1;
   1.354 +      break;
   1.355 +    }
   1.356 +
   1.357 +    /* Set size */
   1.358 +    SDL_SetWindowSize(window, desiredW, desiredH);
   1.359 +    SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH);
   1.360 +   
   1.361 +    /* Get size */
   1.362 +    currentW = desiredW + 1;
   1.363 +    currentH = desiredH + 1;
   1.364 +    SDL_GetWindowSize(window, &currentW, &currentH);
   1.365 +    SDLTest_AssertPass("Call to SDL_GetWindowSize()");
   1.366 +    SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
   1.367 +    SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
   1.368 +
   1.369 +    /* Get just width */
   1.370 +    currentW = desiredW + 1;    
   1.371 +    SDL_GetWindowSize(window, &currentW, NULL);
   1.372 +    SDLTest_AssertPass("Call to SDL_GetWindowSize(&h=NULL)");
   1.373 +    SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
   1.374 +
   1.375 +    /* Get just height */
   1.376 +    currentH = desiredH + 1;
   1.377 +    SDL_GetWindowSize(window, NULL, &currentH);
   1.378 +    SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL)");
   1.379 +    SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
   1.380 +   }
   1.381    }
   1.382  
   1.383 -  SDL_GetWindowPosition(NULL, NULL, NULL);
   1.384 -  SDLTest_AssertPass("Call to SDL_GetWindowPosition(NULL, NULL, NULL)");
   1.385 -  lastError = (char *)SDL_GetError();
   1.386 -  SDLTest_AssertPass("SDL_GetError()");
   1.387 -  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
   1.388 -  if (lastError != NULL) {
   1.389 -      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
   1.390 -         "SDL_GetError(): expected message '%s', was message: '%s'",
   1.391 -         invalidWindowError,
   1.392 -         lastError);
   1.393 +  /* Dummy call with both pointers NULL */
   1.394 +  SDL_GetWindowSize(window, NULL, NULL);
   1.395 +  SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL,&h=NULL)");
   1.396 +
   1.397 +  /* Negative tests for parameter input */
   1.398 +  SDL_ClearError();
   1.399 +  SDLTest_AssertPass("Call to SDL_ClearError()");  
   1.400 +  for (desiredH = -2; desiredH < 2; desiredH++) {
   1.401 +    for (desiredW = -2; desiredW < 2; desiredW++) {
   1.402 +      if (desiredW <= 0 || desiredH <= 0) { 
   1.403 +        SDL_SetWindowSize(window, desiredW, desiredH);
   1.404 +        SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH);
   1.405 +        _checkInvalidParameterError();
   1.406 +      }
   1.407 +    }
   1.408 +  }
   1.409 +   
   1.410 +  /* Clean up */    
   1.411 +  _destroyVideoSuiteTestWindow(window);
   1.412 +    
   1.413 +  /* Set some 'magic' value for later check that nothing was changed */
   1.414 +  referenceW = SDLTest_RandomSint32();
   1.415 +  referenceH = SDLTest_RandomSint32();
   1.416 +  currentW = referenceW;
   1.417 +  currentH = referenceH;
   1.418 +  desiredW = SDLTest_RandomSint32();
   1.419 +  desiredH = SDLTest_RandomSint32();
   1.420 +  
   1.421 +  /* Negative tests for window input */
   1.422 +  SDL_ClearError();
   1.423 +  SDLTest_AssertPass("Call to SDL_ClearError()");
   1.424 +  SDL_GetWindowSize(NULL, &currentW, &currentH);
   1.425 +  SDLTest_AssertPass("Call to SDL_GetWindowSize(window=NULL)");
   1.426 +  SDLTest_AssertCheck(
   1.427 +  	currentW == referenceW && currentH == referenceH, 
   1.428 +  	"Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
   1.429 +  	referenceW, referenceH,
   1.430 +  	currentW, currentH);
   1.431 +  _checkInvalidWindowError();
   1.432 +
   1.433 +  SDL_GetWindowSize(NULL, NULL, NULL);
   1.434 +  SDLTest_AssertPass("Call to SDL_GetWindowSize(NULL, NULL, NULL)");
   1.435 +  _checkInvalidWindowError();
   1.436 +
   1.437 +  SDL_SetWindowSize(NULL, desiredW, desiredH);
   1.438 +  SDLTest_AssertPass("Call to SDL_SetWindowSize(window=NULL)");
   1.439 +  _checkInvalidWindowError();
   1.440 +  
   1.441 +  return TEST_COMPLETED;
   1.442 +}
   1.443 +
   1.444 +/**
   1.445 + * @brief Tests call to SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize
   1.446 + *
   1.447 + */
   1.448 +int
   1.449 +video_getSetWindowMinimumSize(void *arg)
   1.450 +{
   1.451 +  const char* title = "video_getSetWindowMinimumSize Test Window";
   1.452 +  SDL_Window* window;
   1.453 +  int result;
   1.454 +  SDL_Rect display;
   1.455 +  int wVariation, hVariation;
   1.456 +  int referenceW, referenceH;
   1.457 +  int currentW, currentH;
   1.458 +  int desiredW, desiredH;
   1.459 +
   1.460 +  /* Get display bounds for size range */
   1.461 +  result = SDL_GetDisplayBounds(0, &display);
   1.462 +  SDLTest_AssertPass("SDL_GetDisplayBounds()");
   1.463 +  SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
   1.464 +  if (result != 0) return TEST_ABORTED;
   1.465 +
   1.466 +  /* Call against new test window */ 
   1.467 +  window = _createVideoSuiteTestWindow(title);
   1.468 +  if (window == NULL) return TEST_ABORTED;
   1.469 +  
   1.470 +  for (wVariation = 0; wVariation < 5; wVariation++) {
   1.471 +   for (hVariation = 0; hVariation < 5; hVariation++) {
   1.472 +    switch(wVariation) {
   1.473 +     case 0:
   1.474 +      /* 1 Pixel Wide */  
   1.475 +      desiredW = 1;
   1.476 +      break;
   1.477 +     case 1:
   1.478 +      /* Random width inside screen */  
   1.479 +      desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1);
   1.480 +      break;
   1.481 +     case 2:
   1.482 +      /* Width at screen size */  
   1.483 +      desiredW = display.w;
   1.484 +      break;
   1.485 +    }
   1.486 +
   1.487 +    switch(hVariation) {
   1.488 +     case 0:
   1.489 +      /* 1 Pixel High */  
   1.490 +      desiredH = 1;
   1.491 +      break;
   1.492 +     case 1:
   1.493 +      /* Random height inside screen */  
   1.494 +      desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1);
   1.495 +      break;
   1.496 +     case 2:
   1.497 +      /* Height at screen size */  
   1.498 +      desiredH = display.h;
   1.499 +      break;
   1.500 +     case 4:
   1.501 +      /* Height 1 pixel larger than screen */  
   1.502 +      desiredH = display.h + 1;
   1.503 +      break;
   1.504 +    }
   1.505 +
   1.506 +    /* Set size */
   1.507 +    SDL_SetWindowMinimumSize(window, desiredW, desiredH);
   1.508 +    SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH);
   1.509 +   
   1.510 +    /* Get size */
   1.511 +    currentW = desiredW + 1;
   1.512 +    currentH = desiredH + 1;
   1.513 +    SDL_GetWindowMinimumSize(window, &currentW, &currentH);
   1.514 +    SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize()");
   1.515 +    SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
   1.516 +    SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
   1.517 +
   1.518 +    /* Get just width */
   1.519 +    currentW = desiredW + 1;    
   1.520 +    SDL_GetWindowMinimumSize(window, &currentW, NULL);
   1.521 +    SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&h=NULL)");
   1.522 +    SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
   1.523 +
   1.524 +    /* Get just height */
   1.525 +    currentH = desiredH + 1;
   1.526 +    SDL_GetWindowMinimumSize(window, NULL, &currentH);
   1.527 +    SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL)");
   1.528 +    SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
   1.529 +   }
   1.530    }
   1.531  
   1.532 -  SDL_SetWindowPosition(NULL, desiredX, desiredY);
   1.533 -  SDLTest_AssertPass("Call to SDL_SetWindowPosition(window=NULL)");
   1.534 -  lastError = (char *)SDL_GetError();
   1.535 -  SDLTest_AssertPass("SDL_GetError()");
   1.536 -  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
   1.537 -  if (lastError != NULL) {
   1.538 -      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
   1.539 -         "SDL_GetError(): expected message '%s', was message: '%s'",
   1.540 -         invalidWindowError,
   1.541 -         lastError);
   1.542 +  /* Dummy call with both pointers NULL */
   1.543 +  SDL_GetWindowMinimumSize(window, NULL, NULL);
   1.544 +  SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL,&h=NULL)");
   1.545 +
   1.546 +  /* Negative tests for parameter input */
   1.547 +  SDL_ClearError();
   1.548 +  SDLTest_AssertPass("Call to SDL_ClearError()");  
   1.549 +  for (desiredH = -2; desiredH < 2; desiredH++) {
   1.550 +    for (desiredW = -2; desiredW < 2; desiredW++) {
   1.551 +      if (desiredW <= 0 || desiredH <= 0) { 
   1.552 +        SDL_SetWindowMinimumSize(window, desiredW, desiredH);
   1.553 +        SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH);
   1.554 +        _checkInvalidParameterError();
   1.555 +      }
   1.556 +    }
   1.557    }
   1.558 +   
   1.559 +  /* Clean up */    
   1.560 +  _destroyVideoSuiteTestWindow(window);
   1.561 +    
   1.562 +  /* Set some 'magic' value for later check that nothing was changed */
   1.563 +  referenceW = SDLTest_RandomSint32();
   1.564 +  referenceH = SDLTest_RandomSint32();
   1.565 +  currentW = referenceW;
   1.566 +  currentH = referenceH;
   1.567 +  desiredW = SDLTest_RandomSint32();
   1.568 +  desiredH = SDLTest_RandomSint32();
   1.569 +  
   1.570 +  /* Negative tests for window input */
   1.571 +  SDL_ClearError();
   1.572 +  SDLTest_AssertPass("Call to SDL_ClearError()");
   1.573 +  SDL_GetWindowMinimumSize(NULL, &currentW, &currentH);
   1.574 +  SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(window=NULL)");
   1.575 +  SDLTest_AssertCheck(
   1.576 +  	currentW == referenceW && currentH == referenceH, 
   1.577 +  	"Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
   1.578 +  	referenceW, referenceH,
   1.579 +  	currentW, currentH);
   1.580 +  _checkInvalidWindowError();
   1.581 +
   1.582 +  SDL_GetWindowMinimumSize(NULL, NULL, NULL);
   1.583 +  SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(NULL, NULL, NULL)");
   1.584 +  _checkInvalidWindowError();
   1.585 +
   1.586 +  SDL_SetWindowMinimumSize(NULL, desiredW, desiredH);
   1.587 +  SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(window=NULL)");
   1.588 +  _checkInvalidWindowError();
   1.589 +  
   1.590 +  return TEST_COMPLETED;
   1.591 +}
   1.592 +
   1.593 +/**
   1.594 + * @brief Tests call to SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize
   1.595 + *
   1.596 + */
   1.597 +int
   1.598 +video_getSetWindowMaximumSize(void *arg)
   1.599 +{
   1.600 +  const char* title = "video_getSetWindowMaximumSize Test Window";
   1.601 +  SDL_Window* window;
   1.602 +  int result;
   1.603 +  SDL_Rect display;
   1.604 +  int wVariation, hVariation;
   1.605 +  int referenceW, referenceH;
   1.606 +  int currentW, currentH;
   1.607 +  int desiredW, desiredH;
   1.608 +
   1.609 +  /* Get display bounds for size range */
   1.610 +  result = SDL_GetDisplayBounds(0, &display);
   1.611 +  SDLTest_AssertPass("SDL_GetDisplayBounds()");
   1.612 +  SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
   1.613 +  if (result != 0) return TEST_ABORTED;
   1.614 +
   1.615 +  /* Call against new test window */ 
   1.616 +  window = _createVideoSuiteTestWindow(title);
   1.617 +  if (window == NULL) return TEST_ABORTED;
   1.618 +  
   1.619 +  for (wVariation = 0; wVariation < 3; wVariation++) {
   1.620 +   for (hVariation = 0; hVariation < 3; hVariation++) {
   1.621 +    switch(wVariation) {
   1.622 +     case 0:
   1.623 +      /* 1 Pixel Wide */  
   1.624 +      desiredW = 1;
   1.625 +      break;
   1.626 +     case 1:
   1.627 +      /* Random width inside screen */  
   1.628 +      desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1);
   1.629 +      break;
   1.630 +     case 2:
   1.631 +      /* Width at screen size */  
   1.632 +      desiredW = display.w;
   1.633 +      break;
   1.634 +    }
   1.635 +
   1.636 +    switch(hVariation) {
   1.637 +     case 0:
   1.638 +      /* 1 Pixel High */  
   1.639 +      desiredH = 1;
   1.640 +      break;
   1.641 +     case 1:
   1.642 +      /* Random height inside screen */  
   1.643 +      desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1);
   1.644 +      break;
   1.645 +     case 2:
   1.646 +      /* Height at screen size */  
   1.647 +      desiredH = display.h;
   1.648 +      break;
   1.649 +    }
   1.650 +
   1.651 +    /* Set size */
   1.652 +    SDL_SetWindowMaximumSize(window, desiredW, desiredH);
   1.653 +    SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH);
   1.654 +   
   1.655 +    /* Get size */
   1.656 +    currentW = desiredW + 1;
   1.657 +    currentH = desiredH + 1;
   1.658 +    SDL_GetWindowMaximumSize(window, &currentW, &currentH);
   1.659 +    SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize()");
   1.660 +    SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
   1.661 +    SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
   1.662 +
   1.663 +    /* Get just width */
   1.664 +    currentW = desiredW + 1;    
   1.665 +    SDL_GetWindowMaximumSize(window, &currentW, NULL);
   1.666 +    SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&h=NULL)");
   1.667 +    SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
   1.668 +
   1.669 +    /* Get just height */
   1.670 +    currentH = desiredH + 1;
   1.671 +    SDL_GetWindowMaximumSize(window, NULL, &currentH);
   1.672 +    SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL)");
   1.673 +    SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
   1.674 +   }
   1.675 +  }
   1.676 +
   1.677 +  /* Dummy call with both pointers NULL */
   1.678 +  SDL_GetWindowMaximumSize(window, NULL, NULL);
   1.679 +  SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL,&h=NULL)");
   1.680 +
   1.681 +  /* Negative tests for parameter input */
   1.682 +  SDL_ClearError();
   1.683 +  SDLTest_AssertPass("Call to SDL_ClearError()");  
   1.684 +  for (desiredH = -2; desiredH < 2; desiredH++) {
   1.685 +    for (desiredW = -2; desiredW < 2; desiredW++) {
   1.686 +      if (desiredW <= 0 || desiredH <= 0) { 
   1.687 +        SDL_SetWindowMaximumSize(window, desiredW, desiredH);
   1.688 +        SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH);
   1.689 +        _checkInvalidParameterError();
   1.690 +      }
   1.691 +    }
   1.692 +  }
   1.693 +   
   1.694 +  /* Clean up */    
   1.695 +  _destroyVideoSuiteTestWindow(window);
   1.696 +    
   1.697 +  /* Set some 'magic' value for later check that nothing was changed */
   1.698 +  referenceW = SDLTest_RandomSint32();
   1.699 +  referenceH = SDLTest_RandomSint32();
   1.700 +  currentW = referenceW;
   1.701 +  currentH = referenceH;
   1.702 +  desiredW = SDLTest_RandomSint32();
   1.703 +  desiredH = SDLTest_RandomSint32();
   1.704 +  
   1.705 +  /* Negative tests */
   1.706 +  SDL_ClearError();
   1.707 +  SDLTest_AssertPass("Call to SDL_ClearError()");
   1.708 +  SDL_GetWindowMaximumSize(NULL, &currentW, &currentH);
   1.709 +  SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(window=NULL)");
   1.710 +  SDLTest_AssertCheck(
   1.711 +  	currentW == referenceW && currentH == referenceH, 
   1.712 +  	"Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
   1.713 +  	referenceW, referenceH,
   1.714 +  	currentW, currentH);
   1.715 +  _checkInvalidWindowError();
   1.716 +
   1.717 +  SDL_GetWindowMaximumSize(NULL, NULL, NULL);
   1.718 +  SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(NULL, NULL, NULL)");
   1.719 +  _checkInvalidWindowError();
   1.720 +
   1.721 +  SDL_SetWindowMaximumSize(NULL, desiredW, desiredH);
   1.722 +  SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(window=NULL)");
   1.723 +  _checkInvalidWindowError();
   1.724    
   1.725    return TEST_COMPLETED;
   1.726  }
   1.727 @@ -1160,7 +1535,7 @@
   1.728  		{ (SDLTest_TestCaseFp)video_getWindowGammaRampNegative, "video_getWindowGammaRampNegative",  "Get window gamma ramp against invalid input", TEST_ENABLED };
   1.729  
   1.730  static const SDLTest_TestCaseReference videoTest16 =
   1.731 -		{ (SDLTest_TestCaseFp)video_getSetWindowGrab, "video_getSetWindowGrab",  "Checks SDL_GetWindowGrab and SDL_SetWindowGrab", TEST_ENABLED };
   1.732 +		{ (SDLTest_TestCaseFp)video_getSetWindowGrab, "video_getSetWindowGrab",  "Checks SDL_GetWindowGrab and SDL_SetWindowGrab positive and negative cases", TEST_ENABLED };
   1.733  
   1.734  static const SDLTest_TestCaseReference videoTest17 =
   1.735  		{ (SDLTest_TestCaseFp)video_getWindowId, "video_getWindowId",  "Checks SDL_GetWindowID and SDL_GetWindowFromID", TEST_ENABLED };
   1.736 @@ -1169,14 +1544,24 @@
   1.737  		{ (SDLTest_TestCaseFp)video_getWindowPixelFormat, "video_getWindowPixelFormat",  "Checks SDL_GetWindowPixelFormat", TEST_ENABLED };
   1.738  
   1.739  static const SDLTest_TestCaseReference videoTest19 =
   1.740 -		{ (SDLTest_TestCaseFp)video_getSetWindowPosition, "video_getSetWindowPosition",  "Checks SDL_GetWindowPosition and SDL_SetWindowPosition", TEST_ENABLED };
   1.741 +		{ (SDLTest_TestCaseFp)video_getSetWindowPosition, "video_getSetWindowPosition",  "Checks SDL_GetWindowPosition and SDL_SetWindowPosition positive and negative cases", TEST_ENABLED };
   1.742 +
   1.743 +static const SDLTest_TestCaseReference videoTest20 =
   1.744 +		{ (SDLTest_TestCaseFp)video_getSetWindowSize, "video_getSetWindowSize",  "Checks SDL_GetWindowSize and SDL_SetWindowSize positive and negative cases", TEST_ENABLED };
   1.745 +
   1.746 +static const SDLTest_TestCaseReference videoTest21 =
   1.747 +		{ (SDLTest_TestCaseFp)video_getSetWindowMinimumSize, "video_getSetWindowMinimumSize",  "Checks SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize positive and negative cases", TEST_ENABLED };
   1.748 +
   1.749 +static const SDLTest_TestCaseReference videoTest22 =
   1.750 +		{ (SDLTest_TestCaseFp)video_getSetWindowMaximumSize, "video_getSetWindowMaximumSize",  "Checks SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize positive and negative cases", TEST_ENABLED };
   1.751  
   1.752  /* Sequence of Video test cases */
   1.753  static const SDLTest_TestCaseReference *videoTests[] =  {
   1.754  	&videoTest1, &videoTest2, &videoTest3, &videoTest4, &videoTest5, &videoTest6, 
   1.755  	&videoTest7, &videoTest8, &videoTest9, &videoTest10, &videoTest11, &videoTest12, 
   1.756  	&videoTest13, &videoTest14, &videoTest15, &videoTest16, &videoTest17, 
   1.757 -	&videoTest18, &videoTest19, NULL
   1.758 +	&videoTest18, &videoTest19, &videoTest20, &videoTest21, &videoTest22, 
   1.759 +	NULL
   1.760  };
   1.761  
   1.762  /* Video test suite (global) */