Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
authorAndreas Schiffler <aschiffler@ferzkopp.net>
Sun, 03 Mar 2013 17:22:51 -0800
changeset 6956afdc35fa58e9
parent 6955 a3ebd92ff0b2
child 6957 a35f752269d8
Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
src/video/SDL_video.c
test/testautomation_video.c
     1.1 --- a/src/video/SDL_video.c	Sun Mar 03 11:25:43 2013 -0800
     1.2 +++ b/src/video/SDL_video.c	Sun Mar 03 17:22:51 2013 -0800
     1.3 @@ -1524,18 +1524,16 @@
     1.4  void
     1.5  SDL_GetWindowPosition(SDL_Window * window, int *x, int *y)
     1.6  {
     1.7 -    /* Clear the values */
     1.8 -    if (x) {
     1.9 -        *x = 0;
    1.10 -    }
    1.11 -    if (y) {
    1.12 -        *y = 0;
    1.13 -    }
    1.14 -
    1.15      CHECK_WINDOW_MAGIC(window, );
    1.16  
    1.17      /* Fullscreen windows are always at their display's origin */
    1.18      if (window->flags & SDL_WINDOW_FULLSCREEN) {
    1.19 +        if (x) {
    1.20 +            *x = 0;
    1.21 +        }
    1.22 +        if (y) {
    1.23 +            *y = 0;
    1.24 +        }
    1.25      } else {
    1.26          if (x) {
    1.27              *x = window->x;
     2.1 --- a/test/testautomation_video.c	Sun Mar 03 11:25:43 2013 -0800
     2.2 +++ b/test/testautomation_video.c	Sun Mar 03 17:22:51 2013 -0800
     2.3 @@ -4,6 +4,16 @@
     2.4  
     2.5  #include <stdio.h>
     2.6  
     2.7 +/* Visual Studio 2008 doesn't have stdint.h */
     2.8 +#if defined(_MSC_VER) && _MSC_VER <= 1500
     2.9 +#define UINT8_MAX   ~(Uint8)0
    2.10 +#define UINT16_MAX  ~(Uint16)0
    2.11 +#define UINT32_MAX  ~(Uint32)0
    2.12 +#define UINT64_MAX  ~(Uint64)0
    2.13 +#else
    2.14 +#include <stdint.h>
    2.15 +#endif
    2.16 +
    2.17  #include "SDL.h"
    2.18  #include "SDL_test.h"
    2.19  
    2.20 @@ -656,43 +666,43 @@
    2.21  
    2.22    /* Call against new test window */ 
    2.23    window = _createVideoSuiteTestWindow(title);
    2.24 -  if (window != NULL) {
    2.25 -      /* Retrieve no channel */
    2.26 -      result = SDL_GetWindowGammaRamp(window, NULL, NULL, NULL);
    2.27 -      SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(all NULL)");
    2.28 -      SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
    2.29 +  if (window == NULL) return TEST_ABORTED;
    2.30 +  
    2.31 +  /* Retrieve no channel */
    2.32 +  result = SDL_GetWindowGammaRamp(window, NULL, NULL, NULL);
    2.33 +  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(all NULL)");
    2.34 +  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
    2.35  
    2.36 -      /* Retrieve single channel */
    2.37 -      result = SDL_GetWindowGammaRamp(window, red, NULL, NULL);
    2.38 -      SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r)");
    2.39 -      SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
    2.40 +  /* Retrieve single channel */
    2.41 +  result = SDL_GetWindowGammaRamp(window, red, NULL, NULL);
    2.42 +  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r)");
    2.43 +  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
    2.44  
    2.45 -      result = SDL_GetWindowGammaRamp(window, NULL, green, NULL);
    2.46 -      SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(g)");
    2.47 -      SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
    2.48 +  result = SDL_GetWindowGammaRamp(window, NULL, green, NULL);
    2.49 +  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(g)");
    2.50 +  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
    2.51  
    2.52 -      result = SDL_GetWindowGammaRamp(window, NULL, NULL, blue);
    2.53 -      SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(b)");
    2.54 -      SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
    2.55 +  result = SDL_GetWindowGammaRamp(window, NULL, NULL, blue);
    2.56 +  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(b)");
    2.57 +  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
    2.58  
    2.59 -      /* Retrieve two channels */
    2.60 -      result = SDL_GetWindowGammaRamp(window, red, green, NULL);
    2.61 -      SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r, g)");
    2.62 -      SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
    2.63 +  /* Retrieve two channels */
    2.64 +  result = SDL_GetWindowGammaRamp(window, red, green, NULL);
    2.65 +  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r, g)");
    2.66 +  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
    2.67  
    2.68 -      result = SDL_GetWindowGammaRamp(window, NULL, green, blue);
    2.69 -      SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(g,b)");
    2.70 -      SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
    2.71 +  result = SDL_GetWindowGammaRamp(window, NULL, green, blue);
    2.72 +  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(g,b)");
    2.73 +  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
    2.74  
    2.75 -      result = SDL_GetWindowGammaRamp(window, red, NULL, blue);
    2.76 -      SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r,b)");
    2.77 -      SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
    2.78 +  result = SDL_GetWindowGammaRamp(window, red, NULL, blue);
    2.79 +  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r,b)");
    2.80 +  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
    2.81  
    2.82 -      /* Retrieve all channels */
    2.83 -      result = SDL_GetWindowGammaRamp(window, red, green, blue);
    2.84 -      SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r,g,b)");
    2.85 -      SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
    2.86 -  }
    2.87 +  /* Retrieve all channels */
    2.88 +  result = SDL_GetWindowGammaRamp(window, red, green, blue);
    2.89 +  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r,g,b)");
    2.90 +  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
    2.91  
    2.92    /* Clean up */    
    2.93    _destroyVideoSuiteTestWindow(window);
    2.94 @@ -733,6 +743,374 @@
    2.95    return TEST_COMPLETED;
    2.96  }
    2.97  
    2.98 +/* Helper for setting and checking the window grab state */
    2.99 +void 
   2.100 +_setAndCheckWindowGrabState(SDL_Window* window, SDL_bool desiredState)
   2.101 +{
   2.102 +  SDL_bool currentState;
   2.103 +  
   2.104 +  /* Set state */
   2.105 +  SDL_SetWindowGrab(window, desiredState);
   2.106 +  SDLTest_AssertPass("Call to SDL_SetWindowGrab(%s)", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
   2.107 +
   2.108 +  /* Get and check state */
   2.109 +  currentState = SDL_GetWindowGrab(window);
   2.110 +  SDLTest_AssertPass("Call to SDL_GetWindowGrab()");
   2.111 +  SDLTest_AssertCheck(
   2.112 +      currentState == desiredState, 
   2.113 +      "Validate returned state; expected: %s, got: %s", 
   2.114 +      (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE",
   2.115 +      (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
   2.116 +}
   2.117 +
   2.118 +/**
   2.119 + * @brief Tests call to SDL_GetWindowGrab and SDL_SetWindowGrab
   2.120 + *
   2.121 + * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGrab
   2.122 + * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowGrab
   2.123 + */
   2.124 +int
   2.125 +video_getSetWindowGrab(void *arg)
   2.126 +{
   2.127 +  const char *invalidWindowError = "Invalid window";
   2.128 +  char *lastError;
   2.129 +  const char* title = "video_getSetWindowGrab Test Window";
   2.130 +  SDL_Window* window;
   2.131 +  SDL_bool originalState, dummyState, currentState, desiredState;
   2.132 +
   2.133 +  /* Call against new test window */ 
   2.134 +  window = _createVideoSuiteTestWindow(title);
   2.135 +  if (window == NULL) return TEST_ABORTED;
   2.136 +
   2.137 +  /* Get state */  
   2.138 +  originalState = SDL_GetWindowGrab(window);
   2.139 +  SDLTest_AssertPass("Call to SDL_GetWindowGrab()");
   2.140 +
   2.141 +  /* F */
   2.142 +  _setAndCheckWindowGrabState(window, SDL_FALSE);
   2.143 +
   2.144 +  /* F --> F */
   2.145 +  _setAndCheckWindowGrabState(window, SDL_FALSE);
   2.146 +  
   2.147 +  /* F --> T */
   2.148 +  _setAndCheckWindowGrabState(window, SDL_TRUE);
   2.149 +
   2.150 +  /* T --> T */
   2.151 +  _setAndCheckWindowGrabState(window, SDL_TRUE);
   2.152 +
   2.153 +  /* T --> F */
   2.154 +  _setAndCheckWindowGrabState(window, SDL_FALSE);
   2.155 +  
   2.156 +  /* Negative tests */
   2.157 +  dummyState = SDL_GetWindowGrab(NULL);
   2.158 +  SDLTest_AssertPass("Call to SDL_GetWindowGrab(window=NULL)");
   2.159 +  lastError = (char *)SDL_GetError();
   2.160 +  SDLTest_AssertPass("SDL_GetError()");
   2.161 +  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
   2.162 +  if (lastError != NULL) {
   2.163 +      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
   2.164 +         "SDL_GetError(): expected message '%s', was message: '%s'",
   2.165 +         invalidWindowError,
   2.166 +         lastError);
   2.167 +  }
   2.168 +
   2.169 +  SDL_SetWindowGrab(NULL, SDL_FALSE);
   2.170 +  SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
   2.171 +  lastError = (char *)SDL_GetError();
   2.172 +  SDLTest_AssertPass("SDL_GetError()");
   2.173 +  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
   2.174 +  if (lastError != NULL) {
   2.175 +      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
   2.176 +         "SDL_GetError(): expected message '%s', was message: '%s'",
   2.177 +         invalidWindowError,
   2.178 +         lastError);
   2.179 +  }
   2.180 +
   2.181 +  SDL_SetWindowGrab(NULL, SDL_TRUE);
   2.182 +  SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
   2.183 +  lastError = (char *)SDL_GetError();
   2.184 +  SDLTest_AssertPass("SDL_GetError()");
   2.185 +  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
   2.186 +  if (lastError != NULL) {
   2.187 +      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
   2.188 +         "SDL_GetError(): expected message '%s', was message: '%s'",
   2.189 +         invalidWindowError,
   2.190 +         lastError);
   2.191 +  }
   2.192 +  
   2.193 +  /* State should still be F */
   2.194 +  desiredState = SDL_FALSE;
   2.195 +  currentState = SDL_GetWindowGrab(window);
   2.196 +  SDLTest_AssertPass("Call to SDL_GetWindowGrab()");
   2.197 +  SDLTest_AssertCheck(
   2.198 +      currentState == desiredState, 
   2.199 +      "Validate returned state; expected: %s, got: %s", 
   2.200 +      (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE",
   2.201 +      (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
   2.202 +    
   2.203 +  /* Restore state */  
   2.204 +  _setAndCheckWindowGrabState(window, originalState);
   2.205 +
   2.206 +  /* Clean up */    
   2.207 +  _destroyVideoSuiteTestWindow(window);
   2.208 +
   2.209 +  return TEST_COMPLETED;
   2.210 +}
   2.211 +
   2.212 +/**
   2.213 + * @brief Tests call to SDL_GetWindowID and SDL_GetWindowFromID
   2.214 + *
   2.215 + * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowID
   2.216 + * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowFromID
   2.217 + */
   2.218 +int
   2.219 +video_getWindowId(void *arg)
   2.220 +{
   2.221 +  const char *invalidWindowError = "Invalid window";
   2.222 +  char *lastError;
   2.223 +  const char* title = "video_getWindowId Test Window";
   2.224 +  SDL_Window* window;
   2.225 +  SDL_Window* result;
   2.226 +  Uint32 id, randomId;
   2.227 +
   2.228 +  /* Call against new test window */ 
   2.229 +  window = _createVideoSuiteTestWindow(title);
   2.230 +  if (window == NULL) return TEST_ABORTED;
   2.231 +
   2.232 +  /* Get ID */
   2.233 +  id = SDL_GetWindowID(window);
   2.234 +  SDLTest_AssertPass("Call to SDL_GetWindowID()");
   2.235 +
   2.236 +  /* Get window from ID */
   2.237 +  result = SDL_GetWindowFromID(id);
   2.238 +  SDLTest_AssertPass("Call to SDL_GetWindowID(%d)", id);
   2.239 +  SDLTest_AssertCheck(result == window, "Verify result matches window pointer");
   2.240 +
   2.241 +  /* Get window from random large ID, no result check */
   2.242 +  randomId = SDLTest_RandomIntegerInRange(UINT8_MAX,UINT16_MAX);
   2.243 +  result = SDL_GetWindowFromID(randomId);
   2.244 +  SDLTest_AssertPass("Call to SDL_GetWindowID(%d/random_large)", randomId);
   2.245 +
   2.246 +  /* Get window from 0 and Uint32 max ID, no result check */
   2.247 +  result = SDL_GetWindowFromID(0);
   2.248 +  SDLTest_AssertPass("Call to SDL_GetWindowID(0)");
   2.249 +  result = SDL_GetWindowFromID(UINT32_MAX);
   2.250 +  SDLTest_AssertPass("Call to SDL_GetWindowID(UINT32_MAX)");
   2.251 +
   2.252 +  /* Clean up */    
   2.253 +  _destroyVideoSuiteTestWindow(window);
   2.254 +    
   2.255 +  /* Get window from ID for closed window*/
   2.256 +  result = SDL_GetWindowFromID(id);
   2.257 +  SDLTest_AssertPass("Call to SDL_GetWindowID(%d/closed_window)", id);
   2.258 +  SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
   2.259 +
   2.260 +  /* Negative test */
   2.261 +  id = SDL_GetWindowID(NULL);
   2.262 +  SDLTest_AssertPass("Call to SDL_GetWindowID(window=NULL)");
   2.263 +  lastError = (char *)SDL_GetError();
   2.264 +  SDLTest_AssertPass("SDL_GetError()");
   2.265 +  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
   2.266 +  if (lastError != NULL) {
   2.267 +      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
   2.268 +         "SDL_GetError(): expected message '%s', was message: '%s'",
   2.269 +         invalidWindowError,
   2.270 +         lastError);
   2.271 +  }
   2.272 +
   2.273 +  return TEST_COMPLETED;
   2.274 +}
   2.275 +
   2.276 +/**
   2.277 + * @brief Tests call to SDL_GetWindowPixelFormat
   2.278 + *
   2.279 + * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowPixelFormat
   2.280 + */
   2.281 +int
   2.282 +video_getWindowPixelFormat(void *arg)
   2.283 +{
   2.284 +  const char *invalidWindowError = "Invalid window";
   2.285 +  char *lastError;
   2.286 +  const char* title = "video_getWindowPixelFormat Test Window";
   2.287 +  SDL_Window* window;
   2.288 +  Uint32 format;
   2.289 +
   2.290 +  /* Call against new test window */ 
   2.291 +  window = _createVideoSuiteTestWindow(title);
   2.292 +  if (window == NULL) return TEST_ABORTED;
   2.293 +
   2.294 +  /* Get format */
   2.295 +  format = SDL_GetWindowPixelFormat(window);
   2.296 +  SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat()");
   2.297 +  SDLTest_AssertCheck(format != SDL_PIXELFORMAT_UNKNOWN, "Verify that returned format is valid; expected: != %d, got: %d", SDL_PIXELFORMAT_UNKNOWN, format);
   2.298 +   
   2.299 +  /* Clean up */    
   2.300 +  _destroyVideoSuiteTestWindow(window);
   2.301 +    
   2.302 +  /* Negative test */
   2.303 +  format = SDL_GetWindowPixelFormat(NULL);
   2.304 +  SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat(window=NULL)");
   2.305 +  lastError = (char *)SDL_GetError();
   2.306 +  SDLTest_AssertPass("SDL_GetError()");
   2.307 +  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
   2.308 +  if (lastError != NULL) {
   2.309 +      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
   2.310 +         "SDL_GetError(): expected message '%s', was message: '%s'",
   2.311 +         invalidWindowError,
   2.312 +         lastError);
   2.313 +  }
   2.314 +
   2.315 +  return TEST_COMPLETED;
   2.316 +}
   2.317 +
   2.318 +/**
   2.319 + * @brief Tests call to SDL_GetWindowPosition and SDL_SetWindowPosition
   2.320 + *
   2.321 + * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowPosition
   2.322 + * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowPosition
   2.323 + */
   2.324 +int
   2.325 +video_getSetWindowPosition(void *arg)
   2.326 +{
   2.327 +  const char *invalidWindowError = "Invalid window";
   2.328 +  char *lastError;
   2.329 +  const char* title = "video_getSetWindowPosition Test Window";
   2.330 +  SDL_Window* window;
   2.331 +  int xVariation, yVariation;
   2.332 +  int referenceX, referenceY;
   2.333 +  int currentX, currentY;
   2.334 +  int desiredX, desiredY;
   2.335 +
   2.336 +  /* Call against new test window */ 
   2.337 +  window = _createVideoSuiteTestWindow(title);
   2.338 +  if (window == NULL) return TEST_ABORTED;
   2.339 +  
   2.340 +  for (xVariation = 0; xVariation < 4; xVariation++) {
   2.341 +   for (yVariation = 0; yVariation < 4; yVariation++) {
   2.342 +    switch(xVariation) {
   2.343 +     case 0:
   2.344 +      /* Zero X Position */  
   2.345 +      desiredX = 0;
   2.346 +      break;
   2.347 +     case 1:
   2.348 +      /* Random X position inside screen */  
   2.349 +      desiredX = SDLTest_RandomIntegerInRange(1, 100);
   2.350 +      break;
   2.351 +     case 2:
   2.352 +      /* Random X position outside screen (positive) */  
   2.353 +      desiredX = SDLTest_RandomIntegerInRange(10000, 11000);
   2.354 +      break;
   2.355 +     case 3:
   2.356 +      /* Random X position outside screen (negative) */  
   2.357 +      desiredX = SDLTest_RandomIntegerInRange(-1000, -100);
   2.358 +      break;
   2.359 +    }
   2.360 +
   2.361 +    switch(yVariation) {
   2.362 +     case 0:
   2.363 +      /* Zero X Position */  
   2.364 +      desiredY = 0;
   2.365 +      break;
   2.366 +     case 1:
   2.367 +      /* Random X position inside screen */  
   2.368 +      desiredY = SDLTest_RandomIntegerInRange(1, 100);
   2.369 +      break;
   2.370 +     case 2:
   2.371 +      /* Random X position outside screen (positive) */  
   2.372 +      desiredY = SDLTest_RandomIntegerInRange(10000, 11000);
   2.373 +      break;
   2.374 +     case 3:
   2.375 +      /* Random Y position outside screen (negative) */  
   2.376 +      desiredY = SDLTest_RandomIntegerInRange(-1000, -100);
   2.377 +      break;
   2.378 +    }
   2.379 +
   2.380 +    /* Set position */
   2.381 +    SDL_SetWindowPosition(window, desiredX, desiredY);
   2.382 +    SDLTest_AssertPass("Call to SDL_SetWindowPosition(...,%d,%d)", desiredX, desiredY);
   2.383 +   
   2.384 +    /* Get position */
   2.385 +    currentX = desiredX + 1;
   2.386 +    currentY = desiredY + 1;
   2.387 +    SDL_GetWindowPosition(window, &currentX, &currentY);
   2.388 +    SDLTest_AssertPass("Call to SDL_GetWindowPosition()");
   2.389 +    SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX);
   2.390 +    SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY);
   2.391 +
   2.392 +    /* Get position X */
   2.393 +    currentX = desiredX + 1;    
   2.394 +    SDL_GetWindowPosition(window, &currentX, NULL);
   2.395 +    SDLTest_AssertPass("Call to SDL_GetWindowPosition(&y=NULL)");
   2.396 +    SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX);
   2.397 +
   2.398 +    /* Get position Y */
   2.399 +    currentY = desiredY + 1;
   2.400 +    SDL_GetWindowPosition(window, NULL, &currentY);
   2.401 +    SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL)");
   2.402 +    SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY);
   2.403 +   }
   2.404 +  }
   2.405 +
   2.406 +  /* Dummy call with both pointers NULL */
   2.407 +  SDL_GetWindowPosition(window, NULL, NULL);
   2.408 +  SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL,&y=NULL)");
   2.409 +   
   2.410 +  /* Clean up */    
   2.411 +  _destroyVideoSuiteTestWindow(window);
   2.412 +    
   2.413 +  /* Set some 'magic' value for later check that nothing was changed */
   2.414 +  referenceX = SDLTest_RandomSint32();
   2.415 +  referenceY = SDLTest_RandomSint32();
   2.416 +  currentX = referenceX;
   2.417 +  currentY = referenceY;
   2.418 +  desiredX = SDLTest_RandomSint32();
   2.419 +  desiredY = SDLTest_RandomSint32();
   2.420 +  
   2.421 +  /* Negative tests */
   2.422 +  SDL_GetWindowPosition(NULL, &currentX, &currentY);
   2.423 +  SDLTest_AssertPass("Call to SDL_GetWindowPosition(window=NULL)");
   2.424 +  SDLTest_AssertCheck(
   2.425 +  	currentX == referenceX && currentY == referenceY, 
   2.426 +  	"Verify that content of X and Y pointers has not been modified; expected: %d,%d; got: %d,%d",
   2.427 +  	referenceX, referenceY,
   2.428 +  	currentX, currentY);
   2.429 +  lastError = (char *)SDL_GetError();
   2.430 +  SDLTest_AssertPass("SDL_GetError()");
   2.431 +  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
   2.432 +  if (lastError != NULL) {
   2.433 +      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
   2.434 +         "SDL_GetError(): expected message '%s', was message: '%s'",
   2.435 +         invalidWindowError,
   2.436 +         lastError);
   2.437 +  }
   2.438 +
   2.439 +  SDL_GetWindowPosition(NULL, NULL, NULL);
   2.440 +  SDLTest_AssertPass("Call to SDL_GetWindowPosition(NULL, NULL, NULL)");
   2.441 +  lastError = (char *)SDL_GetError();
   2.442 +  SDLTest_AssertPass("SDL_GetError()");
   2.443 +  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
   2.444 +  if (lastError != NULL) {
   2.445 +      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
   2.446 +         "SDL_GetError(): expected message '%s', was message: '%s'",
   2.447 +         invalidWindowError,
   2.448 +         lastError);
   2.449 +  }
   2.450 +
   2.451 +  SDL_SetWindowPosition(NULL, desiredX, desiredY);
   2.452 +  SDLTest_AssertPass("Call to SDL_SetWindowPosition(window=NULL)");
   2.453 +  lastError = (char *)SDL_GetError();
   2.454 +  SDLTest_AssertPass("SDL_GetError()");
   2.455 +  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
   2.456 +  if (lastError != NULL) {
   2.457 +      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
   2.458 +         "SDL_GetError(): expected message '%s', was message: '%s'",
   2.459 +         invalidWindowError,
   2.460 +         lastError);
   2.461 +  }
   2.462 +  
   2.463 +  return TEST_COMPLETED;
   2.464 +}
   2.465 +
   2.466  /* ================= Test References ================== */
   2.467  
   2.468  /* Video test cases */
   2.469 @@ -781,11 +1159,24 @@
   2.470  static const SDLTest_TestCaseReference videoTest15 =
   2.471  		{ (SDLTest_TestCaseFp)video_getWindowGammaRampNegative, "video_getWindowGammaRampNegative",  "Get window gamma ramp against invalid input", TEST_ENABLED };
   2.472  
   2.473 +static const SDLTest_TestCaseReference videoTest16 =
   2.474 +		{ (SDLTest_TestCaseFp)video_getSetWindowGrab, "video_getSetWindowGrab",  "Checks SDL_GetWindowGrab and SDL_SetWindowGrab", TEST_ENABLED };
   2.475 +
   2.476 +static const SDLTest_TestCaseReference videoTest17 =
   2.477 +		{ (SDLTest_TestCaseFp)video_getWindowId, "video_getWindowId",  "Checks SDL_GetWindowID and SDL_GetWindowFromID", TEST_ENABLED };
   2.478 +
   2.479 +static const SDLTest_TestCaseReference videoTest18 =
   2.480 +		{ (SDLTest_TestCaseFp)video_getWindowPixelFormat, "video_getWindowPixelFormat",  "Checks SDL_GetWindowPixelFormat", TEST_ENABLED };
   2.481 +
   2.482 +static const SDLTest_TestCaseReference videoTest19 =
   2.483 +		{ (SDLTest_TestCaseFp)video_getSetWindowPosition, "video_getSetWindowPosition",  "Checks SDL_GetWindowPosition and SDL_SetWindowPosition", TEST_ENABLED };
   2.484 +
   2.485  /* Sequence of Video test cases */
   2.486  static const SDLTest_TestCaseReference *videoTests[] =  {
   2.487  	&videoTest1, &videoTest2, &videoTest3, &videoTest4, &videoTest5, &videoTest6, 
   2.488  	&videoTest7, &videoTest8, &videoTest9, &videoTest10, &videoTest11, &videoTest12, 
   2.489 -	&videoTest13, &videoTest14, &videoTest15, NULL
   2.490 +	&videoTest13, &videoTest14, &videoTest15, &videoTest16, &videoTest17, 
   2.491 +	&videoTest18, &videoTest19, NULL
   2.492  };
   2.493  
   2.494  /* Video test suite (global) */