test/testautomation_video.c
author Ryan C. Gordon <icculus@icculus.org>
Fri, 12 Aug 2016 19:59:00 -0400
changeset 10266 c09f06c4e8c8
parent 9892 f8e6273be2fa
permissions -rw-r--r--
emscripten: send fake mouse events for touches, like other targets do. (This really should be handled at the higher level and not in the individual targets, but this fixes the immediate bug.)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     1
/**
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     2
 * Video test suite
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     3
 */
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     4
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     5
#include <stdio.h>
7066
d61902a0bc21 Maybe actually fix compiler warning this time.
Ryan C. Gordon <icculus@icculus.org>
parents: 7065
diff changeset
     6
#include <string.h>
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     7
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
     8
/* Visual Studio 2008 doesn't have stdint.h */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
     9
#if defined(_MSC_VER) && _MSC_VER <= 1500
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
    10
#define UINT8_MAX   ~(Uint8)0
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
    11
#define UINT16_MAX  ~(Uint16)0
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
    12
#define UINT32_MAX  ~(Uint32)0
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
    13
#define UINT64_MAX  ~(Uint64)0
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
    14
#else
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
    15
#include <stdint.h>
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
    16
#endif
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
    17
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    18
#include "SDL.h"
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    19
#include "SDL_test.h"
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    20
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    21
/* Private helpers */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    22
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    23
/*
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    24
 * Create a test window
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    25
 */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    26
SDL_Window *_createVideoSuiteTestWindow(const char *title)
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    27
{
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    28
  SDL_Window* window;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    29
  int x, y, w, h;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    30
  SDL_WindowFlags flags;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    31
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    32
  /* Standard window */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    33
  x = SDLTest_RandomIntegerInRange(1, 100);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    34
  y = SDLTest_RandomIntegerInRange(1, 100);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    35
  w = SDLTest_RandomIntegerInRange(320, 1024);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    36
  h = SDLTest_RandomIntegerInRange(320, 768);
6984
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
    37
  flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    38
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    39
  window = SDL_CreateWindow(title, x, y, w, h, flags);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    40
  SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    41
  SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    42
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    43
  return window;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    44
}
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    45
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    46
/*
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    47
 * Destroy test window
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    48
 */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    49
void _destroyVideoSuiteTestWindow(SDL_Window *window)
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    50
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    51
  if (window != NULL) {
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    52
     SDL_DestroyWindow(window);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    53
     window = NULL;
9219
c65108ddbeb0 Added missing brackets in test source assert messages.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7719
diff changeset
    54
     SDLTest_AssertPass("Call to SDL_DestroyWindow()");
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    55
  }
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    56
}
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    57
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    58
/* Test case functions */
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    59
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    60
/**
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    61
 * @brief Enable and disable screensaver while checking state
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    62
 */
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    63
int
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    64
video_enableDisableScreensaver(void *arg)
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    65
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    66
    SDL_bool initialResult;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    67
    SDL_bool result;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    68
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    69
    /* Get current state and proceed according to current state */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    70
    initialResult = SDL_IsScreenSaverEnabled();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    71
    SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    72
    if (initialResult == SDL_TRUE) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    73
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    74
      /* Currently enabled: disable first, then enable again */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    75
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    76
      /* Disable screensaver and check */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    77
      SDL_DisableScreenSaver();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    78
      SDLTest_AssertPass("Call to SDL_DisableScreenSaver()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    79
      result = SDL_IsScreenSaverEnabled();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    80
      SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    81
      SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    82
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    83
      /* Enable screensaver and check */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    84
      SDL_EnableScreenSaver();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    85
      SDLTest_AssertPass("Call to SDL_EnableScreenSaver()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    86
      result = SDL_IsScreenSaverEnabled();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    87
      SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    88
      SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    89
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    90
    } else {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    91
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    92
      /* Currently disabled: enable first, then disable again */
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    93
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    94
      /* Enable screensaver and check */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    95
      SDL_EnableScreenSaver();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    96
      SDLTest_AssertPass("Call to SDL_EnableScreenSaver()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    97
      result = SDL_IsScreenSaverEnabled();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    98
      SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
    99
      SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   100
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   101
      /* Disable screensaver and check */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   102
      SDL_DisableScreenSaver();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   103
      SDLTest_AssertPass("Call to SDL_DisableScreenSaver()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   104
      result = SDL_IsScreenSaverEnabled();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   105
      SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   106
      SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   107
    }
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   108
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   109
    return TEST_COMPLETED;
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   110
}
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   111
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   112
/**
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   113
 * @brief Tests the functionality of the SDL_CreateWindow function using different positions
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   114
 */
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   115
int
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   116
video_createWindowVariousPositions(void *arg)
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   117
{
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   118
  SDL_Window* window;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   119
  const char* title = "video_createWindowVariousPositions Test Window";
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   120
  int x, y, w, h;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   121
  int xVariation, yVariation;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   122
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   123
  for (xVariation = 0; xVariation < 6; xVariation++) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   124
   for (yVariation = 0; yVariation < 6; yVariation++) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   125
    switch(xVariation) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   126
     case 0:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   127
      /* Zero X Position */
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   128
      x = 0;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   129
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   130
     case 1:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   131
      /* Random X position inside screen */
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   132
      x = SDLTest_RandomIntegerInRange(1, 100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   133
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   134
     case 2:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   135
      /* Random X position outside screen (positive) */
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   136
      x = SDLTest_RandomIntegerInRange(10000, 11000);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   137
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   138
     case 3:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   139
      /* Random X position outside screen (negative) */
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   140
      x = SDLTest_RandomIntegerInRange(-1000, -100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   141
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   142
     case 4:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   143
      /* Centered X position */
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   144
      x = SDL_WINDOWPOS_CENTERED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   145
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   146
     case 5:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   147
      /* Undefined X position */
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   148
      x = SDL_WINDOWPOS_UNDEFINED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   149
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   150
    }
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   151
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   152
    switch(yVariation) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   153
     case 0:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   154
      /* Zero X Position */
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   155
      y = 0;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   156
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   157
     case 1:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   158
      /* Random X position inside screen */
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   159
      y = SDLTest_RandomIntegerInRange(1, 100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   160
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   161
     case 2:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   162
      /* Random X position outside screen (positive) */
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   163
      y = SDLTest_RandomIntegerInRange(10000, 11000);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   164
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   165
     case 3:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   166
      /* Random Y position outside screen (negative) */
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   167
      y = SDLTest_RandomIntegerInRange(-1000, -100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   168
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   169
     case 4:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   170
      /* Centered Y position */
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   171
      y = SDL_WINDOWPOS_CENTERED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   172
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   173
     case 5:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   174
      /* Undefined Y position */
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   175
      y = SDL_WINDOWPOS_UNDEFINED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   176
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   177
    }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   178
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   179
    w = SDLTest_RandomIntegerInRange(32, 96);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   180
    h = SDLTest_RandomIntegerInRange(32, 96);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   181
    window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   182
    SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   183
    SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   184
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   185
    /* Clean up */
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   186
    _destroyVideoSuiteTestWindow(window);
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   187
   }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   188
  }
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   189
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   190
  return TEST_COMPLETED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   191
}
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   192
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   193
/**
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   194
 * @brief Tests the functionality of the SDL_CreateWindow function using different sizes
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   195
 */
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   196
int
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   197
video_createWindowVariousSizes(void *arg)
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   198
{
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   199
  SDL_Window* window;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   200
  const char* title = "video_createWindowVariousSizes Test Window";
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   201
  int x, y, w, h;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   202
  int wVariation, hVariation;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   203
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   204
  x = SDLTest_RandomIntegerInRange(1, 100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   205
  y = SDLTest_RandomIntegerInRange(1, 100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   206
  for (wVariation = 0; wVariation < 3; wVariation++) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   207
   for (hVariation = 0; hVariation < 3; hVariation++) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   208
    switch(wVariation) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   209
     case 0:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   210
      /* Width of 1 */
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   211
      w = 1;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   212
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   213
     case 1:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   214
      /* Random "normal" width */
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   215
      w = SDLTest_RandomIntegerInRange(320, 1920);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   216
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   217
     case 2:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   218
      /* Random "large" width */
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   219
      w = SDLTest_RandomIntegerInRange(2048, 4095);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   220
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   221
    }
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   222
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   223
    switch(hVariation) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   224
     case 0:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   225
      /* Height of 1 */
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   226
      h = 1;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   227
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   228
     case 1:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   229
      /* Random "normal" height */
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   230
      h = SDLTest_RandomIntegerInRange(320, 1080);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   231
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   232
     case 2:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   233
      /* Random "large" height */
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   234
      h = SDLTest_RandomIntegerInRange(2048, 4095);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   235
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   236
     }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   237
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   238
    window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   239
    SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   240
    SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   241
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   242
    /* Clean up */
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   243
    _destroyVideoSuiteTestWindow(window);
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   244
   }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   245
  }
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   246
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   247
  return TEST_COMPLETED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   248
}
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   249
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   250
/**
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   251
 * @brief Tests the functionality of the SDL_CreateWindow function using different flags
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   252
 */
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   253
int
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   254
video_createWindowVariousFlags(void *arg)
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   255
{
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   256
  SDL_Window* window;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   257
  const char* title = "video_createWindowVariousFlags Test Window";
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   258
  int x, y, w, h;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   259
  int fVariation;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   260
  SDL_WindowFlags flags;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   261
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   262
  /* Standard window */
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   263
  x = SDLTest_RandomIntegerInRange(1, 100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   264
  y = SDLTest_RandomIntegerInRange(1, 100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   265
  w = SDLTest_RandomIntegerInRange(320, 1024);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   266
  h = SDLTest_RandomIntegerInRange(320, 768);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   267
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   268
  for (fVariation = 0; fVariation < 13; fVariation++) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   269
    switch(fVariation) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   270
     case 0:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   271
      flags = SDL_WINDOW_FULLSCREEN;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   272
      /* Skip - blanks screen; comment out next line to run test */
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   273
      continue;
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   274
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   275
     case 1:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   276
      flags = SDL_WINDOW_FULLSCREEN_DESKTOP;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   277
      /* Skip - blanks screen; comment out next line to run test */
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   278
      continue;
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   279
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   280
     case 2:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   281
      flags = SDL_WINDOW_OPENGL;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   282
      break;
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   283
     case 3:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   284
      flags = SDL_WINDOW_SHOWN;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   285
      break;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   286
     case 4:
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   287
      flags = SDL_WINDOW_HIDDEN;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   288
      break;
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   289
     case 5:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   290
      flags = SDL_WINDOW_BORDERLESS;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   291
      break;
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   292
     case 6:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   293
      flags = SDL_WINDOW_RESIZABLE;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   294
      break;
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   295
     case 7:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   296
      flags = SDL_WINDOW_MINIMIZED;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   297
      break;
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   298
     case 8:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   299
      flags = SDL_WINDOW_MAXIMIZED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   300
      break;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   301
     case 9:
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   302
      flags = SDL_WINDOW_INPUT_GRABBED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   303
      break;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   304
     case 10:
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   305
      flags = SDL_WINDOW_INPUT_FOCUS;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   306
      break;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   307
     case 11:
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   308
      flags = SDL_WINDOW_MOUSE_FOCUS;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   309
      break;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   310
     case 12:
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   311
      flags = SDL_WINDOW_FOREIGN;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   312
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   313
    }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   314
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   315
    window = SDL_CreateWindow(title, x, y, w, h, flags);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   316
    SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   317
    SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   318
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   319
    /* Clean up */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   320
    _destroyVideoSuiteTestWindow(window);
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   321
  }
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   322
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   323
  return TEST_COMPLETED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   324
}
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   325
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   326
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   327
/**
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   328
 * @brief Tests the functionality of the SDL_GetWindowFlags function
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   329
 */
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   330
int
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   331
video_getWindowFlags(void *arg)
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   332
{
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   333
  SDL_Window* window;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   334
  const char* title = "video_getWindowFlags Test Window";
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   335
  SDL_WindowFlags flags;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   336
  Uint32 actualFlags;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   337
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   338
  /* Reliable flag set always set in test window */
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   339
  flags = SDL_WINDOW_SHOWN;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   340
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   341
  /* Call against new test window */
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   342
  window = _createVideoSuiteTestWindow(title);
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   343
  if (window != NULL) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   344
      actualFlags = SDL_GetWindowFlags(window);
9219
c65108ddbeb0 Added missing brackets in test source assert messages.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7719
diff changeset
   345
      SDLTest_AssertPass("Call to SDL_GetWindowFlags()");
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   346
      SDLTest_AssertCheck((flags & actualFlags) == flags, "Verify returned value has flags %d set, got: %d", flags, actualFlags);
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   347
  }
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   348
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   349
  /* Clean up */
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   350
  _destroyVideoSuiteTestWindow(window);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   351
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   352
  return TEST_COMPLETED;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   353
}
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   354
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   355
/**
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   356
 * @brief Tests the functionality of the SDL_GetNumDisplayModes function
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   357
 */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   358
int
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   359
video_getNumDisplayModes(void *arg)
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   360
{
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   361
  int result;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   362
  int displayNum;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   363
  int i;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   364
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   365
  /* Get number of displays */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   366
  displayNum = SDL_GetNumVideoDisplays();
9219
c65108ddbeb0 Added missing brackets in test source assert messages.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7719
diff changeset
   367
  SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()");
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   368
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   369
  /* Make call for each display */
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   370
  for (i=0; i<displayNum; i++) {
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   371
    result = SDL_GetNumDisplayModes(i);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   372
    SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d)", i);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   373
    SDLTest_AssertCheck(result >= 1, "Validate returned value from function; expected: >=1; got: %d", result);
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   374
  }
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   375
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   376
  return TEST_COMPLETED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   377
}
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   378
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   379
/**
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   380
 * @brief Tests negative call to SDL_GetNumDisplayModes function
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   381
 */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   382
int
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   383
video_getNumDisplayModesNegative(void *arg)
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   384
{
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   385
  int result;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   386
  int displayNum;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   387
  int displayIndex;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   388
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   389
  /* Get number of displays */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   390
  displayNum = SDL_GetNumVideoDisplays();
9219
c65108ddbeb0 Added missing brackets in test source assert messages.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7719
diff changeset
   391
  SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()");
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   392
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   393
  /* Invalid boundary values */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   394
  displayIndex =  SDLTest_RandomSint32BoundaryValue(0, displayNum, SDL_FALSE);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   395
  result = SDL_GetNumDisplayModes(displayIndex);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   396
  SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/boundary)", displayIndex);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   397
  SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   398
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   399
  /* Large (out-of-bounds) display index */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   400
  displayIndex = SDLTest_RandomIntegerInRange(-2000, -1000);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   401
  result = SDL_GetNumDisplayModes(displayIndex);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   402
  SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/large negative)", displayIndex);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   403
  SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result);
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   404
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   405
  displayIndex = SDLTest_RandomIntegerInRange(1000, 2000);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   406
  result = SDL_GetNumDisplayModes(displayIndex);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   407
  SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/large positive)", displayIndex);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   408
  SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result);
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   409
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   410
  return TEST_COMPLETED;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   411
}
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   412
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   413
/**
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   414
 * @brief Tests the functionality of the SDL_GetClosestDisplayMode function against current resolution
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   415
 */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   416
int
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   417
video_getClosestDisplayModeCurrentResolution(void *arg)
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   418
{
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   419
  int result;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   420
  SDL_DisplayMode current;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   421
  SDL_DisplayMode target;
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   422
  SDL_DisplayMode closest;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   423
  SDL_DisplayMode* dResult;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   424
  int displayNum;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   425
  int i;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   426
  int variation;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   427
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   428
  /* Get number of displays */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   429
  displayNum = SDL_GetNumVideoDisplays();
9219
c65108ddbeb0 Added missing brackets in test source assert messages.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7719
diff changeset
   430
  SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()");
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   431
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   432
  /* Make calls for each display */
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   433
  for (i=0; i<displayNum; i++) {
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   434
    SDLTest_Log("Testing against display: %d", i);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   435
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   436
    /* Get first display mode to get a sane resolution; this should always work */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   437
    result = SDL_GetDisplayMode(i, 0, &current);
9219
c65108ddbeb0 Added missing brackets in test source assert messages.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7719
diff changeset
   438
    SDLTest_AssertPass("Call to SDL_GetDisplayMode()");
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   439
    SDLTest_AssertCheck(result == 0, "Verify return value, expected: 0, got: %d", result);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   440
    if (result != 0) {
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   441
      return TEST_ABORTED;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   442
    }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   443
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   444
    /* Set the desired resolution equals to current resolution */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   445
    target.w = current.w;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   446
    target.h = current.h;
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   447
    for (variation = 0; variation < 8; variation ++) {
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   448
      /* Vary constraints on other query parameters */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   449
      target.format = (variation & 1) ? current.format : 0;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   450
      target.refresh_rate = (variation & 2) ? current.refresh_rate : 0;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   451
      target.driverdata = (variation & 4) ? current.driverdata : 0;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   452
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   453
      /* Make call */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   454
      dResult = SDL_GetClosestDisplayMode(i, &target, &closest);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   455
      SDLTest_AssertPass("Call to SDL_GetClosestDisplayMode(target=current/variation%d)", variation);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   456
      SDLTest_AssertCheck(dResult != NULL, "Verify returned value is not NULL");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   457
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   458
      /* Check that one gets the current resolution back again */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   459
      SDLTest_AssertCheck(closest.w == current.w, "Verify returned width matches current width; expected: %d, got: %d", current.w, closest.w);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   460
      SDLTest_AssertCheck(closest.h == current.h, "Verify returned height matches current height; expected: %d, got: %d", current.h, closest.h);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   461
      SDLTest_AssertCheck(closest.w == dResult->w, "Verify return value matches assigned value; expected: %d, got: %d", closest.w, dResult->w);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   462
      SDLTest_AssertCheck(closest.h == dResult->h, "Verify return value matches assigned value; expected: %d, got: %d", closest.h, dResult->h);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   463
    }
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   464
  }
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   465
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   466
  return TEST_COMPLETED;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   467
}
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   468
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   469
/**
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   470
 * @brief Tests the functionality of the SDL_GetClosestDisplayMode function against random resolution
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   471
 */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   472
int
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   473
video_getClosestDisplayModeRandomResolution(void *arg)
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   474
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   475
  SDL_DisplayMode target;
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   476
  SDL_DisplayMode closest;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   477
  SDL_DisplayMode* dResult;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   478
  int displayNum;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   479
  int i;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   480
  int variation;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   481
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   482
  /* Get number of displays */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   483
  displayNum = SDL_GetNumVideoDisplays();
9219
c65108ddbeb0 Added missing brackets in test source assert messages.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7719
diff changeset
   484
  SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays()");
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   485
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   486
  /* Make calls for each display */
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   487
  for (i=0; i<displayNum; i++) {
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   488
    SDLTest_Log("Testing against display: %d", i);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   489
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   490
    for (variation = 0; variation < 16; variation ++) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   491
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   492
      /* Set random constraints */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   493
      target.w = (variation & 1) ? SDLTest_RandomIntegerInRange(1, 4096) : 0;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   494
      target.h = (variation & 2) ? SDLTest_RandomIntegerInRange(1, 4096) : 0;
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   495
      target.format = (variation & 4) ? SDLTest_RandomIntegerInRange(1, 10) : 0;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   496
      target.refresh_rate = (variation & 8) ? SDLTest_RandomIntegerInRange(25, 120) : 0;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   497
      target.driverdata = 0;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   498
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   499
      /* Make call; may or may not find anything, so don't validate any further */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   500
      dResult = SDL_GetClosestDisplayMode(i, &target, &closest);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   501
      SDLTest_AssertPass("Call to SDL_GetClosestDisplayMode(target=random/variation%d)", variation);
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   502
    }
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   503
  }
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   504
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   505
  return TEST_COMPLETED;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   506
}
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   507
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   508
/**
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   509
 * @brief Tests call to SDL_GetWindowBrightness
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   510
 *
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   511
* @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowBrightness
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   512
 */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   513
int
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   514
video_getWindowBrightness(void *arg)
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   515
{
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   516
  SDL_Window* window;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   517
  const char* title = "video_getWindowBrightness Test Window";
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   518
  float result;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   519
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   520
  /* Call against new test window */
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   521
  window = _createVideoSuiteTestWindow(title);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   522
  if (window != NULL) {
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   523
      result = SDL_GetWindowBrightness(window);
9219
c65108ddbeb0 Added missing brackets in test source assert messages.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7719
diff changeset
   524
      SDLTest_AssertPass("Call to SDL_GetWindowBrightness()");
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   525
      SDLTest_AssertCheck(result >= 0.0 && result <= 1.0, "Validate range of result value; expected: [0.0, 1.0], got: %f", result);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   526
  }
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   527
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   528
  /* Clean up */
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   529
  _destroyVideoSuiteTestWindow(window);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   530
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   531
  return TEST_COMPLETED;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   532
}
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   533
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   534
/**
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   535
 * @brief Tests call to SDL_GetWindowBrightness with invalid input
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   536
 *
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   537
* @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowBrightness
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   538
 */
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   539
int
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   540
video_getWindowBrightnessNegative(void *arg)
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   541
{
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   542
  const char *invalidWindowError = "Invalid window";
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   543
  char *lastError;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   544
  float result;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   545
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   546
  /* Call against invalid window */
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   547
  result = SDL_GetWindowBrightness(NULL);
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   548
  SDLTest_AssertPass("Call to SDL_GetWindowBrightness(window=NULL)");
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   549
  SDLTest_AssertCheck(result == 1.0, "Validate result value; expected: 1.0, got: %f", result);
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   550
  lastError = (char *)SDL_GetError();
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   551
  SDLTest_AssertPass("SDL_GetError()");
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   552
  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   553
  if (lastError != NULL) {
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   554
      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   555
         "SDL_GetError(): expected message '%s', was message: '%s'",
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   556
         invalidWindowError,
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   557
         lastError);
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   558
  }
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   559
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   560
  return TEST_COMPLETED;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   561
}
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   562
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   563
/**
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   564
 * @brief Tests call to SDL_GetWindowDisplayMode
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   565
 *
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   566
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowDisplayMode
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   567
 */
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   568
int
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   569
video_getWindowDisplayMode(void *arg)
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   570
{
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   571
  SDL_Window* window;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   572
  const char* title = "video_getWindowDisplayMode Test Window";
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   573
  SDL_DisplayMode mode;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   574
  int result;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   575
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   576
  /* Invalidate part of the mode content so we can check values later */
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   577
  mode.w = -1;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   578
  mode.h = -1;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   579
  mode.refresh_rate = -1;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   580
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   581
  /* Call against new test window */
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   582
  window = _createVideoSuiteTestWindow(title);
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   583
  if (window != NULL) {
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   584
      result = SDL_GetWindowDisplayMode(window, &mode);
9219
c65108ddbeb0 Added missing brackets in test source assert messages.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7719
diff changeset
   585
      SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode()");
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   586
      SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   587
      SDLTest_AssertCheck(mode.w > 0, "Validate mode.w content; expected: >0, got: %d", mode.w);
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   588
      SDLTest_AssertCheck(mode.h > 0, "Validate mode.h content; expected: >0, got: %d", mode.h);
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   589
      SDLTest_AssertCheck(mode.refresh_rate > 0, "Validate mode.refresh_rate content; expected: >0, got: %d", mode.refresh_rate);
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   590
  }
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   591
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   592
  /* Clean up */
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   593
  _destroyVideoSuiteTestWindow(window);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   594
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   595
  return TEST_COMPLETED;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   596
}
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   597
6984
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   598
/* Helper function that checks for an 'Invalid window' error */
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   599
void _checkInvalidWindowError()
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   600
{
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   601
  const char *invalidWindowError = "Invalid window";
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   602
  char *lastError;
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   603
7062
c0a739679bbd Add test coverage for SDL_SetWindowData and SDL_GetWindowData to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6984
diff changeset
   604
  lastError = (char *)SDL_GetError();
6984
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   605
  SDLTest_AssertPass("SDL_GetError()");
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   606
  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   607
  if (lastError != NULL) {
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   608
      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   609
         "SDL_GetError(): expected message '%s', was message: '%s'",
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   610
         invalidWindowError,
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   611
         lastError);
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   612
      SDL_ClearError();
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   613
      SDLTest_AssertPass("Call to SDL_ClearError()");
6984
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   614
  }
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   615
}
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   616
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   617
/**
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   618
 * @brief Tests call to SDL_GetWindowDisplayMode with invalid input
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   619
 *
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   620
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowDisplayMode
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   621
 */
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   622
int
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   623
video_getWindowDisplayModeNegative(void *arg)
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   624
{
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   625
  const char *expectedError = "Parameter 'mode' is invalid";
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   626
  char *lastError;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   627
  SDL_Window* window;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   628
  const char* title = "video_getWindowDisplayModeNegative Test Window";
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   629
  SDL_DisplayMode mode;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   630
  int result;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   631
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   632
  /* Call against new test window */
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   633
  window = _createVideoSuiteTestWindow(title);
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   634
  if (window != NULL) {
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   635
      result = SDL_GetWindowDisplayMode(window, NULL);
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   636
      SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(...,mode=NULL)");
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   637
      SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result);
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   638
      lastError = (char *)SDL_GetError();
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   639
      SDLTest_AssertPass("SDL_GetError()");
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   640
      SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   641
      if (lastError != NULL) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   642
        SDLTest_AssertCheck(SDL_strcmp(lastError, expectedError) == 0,
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   643
             "SDL_GetError(): expected message '%s', was message: '%s'",
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   644
             expectedError,
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   645
             lastError);
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   646
      }
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   647
  }
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   648
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   649
  /* Clean up */
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   650
  _destroyVideoSuiteTestWindow(window);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   651
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   652
  /* Call against invalid window */
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   653
  result = SDL_GetWindowDisplayMode(NULL, &mode);
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   654
  SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(window=NULL,...)");
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   655
  SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result);
6984
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   656
  _checkInvalidWindowError();
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   657
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   658
  return TEST_COMPLETED;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   659
}
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   660
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   661
/**
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   662
 * @brief Tests call to SDL_GetWindowGammaRamp
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   663
 *
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   664
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGammaRamp
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   665
 */
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   666
int
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   667
video_getWindowGammaRamp(void *arg)
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   668
{
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   669
  SDL_Window* window;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   670
  const char* title = "video_getWindowGammaRamp Test Window";
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   671
  Uint16 red[256];
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   672
  Uint16 green[256];
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   673
  Uint16 blue[256];
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   674
  int result;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   675
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   676
  /* Call against new test window */
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   677
  window = _createVideoSuiteTestWindow(title);
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   678
  if (window == NULL) return TEST_ABORTED;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   679
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   680
  /* Retrieve no channel */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   681
  result = SDL_GetWindowGammaRamp(window, NULL, NULL, NULL);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   682
  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(all NULL)");
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   683
  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   684
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   685
  /* Retrieve single channel */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   686
  result = SDL_GetWindowGammaRamp(window, red, NULL, NULL);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   687
  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r)");
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   688
  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   689
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   690
  result = SDL_GetWindowGammaRamp(window, NULL, green, NULL);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   691
  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(g)");
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   692
  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   693
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   694
  result = SDL_GetWindowGammaRamp(window, NULL, NULL, blue);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   695
  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(b)");
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   696
  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   697
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   698
  /* Retrieve two channels */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   699
  result = SDL_GetWindowGammaRamp(window, red, green, NULL);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   700
  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r, g)");
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   701
  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   702
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   703
  result = SDL_GetWindowGammaRamp(window, NULL, green, blue);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   704
  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(g,b)");
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   705
  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   706
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   707
  result = SDL_GetWindowGammaRamp(window, red, NULL, blue);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   708
  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r,b)");
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   709
  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   710
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   711
  /* Retrieve all channels */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   712
  result = SDL_GetWindowGammaRamp(window, red, green, blue);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   713
  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r,g,b)");
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   714
  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   715
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   716
  /* Clean up */
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   717
  _destroyVideoSuiteTestWindow(window);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   718
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   719
  return TEST_COMPLETED;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   720
}
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   721
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   722
/**
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   723
 * @brief Tests call to SDL_GetWindowGammaRamp with invalid input
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   724
 *
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   725
* @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGammaRamp
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   726
 */
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   727
int
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   728
video_getWindowGammaRampNegative(void *arg)
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   729
{
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   730
  Uint16 red[256];
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   731
  Uint16 green[256];
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   732
  Uint16 blue[256];
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   733
  int result;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   734
6984
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   735
  SDL_ClearError();
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   736
  SDLTest_AssertPass("Call to SDL_ClearError()");
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   737
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   738
  /* Call against invalid window */
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   739
  result = SDL_GetWindowGammaRamp(NULL, red, green, blue);
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   740
  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(window=NULL,r,g,b)");
9254
6c469ea796e4 Fix assert format strings/parameters in testautomation modules; improve output of SDL_CompareSurfaces to aid debugging; update platform_testSetErrorInvalidInput for SDL changes
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 9219
diff changeset
   741
  SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %i", result);
6984
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   742
  _checkInvalidWindowError();
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   743
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   744
  return TEST_COMPLETED;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   745
}
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   746
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   747
/* Helper for setting and checking the window grab state */
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   748
void
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   749
_setAndCheckWindowGrabState(SDL_Window* window, SDL_bool desiredState)
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   750
{
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   751
  SDL_bool currentState;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   752
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   753
  /* Set state */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   754
  SDL_SetWindowGrab(window, desiredState);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   755
  SDLTest_AssertPass("Call to SDL_SetWindowGrab(%s)", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   756
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   757
  /* Get and check state */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   758
  currentState = SDL_GetWindowGrab(window);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   759
  SDLTest_AssertPass("Call to SDL_GetWindowGrab()");
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   760
  SDLTest_AssertCheck(
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   761
      currentState == desiredState,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   762
      "Validate returned state; expected: %s, got: %s",
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   763
      (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE",
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   764
      (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   765
}
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   766
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   767
/**
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   768
 * @brief Tests call to SDL_GetWindowGrab and SDL_SetWindowGrab
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   769
 *
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   770
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGrab
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   771
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowGrab
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   772
 */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   773
int
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   774
video_getSetWindowGrab(void *arg)
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   775
{
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   776
  const char* title = "video_getSetWindowGrab Test Window";
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   777
  SDL_Window* window;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   778
  SDL_bool originalState, dummyState, currentState, desiredState;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   779
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   780
  /* Call against new test window */
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   781
  window = _createVideoSuiteTestWindow(title);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   782
  if (window == NULL) return TEST_ABORTED;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   783
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   784
  /* Get state */
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   785
  originalState = SDL_GetWindowGrab(window);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   786
  SDLTest_AssertPass("Call to SDL_GetWindowGrab()");
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   787
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   788
  /* F */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   789
  _setAndCheckWindowGrabState(window, SDL_FALSE);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   790
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   791
  /* F --> F */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   792
  _setAndCheckWindowGrabState(window, SDL_FALSE);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   793
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   794
  /* F --> T */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   795
  _setAndCheckWindowGrabState(window, SDL_TRUE);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   796
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   797
  /* T --> T */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   798
  _setAndCheckWindowGrabState(window, SDL_TRUE);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   799
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   800
  /* T --> F */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   801
  _setAndCheckWindowGrabState(window, SDL_FALSE);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   802
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   803
  /* Negative tests */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   804
  dummyState = SDL_GetWindowGrab(NULL);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   805
  SDLTest_AssertPass("Call to SDL_GetWindowGrab(window=NULL)");
6984
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   806
  _checkInvalidWindowError();
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   807
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   808
  SDL_SetWindowGrab(NULL, SDL_FALSE);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   809
  SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
6984
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   810
  _checkInvalidWindowError();
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   811
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   812
  SDL_SetWindowGrab(NULL, SDL_TRUE);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   813
  SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
6984
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   814
  _checkInvalidWindowError();
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   815
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   816
  /* State should still be F */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   817
  desiredState = SDL_FALSE;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   818
  currentState = SDL_GetWindowGrab(window);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   819
  SDLTest_AssertPass("Call to SDL_GetWindowGrab()");
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   820
  SDLTest_AssertCheck(
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   821
      currentState == desiredState,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   822
      "Validate returned state; expected: %s, got: %s",
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   823
      (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE",
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   824
      (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   825
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   826
  /* Restore state */
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   827
  _setAndCheckWindowGrabState(window, originalState);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   828
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   829
  /* Clean up */
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   830
  _destroyVideoSuiteTestWindow(window);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   831
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   832
  return TEST_COMPLETED;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   833
}
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   834
6984
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   835
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   836
/**
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   837
 * @brief Tests call to SDL_GetWindowID and SDL_GetWindowFromID
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   838
 *
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   839
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowID
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   840
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowFromID
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   841
 */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   842
int
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   843
video_getWindowId(void *arg)
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   844
{
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   845
  const char* title = "video_getWindowId Test Window";
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   846
  SDL_Window* window;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   847
  SDL_Window* result;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   848
  Uint32 id, randomId;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   849
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   850
  /* Call against new test window */
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   851
  window = _createVideoSuiteTestWindow(title);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   852
  if (window == NULL) return TEST_ABORTED;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   853
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   854
  /* Get ID */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   855
  id = SDL_GetWindowID(window);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   856
  SDLTest_AssertPass("Call to SDL_GetWindowID()");
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   857
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   858
  /* Get window from ID */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   859
  result = SDL_GetWindowFromID(id);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   860
  SDLTest_AssertPass("Call to SDL_GetWindowID(%d)", id);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   861
  SDLTest_AssertCheck(result == window, "Verify result matches window pointer");
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   862
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   863
  /* Get window from random large ID, no result check */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   864
  randomId = SDLTest_RandomIntegerInRange(UINT8_MAX,UINT16_MAX);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   865
  result = SDL_GetWindowFromID(randomId);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   866
  SDLTest_AssertPass("Call to SDL_GetWindowID(%d/random_large)", randomId);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   867
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   868
  /* Get window from 0 and Uint32 max ID, no result check */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   869
  result = SDL_GetWindowFromID(0);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   870
  SDLTest_AssertPass("Call to SDL_GetWindowID(0)");
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   871
  result = SDL_GetWindowFromID(UINT32_MAX);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   872
  SDLTest_AssertPass("Call to SDL_GetWindowID(UINT32_MAX)");
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   873
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   874
  /* Clean up */
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   875
  _destroyVideoSuiteTestWindow(window);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   876
7677
871d43c6968a OCD fixes: Adds a space before */
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7615
diff changeset
   877
  /* Get window from ID for closed window */
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   878
  result = SDL_GetWindowFromID(id);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   879
  SDLTest_AssertPass("Call to SDL_GetWindowID(%d/closed_window)", id);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   880
  SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   881
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   882
  /* Negative test */
6984
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   883
  SDL_ClearError();
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   884
  SDLTest_AssertPass("Call to SDL_ClearError()");
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   885
  id = SDL_GetWindowID(NULL);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   886
  SDLTest_AssertPass("Call to SDL_GetWindowID(window=NULL)");
6984
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   887
  _checkInvalidWindowError();
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   888
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   889
  return TEST_COMPLETED;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   890
}
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   891
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   892
/**
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   893
 * @brief Tests call to SDL_GetWindowPixelFormat
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   894
 *
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   895
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowPixelFormat
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   896
 */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   897
int
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   898
video_getWindowPixelFormat(void *arg)
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   899
{
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   900
  const char* title = "video_getWindowPixelFormat Test Window";
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   901
  SDL_Window* window;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   902
  Uint32 format;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   903
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   904
  /* Call against new test window */
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   905
  window = _createVideoSuiteTestWindow(title);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   906
  if (window == NULL) return TEST_ABORTED;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   907
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   908
  /* Get format */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   909
  format = SDL_GetWindowPixelFormat(window);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   910
  SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat()");
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   911
  SDLTest_AssertCheck(format != SDL_PIXELFORMAT_UNKNOWN, "Verify that returned format is valid; expected: != %d, got: %d", SDL_PIXELFORMAT_UNKNOWN, format);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   912
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   913
  /* Clean up */
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   914
  _destroyVideoSuiteTestWindow(window);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   915
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   916
  /* Negative test */
6984
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   917
  SDL_ClearError();
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   918
  SDLTest_AssertPass("Call to SDL_ClearError()");
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   919
  format = SDL_GetWindowPixelFormat(NULL);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   920
  SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat(window=NULL)");
6984
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   921
  _checkInvalidWindowError();
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   922
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   923
  return TEST_COMPLETED;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   924
}
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   925
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   926
/**
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   927
 * @brief Tests call to SDL_GetWindowPosition and SDL_SetWindowPosition
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   928
 *
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   929
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowPosition
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   930
 * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowPosition
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   931
 */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   932
int
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   933
video_getSetWindowPosition(void *arg)
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   934
{
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   935
  const char* title = "video_getSetWindowPosition Test Window";
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   936
  SDL_Window* window;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   937
  int xVariation, yVariation;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   938
  int referenceX, referenceY;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   939
  int currentX, currentY;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   940
  int desiredX, desiredY;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   941
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   942
  /* Call against new test window */
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   943
  window = _createVideoSuiteTestWindow(title);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   944
  if (window == NULL) return TEST_ABORTED;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   945
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   946
  for (xVariation = 0; xVariation < 4; xVariation++) {
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   947
   for (yVariation = 0; yVariation < 4; yVariation++) {
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   948
    switch(xVariation) {
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   949
     case 0:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   950
      /* Zero X Position */
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   951
      desiredX = 0;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   952
      break;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   953
     case 1:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   954
      /* Random X position inside screen */
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   955
      desiredX = SDLTest_RandomIntegerInRange(1, 100);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   956
      break;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   957
     case 2:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   958
      /* Random X position outside screen (positive) */
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   959
      desiredX = SDLTest_RandomIntegerInRange(10000, 11000);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   960
      break;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   961
     case 3:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   962
      /* Random X position outside screen (negative) */
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   963
      desiredX = SDLTest_RandomIntegerInRange(-1000, -100);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   964
      break;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   965
    }
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   966
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   967
    switch(yVariation) {
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   968
     case 0:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   969
      /* Zero X Position */
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   970
      desiredY = 0;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   971
      break;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   972
     case 1:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   973
      /* Random X position inside screen */
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   974
      desiredY = SDLTest_RandomIntegerInRange(1, 100);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   975
      break;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   976
     case 2:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   977
      /* Random X position outside screen (positive) */
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   978
      desiredY = SDLTest_RandomIntegerInRange(10000, 11000);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   979
      break;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   980
     case 3:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7134
diff changeset
   981
      /* Random Y position outside screen (negative) */
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   982
      desiredY = SDLTest_RandomIntegerInRange(-1000, -100);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936