test/testautomation_video.c
changeset 6891 177f29ae5279
parent 6800 26c6795ec1a4
child 6921 9a29af9de577
     1.1 --- a/test/testautomation_video.c	Fri Feb 15 15:22:12 2013 -0800
     1.2 +++ b/test/testautomation_video.c	Sat Feb 16 23:09:10 2013 -0800
     1.3 @@ -61,15 +61,279 @@
     1.4  	return TEST_COMPLETED;
     1.5  }
     1.6  
     1.7 +/**
     1.8 + * @brief Tests the functionality of the SDL_CreateWindow function using different positions
     1.9 + */
    1.10 +int
    1.11 +video_createWindowVariousPositions(void *arg)
    1.12 +{
    1.13 +  SDL_Window* window;
    1.14 +  const char* title = "video_createWindowVariousPositions Test Window";
    1.15 +  int x, y, w, h;
    1.16 +  int xVariation, yVariation;
    1.17 +  
    1.18 +  for (xVariation = 0; xVariation < 6; xVariation++) {
    1.19 +   for (yVariation = 0; yVariation < 6; yVariation++) {
    1.20 +    switch(xVariation) {
    1.21 +     case 0:
    1.22 +      /* Zero X Position */  
    1.23 +      x = 0;
    1.24 +      break;
    1.25 +     case 1:
    1.26 +      /* Random X position inside screen */  
    1.27 +      x = SDLTest_RandomIntegerInRange(1, 100);
    1.28 +      break;
    1.29 +     case 2:
    1.30 +      /* Random X position outside screen (positive) */  
    1.31 +      x = SDLTest_RandomIntegerInRange(10000, 11000);
    1.32 +      break;
    1.33 +     case 3:
    1.34 +      /* Random X position outside screen (negative) */  
    1.35 +      x = SDLTest_RandomIntegerInRange(-1000, -100);
    1.36 +      break;
    1.37 +     case 4:
    1.38 +      /* Centered X position */  
    1.39 +      x = SDL_WINDOWPOS_CENTERED;
    1.40 +      break;
    1.41 +     case 5:
    1.42 +      /* Undefined X position */  
    1.43 +      x = SDL_WINDOWPOS_UNDEFINED;
    1.44 +      break;
    1.45 +    }
    1.46 +
    1.47 +    switch(yVariation) {
    1.48 +     case 0:
    1.49 +      /* Zero X Position */  
    1.50 +      y = 0;
    1.51 +      break;
    1.52 +     case 1:
    1.53 +      /* Random X position inside screen */  
    1.54 +      y = SDLTest_RandomIntegerInRange(1, 100);
    1.55 +      break;
    1.56 +     case 2:
    1.57 +      /* Random X position outside screen (positive) */  
    1.58 +      y = SDLTest_RandomIntegerInRange(10000, 11000);
    1.59 +      break;
    1.60 +     case 3:
    1.61 +      /* Random Y position outside screen (negative) */  
    1.62 +      y = SDLTest_RandomIntegerInRange(-1000, -100);
    1.63 +      break;
    1.64 +     case 4:
    1.65 +      /* Centered Y position */  
    1.66 +      y = SDL_WINDOWPOS_CENTERED;
    1.67 +      break;
    1.68 +     case 5:
    1.69 +      /* Undefined Y position */  
    1.70 +      y = SDL_WINDOWPOS_UNDEFINED;
    1.71 +      break;
    1.72 +    }
    1.73 +     
    1.74 +    w = SDLTest_RandomIntegerInRange(32, 96);
    1.75 +    h = SDLTest_RandomIntegerInRange(32, 96);
    1.76 +    window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN);
    1.77 +    SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h);
    1.78 +    SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
    1.79 +    if (window != NULL) {
    1.80 +      SDL_DestroyWindow(window);
    1.81 +      SDLTest_AssertPass("Call to SDL_DestroyWindow");
    1.82 +    }
    1.83 +   }
    1.84 +  } 
    1.85 +
    1.86 +  return TEST_COMPLETED;
    1.87 +}
    1.88 +
    1.89 +/**
    1.90 + * @brief Tests the functionality of the SDL_CreateWindow function using different sizes
    1.91 + */
    1.92 +int
    1.93 +video_createWindowVariousSizes(void *arg)
    1.94 +{
    1.95 +  SDL_Window* window;
    1.96 +  const char* title = "video_createWindowVariousSizes Test Window";
    1.97 +  int x, y, w, h;
    1.98 +  int wVariation, hVariation;
    1.99 +  
   1.100 +  x = SDLTest_RandomIntegerInRange(1, 100);
   1.101 +  y = SDLTest_RandomIntegerInRange(1, 100);
   1.102 +  for (wVariation = 0; wVariation < 3; wVariation++) {
   1.103 +   for (hVariation = 0; hVariation < 3; hVariation++) {
   1.104 +    switch(wVariation) {
   1.105 +     case 0:
   1.106 +      /* Width of 1 */  
   1.107 +      w = 1;
   1.108 +      break;
   1.109 +     case 1:
   1.110 +      /* Random "normal" width */  
   1.111 +      w = SDLTest_RandomIntegerInRange(320, 1920);
   1.112 +      break;
   1.113 +     case 2:
   1.114 +      /* Random "large" width */  
   1.115 +      w = SDLTest_RandomIntegerInRange(2048, 4095);
   1.116 +      break;
   1.117 +    }
   1.118 +
   1.119 +    switch(hVariation) {
   1.120 +     case 0:
   1.121 +      /* Height of 1 */  
   1.122 +      h = 1;
   1.123 +      break;
   1.124 +     case 1:
   1.125 +      /* Random "normal" height */  
   1.126 +      h = SDLTest_RandomIntegerInRange(320, 1080);
   1.127 +      break;
   1.128 +     case 2:
   1.129 +      /* Random "large" height */  
   1.130 +      h = SDLTest_RandomIntegerInRange(2048, 4095);
   1.131 +      break;
   1.132 +     }
   1.133 +     
   1.134 +    window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN);
   1.135 +    SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h);
   1.136 +    SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
   1.137 +    if (window != NULL) {
   1.138 +      SDL_DestroyWindow(window);
   1.139 +      SDLTest_AssertPass("Call to SDL_DestroyWindow");
   1.140 +    }
   1.141 +   }
   1.142 +  }  
   1.143 +
   1.144 +  return TEST_COMPLETED;
   1.145 +}
   1.146 +
   1.147 +/**
   1.148 + * @brief Tests the functionality of the SDL_CreateWindow function using different flags
   1.149 + */
   1.150 +int
   1.151 +video_createWindowVariousFlags(void *arg)
   1.152 +{
   1.153 +  SDL_Window* window;
   1.154 +  const char* title = "video_createWindowVariousFlags Test Window";
   1.155 +  int x, y, w, h;
   1.156 +  int fVariation;
   1.157 +  SDL_WindowFlags flags;
   1.158 +  
   1.159 +  /* Standard window */
   1.160 +  x = SDLTest_RandomIntegerInRange(1, 100);
   1.161 +  y = SDLTest_RandomIntegerInRange(1, 100);
   1.162 +  w = SDLTest_RandomIntegerInRange(320, 1024);
   1.163 +  h = SDLTest_RandomIntegerInRange(320, 768);
   1.164 +
   1.165 +  for (fVariation = 0; fVariation < 13; fVariation++) {
   1.166 +    switch(fVariation) {
   1.167 +     case 0:
   1.168 +      flags = SDL_WINDOW_FULLSCREEN;
   1.169 +      /* Skip - blanks screen; comment out next line to run test */
   1.170 +      continue;   
   1.171 +      break;
   1.172 +     case 1:
   1.173 +      flags = SDL_WINDOW_FULLSCREEN_DESKTOP;
   1.174 +      /* Skip - blanks screen; comment out next line to run test */
   1.175 +      continue;  
   1.176 +      break;
   1.177 +     case 2:
   1.178 +      flags = SDL_WINDOW_OPENGL;
   1.179 +      break;  
   1.180 +     case 3:
   1.181 +      flags = SDL_WINDOW_SHOWN;
   1.182 +      break;   
   1.183 +     case 4:    
   1.184 +      flags = SDL_WINDOW_HIDDEN;
   1.185 +      break;     
   1.186 +     case 5:
   1.187 +      flags = SDL_WINDOW_BORDERLESS;
   1.188 +      break;       
   1.189 +     case 6:
   1.190 +      flags = SDL_WINDOW_RESIZABLE;
   1.191 +      break;         
   1.192 +     case 7:
   1.193 +      flags = SDL_WINDOW_MINIMIZED;
   1.194 +      break;           
   1.195 +     case 8:
   1.196 +      flags = SDL_WINDOW_MAXIMIZED;
   1.197 +      break;
   1.198 +     case 9: 
   1.199 +      flags = SDL_WINDOW_INPUT_GRABBED;
   1.200 +      break;
   1.201 +     case 10:              
   1.202 +      flags = SDL_WINDOW_INPUT_FOCUS;
   1.203 +      break;                 
   1.204 +     case 11:                      
   1.205 +      flags = SDL_WINDOW_MOUSE_FOCUS;
   1.206 +      break;
   1.207 +     case 12: 
   1.208 +      flags = SDL_WINDOW_FOREIGN;
   1.209 +      break;
   1.210 +    }
   1.211 +       
   1.212 +    window = SDL_CreateWindow(title, x, y, w, h, flags);
   1.213 +    SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
   1.214 +    SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
   1.215 +    if (window != NULL) {
   1.216 +      SDL_DestroyWindow(window);
   1.217 +      SDLTest_AssertPass("Call to SDL_DestroyWindow");
   1.218 +    }   
   1.219 +  }
   1.220 +
   1.221 +  return TEST_COMPLETED;
   1.222 +}
   1.223 +
   1.224 +/**
   1.225 + * @brief Tests the functionality of the SDL_GetWindowFlags function
   1.226 + */
   1.227 +int
   1.228 +video_getWindowFlags(void *arg)
   1.229 +{
   1.230 +  SDL_Window* window;
   1.231 +  const char* title = "video_getWindowFlags Test Window";
   1.232 +  int x, y, w, h;
   1.233 +  SDL_WindowFlags flags;
   1.234 +  Uint32 actualFlags;
   1.235 +  
   1.236 +  /* Standard window */
   1.237 +  x = SDLTest_RandomIntegerInRange(1, 100);
   1.238 +  y = SDLTest_RandomIntegerInRange(1, 100);
   1.239 +  w = SDLTest_RandomIntegerInRange(320, 1024);
   1.240 +  h = SDLTest_RandomIntegerInRange(320, 768);
   1.241 +  
   1.242 +  /* Reliable flag */
   1.243 +  flags = SDL_WINDOW_SHOWN;
   1.244 +  
   1.245 +  window = SDL_CreateWindow(title, x, y, w, h, flags);
   1.246 +  SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
   1.247 +  SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
   1.248 +  if (window != NULL) {
   1.249 +      actualFlags = SDL_GetWindowFlags(window);
   1.250 +      SDLTest_AssertPass("Call to SDL_GetWindowFlags");
   1.251 +      SDLTest_AssertCheck((flags & actualFlags) == flags, "Verify returned value has flags %d set, got: %d", flags, actualFlags);
   1.252 +      SDL_DestroyWindow(window);
   1.253 +      SDLTest_AssertPass("Call to SDL_DestroyWindow");  
   1.254 +  }
   1.255 +
   1.256 +  return TEST_COMPLETED;
   1.257 +}
   1.258 +
   1.259  /* ================= Test References ================== */
   1.260  
   1.261  /* Video test cases */
   1.262  static const SDLTest_TestCaseReference videoTest1 =
   1.263  		{ (SDLTest_TestCaseFp)video_enableDisableScreensaver, "video_enableDisableScreensaver",  "Enable and disable screenaver while checking state", TEST_ENABLED };
   1.264  
   1.265 +static const SDLTest_TestCaseReference videoTest2 =
   1.266 +		{ (SDLTest_TestCaseFp)video_createWindowVariousPositions, "video_createWindowVariousPositions",  "Create windows at various locations", TEST_ENABLED };
   1.267 +
   1.268 +static const SDLTest_TestCaseReference videoTest3 =
   1.269 +		{ (SDLTest_TestCaseFp)video_createWindowVariousSizes, "video_createWindowVariousSizes",  "Create windows with various sizes", TEST_ENABLED };
   1.270 +
   1.271 +static const SDLTest_TestCaseReference videoTest4 =
   1.272 +		{ (SDLTest_TestCaseFp)video_createWindowVariousFlags, "video_createWindowVariousFlags",  "Create windows using various flags", TEST_ENABLED };
   1.273 +
   1.274 +static const SDLTest_TestCaseReference videoTest5 =
   1.275 +		{ (SDLTest_TestCaseFp)video_getWindowFlags, "video_getWindowFlags",  "Set and get window flags", TEST_ENABLED };
   1.276 +
   1.277  /* Sequence of Video test cases */
   1.278  static const SDLTest_TestCaseReference *videoTests[] =  {
   1.279 -	&videoTest1, NULL
   1.280 +	&videoTest1, &videoTest2, &videoTest3, &videoTest4, &videoTest5, NULL
   1.281  };
   1.282  
   1.283  /* Video test suite (global) */