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