test/testautomation_video.c
author Sam Lantinga <slouken@libsdl.org>
Thu, 23 May 2019 14:19:00 -0700
changeset 12756 4116bf232fe7
parent 9892 f8e6273be2fa
permissions -rw-r--r--
Added a function to get the current Android SDK version at runtime
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;
philipp@9219
    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);
philipp@9219
   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();
philipp@9219
   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();
philipp@9219
   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();
philipp@9219
   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);
philipp@9219
   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();
philipp@9219
   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);
philipp@9219
   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
  float result;
aschiffler@6936
   545
slouken@7191
   546
  /* Call against invalid window */
aschiffler@6936
   547
  result = SDL_GetWindowBrightness(NULL);
aschiffler@6936
   548
  SDLTest_AssertPass("Call to SDL_GetWindowBrightness(window=NULL)");
aschiffler@6936
   549
  SDLTest_AssertCheck(result == 1.0, "Validate result value; expected: 1.0, got: %f", result);
aschiffler@6936
   550
  lastError = (char *)SDL_GetError();
aschiffler@6936
   551
  SDLTest_AssertPass("SDL_GetError()");
aschiffler@6936
   552
  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
aschiffler@6936
   553
  if (lastError != NULL) {
aschiffler@6936
   554
      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
aschiffler@6936
   555
         "SDL_GetError(): expected message '%s', was message: '%s'",
aschiffler@6936
   556
         invalidWindowError,
aschiffler@6936
   557
         lastError);
aschiffler@6936
   558
  }
aschiffler@6936
   559
aschiffler@6936
   560
  return TEST_COMPLETED;
aschiffler@6936
   561
}
aschiffler@6936
   562
aschiffler@6936
   563
/**
aschiffler@6936
   564
 * @brief Tests call to SDL_GetWindowDisplayMode
aschiffler@6936
   565
 *
aschiffler@6936
   566
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowDisplayMode
aschiffler@6936
   567
 */
aschiffler@6936
   568
int
aschiffler@6936
   569
video_getWindowDisplayMode(void *arg)
aschiffler@6936
   570
{
aschiffler@6936
   571
  SDL_Window* window;
aschiffler@6936
   572
  const char* title = "video_getWindowDisplayMode Test Window";
aschiffler@6936
   573
  SDL_DisplayMode mode;
aschiffler@6936
   574
  int result;
aschiffler@6936
   575
aschiffler@6936
   576
  /* Invalidate part of the mode content so we can check values later */
aschiffler@6936
   577
  mode.w = -1;
aschiffler@6936
   578
  mode.h = -1;
aschiffler@6936
   579
  mode.refresh_rate = -1;
aschiffler@6936
   580
slouken@7191
   581
  /* Call against new test window */
aschiffler@6936
   582
  window = _createVideoSuiteTestWindow(title);
aschiffler@6936
   583
  if (window != NULL) {
aschiffler@6936
   584
      result = SDL_GetWindowDisplayMode(window, &mode);
philipp@9219
   585
      SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode()");
aschiffler@6936
   586
      SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
aschiffler@6936
   587
      SDLTest_AssertCheck(mode.w > 0, "Validate mode.w content; expected: >0, got: %d", mode.w);
aschiffler@6936
   588
      SDLTest_AssertCheck(mode.h > 0, "Validate mode.h content; expected: >0, got: %d", mode.h);
aschiffler@6936
   589
      SDLTest_AssertCheck(mode.refresh_rate > 0, "Validate mode.refresh_rate content; expected: >0, got: %d", mode.refresh_rate);
aschiffler@6936
   590
  }
aschiffler@6936
   591
slouken@7191
   592
  /* Clean up */
aschiffler@6936
   593
  _destroyVideoSuiteTestWindow(window);
slouken@7191
   594
aschiffler@6936
   595
  return TEST_COMPLETED;
aschiffler@6936
   596
}
aschiffler@6936
   597
aschiffler@6984
   598
/* Helper function that checks for an 'Invalid window' error */
aschiffler@6984
   599
void _checkInvalidWindowError()
aschiffler@6984
   600
{
aschiffler@6984
   601
  const char *invalidWindowError = "Invalid window";
aschiffler@6984
   602
  char *lastError;
aschiffler@6984
   603
aschiffler@7062
   604
  lastError = (char *)SDL_GetError();
aschiffler@6984
   605
  SDLTest_AssertPass("SDL_GetError()");
aschiffler@6984
   606
  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
aschiffler@6984
   607
  if (lastError != NULL) {
aschiffler@6984
   608
      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
aschiffler@6984
   609
         "SDL_GetError(): expected message '%s', was message: '%s'",
aschiffler@6984
   610
         invalidWindowError,
aschiffler@6984
   611
         lastError);
aschiffler@6984
   612
      SDL_ClearError();
slouken@7191
   613
      SDLTest_AssertPass("Call to SDL_ClearError()");
aschiffler@6984
   614
  }
aschiffler@6984
   615
}
aschiffler@6984
   616
aschiffler@6936
   617
/**
aschiffler@6936
   618
 * @brief Tests call to SDL_GetWindowDisplayMode with invalid input
aschiffler@6936
   619
 *
aschiffler@6936
   620
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowDisplayMode
aschiffler@6936
   621
 */
aschiffler@6936
   622
int
aschiffler@6936
   623
video_getWindowDisplayModeNegative(void *arg)
aschiffler@6936
   624
{
aschiffler@6936
   625
  const char *expectedError = "Parameter 'mode' is invalid";
aschiffler@6936
   626
  char *lastError;
aschiffler@6936
   627
  SDL_Window* window;
aschiffler@6936
   628
  const char* title = "video_getWindowDisplayModeNegative Test Window";
aschiffler@6936
   629
  SDL_DisplayMode mode;
aschiffler@6936
   630
  int result;
aschiffler@6936
   631
slouken@7191
   632
  /* Call against new test window */
aschiffler@6936
   633
  window = _createVideoSuiteTestWindow(title);
aschiffler@6936
   634
  if (window != NULL) {
aschiffler@6936
   635
      result = SDL_GetWindowDisplayMode(window, NULL);
aschiffler@6936
   636
      SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(...,mode=NULL)");
aschiffler@6936
   637
      SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result);
aschiffler@6936
   638
      lastError = (char *)SDL_GetError();
aschiffler@6936
   639
      SDLTest_AssertPass("SDL_GetError()");
aschiffler@6936
   640
      SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
aschiffler@6936
   641
      if (lastError != NULL) {
slouken@7191
   642
        SDLTest_AssertCheck(SDL_strcmp(lastError, expectedError) == 0,
aschiffler@6936
   643
             "SDL_GetError(): expected message '%s', was message: '%s'",
aschiffler@6936
   644
             expectedError,
aschiffler@6936
   645
             lastError);
aschiffler@6936
   646
      }
aschiffler@6936
   647
  }
aschiffler@6936
   648
slouken@7191
   649
  /* Clean up */
aschiffler@6936
   650
  _destroyVideoSuiteTestWindow(window);
slouken@7191
   651
aschiffler@6936
   652
  /* Call against invalid window */
aschiffler@6936
   653
  result = SDL_GetWindowDisplayMode(NULL, &mode);
aschiffler@6936
   654
  SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(window=NULL,...)");
aschiffler@6936
   655
  SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result);
aschiffler@6984
   656
  _checkInvalidWindowError();
aschiffler@6984
   657
aschiffler@6936
   658
  return TEST_COMPLETED;
aschiffler@6936
   659
}
aschiffler@6936
   660
aschiffler@6936
   661
/**
aschiffler@6936
   662
 * @brief Tests call to SDL_GetWindowGammaRamp
aschiffler@6936
   663
 *
aschiffler@6936
   664
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGammaRamp
aschiffler@6936
   665
 */
aschiffler@6936
   666
int
aschiffler@6936
   667
video_getWindowGammaRamp(void *arg)
aschiffler@6936
   668
{
aschiffler@6936
   669
  SDL_Window* window;
aschiffler@6936
   670
  const char* title = "video_getWindowGammaRamp Test Window";
aschiffler@6936
   671
  Uint16 red[256];
aschiffler@6936
   672
  Uint16 green[256];
aschiffler@6936
   673
  Uint16 blue[256];
aschiffler@6936
   674
  int result;
aschiffler@6936
   675
slouken@7191
   676
  /* Call against new test window */
aschiffler@6936
   677
  window = _createVideoSuiteTestWindow(title);
aschiffler@6956
   678
  if (window == NULL) return TEST_ABORTED;
slouken@7191
   679
aschiffler@6956
   680
  /* Retrieve no channel */
aschiffler@6956
   681
  result = SDL_GetWindowGammaRamp(window, NULL, NULL, NULL);
aschiffler@6956
   682
  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(all NULL)");
aschiffler@6956
   683
  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
aschiffler@6936
   684
aschiffler@6956
   685
  /* Retrieve single channel */
aschiffler@6956
   686
  result = SDL_GetWindowGammaRamp(window, red, NULL, NULL);
aschiffler@6956
   687
  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r)");
aschiffler@6956
   688
  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
aschiffler@6936
   689
aschiffler@6956
   690
  result = SDL_GetWindowGammaRamp(window, NULL, green, NULL);
aschiffler@6956
   691
  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(g)");
aschiffler@6956
   692
  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
aschiffler@6936
   693
aschiffler@6956
   694
  result = SDL_GetWindowGammaRamp(window, NULL, NULL, blue);
aschiffler@6956
   695
  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(b)");
aschiffler@6956
   696
  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
aschiffler@6936
   697
aschiffler@6956
   698
  /* Retrieve two channels */
aschiffler@6956
   699
  result = SDL_GetWindowGammaRamp(window, red, green, NULL);
aschiffler@6956
   700
  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r, g)");
aschiffler@6956
   701
  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
aschiffler@6936
   702
aschiffler@6956
   703
  result = SDL_GetWindowGammaRamp(window, NULL, green, blue);
aschiffler@6956
   704
  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(g,b)");
aschiffler@6956
   705
  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
aschiffler@6936
   706
aschiffler@6956
   707
  result = SDL_GetWindowGammaRamp(window, red, NULL, blue);
aschiffler@6956
   708
  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r,b)");
aschiffler@6956
   709
  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
aschiffler@6936
   710
aschiffler@6956
   711
  /* Retrieve all channels */
aschiffler@6956
   712
  result = SDL_GetWindowGammaRamp(window, red, green, blue);
aschiffler@6956
   713
  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r,g,b)");
aschiffler@6956
   714
  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
aschiffler@6936
   715
slouken@7191
   716
  /* Clean up */
aschiffler@6936
   717
  _destroyVideoSuiteTestWindow(window);
slouken@7191
   718
aschiffler@6936
   719
  return TEST_COMPLETED;
aschiffler@6936
   720
}
aschiffler@6936
   721
aschiffler@6936
   722
/**
aschiffler@6936
   723
 * @brief Tests call to SDL_GetWindowGammaRamp with invalid input
aschiffler@6936
   724
 *
aschiffler@6936
   725
* @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGammaRamp
aschiffler@6936
   726
 */
aschiffler@6936
   727
int
aschiffler@6936
   728
video_getWindowGammaRampNegative(void *arg)
aschiffler@6936
   729
{
aschiffler@6936
   730
  Uint16 red[256];
aschiffler@6936
   731
  Uint16 green[256];
aschiffler@6936
   732
  Uint16 blue[256];
aschiffler@6936
   733
  int result;
aschiffler@6936
   734
aschiffler@6984
   735
  SDL_ClearError();
aschiffler@6984
   736
  SDLTest_AssertPass("Call to SDL_ClearError()");
aschiffler@6984
   737
slouken@7191
   738
  /* Call against invalid window */
aschiffler@6936
   739
  result = SDL_GetWindowGammaRamp(NULL, red, green, blue);
aschiffler@6936
   740
  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(window=NULL,r,g,b)");
aschiffler@9254
   741
  SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %i", result);
aschiffler@6984
   742
  _checkInvalidWindowError();
slouken@7191
   743
aschiffler@6936
   744
  return TEST_COMPLETED;
aschiffler@6936
   745
}
aschiffler@6936
   746
aschiffler@6956
   747
/* Helper for setting and checking the window grab state */
slouken@7191
   748
void
aschiffler@6956
   749
_setAndCheckWindowGrabState(SDL_Window* window, SDL_bool desiredState)
aschiffler@6956
   750
{
aschiffler@6956
   751
  SDL_bool currentState;
slouken@7191
   752
aschiffler@6956
   753
  /* Set state */
aschiffler@6956
   754
  SDL_SetWindowGrab(window, desiredState);
aschiffler@6956
   755
  SDLTest_AssertPass("Call to SDL_SetWindowGrab(%s)", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
aschiffler@6956
   756
aschiffler@6956
   757
  /* Get and check state */
aschiffler@6956
   758
  currentState = SDL_GetWindowGrab(window);
aschiffler@6956
   759
  SDLTest_AssertPass("Call to SDL_GetWindowGrab()");
aschiffler@6956
   760
  SDLTest_AssertCheck(
slouken@7191
   761
      currentState == desiredState,
slouken@7191
   762
      "Validate returned state; expected: %s, got: %s",
aschiffler@6956
   763
      (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE",
aschiffler@6956
   764
      (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
aschiffler@6956
   765
}
aschiffler@6956
   766
aschiffler@6956
   767
/**
aschiffler@6956
   768
 * @brief Tests call to SDL_GetWindowGrab and SDL_SetWindowGrab
aschiffler@6956
   769
 *
aschiffler@6956
   770
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGrab
aschiffler@6956
   771
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowGrab
aschiffler@6956
   772
 */
aschiffler@6956
   773
int
aschiffler@6956
   774
video_getSetWindowGrab(void *arg)
aschiffler@6956
   775
{
aschiffler@6956
   776
  const char* title = "video_getSetWindowGrab Test Window";
aschiffler@6956
   777
  SDL_Window* window;
aschiffler@6956
   778
  SDL_bool originalState, dummyState, currentState, desiredState;
aschiffler@6956
   779
slouken@7191
   780
  /* Call against new test window */
aschiffler@6956
   781
  window = _createVideoSuiteTestWindow(title);
aschiffler@6956
   782
  if (window == NULL) return TEST_ABORTED;
aschiffler@6956
   783
slouken@7191
   784
  /* Get state */
aschiffler@6956
   785
  originalState = SDL_GetWindowGrab(window);
aschiffler@6956
   786
  SDLTest_AssertPass("Call to SDL_GetWindowGrab()");
aschiffler@6956
   787
aschiffler@6956
   788
  /* F */
aschiffler@6956
   789
  _setAndCheckWindowGrabState(window, SDL_FALSE);
aschiffler@6956
   790
aschiffler@6956
   791
  /* F --> F */
aschiffler@6956
   792
  _setAndCheckWindowGrabState(window, SDL_FALSE);
slouken@7191
   793
aschiffler@6956
   794
  /* F --> T */
aschiffler@6956
   795
  _setAndCheckWindowGrabState(window, SDL_TRUE);
aschiffler@6956
   796
aschiffler@6956
   797
  /* T --> T */
aschiffler@6956
   798
  _setAndCheckWindowGrabState(window, SDL_TRUE);
aschiffler@6956
   799
aschiffler@6956
   800
  /* T --> F */
aschiffler@6956
   801
  _setAndCheckWindowGrabState(window, SDL_FALSE);
slouken@7191
   802
aschiffler@6956
   803
  /* Negative tests */
aschiffler@6956
   804
  dummyState = SDL_GetWindowGrab(NULL);
aschiffler@6956
   805
  SDLTest_AssertPass("Call to SDL_GetWindowGrab(window=NULL)");
aschiffler@6984
   806
  _checkInvalidWindowError();
aschiffler@6956
   807
aschiffler@6956
   808
  SDL_SetWindowGrab(NULL, SDL_FALSE);
aschiffler@6956
   809
  SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
aschiffler@6984
   810
  _checkInvalidWindowError();
aschiffler@6956
   811
aschiffler@6956
   812
  SDL_SetWindowGrab(NULL, SDL_TRUE);
aschiffler@6956
   813
  SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
aschiffler@6984
   814
  _checkInvalidWindowError();
slouken@7191
   815
aschiffler@6956
   816
  /* State should still be F */
aschiffler@6956
   817
  desiredState = SDL_FALSE;
aschiffler@6956
   818
  currentState = SDL_GetWindowGrab(window);
aschiffler@6956
   819
  SDLTest_AssertPass("Call to SDL_GetWindowGrab()");
aschiffler@6956
   820
  SDLTest_AssertCheck(
slouken@7191
   821
      currentState == desiredState,
slouken@7191
   822
      "Validate returned state; expected: %s, got: %s",
aschiffler@6956
   823
      (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE",
aschiffler@6956
   824
      (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
slouken@7191
   825
slouken@7191
   826
  /* Restore state */
aschiffler@6956
   827
  _setAndCheckWindowGrabState(window, originalState);
aschiffler@6956
   828
slouken@7191
   829
  /* Clean up */
aschiffler@6956
   830
  _destroyVideoSuiteTestWindow(window);
aschiffler@6956
   831
aschiffler@6956
   832
  return TEST_COMPLETED;
aschiffler@6956
   833
}
aschiffler@6956
   834
aschiffler@6984
   835
aschiffler@6956
   836
/**
aschiffler@6956
   837
 * @brief Tests call to SDL_GetWindowID and SDL_GetWindowFromID
aschiffler@6956
   838
 *
aschiffler@6956
   839
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowID
aschiffler@6956
   840
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowFromID
aschiffler@6956
   841
 */
aschiffler@6956
   842
int
aschiffler@6956
   843
video_getWindowId(void *arg)
aschiffler@6956
   844
{
aschiffler@6956
   845
  const char* title = "video_getWindowId Test Window";
aschiffler@6956
   846
  SDL_Window* window;
aschiffler@6956
   847
  SDL_Window* result;
aschiffler@6956
   848
  Uint32 id, randomId;
aschiffler@6956
   849
slouken@7191
   850
  /* Call against new test window */
aschiffler@6956
   851
  window = _createVideoSuiteTestWindow(title);
aschiffler@6956
   852
  if (window == NULL) return TEST_ABORTED;
aschiffler@6956
   853
aschiffler@6956
   854
  /* Get ID */
aschiffler@6956
   855
  id = SDL_GetWindowID(window);
aschiffler@6956
   856
  SDLTest_AssertPass("Call to SDL_GetWindowID()");
aschiffler@6956
   857
aschiffler@6956
   858
  /* Get window from ID */
aschiffler@6956
   859
  result = SDL_GetWindowFromID(id);
aschiffler@6956
   860
  SDLTest_AssertPass("Call to SDL_GetWindowID(%d)", id);
aschiffler@6956
   861
  SDLTest_AssertCheck(result == window, "Verify result matches window pointer");
aschiffler@6956
   862
aschiffler@6956
   863
  /* Get window from random large ID, no result check */
aschiffler@6956
   864
  randomId = SDLTest_RandomIntegerInRange(UINT8_MAX,UINT16_MAX);
aschiffler@6956
   865
  result = SDL_GetWindowFromID(randomId);
aschiffler@6956
   866
  SDLTest_AssertPass("Call to SDL_GetWindowID(%d/random_large)", randomId);
aschiffler@6956
   867
aschiffler@6956
   868
  /* Get window from 0 and Uint32 max ID, no result check */
aschiffler@6956
   869
  result = SDL_GetWindowFromID(0);
aschiffler@6956
   870
  SDLTest_AssertPass("Call to SDL_GetWindowID(0)");
aschiffler@6956
   871
  result = SDL_GetWindowFromID(UINT32_MAX);
aschiffler@6956
   872
  SDLTest_AssertPass("Call to SDL_GetWindowID(UINT32_MAX)");
aschiffler@6956
   873
slouken@7191
   874
  /* Clean up */
aschiffler@6956
   875
  _destroyVideoSuiteTestWindow(window);
slouken@7191
   876
gabomdq@7677
   877
  /* Get window from ID for closed window */
aschiffler@6956
   878
  result = SDL_GetWindowFromID(id);
aschiffler@6956
   879
  SDLTest_AssertPass("Call to SDL_GetWindowID(%d/closed_window)", id);
aschiffler@6956
   880
  SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
aschiffler@6956
   881
aschiffler@6956
   882
  /* Negative test */
aschiffler@6984
   883
  SDL_ClearError();
aschiffler@6984
   884
  SDLTest_AssertPass("Call to SDL_ClearError()");
aschiffler@6956
   885
  id = SDL_GetWindowID(NULL);
aschiffler@6956
   886
  SDLTest_AssertPass("Call to SDL_GetWindowID(window=NULL)");
aschiffler@6984
   887
  _checkInvalidWindowError();
slouken@7191
   888
aschiffler@6956
   889
  return TEST_COMPLETED;
aschiffler@6956
   890
}
aschiffler@6956
   891
aschiffler@6956
   892
/**
aschiffler@6956
   893
 * @brief Tests call to SDL_GetWindowPixelFormat
aschiffler@6956
   894
 *
aschiffler@6956
   895
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowPixelFormat
aschiffler@6956
   896
 */
aschiffler@6956
   897
int
aschiffler@6956
   898
video_getWindowPixelFormat(void *arg)
aschiffler@6956
   899
{
aschiffler@6956
   900
  const char* title = "video_getWindowPixelFormat Test Window";
aschiffler@6956
   901
  SDL_Window* window;
aschiffler@6956
   902
  Uint32 format;
aschiffler@6956
   903
slouken@7191
   904
  /* Call against new test window */
aschiffler@6956
   905
  window = _createVideoSuiteTestWindow(title);
aschiffler@6956
   906
  if (window == NULL) return TEST_ABORTED;
aschiffler@6956
   907
aschiffler@6956
   908
  /* Get format */
aschiffler@6956
   909
  format = SDL_GetWindowPixelFormat(window);
aschiffler@6956
   910
  SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat()");
aschiffler@6956
   911
  SDLTest_AssertCheck(format != SDL_PIXELFORMAT_UNKNOWN, "Verify that returned format is valid; expected: != %d, got: %d", SDL_PIXELFORMAT_UNKNOWN, format);
slouken@7191
   912
slouken@7191
   913
  /* Clean up */
aschiffler@6956
   914
  _destroyVideoSuiteTestWindow(window);
slouken@7191
   915
aschiffler@6956
   916
  /* Negative test */
aschiffler@6984
   917
  SDL_ClearError();
aschiffler@6984
   918
  SDLTest_AssertPass("Call to SDL_ClearError()");
aschiffler@6956
   919
  format = SDL_GetWindowPixelFormat(NULL);
aschiffler@6956
   920
  SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat(window=NULL)");
aschiffler@6984
   921
  _checkInvalidWindowError();
aschiffler@6956
   922
aschiffler@6956
   923
  return TEST_COMPLETED;
aschiffler@6956
   924
}
aschiffler@6956
   925
aschiffler@6956
   926
/**
aschiffler@6956
   927
 * @brief Tests call to SDL_GetWindowPosition and SDL_SetWindowPosition
aschiffler@6956
   928
 *
aschiffler@6956
   929
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowPosition
aschiffler@6956
   930
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowPosition
aschiffler@6956
   931
 */
aschiffler@6956
   932
int
aschiffler@6956
   933
video_getSetWindowPosition(void *arg)
aschiffler@6956
   934
{
aschiffler@6956
   935
  const char* title = "video_getSetWindowPosition Test Window";
aschiffler@6956
   936
  SDL_Window* window;
aschiffler@6956
   937
  int xVariation, yVariation;
aschiffler@6956
   938
  int referenceX, referenceY;
aschiffler@6956
   939
  int currentX, currentY;
aschiffler@6956
   940
  int desiredX, desiredY;
aschiffler@6956
   941
slouken@7191
   942
  /* Call against new test window */
aschiffler@6956
   943
  window = _createVideoSuiteTestWindow(title);
aschiffler@6956
   944
  if (window == NULL) return TEST_ABORTED;
slouken@7191
   945
aschiffler@6956
   946
  for (xVariation = 0; xVariation < 4; xVariation++) {
aschiffler@6956
   947
   for (yVariation = 0; yVariation < 4; yVariation++) {
aschiffler@6956
   948
    switch(xVariation) {
aschiffler@6956
   949
     case 0:
slouken@7191
   950
      /* Zero X Position */
aschiffler@6956
   951
      desiredX = 0;
aschiffler@6956
   952
      break;
aschiffler@6956
   953
     case 1:
slouken@7191
   954
      /* Random X position inside screen */
aschiffler@6956
   955
      desiredX = SDLTest_RandomIntegerInRange(1, 100);
aschiffler@6956
   956
      break;
aschiffler@6956
   957
     case 2:
slouken@7191
   958
      /* Random X position outside screen (positive) */
aschiffler@6956
   959
      desiredX = SDLTest_RandomIntegerInRange(10000, 11000);
aschiffler@6956
   960
      break;
aschiffler@6956
   961
     case 3:
slouken@7191
   962
      /* Random X position outside screen (negative) */
aschiffler@6956
   963
      desiredX = SDLTest_RandomIntegerInRange(-1000, -100);
aschiffler@6956
   964
      break;
aschiffler@6956
   965
    }
aschiffler@6956
   966
aschiffler@6956
   967
    switch(yVariation) {
aschiffler@6956
   968
     case 0:
slouken@7191
   969
      /* Zero X Position */
aschiffler@6956
   970
      desiredY = 0;
aschiffler@6956
   971
      break;
aschiffler@6956
   972
     case 1:
slouken@7191
   973
      /* Random X position inside screen */
aschiffler@6956
   974
      desiredY = SDLTest_RandomIntegerInRange(1, 100);
aschiffler@6956
   975
      break;
aschiffler@6956
   976
     case 2:
slouken@7191
   977
      /* Random X position outside screen (positive) */
aschiffler@6956
   978
      desiredY = SDLTest_RandomIntegerInRange(10000, 11000);
aschiffler@6956
   979
      break;
aschiffler@6956
   980
     case 3:
slouken@7191
   981
      /* Random Y position outside screen (negative) */
aschiffler@6956
   982
      desiredY = SDLTest_RandomIntegerInRange(-1000, -100);
aschiffler@6956
   983
      break;
aschiffler@6956
   984
    }
aschiffler@6956
   985
aschiffler@6956
   986
    /* Set position */
aschiffler@6956
   987
    SDL_SetWindowPosition(window, desiredX, desiredY);
aschiffler@6956
   988
    SDLTest_AssertPass("Call to SDL_SetWindowPosition(...,%d,%d)", desiredX, desiredY);
slouken@7191
   989
aschiffler@6956
   990
    /* Get position */
aschiffler@6956
   991
    currentX = desiredX + 1;
aschiffler@6956
   992
    currentY = desiredY + 1;
aschiffler@6956
   993
    SDL_GetWindowPosition(window, &currentX, &currentY);
aschiffler@6956
   994
    SDLTest_AssertPass("Call to SDL_GetWindowPosition()");
aschiffler@6956
   995
    SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX);
aschiffler@6956
   996
    SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY);
aschiffler@6956
   997
aschiffler@6956
   998
    /* Get position X */
slouken@7191
   999
    currentX = desiredX + 1;
aschiffler@6956
  1000
    SDL_GetWindowPosition(window, &currentX, NULL);
aschiffler@6956
  1001
    SDLTest_AssertPass("Call to SDL_GetWindowPosition(&y=NULL)");
aschiffler@6956
  1002
    SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX);
aschiffler@6956
  1003
aschiffler@6956
  1004
    /* Get position Y */
aschiffler@6956
  1005
    currentY = desiredY + 1;
aschiffler@6956
  1006
    SDL_GetWindowPosition(window, NULL, &currentY);
aschiffler@6956
  1007
    SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL)");
aschiffler@6956
  1008
    SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY);
aschiffler@6956
  1009
   }
aschiffler@6956
  1010
  }
aschiffler@6956
  1011
aschiffler@6956
  1012
  /* Dummy call with both pointers NULL */
aschiffler@6956
  1013
  SDL_GetWindowPosition(window, NULL, NULL);
aschiffler@6956
  1014
  SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL,&y=NULL)");
slouken@7191
  1015
slouken@7191
  1016
  /* Clean up */
aschiffler@6956
  1017
  _destroyVideoSuiteTestWindow(window);
slouken@7191
  1018
aschiffler@6956
  1019
  /* Set some 'magic' value for later check that nothing was changed */
aschiffler@6956
  1020
  referenceX = SDLTest_RandomSint32();
aschiffler@6956
  1021
  referenceY = SDLTest_RandomSint32();
aschiffler@6956
  1022
  currentX = referenceX;
aschiffler@6956
  1023
  currentY = referenceY;
aschiffler@6956
  1024
  desiredX = SDLTest_RandomSint32();
aschiffler@6956
  1025
  desiredY = SDLTest_RandomSint32();
aschiffler@6984
  1026
aschiffler@6956
  1027
  /* Negative tests */
aschiffler@6984
  1028
  SDL_ClearError();
slouken@7191
  1029
  SDLTest_AssertPass("Call to SDL_ClearError()");
aschiffler@6956
  1030
  SDL_GetWindowPosition(NULL, &currentX, &currentY);
aschiffler@6956
  1031
  SDLTest_AssertPass("Call to SDL_GetWindowPosition(window=NULL)");
aschiffler@6956
  1032
  SDLTest_AssertCheck(
slouken@7191
  1033
    currentX == referenceX && currentY == referenceY,
slouken@7191
  1034
    "Verify that content of X and Y pointers has not been modified; expected: %d,%d; got: %d,%d",
slouken@7191
  1035
    referenceX, referenceY,
slouken@7191
  1036
    currentX, currentY);
aschiffler@6984
  1037
  _checkInvalidWindowError();
aschiffler@6984
  1038
aschiffler@6984
  1039
  SDL_GetWindowPosition(NULL, NULL, NULL);
aschiffler@6984
  1040
  SDLTest_AssertPass("Call to SDL_GetWindowPosition(NULL, NULL, NULL)");
aschiffler@6984
  1041
  _checkInvalidWindowError();
aschiffler@6984
  1042
aschiffler@6984
  1043
  SDL_SetWindowPosition(NULL, desiredX, desiredY);
aschiffler@6984
  1044
  SDLTest_AssertPass("Call to SDL_SetWindowPosition(window=NULL)");
aschiffler@6984
  1045
  _checkInvalidWindowError();
slouken@7191
  1046
aschiffler@6984
  1047
  return TEST_COMPLETED;
aschiffler@6984
  1048
}
aschiffler@6984
  1049
aschiffler@6984
  1050
/* Helper function that checks for an 'Invalid parameter' error */
aschiffler@6984
  1051
void _checkInvalidParameterError()
aschiffler@6984
  1052
{
aschiffler@6984
  1053
  const char *invalidParameterError = "Parameter";
aschiffler@6984
  1054
  char *lastError;
aschiffler@6984
  1055
aschiffler@6956
  1056
  lastError = (char *)SDL_GetError();
aschiffler@6956
  1057
  SDLTest_AssertPass("SDL_GetError()");
aschiffler@6956
  1058
  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
aschiffler@6956
  1059
  if (lastError != NULL) {
aschiffler@6984
  1060
      SDLTest_AssertCheck(SDL_strncmp(lastError, invalidParameterError, SDL_strlen(invalidParameterError)) == 0,
aschiffler@6984
  1061
         "SDL_GetError(): expected message starts with '%s', was message: '%s'",
aschiffler@6984
  1062
         invalidParameterError,
aschiffler@6956
  1063
         lastError);
aschiffler@6984
  1064
      SDL_ClearError();
slouken@7191
  1065
      SDLTest_AssertPass("Call to SDL_ClearError()");
aschiffler@6984
  1066
  }
aschiffler@6984
  1067
}
aschiffler@6984
  1068
aschiffler@6984
  1069
/**
aschiffler@6984
  1070
 * @brief Tests call to SDL_GetWindowSize and SDL_SetWindowSize
aschiffler@6984
  1071
 *
aschiffler@6984
  1072
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowSize
aschiffler@6984
  1073
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowSize
aschiffler@6984
  1074
 */
aschiffler@6984
  1075
int
aschiffler@6984
  1076
video_getSetWindowSize(void *arg)
aschiffler@6984
  1077
{
aschiffler@6984
  1078
  const char* title = "video_getSetWindowSize Test Window";
aschiffler@6984
  1079
  SDL_Window* window;
aschiffler@6984
  1080
  int result;
aschiffler@6984
  1081
  SDL_Rect display;
aschiffler@7615
  1082
  int maxwVariation, maxhVariation;
aschiffler@6984
  1083
  int wVariation, hVariation;
aschiffler@6984
  1084
  int referenceW, referenceH;
aschiffler@6984
  1085
  int currentW, currentH;
aschiffler@6984
  1086
  int desiredW, desiredH;
aschiffler@6984
  1087
aschiffler@6984
  1088
  /* Get display bounds for size range */
aschiffler@6984
  1089
  result = SDL_GetDisplayBounds(0, &display);
aschiffler@6984
  1090
  SDLTest_AssertPass("SDL_GetDisplayBounds()");
aschiffler@6984
  1091
  SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
aschiffler@6984
  1092
  if (result != 0) return TEST_ABORTED;
slouken@7191
  1093
slouken@7191
  1094
  /* Call against new test window */
aschiffler@6984
  1095
  window = _createVideoSuiteTestWindow(title);
aschiffler@6984
  1096
  if (window == NULL) return TEST_ABORTED;
slouken@7191
  1097
aschiffler@7615
  1098
#ifdef __WIN32__
aschiffler@7615
  1099
  /* Platform clips window size to screen size */
aschiffler@7615
  1100
  maxwVariation = 4;
aschiffler@7615
  1101
  maxhVariation = 4;
aschiffler@7615
  1102
#else
aschiffler@7615
  1103
  /* Platform allows window size >= screen size */
aschiffler@7615
  1104
  maxwVariation = 5;
aschiffler@7615
  1105
  maxhVariation = 5;
aschiffler@7615
  1106
#endif
aschiffler@7615
  1107
  
aschiffler@7615
  1108
  for (wVariation = 0; wVariation < maxwVariation; wVariation++) {
aschiffler@7615
  1109
   for (hVariation = 0; hVariation < maxhVariation; hVariation++) {
aschiffler@6984
  1110
    switch(wVariation) {
aschiffler@6984
  1111
     case 0:
slouken@7191
  1112
      /* 1 Pixel Wide */
aschiffler@6984
  1113
      desiredW = 1;
aschiffler@6984
  1114
      break;
aschiffler@6984
  1115
     case 1:
slouken@7191
  1116
      /* Random width inside screen */
aschiffler@6984
  1117
      desiredW = SDLTest_RandomIntegerInRange(1, 100);
aschiffler@6984
  1118
      break;
aschiffler@6984
  1119
     case 2:
aschiffler@7615
  1120
      /* Width 1 pixel smaller than screen */
aschiffler@7615
  1121
      desiredW = display.w - 1;
aschiffler@7615
  1122
      break;
aschiffler@7615
  1123
     case 3:
slouken@7191
  1124
      /* Width at screen size */
aschiffler@6984
  1125
      desiredW = display.w;
aschiffler@6984
  1126
      break;
aschiffler@7615
  1127
     case 4:
slouken@7191
  1128
      /* Width 1 pixel larger than screen */
aschiffler@6984
  1129
      desiredW = display.w + 1;
aschiffler@6984
  1130
      break;
aschiffler@6984
  1131
    }
aschiffler@6984
  1132
aschiffler@6984
  1133
    switch(hVariation) {
aschiffler@6984
  1134
     case 0:
slouken@7191
  1135
      /* 1 Pixel High */
aschiffler@6984
  1136
      desiredH = 1;
aschiffler@6984
  1137
      break;
aschiffler@6984
  1138
     case 1:
slouken@7191
  1139
      /* Random height inside screen */
aschiffler@6984
  1140
      desiredH = SDLTest_RandomIntegerInRange(1, 100);
aschiffler@6984
  1141
      break;
aschiffler@6984
  1142
     case 2:
aschiffler@7615
  1143
      /* Height 1 pixel smaller than screen */
aschiffler@7615
  1144
      desiredH = display.h - 1;
aschiffler@7615
  1145
      break;
aschiffler@7615
  1146
     case 3:
slouken@7191
  1147
      /* Height at screen size */
aschiffler@6984
  1148
      desiredH = display.h;
aschiffler@6984
  1149
      break;
aschiffler@7615
  1150
     case 4:
slouken@7191
  1151
      /* Height 1 pixel larger than screen */
aschiffler@6984
  1152
      desiredH = display.h + 1;
aschiffler@6984
  1153
      break;
aschiffler@6984
  1154
    }
aschiffler@6984
  1155
aschiffler@6984
  1156
    /* Set size */
aschiffler@6984
  1157
    SDL_SetWindowSize(window, desiredW, desiredH);
aschiffler@6984
  1158
    SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH);
slouken@7191
  1159
aschiffler@6984
  1160
    /* Get size */
aschiffler@6984
  1161
    currentW = desiredW + 1;
aschiffler@6984
  1162
    currentH = desiredH + 1;
aschiffler@6984
  1163
    SDL_GetWindowSize(window, &currentW, &currentH);
aschiffler@6984
  1164
    SDLTest_AssertPass("Call to SDL_GetWindowSize()");
aschiffler@6984
  1165
    SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
aschiffler@6984
  1166
    SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
aschiffler@6984
  1167
aschiffler@6984
  1168
    /* Get just width */
slouken@7191
  1169
    currentW = desiredW + 1;
aschiffler@6984
  1170
    SDL_GetWindowSize(window, &currentW, NULL);
aschiffler@6984
  1171
    SDLTest_AssertPass("Call to SDL_GetWindowSize(&h=NULL)");
aschiffler@7615
  1172
    SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
aschiffler@6984
  1173
aschiffler@6984
  1174
    /* Get just height */
aschiffler@6984
  1175
    currentH = desiredH + 1;
aschiffler@6984
  1176
    SDL_GetWindowSize(window, NULL, &currentH);
aschiffler@6984
  1177
    SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL)");
aschiffler@7615
  1178
    SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
aschiffler@6984
  1179
   }
aschiffler@6956
  1180
  }
aschiffler@6956
  1181
aschiffler@6984
  1182
  /* Dummy call with both pointers NULL */
aschiffler@6984
  1183
  SDL_GetWindowSize(window, NULL, NULL);
aschiffler@6984
  1184
  SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL,&h=NULL)");
aschiffler@6984
  1185
aschiffler@6984
  1186
  /* Negative tests for parameter input */
aschiffler@6984
  1187
  SDL_ClearError();
slouken@7191
  1188
  SDLTest_AssertPass("Call to SDL_ClearError()");
aschiffler@6984
  1189
  for (desiredH = -2; desiredH < 2; desiredH++) {
aschiffler@6984
  1190
    for (desiredW = -2; desiredW < 2; desiredW++) {
slouken@7191
  1191
      if (desiredW <= 0 || desiredH <= 0) {
aschiffler@6984
  1192
        SDL_SetWindowSize(window, desiredW, desiredH);
aschiffler@6984
  1193
        SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH);
aschiffler@6984
  1194
        _checkInvalidParameterError();
aschiffler@6984
  1195
      }
aschiffler@6984
  1196
    }
aschiffler@6984
  1197
  }
slouken@7191
  1198
slouken@7191
  1199
  /* Clean up */
aschiffler@6984
  1200
  _destroyVideoSuiteTestWindow(window);
slouken@7191
  1201
aschiffler@6984
  1202
  /* Set some 'magic' value for later check that nothing was changed */
aschiffler@6984
  1203
  referenceW = SDLTest_RandomSint32();
aschiffler@6984
  1204
  referenceH = SDLTest_RandomSint32();
aschiffler@6984
  1205
  currentW = referenceW;
aschiffler@6984
  1206
  currentH = referenceH;
aschiffler@6984
  1207
  desiredW = SDLTest_RandomSint32();
aschiffler@6984
  1208
  desiredH = SDLTest_RandomSint32();
slouken@7191
  1209
aschiffler@6984
  1210
  /* Negative tests for window input */
aschiffler@6984
  1211
  SDL_ClearError();
aschiffler@6984
  1212
  SDLTest_AssertPass("Call to SDL_ClearError()");
aschiffler@6984
  1213
  SDL_GetWindowSize(NULL, &currentW, &currentH);
aschiffler@6984
  1214
  SDLTest_AssertPass("Call to SDL_GetWindowSize(window=NULL)");
aschiffler@6984
  1215
  SDLTest_AssertCheck(
slouken@7191
  1216
    currentW == referenceW && currentH == referenceH,
slouken@7191
  1217
    "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
slouken@7191
  1218
    referenceW, referenceH,
slouken@7191
  1219
    currentW, currentH);
aschiffler@6984
  1220
  _checkInvalidWindowError();
aschiffler@6984
  1221
aschiffler@6984
  1222
  SDL_GetWindowSize(NULL, NULL, NULL);
aschiffler@6984
  1223
  SDLTest_AssertPass("Call to SDL_GetWindowSize(NULL, NULL, NULL)");
aschiffler@6984
  1224
  _checkInvalidWindowError();
aschiffler@6984
  1225
aschiffler@6984
  1226
  SDL_SetWindowSize(NULL, desiredW, desiredH);
aschiffler@6984
  1227
  SDLTest_AssertPass("Call to SDL_SetWindowSize(window=NULL)");
aschiffler@6984
  1228
  _checkInvalidWindowError();
slouken@7191
  1229
aschiffler@6984
  1230
  return TEST_COMPLETED;
aschiffler@6984
  1231
}
aschiffler@6984
  1232
aschiffler@6984
  1233
/**
aschiffler@6984
  1234
 * @brief Tests call to SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize
aschiffler@6984
  1235
 *
aschiffler@6984
  1236
 */
aschiffler@6984
  1237
int
aschiffler@6984
  1238
video_getSetWindowMinimumSize(void *arg)
aschiffler@6984
  1239
{
aschiffler@6984
  1240
  const char* title = "video_getSetWindowMinimumSize Test Window";
aschiffler@6984
  1241
  SDL_Window* window;
aschiffler@6984
  1242
  int result;
aschiffler@6984
  1243
  SDL_Rect display;
aschiffler@6984
  1244
  int wVariation, hVariation;
aschiffler@6984
  1245
  int referenceW, referenceH;
aschiffler@6984
  1246
  int currentW, currentH;
aschiffler@6984
  1247
  int desiredW, desiredH;
aschiffler@6984
  1248
aschiffler@6984
  1249
  /* Get display bounds for size range */
aschiffler@6984
  1250
  result = SDL_GetDisplayBounds(0, &display);
aschiffler@6984
  1251
  SDLTest_AssertPass("SDL_GetDisplayBounds()");
aschiffler@6984
  1252
  SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
aschiffler@6984
  1253
  if (result != 0) return TEST_ABORTED;
aschiffler@6984
  1254
slouken@7191
  1255
  /* Call against new test window */
aschiffler@6984
  1256
  window = _createVideoSuiteTestWindow(title);
aschiffler@6984
  1257
  if (window == NULL) return TEST_ABORTED;
slouken@7191
  1258
aschiffler@6984
  1259
  for (wVariation = 0; wVariation < 5; wVariation++) {
aschiffler@6984
  1260
   for (hVariation = 0; hVariation < 5; hVariation++) {
aschiffler@6984
  1261
    switch(wVariation) {
aschiffler@6984
  1262
     case 0:
slouken@7191
  1263
      /* 1 Pixel Wide */
aschiffler@6984
  1264
      desiredW = 1;
aschiffler@6984
  1265
      break;
aschiffler@6984
  1266
     case 1:
slouken@7191
  1267
      /* Random width inside screen */
aschiffler@6984
  1268
      desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1);
aschiffler@6984
  1269
      break;
aschiffler@6984
  1270
     case 2:
slouken@7191
  1271
      /* Width at screen size */
aschiffler@6984
  1272
      desiredW = display.w;
aschiffler@6984
  1273
      break;
aschiffler@6984
  1274
    }
aschiffler@6984
  1275
aschiffler@6984
  1276
    switch(hVariation) {
aschiffler@6984
  1277
     case 0:
slouken@7191
  1278
      /* 1 Pixel High */
aschiffler@6984
  1279
      desiredH = 1;
aschiffler@6984
  1280
      break;
aschiffler@6984
  1281
     case 1:
slouken@7191
  1282
      /* Random height inside screen */
aschiffler@6984
  1283
      desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1);
aschiffler@6984
  1284
      break;
aschiffler@6984
  1285
     case 2:
slouken@7191
  1286
      /* Height at screen size */
aschiffler@6984
  1287
      desiredH = display.h;
aschiffler@6984
  1288
      break;
aschiffler@6984
  1289
     case 4:
slouken@7191
  1290
      /* Height 1 pixel larger than screen */
aschiffler@6984
  1291
      desiredH = display.h + 1;
aschiffler@6984
  1292
      break;
aschiffler@6984
  1293
    }
aschiffler@6984
  1294
aschiffler@6984
  1295
    /* Set size */
aschiffler@6984
  1296
    SDL_SetWindowMinimumSize(window, desiredW, desiredH);
aschiffler@6984
  1297
    SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH);
slouken@7191
  1298
aschiffler@6984
  1299
    /* Get size */
aschiffler@6984
  1300
    currentW = desiredW + 1;
aschiffler@6984
  1301
    currentH = desiredH + 1;
aschiffler@6984
  1302
    SDL_GetWindowMinimumSize(window, &currentW, &currentH);
aschiffler@6984
  1303
    SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize()");
aschiffler@6984
  1304
    SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
aschiffler@6984
  1305
    SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
aschiffler@6984
  1306
aschiffler@6984
  1307
    /* Get just width */
slouken@7191
  1308
    currentW = desiredW + 1;
aschiffler@6984
  1309
    SDL_GetWindowMinimumSize(window, &currentW, NULL);
aschiffler@6984
  1310
    SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&h=NULL)");
aschiffler@6984
  1311
    SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
aschiffler@6984
  1312
aschiffler@6984
  1313
    /* Get just height */
aschiffler@6984
  1314
    currentH = desiredH + 1;
aschiffler@6984
  1315
    SDL_GetWindowMinimumSize(window, NULL, &currentH);
aschiffler@6984
  1316
    SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL)");
aschiffler@6984
  1317
    SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
aschiffler@6984
  1318
   }
aschiffler@6956
  1319
  }
aschiffler@6956
  1320
aschiffler@6984
  1321
  /* Dummy call with both pointers NULL */
aschiffler@6984
  1322
  SDL_GetWindowMinimumSize(window, NULL, NULL);
aschiffler@6984
  1323
  SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL,&h=NULL)");
aschiffler@6984
  1324
aschiffler@6984
  1325
  /* Negative tests for parameter input */
aschiffler@6984
  1326
  SDL_ClearError();
slouken@7191
  1327
  SDLTest_AssertPass("Call to SDL_ClearError()");
aschiffler@6984
  1328
  for (desiredH = -2; desiredH < 2; desiredH++) {
aschiffler@6984
  1329
    for (desiredW = -2; desiredW < 2; desiredW++) {
slouken@7191
  1330
      if (desiredW <= 0 || desiredH <= 0) {
aschiffler@6984
  1331
        SDL_SetWindowMinimumSize(window, desiredW, desiredH);
aschiffler@6984
  1332
        SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH);
aschiffler@6984
  1333
        _checkInvalidParameterError();
aschiffler@6984
  1334
      }
aschiffler@6984
  1335
    }
aschiffler@6956
  1336
  }
slouken@7191
  1337
slouken@7191
  1338
  /* Clean up */
aschiffler@6984
  1339
  _destroyVideoSuiteTestWindow(window);
slouken@7191
  1340
aschiffler@6984
  1341
  /* Set some 'magic' value for later check that nothing was changed */
aschiffler@6984
  1342
  referenceW = SDLTest_RandomSint32();
aschiffler@6984
  1343
  referenceH = SDLTest_RandomSint32();
aschiffler@6984
  1344
  currentW = referenceW;
aschiffler@6984
  1345
  currentH = referenceH;
aschiffler@6984
  1346
  desiredW = SDLTest_RandomSint32();
aschiffler@6984
  1347
  desiredH = SDLTest_RandomSint32();
slouken@7191
  1348
aschiffler@6984
  1349
  /* Negative tests for window input */
aschiffler@6984
  1350
  SDL_ClearError();
aschiffler@6984
  1351
  SDLTest_AssertPass("Call to SDL_ClearError()");
aschiffler@6984
  1352
  SDL_GetWindowMinimumSize(NULL, &currentW, &currentH);
aschiffler@6984
  1353
  SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(window=NULL)");
aschiffler@6984
  1354
  SDLTest_AssertCheck(
slouken@7191
  1355
    currentW == referenceW && currentH == referenceH,
slouken@7191
  1356
    "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
slouken@7191
  1357
    referenceW, referenceH,
slouken@7191
  1358
    currentW, currentH);
aschiffler@6984
  1359
  _checkInvalidWindowError();
aschiffler@6984
  1360
aschiffler@6984
  1361
  SDL_GetWindowMinimumSize(NULL, NULL, NULL);
aschiffler@6984
  1362
  SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(NULL, NULL, NULL)");
aschiffler@6984
  1363
  _checkInvalidWindowError();
aschiffler@6984
  1364
aschiffler@6984
  1365
  SDL_SetWindowMinimumSize(NULL, desiredW, desiredH);
aschiffler@6984
  1366
  SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(window=NULL)");
aschiffler@6984
  1367
  _checkInvalidWindowError();
slouken@7191
  1368
aschiffler@6984
  1369
  return TEST_COMPLETED;
aschiffler@6984
  1370
}
aschiffler@6984
  1371
aschiffler@6984
  1372
/**
aschiffler@6984
  1373
 * @brief Tests call to SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize
aschiffler@6984
  1374
 *
aschiffler@6984
  1375
 */
aschiffler@6984
  1376
int
aschiffler@6984
  1377
video_getSetWindowMaximumSize(void *arg)
aschiffler@6984
  1378
{
aschiffler@6984
  1379
  const char* title = "video_getSetWindowMaximumSize Test Window";
aschiffler@6984
  1380
  SDL_Window* window;
aschiffler@6984
  1381
  int result;
aschiffler@6984
  1382
  SDL_Rect display;
aschiffler@6984
  1383
  int wVariation, hVariation;
aschiffler@6984
  1384
  int referenceW, referenceH;
aschiffler@6984
  1385
  int currentW, currentH;
aschiffler@6984
  1386
  int desiredW, desiredH;
aschiffler@6984
  1387
aschiffler@6984
  1388
  /* Get display bounds for size range */
aschiffler@6984
  1389
  result = SDL_GetDisplayBounds(0, &display);
aschiffler@6984
  1390
  SDLTest_AssertPass("SDL_GetDisplayBounds()");
aschiffler@6984
  1391
  SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
aschiffler@6984
  1392
  if (result != 0) return TEST_ABORTED;
aschiffler@6984
  1393
slouken@7191
  1394
  /* Call against new test window */
aschiffler@6984
  1395
  window = _createVideoSuiteTestWindow(title);
aschiffler@6984
  1396
  if (window == NULL) return TEST_ABORTED;
slouken@7191
  1397
aschiffler@6984
  1398
  for (wVariation = 0; wVariation < 3; wVariation++) {
aschiffler@6984
  1399
   for (hVariation = 0; hVariation < 3; hVariation++) {
aschiffler@6984
  1400
    switch(wVariation) {
aschiffler@6984
  1401
     case 0:
slouken@7191
  1402
      /* 1 Pixel Wide */
aschiffler@6984
  1403
      desiredW = 1;
aschiffler@6984
  1404
      break;
aschiffler@6984
  1405
     case 1:
slouken@7191
  1406
      /* Random width inside screen */
aschiffler@6984
  1407
      desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1);
aschiffler@6984
  1408
      break;
aschiffler@6984
  1409
     case 2:
slouken@7191
  1410
      /* Width at screen size */
aschiffler@6984
  1411
      desiredW = display.w;
aschiffler@6984
  1412
      break;
aschiffler@6984
  1413
    }
aschiffler@6984
  1414
aschiffler@6984
  1415
    switch(hVariation) {
aschiffler@6984
  1416
     case 0:
slouken@7191
  1417
      /* 1 Pixel High */
aschiffler@6984
  1418
      desiredH = 1;
aschiffler@6984
  1419
      break;
aschiffler@6984
  1420
     case 1:
slouken@7191
  1421
      /* Random height inside screen */
aschiffler@6984
  1422
      desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1);
aschiffler@6984
  1423
      break;
aschiffler@6984
  1424
     case 2:
slouken@7191
  1425
      /* Height at screen size */
aschiffler@6984
  1426
      desiredH = display.h;
aschiffler@6984
  1427
      break;
aschiffler@6984
  1428
    }
aschiffler@6984
  1429
aschiffler@6984
  1430
    /* Set size */
aschiffler@6984
  1431
    SDL_SetWindowMaximumSize(window, desiredW, desiredH);
aschiffler@6984
  1432
    SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH);
slouken@7191
  1433
aschiffler@6984
  1434
    /* Get size */
aschiffler@6984
  1435
    currentW = desiredW + 1;
aschiffler@6984
  1436
    currentH = desiredH + 1;
aschiffler@6984
  1437
    SDL_GetWindowMaximumSize(window, &currentW, &currentH);
aschiffler@6984
  1438
    SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize()");
aschiffler@6984
  1439
    SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
aschiffler@6984
  1440
    SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
aschiffler@6984
  1441
aschiffler@6984
  1442
    /* Get just width */
slouken@7191
  1443
    currentW = desiredW + 1;
aschiffler@6984
  1444
    SDL_GetWindowMaximumSize(window, &currentW, NULL);
aschiffler@6984
  1445
    SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&h=NULL)");
aschiffler@6984
  1446
    SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
aschiffler@6984
  1447
aschiffler@6984
  1448
    /* Get just height */
aschiffler@6984
  1449
    currentH = desiredH + 1;
aschiffler@6984
  1450
    SDL_GetWindowMaximumSize(window, NULL, &currentH);
aschiffler@6984
  1451
    SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL)");
aschiffler@6984
  1452
    SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
aschiffler@6984
  1453
   }
aschiffler@6984
  1454
  }
aschiffler@6984
  1455
aschiffler@6984
  1456
  /* Dummy call with both pointers NULL */
aschiffler@6984
  1457
  SDL_GetWindowMaximumSize(window, NULL, NULL);
aschiffler@6984
  1458
  SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL,&h=NULL)");
aschiffler@6984
  1459
aschiffler@6984
  1460
  /* Negative tests for parameter input */
aschiffler@6984
  1461
  SDL_ClearError();
slouken@7191
  1462
  SDLTest_AssertPass("Call to SDL_ClearError()");
aschiffler@6984
  1463
  for (desiredH = -2; desiredH < 2; desiredH++) {
aschiffler@6984
  1464
    for (desiredW = -2; desiredW < 2; desiredW++) {
slouken@7191
  1465
      if (desiredW <= 0 || desiredH <= 0) {
aschiffler@6984
  1466
        SDL_SetWindowMaximumSize(window, desiredW, desiredH);
aschiffler@6984
  1467
        SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH);
aschiffler@6984
  1468
        _checkInvalidParameterError();
aschiffler@6984
  1469
      }
aschiffler@6984
  1470
    }
aschiffler@6984
  1471
  }
slouken@7191
  1472
slouken@7191
  1473
  /* Clean up */
aschiffler@6984
  1474
  _destroyVideoSuiteTestWindow(window);
slouken@7191
  1475
aschiffler@6984
  1476
  /* Set some 'magic' value for later check that nothing was changed */
aschiffler@6984
  1477
  referenceW = SDLTest_RandomSint32();
aschiffler@6984
  1478
  referenceH = SDLTest_RandomSint32();
aschiffler@6984
  1479
  currentW = referenceW;
aschiffler@6984
  1480
  currentH = referenceH;
aschiffler@6984
  1481
  desiredW = SDLTest_RandomSint32();
aschiffler@6984
  1482
  desiredH = SDLTest_RandomSint32();
slouken@7191
  1483
aschiffler@6984
  1484
  /* Negative tests */
aschiffler@6984
  1485
  SDL_ClearError();
aschiffler@6984
  1486
  SDLTest_AssertPass("Call to SDL_ClearError()");
aschiffler@6984
  1487
  SDL_GetWindowMaximumSize(NULL, &currentW, &currentH);
aschiffler@6984
  1488
  SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(window=NULL)");
aschiffler@6984
  1489
  SDLTest_AssertCheck(
slouken@7191
  1490
    currentW == referenceW && currentH == referenceH,
slouken@7191
  1491
    "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
slouken@7191
  1492
    referenceW, referenceH,
slouken@7191
  1493
    currentW, currentH);
aschiffler@6984
  1494
  _checkInvalidWindowError();
aschiffler@6984
  1495
aschiffler@6984
  1496
  SDL_GetWindowMaximumSize(NULL, NULL, NULL);
aschiffler@6984
  1497
  SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(NULL, NULL, NULL)");
aschiffler@6984
  1498
  _checkInvalidWindowError();
aschiffler@6984
  1499
aschiffler@6984
  1500
  SDL_SetWindowMaximumSize(NULL, desiredW, desiredH);
aschiffler@6984
  1501
  SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(window=NULL)");
aschiffler@6984
  1502
  _checkInvalidWindowError();
slouken@7191
  1503
aschiffler@6956
  1504
  return TEST_COMPLETED;
aschiffler@6956
  1505
}
aschiffler@6956
  1506
aschiffler@7062
  1507
aschiffler@7062
  1508
/**
aschiffler@7062
  1509
 * @brief Tests call to SDL_SetWindowData and SDL_GetWindowData
aschiffler@7062
  1510
 *
aschiffler@7062
  1511
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowData
aschiffler@7062
  1512
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowData
aschiffler@7062
  1513
 */
aschiffler@7062
  1514
int
aschiffler@7062
  1515
video_getSetWindowData(void *arg)
aschiffler@7062
  1516
{
aschiffler@7062
  1517
  int returnValue = TEST_COMPLETED;
aschiffler@7062
  1518
  const char* title = "video_setGetWindowData Test Window";
aschiffler@7062
  1519
  SDL_Window* window;
aschiffler@7062
  1520
  const char *referenceName = "TestName";
aschiffler@7062
  1521
  const char *name = "TestName";
aschiffler@7062
  1522
  const char *referenceName2 = "TestName2";
aschiffler@7062
  1523
  const char *name2 = "TestName2";
aschiffler@7062
  1524
  int datasize;
philipp@9892
  1525
  char *referenceUserdata = NULL;
philipp@9892
  1526
  char *userdata = NULL;
philipp@9892
  1527
  char *referenceUserdata2 = NULL;
philipp@9892
  1528
  char *userdata2 = NULL;
aschiffler@7062
  1529
  char *result;
aschiffler@7062
  1530
  int iteration;
aschiffler@7062
  1531
slouken@7191
  1532
  /* Call against new test window */
aschiffler@7062
  1533
  window = _createVideoSuiteTestWindow(title);
aschiffler@7062
  1534
  if (window == NULL) return TEST_ABORTED;
aschiffler@7062
  1535
aschiffler@7062
  1536
  /* Create testdata */
slouken@7191
  1537
  datasize = SDLTest_RandomIntegerInRange(1, 32);
aschiffler@7062
  1538
  referenceUserdata =  SDLTest_RandomAsciiStringOfSize(datasize);
slouken@7191
  1539
  if (referenceUserdata == NULL) {
slouken@7191
  1540
    returnValue = TEST_ABORTED;
slouken@7191
  1541
    goto cleanup;
aschiffler@7062
  1542
  }
icculus@7065
  1543
  userdata = SDL_strdup(referenceUserdata);
aschiffler@7062
  1544
  if (userdata == NULL) {
slouken@7191
  1545
    returnValue = TEST_ABORTED;
slouken@7191
  1546
    goto cleanup;
aschiffler@7062
  1547
  }
slouken@7191
  1548
  datasize = SDLTest_RandomIntegerInRange(1, 32);
aschiffler@7062
  1549
  referenceUserdata2 =  SDLTest_RandomAsciiStringOfSize(datasize);
slouken@7191
  1550
  if (referenceUserdata2 == NULL) {
slouken@7191
  1551
    returnValue = TEST_ABORTED;
slouken@7191
  1552
    goto cleanup;
aschiffler@7062
  1553
  }
aschiffler@7134
  1554
  userdata2 = (char *)SDL_strdup(referenceUserdata2);
aschiffler@7062
  1555
  if (userdata2 == NULL) {
slouken@7191
  1556
    returnValue = TEST_ABORTED;
slouken@7191
  1557
    goto cleanup;
aschiffler@7062
  1558
  }
slouken@7191
  1559
aschiffler@7062
  1560
  /* Get non-existent data */
aschiffler@7062
  1561
  result = (char *)SDL_GetWindowData(window, name);
aschiffler@7062
  1562
  SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name);
aschiffler@7062
  1563
  SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
aschiffler@7062
  1564
  SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
slouken@7191
  1565
aschiffler@7062
  1566
  /* Set data */
aschiffler@7134
  1567
  result = (char *)SDL_SetWindowData(window, name, userdata);
aschiffler@7062
  1568
  SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s)", name, userdata);
aschiffler@7062
  1569
  SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
aschiffler@7062
  1570
  SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
aschiffler@7062
  1571
  SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
slouken@7191
  1572
aschiffler@7062
  1573
  /* Get data (twice) */
aschiffler@7062
  1574
  for (iteration = 1; iteration <= 2; iteration++) {
aschiffler@7062
  1575
    result = (char *)SDL_GetWindowData(window, name);
aschiffler@7062
  1576
    SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [iteration %d]", name, iteration);
aschiffler@7062
  1577
    SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
aschiffler@7062
  1578
    SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
aschiffler@7062
  1579
  }
slouken@7191
  1580
aschiffler@7062
  1581
  /* Set data again twice */
aschiffler@7062
  1582
  for (iteration = 1; iteration <= 2; iteration++) {
aschiffler@7134
  1583
    result = (char *)SDL_SetWindowData(window, name, userdata);
aschiffler@7062
  1584
    SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [iteration %d]", name, userdata, iteration);
aschiffler@7062
  1585
    SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
aschiffler@7062
  1586
    SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
aschiffler@7062
  1587
    SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
aschiffler@7062
  1588
  }
slouken@7191
  1589
aschiffler@7062
  1590
  /* Get data again */
aschiffler@7062
  1591
  result = (char *)SDL_GetWindowData(window, name);
aschiffler@7062
  1592
  SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [again]", name);
aschiffler@7062
  1593
  SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
aschiffler@7062
  1594
  SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
aschiffler@7062
  1595
aschiffler@7062
  1596
  /* Set data with new data */
aschiffler@7134
  1597
  result = (char *)SDL_SetWindowData(window, name, userdata2);
aschiffler@7062
  1598
  SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [new userdata]", name, userdata2);
aschiffler@7062
  1599
  SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
aschiffler@7062
  1600
  SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
aschiffler@7062
  1601
  SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
aschiffler@7062
  1602
  SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
aschiffler@7062
  1603
aschiffler@7062
  1604
  /* Set data with new data again */
aschiffler@7134
  1605
  result = (char *)SDL_SetWindowData(window, name, userdata2);
aschiffler@7062
  1606
  SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [new userdata again]", name, userdata2);
aschiffler@7062
  1607
  SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result);
aschiffler@7062
  1608
  SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
aschiffler@7062
  1609
  SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
aschiffler@7062
  1610
  SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
slouken@7191
  1611
aschiffler@7062
  1612
  /* Get new data */
aschiffler@7062
  1613
  result = (char *)SDL_GetWindowData(window, name);
aschiffler@7062
  1614
  SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name);
aschiffler@7062
  1615
  SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result);
aschiffler@7062
  1616
  SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
aschiffler@7062
  1617
aschiffler@7062
  1618
  /* Set data with NULL to clear */
aschiffler@7134
  1619
  result = (char *)SDL_SetWindowData(window, name, NULL);
aschiffler@9254
  1620
  SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,NULL)", name);
aschiffler@7062
  1621
  SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata2, result);
aschiffler@7062
  1622
  SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
aschiffler@7062
  1623
  SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
aschiffler@7062
  1624
  SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
aschiffler@7062
  1625
aschiffler@7062
  1626
  /* Set data with NULL to clear again */
aschiffler@7134
  1627
  result = (char *)SDL_SetWindowData(window, name, NULL);
aschiffler@9254
  1628
  SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,NULL) [again]", name);
aschiffler@7062
  1629
  SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
aschiffler@7062
  1630
  SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
aschiffler@7062
  1631
  SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
aschiffler@7062
  1632
  SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2);
slouken@7191
  1633
aschiffler@7062
  1634
  /* Get non-existent data */
aschiffler@7062
  1635
  result = (char *)SDL_GetWindowData(window, name);
aschiffler@7062
  1636
  SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name);
aschiffler@7062
  1637
  SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
aschiffler@7062
  1638
  SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
aschiffler@7062
  1639
aschiffler@7062
  1640
  /* Get non-existent data new name */
aschiffler@7062
  1641
  result = (char *)SDL_GetWindowData(window, name2);
aschiffler@7062
  1642
  SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name2);
aschiffler@7062
  1643
  SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
aschiffler@7062
  1644
  SDLTest_AssertCheck(SDL_strcmp(referenceName2, name2) == 0, "Validate that name2 was not changed, expected: %s, got: %s", referenceName2, name2);
aschiffler@7062
  1645
aschiffler@7062
  1646
  /* Set data (again) */
aschiffler@7134
  1647
  result = (char *)SDL_SetWindowData(window, name, userdata);
aschiffler@7062
  1648
  SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [again, after clear]", name, userdata);
aschiffler@7062
  1649
  SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
aschiffler@7062
  1650
  SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
aschiffler@7062
  1651
  SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata);
slouken@7191
  1652
aschiffler@7062
  1653
  /* Get data (again) */
aschiffler@7062
  1654
  result = (char *)SDL_GetWindowData(window, name);
aschiffler@7062
  1655
  SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [again, after clear]", name);
aschiffler@7062
  1656
  SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result);
aschiffler@7062
  1657
  SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name);
aschiffler@7062
  1658
aschiffler@7062
  1659
  /* Negative test */
aschiffler@7062
  1660
  SDL_ClearError();
aschiffler@7062
  1661
  SDLTest_AssertPass("Call to SDL_ClearError()");
aschiffler@7062
  1662
slouken@7191
  1663
  /* Set with invalid window */
aschiffler@7134
  1664
  result = (char *)SDL_SetWindowData(NULL, name, userdata);
aschiffler@7062
  1665
  SDLTest_AssertPass("Call to SDL_SetWindowData(window=NULL)");
aschiffler@7062
  1666
  SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
aschiffler@7062
  1667
  _checkInvalidWindowError();
slouken@7191
  1668
aschiffler@7062
  1669
  /* Set data with NULL name, valid userdata */
aschiffler@7134
  1670
  result = (char *)SDL_SetWindowData(window, NULL, userdata);
aschiffler@7062
  1671
  SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL)");
aschiffler@7062
  1672
  SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
aschiffler@7062
  1673
  _checkInvalidParameterError();
aschiffler@7062
  1674
aschiffler@7062
  1675
  /* Set data with empty name, valid userdata */
aschiffler@7134
  1676
  result = (char *)SDL_SetWindowData(window, "", userdata);
aschiffler@7062
  1677
  SDLTest_AssertPass("Call to SDL_SetWindowData(name='')");
aschiffler@7062
  1678
  SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
aschiffler@7062
  1679
  _checkInvalidParameterError();
aschiffler@7062
  1680
aschiffler@7062
  1681
  /* Set data with NULL name, NULL userdata */
aschiffler@7134
  1682
  result = (char *)SDL_SetWindowData(window, NULL, NULL);
aschiffler@7062
  1683
  SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL,userdata=NULL)");
aschiffler@7062
  1684
  SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
aschiffler@7062
  1685
  _checkInvalidParameterError();
aschiffler@7062
  1686
aschiffler@7062
  1687
  /* Set data with empty name, NULL userdata */
aschiffler@7134
  1688
  result = (char *)SDL_SetWindowData(window, "", NULL);
aschiffler@7062
  1689
  SDLTest_AssertPass("Call to SDL_SetWindowData(name='',userdata=NULL)");
aschiffler@7062
  1690
  SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
aschiffler@7062
  1691
  _checkInvalidParameterError();
aschiffler@7062
  1692
aschiffler@7062
  1693
  /* Get with invalid window */
aschiffler@7134
  1694
  result = (char *)SDL_GetWindowData(NULL, name);
aschiffler@7062
  1695
  SDLTest_AssertPass("Call to SDL_GetWindowData(window=NULL)");
aschiffler@7062
  1696
  SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
aschiffler@7062
  1697
  _checkInvalidWindowError();
slouken@7191
  1698
aschiffler@7062
  1699
  /* Get data with NULL name */
aschiffler@7134
  1700
  result = (char *)SDL_GetWindowData(window, NULL);
aschiffler@7062
  1701
  SDLTest_AssertPass("Call to SDL_GetWindowData(name=NULL)");
aschiffler@7062
  1702
  SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
aschiffler@7062
  1703
  _checkInvalidParameterError();
aschiffler@7062
  1704
aschiffler@7062
  1705
  /* Get data with empty name */
aschiffler@7134
  1706
  result = (char *)SDL_GetWindowData(window, "");
aschiffler@7062
  1707
  SDLTest_AssertPass("Call to SDL_GetWindowData(name='')");
aschiffler@7062
  1708
  SDLTest_AssertCheck(result == NULL, "Validate that result is NULL");
aschiffler@7062
  1709
  _checkInvalidParameterError();
aschiffler@7062
  1710
aschiffler@7062
  1711
  /* Clean up */
aschiffler@7062
  1712
  _destroyVideoSuiteTestWindow(window);
slouken@7191
  1713
aschiffler@7062
  1714
  cleanup:
slouken@7719
  1715
  SDL_free(referenceUserdata);
slouken@7719
  1716
  SDL_free(referenceUserdata2);
slouken@7719
  1717
  SDL_free(userdata);
slouken@7719
  1718
  SDL_free(userdata2);
slouken@7191
  1719
aschiffler@7062
  1720
  return returnValue;
aschiffler@7062
  1721
}
aschiffler@7062
  1722
aschiffler@7062
  1723
aschiffler@6800
  1724
/* ================= Test References ================== */
aschiffler@6800
  1725
aschiffler@6800
  1726
/* Video test cases */
aschiffler@6800
  1727
static const SDLTest_TestCaseReference videoTest1 =
slouken@7191
  1728
        { (SDLTest_TestCaseFp)video_enableDisableScreensaver, "video_enableDisableScreensaver",  "Enable and disable screenaver while checking state", TEST_ENABLED };
aschiffler@6800
  1729
aschiffler@6891
  1730
static const SDLTest_TestCaseReference videoTest2 =
slouken@7191
  1731
        { (SDLTest_TestCaseFp)video_createWindowVariousPositions, "video_createWindowVariousPositions",  "Create windows at various locations", TEST_ENABLED };
aschiffler@6891
  1732
aschiffler@6891
  1733
static const SDLTest_TestCaseReference videoTest3 =
slouken@7191
  1734
        { (SDLTest_TestCaseFp)video_createWindowVariousSizes, "video_createWindowVariousSizes",  "Create windows with various sizes", TEST_ENABLED };
aschiffler@6891
  1735
aschiffler@6891
  1736
static const SDLTest_TestCaseReference videoTest4 =
slouken@7191
  1737
        { (SDLTest_TestCaseFp)video_createWindowVariousFlags, "video_createWindowVariousFlags",  "Create windows using various flags", TEST_ENABLED };
aschiffler@6891
  1738
aschiffler@6891
  1739
static const SDLTest_TestCaseReference videoTest5 =
slouken@7191
  1740
        { (SDLTest_TestCaseFp)video_getWindowFlags, "video_getWindowFlags",  "Get window flags set during SDL_CreateWindow", TEST_ENABLED };
aschiffler@6921
  1741
aschiffler@6921
  1742
static const SDLTest_TestCaseReference videoTest6 =
slouken@7191
  1743
        { (SDLTest_TestCaseFp)video_getNumDisplayModes, "video_getNumDisplayModes",  "Use SDL_GetNumDisplayModes function to get number of display modes", TEST_ENABLED };
aschiffler@6921
  1744
aschiffler@6921
  1745
static const SDLTest_TestCaseReference videoTest7 =
slouken@7191
  1746
        { (SDLTest_TestCaseFp)video_getNumDisplayModesNegative, "video_getNumDisplayModesNegative",  "Negative tests for SDL_GetNumDisplayModes", TEST_ENABLED };
aschiffler@6921
  1747
aschiffler@6921
  1748
static const SDLTest_TestCaseReference videoTest8 =
slouken@7191
  1749
        { (SDLTest_TestCaseFp)video_getClosestDisplayModeCurrentResolution, "video_getClosestDisplayModeCurrentResolution",  "Use function to get closes match to requested display mode for current resolution", TEST_ENABLED };
aschiffler@6921
  1750
aschiffler@6921
  1751
static const SDLTest_TestCaseReference videoTest9 =
slouken@7191
  1752
        { (SDLTest_TestCaseFp)video_getClosestDisplayModeRandomResolution, "video_getClosestDisplayModeRandomResolution",  "Use function to get closes match to requested display mode for random resolution", TEST_ENABLED };
aschiffler@6921
  1753
aschiffler@6921
  1754
static const SDLTest_TestCaseReference videoTest10 =
slouken@7191
  1755
        { (SDLTest_TestCaseFp)video_getWindowBrightness, "video_getWindowBrightness",  "Get window brightness", TEST_ENABLED };
aschiffler@6891
  1756
aschiffler@6936
  1757
static const SDLTest_TestCaseReference videoTest11 =
slouken@7191
  1758
        { (SDLTest_TestCaseFp)video_getWindowBrightnessNegative, "video_getWindowBrightnessNegative",  "Get window brightness with invalid input", TEST_ENABLED };
aschiffler@6936
  1759
aschiffler@6936
  1760
static const SDLTest_TestCaseReference videoTest12 =
slouken@7191
  1761
        { (SDLTest_TestCaseFp)video_getWindowDisplayMode, "video_getWindowDisplayMode",  "Get window display mode", TEST_ENABLED };
aschiffler@6936
  1762
aschiffler@6936
  1763
static const SDLTest_TestCaseReference videoTest13 =
slouken@7191
  1764
        { (SDLTest_TestCaseFp)video_getWindowDisplayModeNegative, "video_getWindowDisplayModeNegative",  "Get window display mode with invalid input", TEST_ENABLED };
aschiffler@6936
  1765
aschiffler@6936
  1766
static const SDLTest_TestCaseReference videoTest14 =
slouken@7191
  1767
        { (SDLTest_TestCaseFp)video_getWindowGammaRamp, "video_getWindowGammaRamp",  "Get window gamma ramp", TEST_ENABLED };
aschiffler@6936
  1768
aschiffler@6936
  1769
static const SDLTest_TestCaseReference videoTest15 =
slouken@7191
  1770
        { (SDLTest_TestCaseFp)video_getWindowGammaRampNegative, "video_getWindowGammaRampNegative",  "Get window gamma ramp against invalid input", TEST_ENABLED };
aschiffler@6936
  1771
aschiffler@6956
  1772
static const SDLTest_TestCaseReference videoTest16 =
slouken@7191
  1773
        { (SDLTest_TestCaseFp)video_getSetWindowGrab, "video_getSetWindowGrab",  "Checks SDL_GetWindowGrab and SDL_SetWindowGrab positive and negative cases", TEST_ENABLED };
aschiffler@6956
  1774
aschiffler@6956
  1775
static const SDLTest_TestCaseReference videoTest17 =
slouken@7191
  1776
        { (SDLTest_TestCaseFp)video_getWindowId, "video_getWindowId",  "Checks SDL_GetWindowID and SDL_GetWindowFromID", TEST_ENABLED };
aschiffler@6956
  1777
aschiffler@6956
  1778
static const SDLTest_TestCaseReference videoTest18 =
slouken@7191
  1779
        { (SDLTest_TestCaseFp)video_getWindowPixelFormat, "video_getWindowPixelFormat",  "Checks SDL_GetWindowPixelFormat", TEST_ENABLED };
aschiffler@6956
  1780
aschiffler@6956
  1781
static const SDLTest_TestCaseReference videoTest19 =
slouken@7191
  1782
        { (SDLTest_TestCaseFp)video_getSetWindowPosition, "video_getSetWindowPosition",  "Checks SDL_GetWindowPosition and SDL_SetWindowPosition positive and negative cases", TEST_ENABLED };
aschiffler@6984
  1783
aschiffler@6984
  1784
static const SDLTest_TestCaseReference videoTest20 =
slouken@7191
  1785
        { (SDLTest_TestCaseFp)video_getSetWindowSize, "video_getSetWindowSize",  "Checks SDL_GetWindowSize and SDL_SetWindowSize positive and negative cases", TEST_ENABLED };
aschiffler@6984
  1786
aschiffler@6984
  1787
static const SDLTest_TestCaseReference videoTest21 =
slouken@7191
  1788
        { (SDLTest_TestCaseFp)video_getSetWindowMinimumSize, "video_getSetWindowMinimumSize",  "Checks SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize positive and negative cases", TEST_ENABLED };
aschiffler@6984
  1789
aschiffler@6984
  1790
static const SDLTest_TestCaseReference videoTest22 =
slouken@7191
  1791
        { (SDLTest_TestCaseFp)video_getSetWindowMaximumSize, "video_getSetWindowMaximumSize",  "Checks SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize positive and negative cases", TEST_ENABLED };
aschiffler@6956
  1792
aschiffler@7062
  1793
static const SDLTest_TestCaseReference videoTest23 =
slouken@7191
  1794
        { (SDLTest_TestCaseFp)video_getSetWindowData, "video_getSetWindowData",  "Checks SDL_SetWindowData and SDL_GetWindowData positive and negative cases", TEST_ENABLED };
aschiffler@7062
  1795
aschiffler@6800
  1796
/* Sequence of Video test cases */
aschiffler@6800
  1797
static const SDLTest_TestCaseReference *videoTests[] =  {
slouken@7191
  1798
    &videoTest1, &videoTest2, &videoTest3, &videoTest4, &videoTest5, &videoTest6,
slouken@7191
  1799
    &videoTest7, &videoTest8, &videoTest9, &videoTest10, &videoTest11, &videoTest12,
slouken@7191
  1800
    &videoTest13, &videoTest14, &videoTest15, &videoTest16, &videoTest17,
slouken@7191
  1801
    &videoTest18, &videoTest19, &videoTest20, &videoTest21, &videoTest22,
slouken@7191
  1802
    &videoTest23, NULL
aschiffler@6800
  1803
};
aschiffler@6800
  1804
aschiffler@6800
  1805
/* Video test suite (global) */
aschiffler@6800
  1806
SDLTest_TestSuiteReference videoTestSuite = {
slouken@7191
  1807
    "Video",
slouken@7191
  1808
    NULL,
slouken@7191
  1809
    videoTests,
slouken@7191
  1810
    NULL
aschiffler@6800
  1811
};