test/testautomation_video.c
author Andreas Schiffler <aschiffler@ferzkopp.net>
Tue, 23 Apr 2013 20:45:49 -0700
changeset 7101 ea2e8eb622e1
parent 7066 d61902a0bc21
child 7134 09ee216e6a25
permissions -rw-r--r--
Fix double free in video test suite
     1 /**
     2  * Video test suite
     3  */
     4 
     5 #include <stdio.h>
     6 #include <string.h>
     7 
     8 /* Visual Studio 2008 doesn't have stdint.h */
     9 #if defined(_MSC_VER) && _MSC_VER <= 1500
    10 #define UINT8_MAX   ~(Uint8)0
    11 #define UINT16_MAX  ~(Uint16)0
    12 #define UINT32_MAX  ~(Uint32)0
    13 #define UINT64_MAX  ~(Uint64)0
    14 #else
    15 #include <stdint.h>
    16 #endif
    17 
    18 #include "SDL.h"
    19 #include "SDL_test.h"
    20 
    21 /* Private helpers */
    22 
    23 /* 
    24  * Create a test window
    25  */
    26 SDL_Window *_createVideoSuiteTestWindow(const char *title)
    27 {
    28   SDL_Window* window;
    29   int x, y, w, h;
    30   SDL_WindowFlags flags;
    31 
    32   /* Standard window */
    33   x = SDLTest_RandomIntegerInRange(1, 100);
    34   y = SDLTest_RandomIntegerInRange(1, 100);
    35   w = SDLTest_RandomIntegerInRange(320, 1024);
    36   h = SDLTest_RandomIntegerInRange(320, 768);
    37   flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS;
    38   
    39   window = SDL_CreateWindow(title, x, y, w, h, flags);
    40   SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
    41   SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
    42 
    43   return window;
    44 }
    45 
    46 /*
    47  * Destroy test window  
    48  */
    49 void _destroyVideoSuiteTestWindow(SDL_Window *window)
    50 {
    51   if (window != NULL) {  
    52      SDL_DestroyWindow(window);
    53      window = NULL;
    54      SDLTest_AssertPass("Call to SDL_DestroyWindow");
    55   }
    56 }
    57 
    58 /* Test case functions */
    59 
    60 /**
    61  * @brief Enable and disable screensaver while checking state
    62  */
    63 int
    64 video_enableDisableScreensaver(void *arg)
    65 {
    66 	SDL_bool initialResult;
    67 	SDL_bool result;
    68 
    69 	/* Get current state and proceed according to current state */
    70 	initialResult = SDL_IsScreenSaverEnabled();
    71 	SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");	
    72 	if (initialResult == SDL_TRUE) {
    73 	
    74 	  /* Currently enabled: disable first, then enable again */
    75 	  
    76 	  /* Disable screensaver and check */	
    77 	  SDL_DisableScreenSaver();
    78 	  SDLTest_AssertPass("Call to SDL_DisableScreenSaver()");	
    79 	  result = SDL_IsScreenSaverEnabled();
    80 	  SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
    81 	  SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);
    82 	
    83 	  /* Enable screensaver and check */	
    84 	  SDL_EnableScreenSaver();
    85 	  SDLTest_AssertPass("Call to SDL_EnableScreenSaver()");
    86 	  result = SDL_IsScreenSaverEnabled();
    87 	  SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
    88 	  SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
    89 
    90 	} else {
    91 
    92 	  /* Currently disabled: enable first, then disable again */
    93 	  
    94 	  /* Enable screensaver and check */	
    95 	  SDL_EnableScreenSaver();
    96 	  SDLTest_AssertPass("Call to SDL_EnableScreenSaver()");
    97 	  result = SDL_IsScreenSaverEnabled();
    98 	  SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
    99 	  SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
   100 
   101 	  /* Disable screensaver and check */	
   102 	  SDL_DisableScreenSaver();
   103 	  SDLTest_AssertPass("Call to SDL_DisableScreenSaver()");	
   104 	  result = SDL_IsScreenSaverEnabled();
   105 	  SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
   106 	  SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);	
   107 	}	
   108 	
   109 	return TEST_COMPLETED;
   110 }
   111 
   112 /**
   113  * @brief Tests the functionality of the SDL_CreateWindow function using different positions
   114  */
   115 int
   116 video_createWindowVariousPositions(void *arg)
   117 {
   118   SDL_Window* window;
   119   const char* title = "video_createWindowVariousPositions Test Window";
   120   int x, y, w, h;
   121   int xVariation, yVariation;
   122   
   123   for (xVariation = 0; xVariation < 6; xVariation++) {
   124    for (yVariation = 0; yVariation < 6; yVariation++) {
   125     switch(xVariation) {
   126      case 0:
   127       /* Zero X Position */  
   128       x = 0;
   129       break;
   130      case 1:
   131       /* Random X position inside screen */  
   132       x = SDLTest_RandomIntegerInRange(1, 100);
   133       break;
   134      case 2:
   135       /* Random X position outside screen (positive) */  
   136       x = SDLTest_RandomIntegerInRange(10000, 11000);
   137       break;
   138      case 3:
   139       /* Random X position outside screen (negative) */  
   140       x = SDLTest_RandomIntegerInRange(-1000, -100);
   141       break;
   142      case 4:
   143       /* Centered X position */  
   144       x = SDL_WINDOWPOS_CENTERED;
   145       break;
   146      case 5:
   147       /* Undefined X position */  
   148       x = SDL_WINDOWPOS_UNDEFINED;
   149       break;
   150     }
   151 
   152     switch(yVariation) {
   153      case 0:
   154       /* Zero X Position */  
   155       y = 0;
   156       break;
   157      case 1:
   158       /* Random X position inside screen */  
   159       y = SDLTest_RandomIntegerInRange(1, 100);
   160       break;
   161      case 2:
   162       /* Random X position outside screen (positive) */  
   163       y = SDLTest_RandomIntegerInRange(10000, 11000);
   164       break;
   165      case 3:
   166       /* Random Y position outside screen (negative) */  
   167       y = SDLTest_RandomIntegerInRange(-1000, -100);
   168       break;
   169      case 4:
   170       /* Centered Y position */  
   171       y = SDL_WINDOWPOS_CENTERED;
   172       break;
   173      case 5:
   174       /* Undefined Y position */  
   175       y = SDL_WINDOWPOS_UNDEFINED;
   176       break;
   177     }
   178      
   179     w = SDLTest_RandomIntegerInRange(32, 96);
   180     h = SDLTest_RandomIntegerInRange(32, 96);
   181     window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN);
   182     SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h);
   183     SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
   184 
   185     /* Clean up */    
   186     _destroyVideoSuiteTestWindow(window);
   187    }
   188   } 
   189 
   190   return TEST_COMPLETED;
   191 }
   192 
   193 /**
   194  * @brief Tests the functionality of the SDL_CreateWindow function using different sizes
   195  */
   196 int
   197 video_createWindowVariousSizes(void *arg)
   198 {
   199   SDL_Window* window;
   200   const char* title = "video_createWindowVariousSizes Test Window";
   201   int x, y, w, h;
   202   int wVariation, hVariation;
   203   
   204   x = SDLTest_RandomIntegerInRange(1, 100);
   205   y = SDLTest_RandomIntegerInRange(1, 100);
   206   for (wVariation = 0; wVariation < 3; wVariation++) {
   207    for (hVariation = 0; hVariation < 3; hVariation++) {
   208     switch(wVariation) {
   209      case 0:
   210       /* Width of 1 */  
   211       w = 1;
   212       break;
   213      case 1:
   214       /* Random "normal" width */  
   215       w = SDLTest_RandomIntegerInRange(320, 1920);
   216       break;
   217      case 2:
   218       /* Random "large" width */  
   219       w = SDLTest_RandomIntegerInRange(2048, 4095);
   220       break;
   221     }
   222 
   223     switch(hVariation) {
   224      case 0:
   225       /* Height of 1 */  
   226       h = 1;
   227       break;
   228      case 1:
   229       /* Random "normal" height */  
   230       h = SDLTest_RandomIntegerInRange(320, 1080);
   231       break;
   232      case 2:
   233       /* Random "large" height */  
   234       h = SDLTest_RandomIntegerInRange(2048, 4095);
   235       break;
   236      }
   237      
   238     window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN);
   239     SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h);
   240     SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
   241 
   242     /* Clean up */    
   243     _destroyVideoSuiteTestWindow(window);
   244    }
   245   }  
   246 
   247   return TEST_COMPLETED;
   248 }
   249 
   250 /**
   251  * @brief Tests the functionality of the SDL_CreateWindow function using different flags
   252  */
   253 int
   254 video_createWindowVariousFlags(void *arg)
   255 {
   256   SDL_Window* window;
   257   const char* title = "video_createWindowVariousFlags Test Window";
   258   int x, y, w, h;
   259   int fVariation;
   260   SDL_WindowFlags flags;
   261   
   262   /* Standard window */
   263   x = SDLTest_RandomIntegerInRange(1, 100);
   264   y = SDLTest_RandomIntegerInRange(1, 100);
   265   w = SDLTest_RandomIntegerInRange(320, 1024);
   266   h = SDLTest_RandomIntegerInRange(320, 768);
   267 
   268   for (fVariation = 0; fVariation < 13; fVariation++) {
   269     switch(fVariation) {
   270      case 0:
   271       flags = SDL_WINDOW_FULLSCREEN;
   272       /* Skip - blanks screen; comment out next line to run test */
   273       continue;   
   274       break;
   275      case 1:
   276       flags = SDL_WINDOW_FULLSCREEN_DESKTOP;
   277       /* Skip - blanks screen; comment out next line to run test */
   278       continue;  
   279       break;
   280      case 2:
   281       flags = SDL_WINDOW_OPENGL;
   282       break;  
   283      case 3:
   284       flags = SDL_WINDOW_SHOWN;
   285       break;   
   286      case 4:    
   287       flags = SDL_WINDOW_HIDDEN;
   288       break;     
   289      case 5:
   290       flags = SDL_WINDOW_BORDERLESS;
   291       break;       
   292      case 6:
   293       flags = SDL_WINDOW_RESIZABLE;
   294       break;         
   295      case 7:
   296       flags = SDL_WINDOW_MINIMIZED;
   297       break;           
   298      case 8:
   299       flags = SDL_WINDOW_MAXIMIZED;
   300       break;
   301      case 9: 
   302       flags = SDL_WINDOW_INPUT_GRABBED;
   303       break;
   304      case 10:              
   305       flags = SDL_WINDOW_INPUT_FOCUS;
   306       break;                 
   307      case 11:                      
   308       flags = SDL_WINDOW_MOUSE_FOCUS;
   309       break;
   310      case 12: 
   311       flags = SDL_WINDOW_FOREIGN;
   312       break;
   313     }
   314        
   315     window = SDL_CreateWindow(title, x, y, w, h, flags);
   316     SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
   317     SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
   318 
   319     /* Clean up */    
   320     _destroyVideoSuiteTestWindow(window);  
   321   }
   322 
   323   return TEST_COMPLETED;
   324 }
   325 
   326 
   327 /**
   328  * @brief Tests the functionality of the SDL_GetWindowFlags function
   329  */
   330 int
   331 video_getWindowFlags(void *arg)
   332 {
   333   SDL_Window* window;
   334   const char* title = "video_getWindowFlags Test Window";
   335   SDL_WindowFlags flags;
   336   Uint32 actualFlags;
   337   
   338   /* Reliable flag set always set in test window */
   339   flags = SDL_WINDOW_SHOWN;
   340   
   341   /* Call against new test window */ 
   342   window = _createVideoSuiteTestWindow(title);
   343   if (window != NULL) {
   344       actualFlags = SDL_GetWindowFlags(window);
   345       SDLTest_AssertPass("Call to SDL_GetWindowFlags");
   346       SDLTest_AssertCheck((flags & actualFlags) == flags, "Verify returned value has flags %d set, got: %d", flags, actualFlags);
   347   }
   348 
   349   /* Clean up */    
   350   _destroyVideoSuiteTestWindow(window);
   351   
   352   return TEST_COMPLETED;
   353 }
   354 
   355 /**
   356  * @brief Tests the functionality of the SDL_GetNumDisplayModes function
   357  */
   358 int
   359 video_getNumDisplayModes(void *arg)
   360 {
   361   int result;
   362   int displayNum;
   363   int i;
   364 
   365   /* Get number of displays */
   366   displayNum = SDL_GetNumVideoDisplays();
   367   SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays");
   368 
   369   /* Make call for each display */  
   370   for (i=0; i<displayNum; i++) {
   371     result = SDL_GetNumDisplayModes(i);
   372     SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d)", i);
   373     SDLTest_AssertCheck(result >= 1, "Validate returned value from function; expected: >=1; got: %d", result);
   374   }
   375 
   376   return TEST_COMPLETED;
   377 }
   378 
   379 /**
   380  * @brief Tests negative call to SDL_GetNumDisplayModes function
   381  */
   382 int
   383 video_getNumDisplayModesNegative(void *arg)
   384 {
   385   int result;
   386   int displayNum;
   387   int displayIndex;
   388 
   389   /* Get number of displays */
   390   displayNum = SDL_GetNumVideoDisplays();
   391   SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays");
   392 
   393   /* Invalid boundary values */
   394   displayIndex =  SDLTest_RandomSint32BoundaryValue(0, displayNum, SDL_FALSE);
   395   result = SDL_GetNumDisplayModes(displayIndex);
   396   SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/boundary)", displayIndex);
   397   SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result);  
   398   
   399   /* Large (out-of-bounds) display index */
   400   displayIndex = SDLTest_RandomIntegerInRange(-2000, -1000);
   401   result = SDL_GetNumDisplayModes(displayIndex);
   402   SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/large negative)", displayIndex);
   403   SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result);  
   404 
   405   displayIndex = SDLTest_RandomIntegerInRange(1000, 2000);
   406   result = SDL_GetNumDisplayModes(displayIndex);
   407   SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/large positive)", displayIndex);
   408   SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result);  
   409 
   410   return TEST_COMPLETED;
   411 }
   412 
   413 /**
   414  * @brief Tests the functionality of the SDL_GetClosestDisplayMode function against current resolution
   415  */
   416 int
   417 video_getClosestDisplayModeCurrentResolution(void *arg)
   418 {
   419   int result;
   420   SDL_DisplayMode current; 
   421   SDL_DisplayMode target; 
   422   SDL_DisplayMode closest;
   423   SDL_DisplayMode* dResult;
   424   int displayNum;
   425   int i;
   426   int variation;
   427 
   428   /* Get number of displays */
   429   displayNum = SDL_GetNumVideoDisplays();
   430   SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays");
   431 
   432   /* Make calls for each display */  
   433   for (i=0; i<displayNum; i++) {
   434     SDLTest_Log("Testing against display: %d", i);
   435   
   436     /* Get first display mode to get a sane resolution; this should always work */
   437     result = SDL_GetDisplayMode(i, 0, &current);
   438     SDLTest_AssertPass("Call to SDL_GetDisplayMode");
   439     SDLTest_AssertCheck(result == 0, "Verify return value, expected: 0, got: %d", result);
   440     if (result != 0) {
   441       return TEST_ABORTED;
   442     }
   443        
   444     /* Set the desired resolution equals to current resolution */
   445     target.w = current.w;
   446     target.h = current.h;    
   447     for (variation = 0; variation < 8; variation ++) {
   448       /* Vary constraints on other query parameters */
   449       target.format = (variation & 1) ? current.format : 0;
   450       target.refresh_rate = (variation & 2) ? current.refresh_rate : 0;
   451       target.driverdata = (variation & 4) ? current.driverdata : 0;
   452           
   453       /* Make call */
   454       dResult = SDL_GetClosestDisplayMode(i, &target, &closest);
   455       SDLTest_AssertPass("Call to SDL_GetClosestDisplayMode(target=current/variation%d)", variation);
   456       SDLTest_AssertCheck(dResult != NULL, "Verify returned value is not NULL");
   457     
   458       /* Check that one gets the current resolution back again */
   459       SDLTest_AssertCheck(closest.w == current.w, "Verify returned width matches current width; expected: %d, got: %d", current.w, closest.w);
   460       SDLTest_AssertCheck(closest.h == current.h, "Verify returned height matches current height; expected: %d, got: %d", current.h, closest.h);
   461       SDLTest_AssertCheck(closest.w == dResult->w, "Verify return value matches assigned value; expected: %d, got: %d", closest.w, dResult->w);
   462       SDLTest_AssertCheck(closest.h == dResult->h, "Verify return value matches assigned value; expected: %d, got: %d", closest.h, dResult->h);
   463     }
   464   }
   465 
   466   return TEST_COMPLETED;
   467 }
   468 
   469 /**
   470  * @brief Tests the functionality of the SDL_GetClosestDisplayMode function against random resolution
   471  */
   472 int
   473 video_getClosestDisplayModeRandomResolution(void *arg)
   474 {
   475   SDL_DisplayMode target; 
   476   SDL_DisplayMode closest;
   477   SDL_DisplayMode* dResult;
   478   int displayNum;
   479   int i;
   480   int variation;
   481 
   482   /* Get number of displays */
   483   displayNum = SDL_GetNumVideoDisplays();
   484   SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays");
   485 
   486   /* Make calls for each display */  
   487   for (i=0; i<displayNum; i++) {
   488     SDLTest_Log("Testing against display: %d", i);
   489          
   490     for (variation = 0; variation < 16; variation ++) {
   491     
   492       /* Set random constraints */
   493       target.w = (variation & 1) ? SDLTest_RandomIntegerInRange(1, 4096) : 0;
   494       target.h = (variation & 2) ? SDLTest_RandomIntegerInRange(1, 4096) : 0;    
   495       target.format = (variation & 4) ? SDLTest_RandomIntegerInRange(1, 10) : 0;
   496       target.refresh_rate = (variation & 8) ? SDLTest_RandomIntegerInRange(25, 120) : 0;
   497       target.driverdata = 0;
   498           
   499       /* Make call; may or may not find anything, so don't validate any further */
   500       dResult = SDL_GetClosestDisplayMode(i, &target, &closest);
   501       SDLTest_AssertPass("Call to SDL_GetClosestDisplayMode(target=random/variation%d)", variation);      
   502     }
   503   }
   504 
   505   return TEST_COMPLETED;
   506 }
   507 
   508 /**
   509  * @brief Tests call to SDL_GetWindowBrightness
   510  *
   511 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowBrightness
   512  */
   513 int
   514 video_getWindowBrightness(void *arg)
   515 {
   516   SDL_Window* window;
   517   const char* title = "video_getWindowBrightness Test Window";
   518   float result;
   519 
   520   /* Call against new test window */ 
   521   window = _createVideoSuiteTestWindow(title);
   522   if (window != NULL) {
   523       result = SDL_GetWindowBrightness(window);
   524       SDLTest_AssertPass("Call to SDL_GetWindowBrightness");
   525       SDLTest_AssertCheck(result >= 0.0 && result <= 1.0, "Validate range of result value; expected: [0.0, 1.0], got: %f", result);
   526   }
   527 
   528   /* Clean up */    
   529   _destroyVideoSuiteTestWindow(window);
   530   
   531   return TEST_COMPLETED;
   532 }
   533 
   534 /**
   535  * @brief Tests call to SDL_GetWindowBrightness with invalid input
   536  *
   537 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowBrightness
   538  */
   539 int
   540 video_getWindowBrightnessNegative(void *arg)
   541 {
   542   const char *invalidWindowError = "Invalid window";
   543   char *lastError;
   544   const char* title = "video_getWindowBrightnessNegative Test Window";
   545   float result;
   546 
   547   /* Call against invalid window */ 
   548   result = SDL_GetWindowBrightness(NULL);
   549   SDLTest_AssertPass("Call to SDL_GetWindowBrightness(window=NULL)");
   550   SDLTest_AssertCheck(result == 1.0, "Validate result value; expected: 1.0, got: %f", result);
   551   lastError = (char *)SDL_GetError();
   552   SDLTest_AssertPass("SDL_GetError()");
   553   SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
   554   if (lastError != NULL) {
   555       SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
   556          "SDL_GetError(): expected message '%s', was message: '%s'",
   557          invalidWindowError,
   558          lastError);
   559   }
   560 
   561   return TEST_COMPLETED;
   562 }
   563 
   564 /**
   565  * @brief Tests call to SDL_GetWindowDisplayMode
   566  *
   567  * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowDisplayMode
   568  */
   569 int
   570 video_getWindowDisplayMode(void *arg)
   571 {
   572   SDL_Window* window;
   573   const char* title = "video_getWindowDisplayMode Test Window";
   574   SDL_DisplayMode mode;
   575   int result;
   576 
   577   /* Invalidate part of the mode content so we can check values later */
   578   mode.w = -1;
   579   mode.h = -1;
   580   mode.refresh_rate = -1;
   581 
   582   /* Call against new test window */ 
   583   window = _createVideoSuiteTestWindow(title);
   584   if (window != NULL) {
   585       result = SDL_GetWindowDisplayMode(window, &mode);
   586       SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode");
   587       SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
   588       SDLTest_AssertCheck(mode.w > 0, "Validate mode.w content; expected: >0, got: %d", mode.w);
   589       SDLTest_AssertCheck(mode.h > 0, "Validate mode.h content; expected: >0, got: %d", mode.h);
   590       SDLTest_AssertCheck(mode.refresh_rate > 0, "Validate mode.refresh_rate content; expected: >0, got: %d", mode.refresh_rate);
   591   }
   592 
   593   /* Clean up */    
   594   _destroyVideoSuiteTestWindow(window);
   595   
   596   return TEST_COMPLETED;
   597 }
   598 
   599 /* Helper function that checks for an 'Invalid window' error */
   600 void _checkInvalidWindowError()
   601 {
   602   const char *invalidWindowError = "Invalid window";
   603   char *lastError;
   604 
   605   lastError = (char *)SDL_GetError();
   606   SDLTest_AssertPass("SDL_GetError()");
   607   SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
   608   if (lastError != NULL) {
   609       SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
   610          "SDL_GetError(): expected message '%s', was message: '%s'",
   611          invalidWindowError,
   612          lastError);
   613       SDL_ClearError();
   614       SDLTest_AssertPass("Call to SDL_ClearError()");  
   615   }
   616 }
   617 
   618 /**
   619  * @brief Tests call to SDL_GetWindowDisplayMode with invalid input
   620  *
   621  * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowDisplayMode
   622  */
   623 int
   624 video_getWindowDisplayModeNegative(void *arg)
   625 {
   626   const char *expectedError = "Parameter 'mode' is invalid";
   627   char *lastError;
   628   SDL_Window* window;
   629   const char* title = "video_getWindowDisplayModeNegative Test Window";
   630   SDL_DisplayMode mode;
   631   int result;
   632 
   633   /* Call against new test window */ 
   634   window = _createVideoSuiteTestWindow(title);
   635   if (window != NULL) {
   636       result = SDL_GetWindowDisplayMode(window, NULL);
   637       SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(...,mode=NULL)");
   638       SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result);
   639       lastError = (char *)SDL_GetError();
   640       SDLTest_AssertPass("SDL_GetError()");
   641       SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
   642       if (lastError != NULL) {
   643       	SDLTest_AssertCheck(SDL_strcmp(lastError, expectedError) == 0,
   644              "SDL_GetError(): expected message '%s', was message: '%s'",
   645              expectedError,
   646              lastError);
   647       }
   648   }
   649 
   650   /* Clean up */    
   651   _destroyVideoSuiteTestWindow(window);
   652   
   653   /* Call against invalid window */
   654   result = SDL_GetWindowDisplayMode(NULL, &mode);
   655   SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(window=NULL,...)");
   656   SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result);
   657   _checkInvalidWindowError();
   658 
   659   return TEST_COMPLETED;
   660 }
   661 
   662 /**
   663  * @brief Tests call to SDL_GetWindowGammaRamp
   664  *
   665  * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGammaRamp
   666  */
   667 int
   668 video_getWindowGammaRamp(void *arg)
   669 {
   670   SDL_Window* window;
   671   const char* title = "video_getWindowGammaRamp Test Window";
   672   Uint16 red[256];
   673   Uint16 green[256];
   674   Uint16 blue[256];
   675   int result;
   676 
   677   /* Call against new test window */ 
   678   window = _createVideoSuiteTestWindow(title);
   679   if (window == NULL) return TEST_ABORTED;
   680   
   681   /* Retrieve no channel */
   682   result = SDL_GetWindowGammaRamp(window, NULL, NULL, NULL);
   683   SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(all NULL)");
   684   SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
   685 
   686   /* Retrieve single channel */
   687   result = SDL_GetWindowGammaRamp(window, red, NULL, NULL);
   688   SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r)");
   689   SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
   690 
   691   result = SDL_GetWindowGammaRamp(window, NULL, green, NULL);
   692   SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(g)");
   693   SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
   694 
   695   result = SDL_GetWindowGammaRamp(window, NULL, NULL, blue);
   696   SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(b)");
   697   SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
   698 
   699   /* Retrieve two channels */
   700   result = SDL_GetWindowGammaRamp(window, red, green, NULL);
   701   SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r, g)");
   702   SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
   703 
   704   result = SDL_GetWindowGammaRamp(window, NULL, green, blue);
   705   SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(g,b)");
   706   SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
   707 
   708   result = SDL_GetWindowGammaRamp(window, red, NULL, blue);
   709   SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r,b)");
   710   SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
   711 
   712   /* Retrieve all channels */
   713   result = SDL_GetWindowGammaRamp(window, red, green, blue);
   714   SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r,g,b)");
   715   SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
   716 
   717   /* Clean up */    
   718   _destroyVideoSuiteTestWindow(window);
   719   
   720   return TEST_COMPLETED;
   721 }
   722 
   723 /**
   724  * @brief Tests call to SDL_GetWindowGammaRamp with invalid input
   725  *
   726 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGammaRamp
   727  */
   728 int
   729 video_getWindowGammaRampNegative(void *arg)
   730 {
   731   const char* title = "video_getWindowGammaRampNegative Test Window";
   732   Uint16 red[256];
   733   Uint16 green[256];
   734   Uint16 blue[256];
   735   int result;
   736 
   737   SDL_ClearError();
   738   SDLTest_AssertPass("Call to SDL_ClearError()");
   739 
   740   /* Call against invalid window */ 
   741   result = SDL_GetWindowGammaRamp(NULL, red, green, blue);
   742   SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(window=NULL,r,g,b)");
   743   SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %f", result);
   744   _checkInvalidWindowError();
   745   
   746   return TEST_COMPLETED;
   747 }
   748 
   749 /* Helper for setting and checking the window grab state */
   750 void 
   751 _setAndCheckWindowGrabState(SDL_Window* window, SDL_bool desiredState)
   752 {
   753   SDL_bool currentState;
   754   
   755   /* Set state */
   756   SDL_SetWindowGrab(window, desiredState);
   757   SDLTest_AssertPass("Call to SDL_SetWindowGrab(%s)", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
   758 
   759   /* Get and check state */
   760   currentState = SDL_GetWindowGrab(window);
   761   SDLTest_AssertPass("Call to SDL_GetWindowGrab()");
   762   SDLTest_AssertCheck(
   763       currentState == desiredState, 
   764       "Validate returned state; expected: %s, got: %s", 
   765       (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE",
   766       (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
   767 }
   768 
   769 /**
   770  * @brief Tests call to SDL_GetWindowGrab and SDL_SetWindowGrab
   771  *
   772  * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGrab
   773  * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowGrab
   774  */
   775 int
   776 video_getSetWindowGrab(void *arg)
   777 {
   778   const char* title = "video_getSetWindowGrab Test Window";
   779   SDL_Window* window;
   780   SDL_bool originalState, dummyState, currentState, desiredState;
   781 
   782   /* Call against new test window */ 
   783   window = _createVideoSuiteTestWindow(title);
   784   if (window == NULL) return TEST_ABORTED;
   785 
   786   /* Get state */  
   787   originalState = SDL_GetWindowGrab(window);
   788   SDLTest_AssertPass("Call to SDL_GetWindowGrab()");
   789 
   790   /* F */
   791   _setAndCheckWindowGrabState(window, SDL_FALSE);
   792 
   793   /* F --> F */
   794   _setAndCheckWindowGrabState(window, SDL_FALSE);
   795   
   796   /* F --> T */
   797   _setAndCheckWindowGrabState(window, SDL_TRUE);
   798 
   799   /* T --> T */
   800   _setAndCheckWindowGrabState(window, SDL_TRUE);
   801 
   802   /* T --> F */
   803   _setAndCheckWindowGrabState(window, SDL_FALSE);
   804   
   805   /* Negative tests */
   806   dummyState = SDL_GetWindowGrab(NULL);
   807   SDLTest_AssertPass("Call to SDL_GetWindowGrab(window=NULL)");
   808   _checkInvalidWindowError();
   809 
   810   SDL_SetWindowGrab(NULL, SDL_FALSE);
   811   SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
   812   _checkInvalidWindowError();
   813 
   814   SDL_SetWindowGrab(NULL, SDL_TRUE);
   815   SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
   816   _checkInvalidWindowError();
   817   
   818   /* State should still be F */
   819   desiredState = SDL_FALSE;
   820   currentState = SDL_GetWindowGrab(window);
   821   SDLTest_AssertPass("Call to SDL_GetWindowGrab()");
   822   SDLTest_AssertCheck(
   823       currentState == desiredState, 
   824       "Validate returned state; expected: %s, got: %s", 
   825       (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE",
   826       (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
   827     
   828   /* Restore state */  
   829   _setAndCheckWindowGrabState(window, originalState);
   830 
   831   /* Clean up */    
   832   _destroyVideoSuiteTestWindow(window);
   833 
   834   return TEST_COMPLETED;
   835 }
   836 
   837 
   838 /**
   839  * @brief Tests call to SDL_GetWindowID and SDL_GetWindowFromID
   840  *
   841  * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowID
   842  * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowFromID
   843  */
   844 int
   845 video_getWindowId(void *arg)
   846 {
   847   const char* title = "video_getWindowId Test Window";
   848   SDL_Window* window;
   849   SDL_Window* result;
   850   Uint32 id, randomId;
   851 
   852   /* Call against new test window */ 
   853   window = _createVideoSuiteTestWindow(title);
   854   if (window == NULL) return TEST_ABORTED;
   855 
   856   /* Get ID */
   857   id = SDL_GetWindowID(window);
   858   SDLTest_AssertPass("Call to SDL_GetWindowID()");
   859 
   860   /* Get window from ID */
   861   result = SDL_GetWindowFromID(id);
   862   SDLTest_AssertPass("Call to SDL_GetWindowID(%d)", id);
   863   SDLTest_AssertCheck(result == window, "Verify result matches window pointer");
   864 
   865   /* Get window from random large ID, no result check */
   866   randomId = SDLTest_RandomIntegerInRange(UINT8_MAX,UINT16_MAX);
   867   result = SDL_GetWindowFromID(randomId);
   868   SDLTest_AssertPass("Call to SDL_GetWindowID(%d/random_large)", randomId);
   869 
   870   /* Get window from 0 and Uint32 max ID, no result check */
   871   result = SDL_GetWindowFromID(0);
   872   SDLTest_AssertPass("Call to SDL_GetWindowID(0)");
   873   result = SDL_GetWindowFromID(UINT32_MAX);
   874   SDLTest_AssertPass("Call to SDL_GetWindowID(UINT32_MAX)");
   875 
   876   /* Clean up */    
   877   _destroyVideoSuiteTestWindow(window);
   878     
   879   /* Get window from ID for closed window*/
   880   result = SDL_GetWindowFromID(id);
   881   SDLTest_AssertPass("Call to SDL_GetWindowID(%d/closed_window)", id);
   882   SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
   883 
   884   /* Negative test */
   885   SDL_ClearError();
   886   SDLTest_AssertPass("Call to SDL_ClearError()");
   887   id = SDL_GetWindowID(NULL);
   888   SDLTest_AssertPass("Call to SDL_GetWindowID(window=NULL)");
   889   _checkInvalidWindowError();
   890   
   891   return TEST_COMPLETED;
   892 }
   893 
   894 /**
   895  * @brief Tests call to SDL_GetWindowPixelFormat
   896  *
   897  * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowPixelFormat
   898  */
   899 int
   900 video_getWindowPixelFormat(void *arg)
   901 {
   902   const char* title = "video_getWindowPixelFormat Test Window";
   903   SDL_Window* window;
   904   Uint32 format;
   905 
   906   /* Call against new test window */ 
   907   window = _createVideoSuiteTestWindow(title);
   908   if (window == NULL) return TEST_ABORTED;
   909 
   910   /* Get format */
   911   format = SDL_GetWindowPixelFormat(window);
   912   SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat()");
   913   SDLTest_AssertCheck(format != SDL_PIXELFORMAT_UNKNOWN, "Verify that returned format is valid; expected: != %d, got: %d", SDL_PIXELFORMAT_UNKNOWN, format);
   914    
   915   /* Clean up */    
   916   _destroyVideoSuiteTestWindow(window);
   917     
   918   /* Negative test */
   919   SDL_ClearError();
   920   SDLTest_AssertPass("Call to SDL_ClearError()");
   921   format = SDL_GetWindowPixelFormat(NULL);
   922   SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat(window=NULL)");
   923   _checkInvalidWindowError();
   924 
   925   return TEST_COMPLETED;
   926 }
   927 
   928 /**
   929  * @brief Tests call to SDL_GetWindowPosition and SDL_SetWindowPosition
   930  *
   931  * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowPosition
   932  * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowPosition
   933  */
   934 int
   935 video_getSetWindowPosition(void *arg)
   936 {
   937   const char* title = "video_getSetWindowPosition Test Window";
   938   SDL_Window* window;
   939   int xVariation, yVariation;
   940   int referenceX, referenceY;
   941   int currentX, currentY;
   942   int desiredX, desiredY;
   943 
   944   /* Call against new test window */ 
   945   window = _createVideoSuiteTestWindow(title);
   946   if (window == NULL) return TEST_ABORTED;
   947   
   948   for (xVariation = 0; xVariation < 4; xVariation++) {
   949    for (yVariation = 0; yVariation < 4; yVariation++) {
   950     switch(xVariation) {
   951      case 0:
   952       /* Zero X Position */  
   953       desiredX = 0;
   954       break;
   955      case 1:
   956       /* Random X position inside screen */  
   957       desiredX = SDLTest_RandomIntegerInRange(1, 100);
   958       break;
   959      case 2:
   960       /* Random X position outside screen (positive) */  
   961       desiredX = SDLTest_RandomIntegerInRange(10000, 11000);
   962       break;
   963      case 3:
   964       /* Random X position outside screen (negative) */  
   965       desiredX = SDLTest_RandomIntegerInRange(-1000, -100);
   966       break;
   967     }
   968 
   969     switch(yVariation) {
   970      case 0:
   971       /* Zero X Position */  
   972       desiredY = 0;
   973       break;
   974      case 1:
   975       /* Random X position inside screen */  
   976       desiredY = SDLTest_RandomIntegerInRange(1, 100);
   977       break;
   978      case 2:
   979       /* Random X position outside screen (positive) */  
   980       desiredY = SDLTest_RandomIntegerInRange(10000, 11000);
   981       break;
   982      case 3:
   983       /* Random Y position outside screen (negative) */  
   984       desiredY = SDLTest_RandomIntegerInRange(-1000, -100);
   985       break;
   986     }
   987 
   988     /* Set position */
   989     SDL_SetWindowPosition(window, desiredX, desiredY);
   990     SDLTest_AssertPass("Call to SDL_SetWindowPosition(...,%d,%d)", desiredX, desiredY);
   991    
   992     /* Get position */
   993     currentX = desiredX + 1;
   994     currentY = desiredY + 1;
   995     SDL_GetWindowPosition(window, &currentX, &currentY);
   996     SDLTest_AssertPass("Call to SDL_GetWindowPosition()");
   997     SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX);
   998     SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY);
   999 
  1000     /* Get position X */
  1001     currentX = desiredX + 1;    
  1002     SDL_GetWindowPosition(window, &currentX, NULL);
  1003     SDLTest_AssertPass("Call to SDL_GetWindowPosition(&y=NULL)");
  1004     SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX);
  1005 
  1006     /* Get position Y */
  1007     currentY = desiredY + 1;
  1008     SDL_GetWindowPosition(window, NULL, &currentY);
  1009     SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL)");
  1010     SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY);
  1011    }
  1012   }
  1013 
  1014   /* Dummy call with both pointers NULL */
  1015   SDL_GetWindowPosition(window, NULL, NULL);
  1016   SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL,&y=NULL)");
  1017    
  1018   /* Clean up */    
  1019   _destroyVideoSuiteTestWindow(window);
  1020     
  1021   /* Set some 'magic' value for later check that nothing was changed */
  1022   referenceX = SDLTest_RandomSint32();
  1023   referenceY = SDLTest_RandomSint32();
  1024   currentX = referenceX;
  1025   currentY = referenceY;
  1026   desiredX = SDLTest_RandomSint32();
  1027   desiredY = SDLTest_RandomSint32();
  1028 
  1029   /* Negative tests */
  1030   SDL_ClearError();
  1031   SDLTest_AssertPass("Call to SDL_ClearError()");  
  1032   SDL_GetWindowPosition(NULL, &currentX, &currentY);
  1033   SDLTest_AssertPass("Call to SDL_GetWindowPosition(window=NULL)");
  1034   SDLTest_AssertCheck(
  1035   	currentX == referenceX && currentY == referenceY, 
  1036   	"Verify that content of X and Y pointers has not been modified; expected: %d,%d; got: %d,%d",
  1037   	referenceX, referenceY,
  1038   	currentX, currentY);
  1039   _checkInvalidWindowError();
  1040 
  1041   SDL_GetWindowPosition(NULL, NULL, NULL);
  1042   SDLTest_AssertPass("Call to SDL_GetWindowPosition(NULL, NULL, NULL)");
  1043   _checkInvalidWindowError();
  1044 
  1045   SDL_SetWindowPosition(NULL, desiredX, desiredY);
  1046   SDLTest_AssertPass("Call to SDL_SetWindowPosition(window=NULL)");
  1047   _checkInvalidWindowError();
  1048   
  1049   return TEST_COMPLETED;
  1050 }
  1051 
  1052 /* Helper function that checks for an 'Invalid parameter' error */
  1053 void _checkInvalidParameterError()
  1054 {
  1055   const char *invalidParameterError = "Parameter";
  1056   char *lastError;
  1057 
  1058   lastError = (char *)SDL_GetError();
  1059   SDLTest_AssertPass("SDL_GetError()");
  1060   SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
  1061   if (lastError != NULL) {
  1062       SDLTest_AssertCheck(SDL_strncmp(lastError, invalidParameterError, SDL_strlen(invalidParameterError)) == 0,
  1063          "SDL_GetError(): expected message starts with '%s', was message: '%s'",
  1064          invalidParameterError,
  1065          lastError);
  1066       SDL_ClearError();
  1067       SDLTest_AssertPass("Call to SDL_ClearError()");  
  1068   }
  1069 }
  1070 
  1071 /**
  1072  * @brief Tests call to SDL_GetWindowSize and SDL_SetWindowSize
  1073  *
  1074  * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowSize
  1075  * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowSize
  1076  */
  1077 int
  1078 video_getSetWindowSize(void *arg)
  1079 {
  1080   const char* title = "video_getSetWindowSize Test Window";
  1081   SDL_Window* window;
  1082   int result;
  1083   SDL_Rect display;
  1084   int wVariation, hVariation;
  1085   int referenceW, referenceH;
  1086   int currentW, currentH;
  1087   int desiredW, desiredH;
  1088 
  1089   /* Get display bounds for size range */
  1090   result = SDL_GetDisplayBounds(0, &display);
  1091   SDLTest_AssertPass("SDL_GetDisplayBounds()");
  1092   SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
  1093   if (result != 0) return TEST_ABORTED;
  1094   
  1095   /* Call against new test window */ 
  1096   window = _createVideoSuiteTestWindow(title);
  1097   if (window == NULL) return TEST_ABORTED;
  1098   
  1099   for (wVariation = 0; wVariation < 4; wVariation++) {
  1100    for (hVariation = 0; hVariation < 4; hVariation++) {
  1101     switch(wVariation) {
  1102      case 0:
  1103       /* 1 Pixel Wide */  
  1104       desiredW = 1;
  1105       break;
  1106      case 1:
  1107       /* Random width inside screen */  
  1108       desiredW = SDLTest_RandomIntegerInRange(1, 100);
  1109       break;
  1110      case 2:
  1111       /* Width at screen size */  
  1112       desiredW = display.w;
  1113       break;
  1114      case 3:
  1115       /* Width 1 pixel larger than screen */  
  1116       desiredW = display.w + 1;
  1117       break;
  1118     }
  1119 
  1120     switch(hVariation) {
  1121      case 0:
  1122       /* 1 Pixel High */  
  1123       desiredH = 1;
  1124       break;
  1125      case 1:
  1126       /* Random height inside screen */  
  1127       desiredH = SDLTest_RandomIntegerInRange(1, 100);
  1128       break;
  1129      case 2:
  1130       /* Height at screen size */  
  1131       desiredH = display.h;
  1132       break;
  1133      case 3:
  1134       /* Height 1 pixel larger than screen */  
  1135       desiredH = display.h + 1;
  1136       break;
  1137     }
  1138 
  1139     /* Set size */
  1140     SDL_SetWindowSize(window, desiredW, desiredH);
  1141     SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH);
  1142    
  1143     /* Get size */
  1144     currentW = desiredW + 1;
  1145     currentH = desiredH + 1;
  1146     SDL_GetWindowSize(window, &currentW, &currentH);
  1147     SDLTest_AssertPass("Call to SDL_GetWindowSize()");
  1148     SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
  1149     SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
  1150 
  1151     /* Get just width */
  1152     currentW = desiredW + 1;    
  1153     SDL_GetWindowSize(window, &currentW, NULL);
  1154     SDLTest_AssertPass("Call to SDL_GetWindowSize(&h=NULL)");
  1155     SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
  1156 
  1157     /* Get just height */
  1158     currentH = desiredH + 1;
  1159     SDL_GetWindowSize(window, NULL, &currentH);
  1160     SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL)");
  1161     SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
  1162    }
  1163   }
  1164 
  1165   /* Dummy call with both pointers NULL */
  1166   SDL_GetWindowSize(window, NULL, NULL);
  1167   SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL,&h=NULL)");
  1168 
  1169   /* Negative tests for parameter input */
  1170   SDL_ClearError();
  1171   SDLTest_AssertPass("Call to SDL_ClearError()");  
  1172   for (desiredH = -2; desiredH < 2; desiredH++) {
  1173     for (desiredW = -2; desiredW < 2; desiredW++) {
  1174       if (desiredW <= 0 || desiredH <= 0) { 
  1175         SDL_SetWindowSize(window, desiredW, desiredH);
  1176         SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH);
  1177         _checkInvalidParameterError();
  1178       }
  1179     }
  1180   }
  1181    
  1182   /* Clean up */    
  1183   _destroyVideoSuiteTestWindow(window);
  1184     
  1185   /* Set some 'magic' value for later check that nothing was changed */
  1186   referenceW = SDLTest_RandomSint32();
  1187   referenceH = SDLTest_RandomSint32();
  1188   currentW = referenceW;
  1189   currentH = referenceH;
  1190   desiredW = SDLTest_RandomSint32();
  1191   desiredH = SDLTest_RandomSint32();
  1192   
  1193   /* Negative tests for window input */
  1194   SDL_ClearError();
  1195   SDLTest_AssertPass("Call to SDL_ClearError()");
  1196   SDL_GetWindowSize(NULL, &currentW, &currentH);
  1197   SDLTest_AssertPass("Call to SDL_GetWindowSize(window=NULL)");
  1198   SDLTest_AssertCheck(
  1199   	currentW == referenceW && currentH == referenceH, 
  1200   	"Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
  1201   	referenceW, referenceH,
  1202   	currentW, currentH);
  1203   _checkInvalidWindowError();
  1204 
  1205   SDL_GetWindowSize(NULL, NULL, NULL);
  1206   SDLTest_AssertPass("Call to SDL_GetWindowSize(NULL, NULL, NULL)");
  1207   _checkInvalidWindowError();
  1208 
  1209   SDL_SetWindowSize(NULL, desiredW, desiredH);
  1210   SDLTest_AssertPass("Call to SDL_SetWindowSize(window=NULL)");
  1211   _checkInvalidWindowError();
  1212   
  1213   return TEST_COMPLETED;
  1214 }
  1215 
  1216 /**
  1217  * @brief Tests call to SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize
  1218  *
  1219  */
  1220 int
  1221 video_getSetWindowMinimumSize(void *arg)
  1222 {
  1223   const char* title = "video_getSetWindowMinimumSize Test Window";
  1224   SDL_Window* window;
  1225   int result;
  1226   SDL_Rect display;
  1227   int wVariation, hVariation;
  1228   int referenceW, referenceH;
  1229   int currentW, currentH;
  1230   int desiredW, desiredH;
  1231 
  1232   /* Get display bounds for size range */
  1233   result = SDL_GetDisplayBounds(0, &display);
  1234   SDLTest_AssertPass("SDL_GetDisplayBounds()");
  1235   SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
  1236   if (result != 0) return TEST_ABORTED;
  1237 
  1238   /* Call against new test window */ 
  1239   window = _createVideoSuiteTestWindow(title);
  1240   if (window == NULL) return TEST_ABORTED;
  1241   
  1242   for (wVariation = 0; wVariation < 5; wVariation++) {
  1243    for (hVariation = 0; hVariation < 5; hVariation++) {
  1244     switch(wVariation) {
  1245      case 0:
  1246       /* 1 Pixel Wide */  
  1247       desiredW = 1;
  1248       break;
  1249      case 1:
  1250       /* Random width inside screen */  
  1251       desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1);
  1252       break;
  1253      case 2:
  1254       /* Width at screen size */  
  1255       desiredW = display.w;
  1256       break;
  1257     }
  1258 
  1259     switch(hVariation) {
  1260      case 0:
  1261       /* 1 Pixel High */  
  1262       desiredH = 1;
  1263       break;
  1264      case 1:
  1265       /* Random height inside screen */  
  1266       desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1);
  1267       break;
  1268      case 2:
  1269       /* Height at screen size */  
  1270       desiredH = display.h;
  1271       break;
  1272      case 4:
  1273       /* Height 1 pixel larger than screen */  
  1274       desiredH = display.h + 1;
  1275       break;
  1276     }
  1277 
  1278     /* Set size */
  1279     SDL_SetWindowMinimumSize(window, desiredW, desiredH);
  1280     SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH);
  1281    
  1282     /* Get size */
  1283     currentW = desiredW + 1;
  1284     currentH = desiredH + 1;
  1285     SDL_GetWindowMinimumSize(window, &currentW, &currentH);
  1286     SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize()");
  1287     SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
  1288     SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
  1289 
  1290     /* Get just width */
  1291     currentW = desiredW + 1;    
  1292     SDL_GetWindowMinimumSize(window, &currentW, NULL);
  1293     SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&h=NULL)");
  1294     SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
  1295 
  1296     /* Get just height */
  1297     currentH = desiredH + 1;
  1298     SDL_GetWindowMinimumSize(window, NULL, &currentH);
  1299     SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL)");
  1300     SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
  1301    }
  1302   }
  1303 
  1304   /* Dummy call with both pointers NULL */
  1305   SDL_GetWindowMinimumSize(window, NULL, NULL);
  1306   SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL,&h=NULL)");
  1307 
  1308   /* Negative tests for parameter input */
  1309   SDL_ClearError();
  1310   SDLTest_AssertPass("Call to SDL_ClearError()");  
  1311   for (desiredH = -2; desiredH < 2; desiredH++) {
  1312     for (desiredW = -2; desiredW < 2; desiredW++) {
  1313       if (desiredW <= 0 || desiredH <= 0) { 
  1314         SDL_SetWindowMinimumSize(window, desiredW, desiredH);
  1315         SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH);
  1316         _checkInvalidParameterError();
  1317       }
  1318     }
  1319   }
  1320    
  1321   /* Clean up */    
  1322   _destroyVideoSuiteTestWindow(window);
  1323     
  1324   /* Set some 'magic' value for later check that nothing was changed */
  1325   referenceW = SDLTest_RandomSint32();
  1326   referenceH = SDLTest_RandomSint32();
  1327   currentW = referenceW;
  1328   currentH = referenceH;
  1329   desiredW = SDLTest_RandomSint32();
  1330   desiredH = SDLTest_RandomSint32();
  1331   
  1332   /* Negative tests for window input */
  1333   SDL_ClearError();
  1334   SDLTest_AssertPass("Call to SDL_ClearError()");
  1335   SDL_GetWindowMinimumSize(NULL, &currentW, &currentH);
  1336   SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(window=NULL)");
  1337   SDLTest_AssertCheck(
  1338   	currentW == referenceW && currentH == referenceH, 
  1339   	"Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
  1340   	referenceW, referenceH,
  1341   	currentW, currentH);
  1342   _checkInvalidWindowError();
  1343 
  1344   SDL_GetWindowMinimumSize(NULL, NULL, NULL);
  1345   SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(NULL, NULL, NULL)");
  1346   _checkInvalidWindowError();
  1347 
  1348   SDL_SetWindowMinimumSize(NULL, desiredW, desiredH);
  1349   SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(window=NULL)");
  1350   _checkInvalidWindowError();
  1351   
  1352   return TEST_COMPLETED;
  1353 }
  1354 
  1355 /**
  1356  * @brief Tests call to SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize
  1357  *
  1358  */
  1359 int
  1360 video_getSetWindowMaximumSize(void *arg)
  1361 {
  1362   const char* title = "video_getSetWindowMaximumSize Test Window";
  1363   SDL_Window* window;
  1364   int result;
  1365   SDL_Rect display;
  1366   int wVariation, hVariation;
  1367   int referenceW, referenceH;
  1368   int currentW, currentH;
  1369   int desiredW, desiredH;
  1370 
  1371   /* Get display bounds for size range */
  1372   result = SDL_GetDisplayBounds(0, &display);
  1373   SDLTest_AssertPass("SDL_GetDisplayBounds()");
  1374   SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
  1375   if (result != 0) return TEST_ABORTED;
  1376 
  1377   /* Call against new test window */ 
  1378   window = _createVideoSuiteTestWindow(title);
  1379   if (window == NULL) return TEST_ABORTED;
  1380   
  1381   for (wVariation = 0; wVariation < 3; wVariation++) {
  1382    for (hVariation = 0; hVariation < 3; hVariation++) {
  1383     switch(wVariation) {
  1384      case 0:
  1385       /* 1 Pixel Wide */  
  1386       desiredW = 1;
  1387       break;
  1388      case 1:
  1389       /* Random width inside screen */  
  1390       desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1);
  1391       break;
  1392      case 2:
  1393       /* Width at screen size */  
  1394       desiredW = display.w;
  1395       break;
  1396     }
  1397 
  1398     switch(hVariation) {
  1399      case 0:
  1400       /* 1 Pixel High */  
  1401       desiredH = 1;
  1402       break;
  1403      case 1:
  1404       /* Random height inside screen */  
  1405       desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1);
  1406       break;
  1407      case 2:
  1408       /* Height at screen size */  
  1409       desiredH = display.h;
  1410       break;
  1411     }
  1412 
  1413     /* Set size */
  1414     SDL_SetWindowMaximumSize(window, desiredW, desiredH);
  1415     SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH);
  1416    
  1417     /* Get size */
  1418     currentW = desiredW + 1;
  1419     currentH = desiredH + 1;
  1420     SDL_GetWindowMaximumSize(window, &currentW, &currentH);
  1421     SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize()");
  1422     SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
  1423     SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
  1424 
  1425     /* Get just width */
  1426     currentW = desiredW + 1;    
  1427     SDL_GetWindowMaximumSize(window, &currentW, NULL);
  1428     SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&h=NULL)");
  1429     SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
  1430 
  1431     /* Get just height */
  1432     currentH = desiredH + 1;
  1433     SDL_GetWindowMaximumSize(window, NULL, &currentH);
  1434     SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL)");
  1435     SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
  1436    }
  1437   }
  1438 
  1439   /* Dummy call with both pointers NULL */
  1440   SDL_GetWindowMaximumSize(window, NULL, NULL);
  1441   SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL,&h=NULL)");
  1442 
  1443   /* Negative tests for parameter input */
  1444   SDL_ClearError();
  1445   SDLTest_AssertPass("Call to SDL_ClearError()");  
  1446   for (desiredH = -2; desiredH < 2; desiredH++) {
  1447     for (desiredW = -2; desiredW < 2; desiredW++) {
  1448       if (desiredW <= 0 || desiredH <= 0) { 
  1449         SDL_SetWindowMaximumSize(window, desiredW, desiredH);
  1450         SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH);
  1451         _checkInvalidParameterError();
  1452       }
  1453     }
  1454   }
  1455    
  1456   /* Clean up */    
  1457   _destroyVideoSuiteTestWindow(window);
  1458     
  1459   /* Set some 'magic' value for later check that nothing was changed */
  1460   referenceW = SDLTest_RandomSint32();
  1461   referenceH = SDLTest_RandomSint32();
  1462   currentW = referenceW;
  1463   currentH = referenceH;
  1464   desiredW = SDLTest_RandomSint32();
  1465   desiredH = SDLTest_RandomSint32();
  1466   
  1467   /* Negative tests */
  1468   SDL_ClearError();
  1469   SDLTest_AssertPass("Call to SDL_ClearError()");
  1470   SDL_GetWindowMaximumSize(NULL, &currentW, &currentH);
  1471   SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(window=NULL)");
  1472   SDLTest_AssertCheck(
  1473   	currentW == referenceW && currentH == referenceH, 
  1474   	"Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
  1475   	referenceW, referenceH,
  1476   	currentW, currentH);
  1477   _checkInvalidWindowError();
  1478 
  1479   SDL_GetWindowMaximumSize(NULL, NULL, NULL);
  1480   SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(NULL, NULL, NULL)");
  1481   _checkInvalidWindowError();
  1482 
  1483   SDL_SetWindowMaximumSize(NULL, desiredW, desiredH);
  1484   SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(window=NULL)");
  1485   _checkInvalidWindowError();
  1486   
  1487   return TEST_COMPLETED;
  1488 }
  1489 
  1490 
  1491 /**
  1492  * @brief Tests call to SDL_SetWindowData and SDL_GetWindowData
  1493  *
  1494  * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowData
  1495  * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowData
  1496  */
  1497 int
  1498 video_getSetWindowData(void *arg)
  1499 {
  1500   int returnValue = TEST_COMPLETED;
  1501   const char* title = "video_setGetWindowData Test Window";
  1502   SDL_Window* window;
  1503   const char *referenceName = "TestName";
  1504   const char *name = "TestName";
  1505   const char *referenceName2 = "TestName2";
  1506   const char *name2 = "TestName2";
  1507   int datasize;
  1508   char *referenceUserdata;
  1509   char *userdata;
  1510   char *referenceUserdata2;
  1511   char *userdata2;
  1512   char *result;
  1513   int iteration;
  1514 
  1515   /* Call against new test window */ 
  1516   window = _createVideoSuiteTestWindow(title);
  1517   if (window == NULL) return TEST_ABORTED;
  1518 
  1519   /* Create testdata */
  1520   datasize = SDLTest_RandomIntegerInRange(1, 32); 
  1521   referenceUserdata =  SDLTest_RandomAsciiStringOfSize(datasize);
  1522   if (referenceUserdata == NULL) { 
  1523   	returnValue = TEST_ABORTED; 
  1524   	goto cleanup; 
  1525   }
  1526   userdata = SDL_strdup(referenceUserdata);
  1527   if (userdata == NULL) {
  1528   	returnValue = TEST_ABORTED; 
  1529   	goto cleanup; 
  1530   }
  1531   datasize = SDLTest_RandomIntegerInRange(1, 32); 
  1532   referenceUserdata2 =  SDLTest_RandomAsciiStringOfSize(datasize);
  1533   if (referenceUserdata2 == NULL) { 
  1534   	returnValue = TEST_ABORTED; 
  1535   	goto cleanup; 
  1536   }
  1537   userdata2 = (char *)strdup(referenceUserdata2);
  1538   if (userdata2 == NULL) {
  1539   	returnValue = TEST_ABORTED;
  1540   	goto cleanup;
  1541   }
  1542  
  1543   /* Get non-existent data */
  1544   result = (char *)SDL_GetWindowData(window, name);
  1545   SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name);
  1546   SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1547   SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1548   
  1549   /* Set data */
  1550   result = SDL_SetWindowData(window, name, userdata);
  1551   SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s)", name, userdata);
  1552   SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1553   SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1554   SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
  1555   
  1556   /* Get data (twice) */
  1557   for (iteration = 1; iteration <= 2; iteration++) {
  1558     result = (char *)SDL_GetWindowData(window, name);
  1559     SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [iteration %d]", name, iteration);
  1560     SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
  1561     SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1562   }
  1563   
  1564   /* Set data again twice */
  1565   for (iteration = 1; iteration <= 2; iteration++) {
  1566     result = SDL_SetWindowData(window, name, userdata);
  1567     SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [iteration %d]", name, userdata, iteration);
  1568     SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
  1569     SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1570     SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
  1571   }
  1572   
  1573   /* Get data again */
  1574   result = (char *)SDL_GetWindowData(window, name);
  1575   SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [again]", name);
  1576   SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
  1577   SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1578 
  1579   /* Set data with new data */
  1580   result = SDL_SetWindowData(window, name, userdata2);
  1581   SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [new userdata]", name, userdata2);
  1582   SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
  1583   SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1584   SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
  1585   SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
  1586 
  1587   /* Set data with new data again */
  1588   result = SDL_SetWindowData(window, name, userdata2);
  1589   SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [new userdata again]", name, userdata2);
  1590   SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result);
  1591   SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1592   SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
  1593   SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
  1594   
  1595   /* Get new data */
  1596   result = (char *)SDL_GetWindowData(window, name);
  1597   SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name);
  1598   SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result);
  1599   SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1600 
  1601   /* Set data with NULL to clear */
  1602   result = SDL_SetWindowData(window, name, NULL);
  1603   SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,NULL)", name, userdata);
  1604   SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result);
  1605   SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1606   SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
  1607   SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
  1608 
  1609   /* Set data with NULL to clear again */
  1610   result = SDL_SetWindowData(window, name, NULL);
  1611   SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,NULL) [again]", name, userdata);
  1612   SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1613   SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1614   SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
  1615   SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
  1616   
  1617   /* Get non-existent data */
  1618   result = (char *)SDL_GetWindowData(window, name);
  1619   SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name);
  1620   SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1621   SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1622 
  1623   /* Get non-existent data new name */
  1624   result = (char *)SDL_GetWindowData(window, name2);
  1625   SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name2);
  1626   SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1627   SDLTest_AssertCheck(SDL_strcmp(referenceName2, name2) == 0, "Validate that name2 was not changed, expected: %s, got: %s", referenceName2, name2);
  1628 
  1629   /* Set data (again) */
  1630   result = SDL_SetWindowData(window, name, userdata);
  1631   SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [again, after clear]", name, userdata);
  1632   SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1633   SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1634   SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
  1635   
  1636   /* Get data (again) */
  1637   result = (char *)SDL_GetWindowData(window, name);
  1638   SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [again, after clear]", name);
  1639   SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
  1640   SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
  1641 
  1642   /* Negative test */
  1643   SDL_ClearError();
  1644   SDLTest_AssertPass("Call to SDL_ClearError()");
  1645 
  1646   /* Set with invalid window */ 
  1647   result = SDL_SetWindowData(NULL, name, userdata);
  1648   SDLTest_AssertPass("Call to SDL_SetWindowData(window=NULL)");
  1649   SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1650   _checkInvalidWindowError();
  1651   
  1652   /* Set data with NULL name, valid userdata */
  1653   result = SDL_SetWindowData(window, NULL, userdata);
  1654   SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL)");
  1655   SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1656   _checkInvalidParameterError();
  1657 
  1658   /* Set data with empty name, valid userdata */
  1659   result = SDL_SetWindowData(window, "", userdata);
  1660   SDLTest_AssertPass("Call to SDL_SetWindowData(name='')");
  1661   SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1662   _checkInvalidParameterError();
  1663 
  1664   /* Set data with NULL name, NULL userdata */
  1665   result = SDL_SetWindowData(window, NULL, NULL);
  1666   SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL,userdata=NULL)");
  1667   SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1668   _checkInvalidParameterError();
  1669 
  1670   /* Set data with empty name, NULL userdata */
  1671   result = SDL_SetWindowData(window, "", NULL);
  1672   SDLTest_AssertPass("Call to SDL_SetWindowData(name='',userdata=NULL)");
  1673   SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1674   _checkInvalidParameterError();
  1675 
  1676   /* Get with invalid window */
  1677   result = SDL_GetWindowData(NULL, name);
  1678   SDLTest_AssertPass("Call to SDL_GetWindowData(window=NULL)");
  1679   SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1680   _checkInvalidWindowError();
  1681   
  1682   /* Get data with NULL name */
  1683   result = SDL_GetWindowData(window, NULL);
  1684   SDLTest_AssertPass("Call to SDL_GetWindowData(name=NULL)");
  1685   SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1686   _checkInvalidParameterError();
  1687 
  1688   /* Get data with empty name */
  1689   result = SDL_GetWindowData(window, "");
  1690   SDLTest_AssertPass("Call to SDL_GetWindowData(name='')");
  1691   SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
  1692   _checkInvalidParameterError();
  1693 
  1694   /* Clean up */
  1695   _destroyVideoSuiteTestWindow(window);
  1696          
  1697   cleanup:
  1698   if (referenceUserdata != NULL) SDL_free(referenceUserdata);
  1699   if (referenceUserdata2 != NULL) SDL_free(referenceUserdata2);
  1700   if (userdata != NULL) SDL_free(userdata);
  1701   if (userdata2 != NULL) SDL_free(userdata2);
  1702   
  1703   return returnValue;
  1704 }
  1705 
  1706 
  1707 /* ================= Test References ================== */
  1708 
  1709 /* Video test cases */
  1710 static const SDLTest_TestCaseReference videoTest1 =
  1711 		{ (SDLTest_TestCaseFp)video_enableDisableScreensaver, "video_enableDisableScreensaver",  "Enable and disable screenaver while checking state", TEST_ENABLED };
  1712 
  1713 static const SDLTest_TestCaseReference videoTest2 =
  1714 		{ (SDLTest_TestCaseFp)video_createWindowVariousPositions, "video_createWindowVariousPositions",  "Create windows at various locations", TEST_ENABLED };
  1715 
  1716 static const SDLTest_TestCaseReference videoTest3 =
  1717 		{ (SDLTest_TestCaseFp)video_createWindowVariousSizes, "video_createWindowVariousSizes",  "Create windows with various sizes", TEST_ENABLED };
  1718 
  1719 static const SDLTest_TestCaseReference videoTest4 =
  1720 		{ (SDLTest_TestCaseFp)video_createWindowVariousFlags, "video_createWindowVariousFlags",  "Create windows using various flags", TEST_ENABLED };
  1721 
  1722 static const SDLTest_TestCaseReference videoTest5 =
  1723 		{ (SDLTest_TestCaseFp)video_getWindowFlags, "video_getWindowFlags",  "Get window flags set during SDL_CreateWindow", TEST_ENABLED };
  1724 
  1725 static const SDLTest_TestCaseReference videoTest6 =
  1726 		{ (SDLTest_TestCaseFp)video_getNumDisplayModes, "video_getNumDisplayModes",  "Use SDL_GetNumDisplayModes function to get number of display modes", TEST_ENABLED };
  1727 
  1728 static const SDLTest_TestCaseReference videoTest7 =
  1729 		{ (SDLTest_TestCaseFp)video_getNumDisplayModesNegative, "video_getNumDisplayModesNegative",  "Negative tests for SDL_GetNumDisplayModes", TEST_ENABLED };
  1730 
  1731 static const SDLTest_TestCaseReference videoTest8 =
  1732 		{ (SDLTest_TestCaseFp)video_getClosestDisplayModeCurrentResolution, "video_getClosestDisplayModeCurrentResolution",  "Use function to get closes match to requested display mode for current resolution", TEST_ENABLED };
  1733 
  1734 static const SDLTest_TestCaseReference videoTest9 =
  1735 		{ (SDLTest_TestCaseFp)video_getClosestDisplayModeRandomResolution, "video_getClosestDisplayModeRandomResolution",  "Use function to get closes match to requested display mode for random resolution", TEST_ENABLED };
  1736 
  1737 static const SDLTest_TestCaseReference videoTest10 =
  1738 		{ (SDLTest_TestCaseFp)video_getWindowBrightness, "video_getWindowBrightness",  "Get window brightness", TEST_ENABLED };
  1739 
  1740 static const SDLTest_TestCaseReference videoTest11 =
  1741 		{ (SDLTest_TestCaseFp)video_getWindowBrightnessNegative, "video_getWindowBrightnessNegative",  "Get window brightness with invalid input", TEST_ENABLED };
  1742 
  1743 static const SDLTest_TestCaseReference videoTest12 =
  1744 		{ (SDLTest_TestCaseFp)video_getWindowDisplayMode, "video_getWindowDisplayMode",  "Get window display mode", TEST_ENABLED };
  1745 
  1746 static const SDLTest_TestCaseReference videoTest13 =
  1747 		{ (SDLTest_TestCaseFp)video_getWindowDisplayModeNegative, "video_getWindowDisplayModeNegative",  "Get window display mode with invalid input", TEST_ENABLED };
  1748 
  1749 static const SDLTest_TestCaseReference videoTest14 =
  1750 		{ (SDLTest_TestCaseFp)video_getWindowGammaRamp, "video_getWindowGammaRamp",  "Get window gamma ramp", TEST_ENABLED };
  1751 
  1752 static const SDLTest_TestCaseReference videoTest15 =
  1753 		{ (SDLTest_TestCaseFp)video_getWindowGammaRampNegative, "video_getWindowGammaRampNegative",  "Get window gamma ramp against invalid input", TEST_ENABLED };
  1754 
  1755 static const SDLTest_TestCaseReference videoTest16 =
  1756 		{ (SDLTest_TestCaseFp)video_getSetWindowGrab, "video_getSetWindowGrab",  "Checks SDL_GetWindowGrab and SDL_SetWindowGrab positive and negative cases", TEST_ENABLED };
  1757 
  1758 static const SDLTest_TestCaseReference videoTest17 =
  1759 		{ (SDLTest_TestCaseFp)video_getWindowId, "video_getWindowId",  "Checks SDL_GetWindowID and SDL_GetWindowFromID", TEST_ENABLED };
  1760 
  1761 static const SDLTest_TestCaseReference videoTest18 =
  1762 		{ (SDLTest_TestCaseFp)video_getWindowPixelFormat, "video_getWindowPixelFormat",  "Checks SDL_GetWindowPixelFormat", TEST_ENABLED };
  1763 
  1764 static const SDLTest_TestCaseReference videoTest19 =
  1765 		{ (SDLTest_TestCaseFp)video_getSetWindowPosition, "video_getSetWindowPosition",  "Checks SDL_GetWindowPosition and SDL_SetWindowPosition positive and negative cases", TEST_ENABLED };
  1766 
  1767 static const SDLTest_TestCaseReference videoTest20 =
  1768 		{ (SDLTest_TestCaseFp)video_getSetWindowSize, "video_getSetWindowSize",  "Checks SDL_GetWindowSize and SDL_SetWindowSize positive and negative cases", TEST_ENABLED };
  1769 
  1770 static const SDLTest_TestCaseReference videoTest21 =
  1771 		{ (SDLTest_TestCaseFp)video_getSetWindowMinimumSize, "video_getSetWindowMinimumSize",  "Checks SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize positive and negative cases", TEST_ENABLED };
  1772 
  1773 static const SDLTest_TestCaseReference videoTest22 =
  1774 		{ (SDLTest_TestCaseFp)video_getSetWindowMaximumSize, "video_getSetWindowMaximumSize",  "Checks SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize positive and negative cases", TEST_ENABLED };
  1775 
  1776 static const SDLTest_TestCaseReference videoTest23 =
  1777 		{ (SDLTest_TestCaseFp)video_getSetWindowData, "video_getSetWindowData",  "Checks SDL_SetWindowData and SDL_GetWindowData positive and negative cases", TEST_ENABLED };
  1778 
  1779 /* Sequence of Video test cases */
  1780 static const SDLTest_TestCaseReference *videoTests[] =  {
  1781 	&videoTest1, &videoTest2, &videoTest3, &videoTest4, &videoTest5, &videoTest6, 
  1782 	&videoTest7, &videoTest8, &videoTest9, &videoTest10, &videoTest11, &videoTest12, 
  1783 	&videoTest13, &videoTest14, &videoTest15, &videoTest16, &videoTest17, 
  1784 	&videoTest18, &videoTest19, &videoTest20, &videoTest21, &videoTest22, 
  1785 	&videoTest23, NULL
  1786 };
  1787 
  1788 /* Video test suite (global) */
  1789 SDLTest_TestSuiteReference videoTestSuite = {
  1790 	"Video",
  1791 	NULL,
  1792 	videoTests,
  1793 	NULL
  1794 };