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