Add parameter checking to SetWindowSize functions; add tests to video suite
authorAndreas Schiffler <aschiffler@ferzkopp.net>
Fri, 08 Mar 2013 23:33:07 -0800
changeset 6984 ae9c4b12f3e2
parent 6983 b72f56ab9867
child 6985 a0f905ecdda3
Add parameter checking to SetWindowSize functions; add tests to video suite
include/SDL_video.h
src/video/SDL_video.c
test/testautomation_video.c
--- a/include/SDL_video.h	Fri Mar 08 23:04:53 2013 -0800
+++ b/include/SDL_video.h	Fri Mar 08 23:33:07 2013 -0800
@@ -504,6 +504,9 @@
 /**
  *  \brief Get the position of a window.
  *  
+ *  \param x        Pointer to variable for storing the x position, may be NULL
+ *  \param y        Pointer to variable for storing the y position, may be NULL
+ *
  *  \sa SDL_SetWindowPosition()
  */
 extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window,
@@ -512,6 +515,9 @@
 /**
  *  \brief Set the size of a window's client area.
  *  
+ *  \param w        The width of the window, must be >0
+ *  \param h        The height of the window, must be >0
+ *
  *  \note You can't change the size of a fullscreen window, it automatically
  *        matches the size of the display mode.
  *  
@@ -523,6 +529,9 @@
 /**
  *  \brief Get the size of a window's client area.
  *  
+ *  \param w        Pointer to variable for storing the width, may be NULL
+ *  \param h        Pointer to variable for storing the height, may be NULL
+ *  
  *  \sa SDL_SetWindowSize()
  */
 extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w,
@@ -530,6 +539,9 @@
     
 /**
  *  \brief Set the minimum size of a window's client area.
+ *  
+ *  \param min_w     The minimum width of the window, must be >0
+ *  \param min_h     The minimum height of the window, must be >0
  *
  *  \note You can't change the minimum size of a fullscreen window, it
  *        automatically matches the size of the display mode.
@@ -542,7 +554,10 @@
     
 /**
  *  \brief Get the minimum size of a window's client area.
- *
+ *  
+ *  \param w        Pointer to variable for storing the minimum width, may be NULL
+ *  \param h        Pointer to variable for storing the minimum height, may be NULL
+ *  
  *  \sa SDL_GetWindowMaximumSize()
  *  \sa SDL_SetWindowMinimumSize()
  */
@@ -552,6 +567,9 @@
 /**
  *  \brief Set the maximum size of a window's client area.
  *
+ *  \param max_w     The maximum width of the window, must be >0
+ *  \param max_h     The maximum height of the window, must be >0
+ *
  *  \note You can't change the maximum size of a fullscreen window, it
  *        automatically matches the size of the display mode.
  *
@@ -563,6 +581,9 @@
     
 /**
  *  \brief Get the maximum size of a window's client area.
+ *  
+ *  \param w        Pointer to variable for storing the maximum width, may be NULL
+ *  \param h        Pointer to variable for storing the maximum height, may be NULL
  *
  *  \sa SDL_GetWindowMinimumSize()
  *  \sa SDL_SetWindowMaximumSize()
--- a/src/video/SDL_video.c	Fri Mar 08 23:04:53 2013 -0800
+++ b/src/video/SDL_video.c	Fri Mar 08 23:33:07 2013 -0800
@@ -1566,6 +1566,14 @@
 SDL_SetWindowSize(SDL_Window * window, int w, int h)
 {
     CHECK_WINDOW_MAGIC(window, );
+    if (w <= 0) {
+        SDL_InvalidParamError("w");
+        return;
+    }
+    if (h <= 0) {
+        SDL_InvalidParamError("h");
+        return;
+    }
 
     /* FIXME: Should this change fullscreen modes? */
     if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
@@ -1584,30 +1592,27 @@
 void
 SDL_GetWindowSize(SDL_Window * window, int *w, int *h)
 {
-    int dummy;
-
-    if (!w) {
-        w = &dummy;
-    }
-    if (!h) {
-        h = &dummy;
+    CHECK_WINDOW_MAGIC(window, );
+    if (w) {
+        *w = window->w;
     }
-
-    *w = 0;
-    *h = 0;
-
-    CHECK_WINDOW_MAGIC(window, );
-
-    if (_this && window && window->magic == &_this->window_magic) {
-        *w = window->w;
+    if (h) {
         *h = window->h;
-    }
+    }                                
 }
 
 void
 SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h)
 {
     CHECK_WINDOW_MAGIC(window, );
+    if (min_w <= 0) {
+        SDL_InvalidParamError("min_w");
+        return;
+    }
+    if (min_h <= 0) {
+        SDL_InvalidParamError("min_h");
+        return;
+    }
     
     if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
         window->min_w = min_w;
@@ -1623,22 +1628,11 @@
 void
 SDL_GetWindowMinimumSize(SDL_Window * window, int *min_w, int *min_h)
 {
-    int dummy;
-    
-    if (!min_w) {
-        min_w = &dummy;
-    }
-    if (!min_h) {
-        min_h = &dummy;
+    CHECK_WINDOW_MAGIC(window, );
+    if (min_w) {
+        *min_w = window->min_w;
     }
-    
-    *min_w = 0;
-    *min_h = 0;
-    
-    CHECK_WINDOW_MAGIC(window, );
-    
-    if (_this && window && window->magic == &_this->window_magic) {
-        *min_w = window->min_w;
+    if (min_h) {
         *min_h = window->min_h;
     }
 }
@@ -1647,6 +1641,14 @@
 SDL_SetWindowMaximumSize(SDL_Window * window, int max_w, int max_h)
 {
     CHECK_WINDOW_MAGIC(window, );
+    if (max_w <= 0) {
+        SDL_InvalidParamError("max_w");
+        return;
+    }
+    if (max_h <= 0) {
+        SDL_InvalidParamError("max_h");
+        return;
+    }
     
     if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
         window->max_w = max_w;
@@ -1662,22 +1664,11 @@
 void
 SDL_GetWindowMaximumSize(SDL_Window * window, int *max_w, int *max_h)
 {
-    int dummy;
-    
-    if (!max_w) {
-        max_w = &dummy;
-    }
-    if (!max_h) {
-        max_h = &dummy;
+    CHECK_WINDOW_MAGIC(window, );
+    if (max_w) {
+        *max_w = window->max_w;
     }
-    
-    *max_w = 0;
-    *max_h = 0;
-    
-    CHECK_WINDOW_MAGIC(window, );
-    
-    if (_this && window && window->magic == &_this->window_magic) {
-        *max_w = window->max_w;
+    if (max_h) {
         *max_h = window->max_h;
     }
 }
--- a/test/testautomation_video.c	Fri Mar 08 23:04:53 2013 -0800
+++ b/test/testautomation_video.c	Fri Mar 08 23:33:07 2013 -0800
@@ -33,7 +33,7 @@
   y = SDLTest_RandomIntegerInRange(1, 100);
   w = SDLTest_RandomIntegerInRange(320, 1024);
   h = SDLTest_RandomIntegerInRange(320, 768);
-  flags = SDL_WINDOW_SHOWN;
+  flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS;
   
   window = SDL_CreateWindow(title, x, y, w, h, flags);
   SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
@@ -315,7 +315,6 @@
     SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
     SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
 
-
     /* Clean up */    
     _destroyVideoSuiteTestWindow(window);  
   }
@@ -596,6 +595,25 @@
   return TEST_COMPLETED;
 }
 
+/* Helper function that checks for an 'Invalid window' error */
+void _checkInvalidWindowError()
+{
+  const char *invalidWindowError = "Invalid window";
+  char *lastError;
+
+ lastError = (char *)SDL_GetError();
+  SDLTest_AssertPass("SDL_GetError()");
+  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
+  if (lastError != NULL) {
+      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
+         "SDL_GetError(): expected message '%s', was message: '%s'",
+         invalidWindowError,
+         lastError);
+      SDL_ClearError();
+      SDLTest_AssertPass("Call to SDL_ClearError()");  
+  }
+}
+
 /**
  * @brief Tests call to SDL_GetWindowDisplayMode with invalid input
  *
@@ -605,7 +623,6 @@
 video_getWindowDisplayModeNegative(void *arg)
 {
   const char *expectedError = "Parameter 'mode' is invalid";
-  const char *invalidWindowError = "Invalid window";
   char *lastError;
   SDL_Window* window;
   const char* title = "video_getWindowDisplayModeNegative Test Window";
@@ -636,16 +653,8 @@
   result = SDL_GetWindowDisplayMode(NULL, &mode);
   SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(window=NULL,...)");
   SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result);
-  lastError = (char *)SDL_GetError();
-  SDLTest_AssertPass("SDL_GetError()");
-  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
-  if (lastError != NULL) {
-      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
-         "SDL_GetError(): expected message '%s', was message: '%s'",
-         invalidWindowError,
-         lastError);
-  }
-  
+  _checkInvalidWindowError();
+
   return TEST_COMPLETED;
 }
 
@@ -718,28 +727,21 @@
 int
 video_getWindowGammaRampNegative(void *arg)
 {
-  const char *invalidWindowError = "Invalid window";
-  char *lastError;
   const char* title = "video_getWindowGammaRampNegative Test Window";
   Uint16 red[256];
   Uint16 green[256];
   Uint16 blue[256];
   int result;
 
+  SDL_ClearError();
+  SDLTest_AssertPass("Call to SDL_ClearError()");
+
   /* Call against invalid window */ 
   result = SDL_GetWindowGammaRamp(NULL, red, green, blue);
   SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(window=NULL,r,g,b)");
   SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %f", result);
-  lastError = (char *)SDL_GetError();
-  SDLTest_AssertPass("SDL_GetError()");
-  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
-  if (lastError != NULL) {
-      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
-         "SDL_GetError(): expected message '%s', was message: '%s'",
-         invalidWindowError,
-         lastError);
-  }
-
+  _checkInvalidWindowError();
+  
   return TEST_COMPLETED;
 }
 
@@ -772,8 +774,6 @@
 int
 video_getSetWindowGrab(void *arg)
 {
-  const char *invalidWindowError = "Invalid window";
-  char *lastError;
   const char* title = "video_getSetWindowGrab Test Window";
   SDL_Window* window;
   SDL_bool originalState, dummyState, currentState, desiredState;
@@ -804,39 +804,15 @@
   /* Negative tests */
   dummyState = SDL_GetWindowGrab(NULL);
   SDLTest_AssertPass("Call to SDL_GetWindowGrab(window=NULL)");
-  lastError = (char *)SDL_GetError();
-  SDLTest_AssertPass("SDL_GetError()");
-  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
-  if (lastError != NULL) {
-      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
-         "SDL_GetError(): expected message '%s', was message: '%s'",
-         invalidWindowError,
-         lastError);
-  }
+  _checkInvalidWindowError();
 
   SDL_SetWindowGrab(NULL, SDL_FALSE);
   SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
-  lastError = (char *)SDL_GetError();
-  SDLTest_AssertPass("SDL_GetError()");
-  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
-  if (lastError != NULL) {
-      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
-         "SDL_GetError(): expected message '%s', was message: '%s'",
-         invalidWindowError,
-         lastError);
-  }
+  _checkInvalidWindowError();
 
   SDL_SetWindowGrab(NULL, SDL_TRUE);
   SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
-  lastError = (char *)SDL_GetError();
-  SDLTest_AssertPass("SDL_GetError()");
-  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
-  if (lastError != NULL) {
-      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
-         "SDL_GetError(): expected message '%s', was message: '%s'",
-         invalidWindowError,
-         lastError);
-  }
+  _checkInvalidWindowError();
   
   /* State should still be F */
   desiredState = SDL_FALSE;
@@ -857,6 +833,7 @@
   return TEST_COMPLETED;
 }
 
+
 /**
  * @brief Tests call to SDL_GetWindowID and SDL_GetWindowFromID
  *
@@ -866,8 +843,6 @@
 int
 video_getWindowId(void *arg)
 {
-  const char *invalidWindowError = "Invalid window";
-  char *lastError;
   const char* title = "video_getWindowId Test Window";
   SDL_Window* window;
   SDL_Window* result;
@@ -906,18 +881,12 @@
   SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
 
   /* Negative test */
+  SDL_ClearError();
+  SDLTest_AssertPass("Call to SDL_ClearError()");
   id = SDL_GetWindowID(NULL);
   SDLTest_AssertPass("Call to SDL_GetWindowID(window=NULL)");
-  lastError = (char *)SDL_GetError();
-  SDLTest_AssertPass("SDL_GetError()");
-  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
-  if (lastError != NULL) {
-      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
-         "SDL_GetError(): expected message '%s', was message: '%s'",
-         invalidWindowError,
-         lastError);
-  }
-
+  _checkInvalidWindowError();
+  
   return TEST_COMPLETED;
 }
 
@@ -929,8 +898,6 @@
 int
 video_getWindowPixelFormat(void *arg)
 {
-  const char *invalidWindowError = "Invalid window";
-  char *lastError;
   const char* title = "video_getWindowPixelFormat Test Window";
   SDL_Window* window;
   Uint32 format;
@@ -948,17 +915,11 @@
   _destroyVideoSuiteTestWindow(window);
     
   /* Negative test */
+  SDL_ClearError();
+  SDLTest_AssertPass("Call to SDL_ClearError()");
   format = SDL_GetWindowPixelFormat(NULL);
   SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat(window=NULL)");
-  lastError = (char *)SDL_GetError();
-  SDLTest_AssertPass("SDL_GetError()");
-  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
-  if (lastError != NULL) {
-      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
-         "SDL_GetError(): expected message '%s', was message: '%s'",
-         invalidWindowError,
-         lastError);
-  }
+  _checkInvalidWindowError();
 
   return TEST_COMPLETED;
 }
@@ -972,8 +933,6 @@
 int
 video_getSetWindowPosition(void *arg)
 {
-  const char *invalidWindowError = "Invalid window";
-  char *lastError;
   const char* title = "video_getSetWindowPosition Test Window";
   SDL_Window* window;
   int xVariation, yVariation;
@@ -1065,8 +1024,10 @@
   currentY = referenceY;
   desiredX = SDLTest_RandomSint32();
   desiredY = SDLTest_RandomSint32();
-  
+
   /* Negative tests */
+  SDL_ClearError();
+  SDLTest_AssertPass("Call to SDL_ClearError()");  
   SDL_GetWindowPosition(NULL, &currentX, &currentY);
   SDLTest_AssertPass("Call to SDL_GetWindowPosition(window=NULL)");
   SDLTest_AssertCheck(
@@ -1074,39 +1035,453 @@
   	"Verify that content of X and Y pointers has not been modified; expected: %d,%d; got: %d,%d",
   	referenceX, referenceY,
   	currentX, currentY);
-  lastError = (char *)SDL_GetError();
-  SDLTest_AssertPass("SDL_GetError()");
-  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
-  if (lastError != NULL) {
-      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
-         "SDL_GetError(): expected message '%s', was message: '%s'",
-         invalidWindowError,
-         lastError);
-  }
+  _checkInvalidWindowError();
 
   SDL_GetWindowPosition(NULL, NULL, NULL);
   SDLTest_AssertPass("Call to SDL_GetWindowPosition(NULL, NULL, NULL)");
+  _checkInvalidWindowError();
+
+  SDL_SetWindowPosition(NULL, desiredX, desiredY);
+  SDLTest_AssertPass("Call to SDL_SetWindowPosition(window=NULL)");
+  _checkInvalidWindowError();
+  
+  return TEST_COMPLETED;
+}
+
+/* Helper function that checks for an 'Invalid parameter' error */
+void _checkInvalidParameterError()
+{
+  const char *invalidParameterError = "Parameter";
+  char *lastError;
+
   lastError = (char *)SDL_GetError();
   SDLTest_AssertPass("SDL_GetError()");
   SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
   if (lastError != NULL) {
-      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
-         "SDL_GetError(): expected message '%s', was message: '%s'",
-         invalidWindowError,
+      SDLTest_AssertCheck(SDL_strncmp(lastError, invalidParameterError, SDL_strlen(invalidParameterError)) == 0,
+         "SDL_GetError(): expected message starts with '%s', was message: '%s'",
+         invalidParameterError,
          lastError);
+      SDL_ClearError();
+      SDLTest_AssertPass("Call to SDL_ClearError()");  
+  }
+}
+
+/**
+ * @brief Tests call to SDL_GetWindowSize and SDL_SetWindowSize
+ *
+ * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowSize
+ * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowSize
+ */
+int
+video_getSetWindowSize(void *arg)
+{
+  const char* title = "video_getSetWindowSize Test Window";
+  SDL_Window* window;
+  int result;
+  SDL_Rect display;
+  int wVariation, hVariation;
+  int referenceW, referenceH;
+  int currentW, currentH;
+  int desiredW, desiredH;
+
+  /* Get display bounds for size range */
+  result = SDL_GetDisplayBounds(0, &display);
+  SDLTest_AssertPass("SDL_GetDisplayBounds()");
+  SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
+  if (result != 0) return TEST_ABORTED;
+  
+  /* Call against new test window */ 
+  window = _createVideoSuiteTestWindow(title);
+  if (window == NULL) return TEST_ABORTED;
+  
+  for (wVariation = 0; wVariation < 4; wVariation++) {
+   for (hVariation = 0; hVariation < 4; hVariation++) {
+    switch(wVariation) {
+     case 0:
+      /* 1 Pixel Wide */  
+      desiredW = 1;
+      break;
+     case 1:
+      /* Random width inside screen */  
+      desiredW = SDLTest_RandomIntegerInRange(1, 100);
+      break;
+     case 2:
+      /* Width at screen size */  
+      desiredW = display.w;
+      break;
+     case 3:
+      /* Width 1 pixel larger than screen */  
+      desiredW = display.w + 1;
+      break;
+    }
+
+    switch(hVariation) {
+     case 0:
+      /* 1 Pixel High */  
+      desiredH = 1;
+      break;
+     case 1:
+      /* Random height inside screen */  
+      desiredH = SDLTest_RandomIntegerInRange(1, 100);
+      break;
+     case 2:
+      /* Height at screen size */  
+      desiredH = display.h;
+      break;
+     case 3:
+      /* Height 1 pixel larger than screen */  
+      desiredH = display.h + 1;
+      break;
+    }
+
+    /* Set size */
+    SDL_SetWindowSize(window, desiredW, desiredH);
+    SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH);
+   
+    /* Get size */
+    currentW = desiredW + 1;
+    currentH = desiredH + 1;
+    SDL_GetWindowSize(window, &currentW, &currentH);
+    SDLTest_AssertPass("Call to SDL_GetWindowSize()");
+    SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
+    SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
+
+    /* Get just width */
+    currentW = desiredW + 1;    
+    SDL_GetWindowSize(window, &currentW, NULL);
+    SDLTest_AssertPass("Call to SDL_GetWindowSize(&h=NULL)");
+    SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
+
+    /* Get just height */
+    currentH = desiredH + 1;
+    SDL_GetWindowSize(window, NULL, &currentH);
+    SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL)");
+    SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
+   }
   }
 
-  SDL_SetWindowPosition(NULL, desiredX, desiredY);
-  SDLTest_AssertPass("Call to SDL_SetWindowPosition(window=NULL)");
-  lastError = (char *)SDL_GetError();
-  SDLTest_AssertPass("SDL_GetError()");
-  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
-  if (lastError != NULL) {
-      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
-         "SDL_GetError(): expected message '%s', was message: '%s'",
-         invalidWindowError,
-         lastError);
+  /* Dummy call with both pointers NULL */
+  SDL_GetWindowSize(window, NULL, NULL);
+  SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL,&h=NULL)");
+
+  /* Negative tests for parameter input */
+  SDL_ClearError();
+  SDLTest_AssertPass("Call to SDL_ClearError()");  
+  for (desiredH = -2; desiredH < 2; desiredH++) {
+    for (desiredW = -2; desiredW < 2; desiredW++) {
+      if (desiredW <= 0 || desiredH <= 0) { 
+        SDL_SetWindowSize(window, desiredW, desiredH);
+        SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH);
+        _checkInvalidParameterError();
+      }
+    }
+  }
+   
+  /* Clean up */    
+  _destroyVideoSuiteTestWindow(window);
+    
+  /* Set some 'magic' value for later check that nothing was changed */
+  referenceW = SDLTest_RandomSint32();
+  referenceH = SDLTest_RandomSint32();
+  currentW = referenceW;
+  currentH = referenceH;
+  desiredW = SDLTest_RandomSint32();
+  desiredH = SDLTest_RandomSint32();
+  
+  /* Negative tests for window input */
+  SDL_ClearError();
+  SDLTest_AssertPass("Call to SDL_ClearError()");
+  SDL_GetWindowSize(NULL, &currentW, &currentH);
+  SDLTest_AssertPass("Call to SDL_GetWindowSize(window=NULL)");
+  SDLTest_AssertCheck(
+  	currentW == referenceW && currentH == referenceH, 
+  	"Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
+  	referenceW, referenceH,
+  	currentW, currentH);
+  _checkInvalidWindowError();
+
+  SDL_GetWindowSize(NULL, NULL, NULL);
+  SDLTest_AssertPass("Call to SDL_GetWindowSize(NULL, NULL, NULL)");
+  _checkInvalidWindowError();
+
+  SDL_SetWindowSize(NULL, desiredW, desiredH);
+  SDLTest_AssertPass("Call to SDL_SetWindowSize(window=NULL)");
+  _checkInvalidWindowError();
+  
+  return TEST_COMPLETED;
+}
+
+/**
+ * @brief Tests call to SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize
+ *
+ */
+int
+video_getSetWindowMinimumSize(void *arg)
+{
+  const char* title = "video_getSetWindowMinimumSize Test Window";
+  SDL_Window* window;
+  int result;
+  SDL_Rect display;
+  int wVariation, hVariation;
+  int referenceW, referenceH;
+  int currentW, currentH;
+  int desiredW, desiredH;
+
+  /* Get display bounds for size range */
+  result = SDL_GetDisplayBounds(0, &display);
+  SDLTest_AssertPass("SDL_GetDisplayBounds()");
+  SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
+  if (result != 0) return TEST_ABORTED;
+
+  /* Call against new test window */ 
+  window = _createVideoSuiteTestWindow(title);
+  if (window == NULL) return TEST_ABORTED;
+  
+  for (wVariation = 0; wVariation < 5; wVariation++) {
+   for (hVariation = 0; hVariation < 5; hVariation++) {
+    switch(wVariation) {
+     case 0:
+      /* 1 Pixel Wide */  
+      desiredW = 1;
+      break;
+     case 1:
+      /* Random width inside screen */  
+      desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1);
+      break;
+     case 2:
+      /* Width at screen size */  
+      desiredW = display.w;
+      break;
+    }
+
+    switch(hVariation) {
+     case 0:
+      /* 1 Pixel High */  
+      desiredH = 1;
+      break;
+     case 1:
+      /* Random height inside screen */  
+      desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1);
+      break;
+     case 2:
+      /* Height at screen size */  
+      desiredH = display.h;
+      break;
+     case 4:
+      /* Height 1 pixel larger than screen */  
+      desiredH = display.h + 1;
+      break;
+    }
+
+    /* Set size */
+    SDL_SetWindowMinimumSize(window, desiredW, desiredH);
+    SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH);
+   
+    /* Get size */
+    currentW = desiredW + 1;
+    currentH = desiredH + 1;
+    SDL_GetWindowMinimumSize(window, &currentW, &currentH);
+    SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize()");
+    SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
+    SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
+
+    /* Get just width */
+    currentW = desiredW + 1;    
+    SDL_GetWindowMinimumSize(window, &currentW, NULL);
+    SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&h=NULL)");
+    SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
+
+    /* Get just height */
+    currentH = desiredH + 1;
+    SDL_GetWindowMinimumSize(window, NULL, &currentH);
+    SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL)");
+    SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
+   }
+  }
+
+  /* Dummy call with both pointers NULL */
+  SDL_GetWindowMinimumSize(window, NULL, NULL);
+  SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL,&h=NULL)");
+
+  /* Negative tests for parameter input */
+  SDL_ClearError();
+  SDLTest_AssertPass("Call to SDL_ClearError()");  
+  for (desiredH = -2; desiredH < 2; desiredH++) {
+    for (desiredW = -2; desiredW < 2; desiredW++) {
+      if (desiredW <= 0 || desiredH <= 0) { 
+        SDL_SetWindowMinimumSize(window, desiredW, desiredH);
+        SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH);
+        _checkInvalidParameterError();
+      }
+    }
   }
+   
+  /* Clean up */    
+  _destroyVideoSuiteTestWindow(window);
+    
+  /* Set some 'magic' value for later check that nothing was changed */
+  referenceW = SDLTest_RandomSint32();
+  referenceH = SDLTest_RandomSint32();
+  currentW = referenceW;
+  currentH = referenceH;
+  desiredW = SDLTest_RandomSint32();
+  desiredH = SDLTest_RandomSint32();
+  
+  /* Negative tests for window input */
+  SDL_ClearError();
+  SDLTest_AssertPass("Call to SDL_ClearError()");
+  SDL_GetWindowMinimumSize(NULL, &currentW, &currentH);
+  SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(window=NULL)");
+  SDLTest_AssertCheck(
+  	currentW == referenceW && currentH == referenceH, 
+  	"Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
+  	referenceW, referenceH,
+  	currentW, currentH);
+  _checkInvalidWindowError();
+
+  SDL_GetWindowMinimumSize(NULL, NULL, NULL);
+  SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(NULL, NULL, NULL)");
+  _checkInvalidWindowError();
+
+  SDL_SetWindowMinimumSize(NULL, desiredW, desiredH);
+  SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(window=NULL)");
+  _checkInvalidWindowError();
+  
+  return TEST_COMPLETED;
+}
+
+/**
+ * @brief Tests call to SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize
+ *
+ */
+int
+video_getSetWindowMaximumSize(void *arg)
+{
+  const char* title = "video_getSetWindowMaximumSize Test Window";
+  SDL_Window* window;
+  int result;
+  SDL_Rect display;
+  int wVariation, hVariation;
+  int referenceW, referenceH;
+  int currentW, currentH;
+  int desiredW, desiredH;
+
+  /* Get display bounds for size range */
+  result = SDL_GetDisplayBounds(0, &display);
+  SDLTest_AssertPass("SDL_GetDisplayBounds()");
+  SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
+  if (result != 0) return TEST_ABORTED;
+
+  /* Call against new test window */ 
+  window = _createVideoSuiteTestWindow(title);
+  if (window == NULL) return TEST_ABORTED;
+  
+  for (wVariation = 0; wVariation < 3; wVariation++) {
+   for (hVariation = 0; hVariation < 3; hVariation++) {
+    switch(wVariation) {
+     case 0:
+      /* 1 Pixel Wide */  
+      desiredW = 1;
+      break;
+     case 1:
+      /* Random width inside screen */  
+      desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1);
+      break;
+     case 2:
+      /* Width at screen size */  
+      desiredW = display.w;
+      break;
+    }
+
+    switch(hVariation) {
+     case 0:
+      /* 1 Pixel High */  
+      desiredH = 1;
+      break;
+     case 1:
+      /* Random height inside screen */  
+      desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1);
+      break;
+     case 2:
+      /* Height at screen size */  
+      desiredH = display.h;
+      break;
+    }
+
+    /* Set size */
+    SDL_SetWindowMaximumSize(window, desiredW, desiredH);
+    SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH);
+   
+    /* Get size */
+    currentW = desiredW + 1;
+    currentH = desiredH + 1;
+    SDL_GetWindowMaximumSize(window, &currentW, &currentH);
+    SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize()");
+    SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
+    SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
+
+    /* Get just width */
+    currentW = desiredW + 1;    
+    SDL_GetWindowMaximumSize(window, &currentW, NULL);
+    SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&h=NULL)");
+    SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
+
+    /* Get just height */
+    currentH = desiredH + 1;
+    SDL_GetWindowMaximumSize(window, NULL, &currentH);
+    SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL)");
+    SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
+   }
+  }
+
+  /* Dummy call with both pointers NULL */
+  SDL_GetWindowMaximumSize(window, NULL, NULL);
+  SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL,&h=NULL)");
+
+  /* Negative tests for parameter input */
+  SDL_ClearError();
+  SDLTest_AssertPass("Call to SDL_ClearError()");  
+  for (desiredH = -2; desiredH < 2; desiredH++) {
+    for (desiredW = -2; desiredW < 2; desiredW++) {
+      if (desiredW <= 0 || desiredH <= 0) { 
+        SDL_SetWindowMaximumSize(window, desiredW, desiredH);
+        SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH);
+        _checkInvalidParameterError();
+      }
+    }
+  }
+   
+  /* Clean up */    
+  _destroyVideoSuiteTestWindow(window);
+    
+  /* Set some 'magic' value for later check that nothing was changed */
+  referenceW = SDLTest_RandomSint32();
+  referenceH = SDLTest_RandomSint32();
+  currentW = referenceW;
+  currentH = referenceH;
+  desiredW = SDLTest_RandomSint32();
+  desiredH = SDLTest_RandomSint32();
+  
+  /* Negative tests */
+  SDL_ClearError();
+  SDLTest_AssertPass("Call to SDL_ClearError()");
+  SDL_GetWindowMaximumSize(NULL, &currentW, &currentH);
+  SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(window=NULL)");
+  SDLTest_AssertCheck(
+  	currentW == referenceW && currentH == referenceH, 
+  	"Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
+  	referenceW, referenceH,
+  	currentW, currentH);
+  _checkInvalidWindowError();
+
+  SDL_GetWindowMaximumSize(NULL, NULL, NULL);
+  SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(NULL, NULL, NULL)");
+  _checkInvalidWindowError();
+
+  SDL_SetWindowMaximumSize(NULL, desiredW, desiredH);
+  SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(window=NULL)");
+  _checkInvalidWindowError();
   
   return TEST_COMPLETED;
 }
@@ -1160,7 +1535,7 @@
 		{ (SDLTest_TestCaseFp)video_getWindowGammaRampNegative, "video_getWindowGammaRampNegative",  "Get window gamma ramp against invalid input", TEST_ENABLED };
 
 static const SDLTest_TestCaseReference videoTest16 =
-		{ (SDLTest_TestCaseFp)video_getSetWindowGrab, "video_getSetWindowGrab",  "Checks SDL_GetWindowGrab and SDL_SetWindowGrab", TEST_ENABLED };
+		{ (SDLTest_TestCaseFp)video_getSetWindowGrab, "video_getSetWindowGrab",  "Checks SDL_GetWindowGrab and SDL_SetWindowGrab positive and negative cases", TEST_ENABLED };
 
 static const SDLTest_TestCaseReference videoTest17 =
 		{ (SDLTest_TestCaseFp)video_getWindowId, "video_getWindowId",  "Checks SDL_GetWindowID and SDL_GetWindowFromID", TEST_ENABLED };
@@ -1169,14 +1544,24 @@
 		{ (SDLTest_TestCaseFp)video_getWindowPixelFormat, "video_getWindowPixelFormat",  "Checks SDL_GetWindowPixelFormat", TEST_ENABLED };
 
 static const SDLTest_TestCaseReference videoTest19 =
-		{ (SDLTest_TestCaseFp)video_getSetWindowPosition, "video_getSetWindowPosition",  "Checks SDL_GetWindowPosition and SDL_SetWindowPosition", TEST_ENABLED };
+		{ (SDLTest_TestCaseFp)video_getSetWindowPosition, "video_getSetWindowPosition",  "Checks SDL_GetWindowPosition and SDL_SetWindowPosition positive and negative cases", TEST_ENABLED };
+
+static const SDLTest_TestCaseReference videoTest20 =
+		{ (SDLTest_TestCaseFp)video_getSetWindowSize, "video_getSetWindowSize",  "Checks SDL_GetWindowSize and SDL_SetWindowSize positive and negative cases", TEST_ENABLED };
+
+static const SDLTest_TestCaseReference videoTest21 =
+		{ (SDLTest_TestCaseFp)video_getSetWindowMinimumSize, "video_getSetWindowMinimumSize",  "Checks SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize positive and negative cases", TEST_ENABLED };
+
+static const SDLTest_TestCaseReference videoTest22 =
+		{ (SDLTest_TestCaseFp)video_getSetWindowMaximumSize, "video_getSetWindowMaximumSize",  "Checks SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize positive and negative cases", TEST_ENABLED };
 
 /* Sequence of Video test cases */
 static const SDLTest_TestCaseReference *videoTests[] =  {
 	&videoTest1, &videoTest2, &videoTest3, &videoTest4, &videoTest5, &videoTest6, 
 	&videoTest7, &videoTest8, &videoTest9, &videoTest10, &videoTest11, &videoTest12, 
 	&videoTest13, &videoTest14, &videoTest15, &videoTest16, &videoTest17, 
-	&videoTest18, &videoTest19, NULL
+	&videoTest18, &videoTest19, &videoTest20, &videoTest21, &videoTest22, 
+	NULL
 };
 
 /* Video test suite (global) */