test/testautomation_video.c
author Ryan C. Gordon <icculus@icculus.org>
Mon, 15 Apr 2013 22:49:23 -0400
changeset 7065 e171653481d4
parent 7062 c0a739679bbd
child 7066 d61902a0bc21
permissions -rw-r--r--
Fixed a compiler warning on Visual Studio.
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>
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     6
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
     7
/* 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
     8
#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
     9
#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
    10
#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
    11
#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
    12
#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
    13
#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
    14
#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
    15
#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
    16
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    17
#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
    18
#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
    19
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    20
/* Private helpers */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    21
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    22
/* 
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    23
 * Create a test window
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    24
 */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    25
SDL_Window *_createVideoSuiteTestWindow(const char *title)
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    26
{
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    27
  SDL_Window* window;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    28
  int x, y, w, h;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    29
  SDL_WindowFlags flags;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    30
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    31
  /* Standard window */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    32
  x = SDLTest_RandomIntegerInRange(1, 100);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    33
  y = SDLTest_RandomIntegerInRange(1, 100);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    34
  w = SDLTest_RandomIntegerInRange(320, 1024);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    35
  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
    36
  flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS;
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    37
  
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    38
  window = SDL_CreateWindow(title, x, y, w, h, flags);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    39
  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
    40
  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
    41
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    42
  return window;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    43
}
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
 * Destroy test window  
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    47
 */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    48
void _destroyVideoSuiteTestWindow(SDL_Window *window)
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    49
{
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    50
  if (window != NULL) {  
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    51
     SDL_DestroyWindow(window);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    52
     window = NULL;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    53
     SDLTest_AssertPass("Call to SDL_DestroyWindow");
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    54
  }
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
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    57
/* 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
    58
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
 * @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
    61
 */
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    62
int
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    63
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
    64
{
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    65
	SDL_bool initialResult;
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    66
	SDL_bool result;
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    67
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    68
	/* Get current state and proceed according to current state */
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    69
	initialResult = SDL_IsScreenSaverEnabled();
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    70
	SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    71
	if (initialResult == SDL_TRUE) {
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    72
	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    73
	  /* Currently enabled: disable first, then enable again */
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    74
	  
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    75
	  /* Disable screensaver and check */	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    76
	  SDL_DisableScreenSaver();
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    77
	  SDLTest_AssertPass("Call to SDL_DisableScreenSaver()");	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    78
	  result = SDL_IsScreenSaverEnabled();
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    79
	  SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    80
	  SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    81
	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    82
	  /* Enable screensaver and check */	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    83
	  SDL_EnableScreenSaver();
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    84
	  SDLTest_AssertPass("Call to SDL_EnableScreenSaver()");
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    85
	  result = SDL_IsScreenSaverEnabled();
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    86
	  SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    87
	  SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    88
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    89
	} else {
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    90
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    91
	  /* Currently disabled: enable first, then disable again */
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    92
	  
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    93
	  /* Enable screensaver and check */	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    94
	  SDL_EnableScreenSaver();
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    95
	  SDLTest_AssertPass("Call to SDL_EnableScreenSaver()");
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    96
	  result = SDL_IsScreenSaverEnabled();
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    97
	  SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    98
	  SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    99
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   100
	  /* Disable screensaver and check */	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   101
	  SDL_DisableScreenSaver();
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   102
	  SDLTest_AssertPass("Call to SDL_DisableScreenSaver()");	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   103
	  result = SDL_IsScreenSaverEnabled();
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   104
	  SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   105
	  SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   106
	}	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   107
	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   108
	return TEST_COMPLETED;
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   109
}
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   110
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   111
/**
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   112
 * @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
   113
 */
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   114
int
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   115
video_createWindowVariousPositions(void *arg)
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   116
{
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   117
  SDL_Window* window;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   118
  const char* title = "video_createWindowVariousPositions Test Window";
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   119
  int x, y, w, h;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   120
  int xVariation, yVariation;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   121
  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   122
  for (xVariation = 0; xVariation < 6; xVariation++) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   123
   for (yVariation = 0; yVariation < 6; yVariation++) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   124
    switch(xVariation) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   125
     case 0:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   126
      /* Zero X Position */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   127
      x = 0;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   128
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   129
     case 1:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   130
      /* Random X position inside screen */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   131
      x = SDLTest_RandomIntegerInRange(1, 100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   132
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   133
     case 2:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   134
      /* Random X position outside screen (positive) */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   135
      x = SDLTest_RandomIntegerInRange(10000, 11000);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   136
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   137
     case 3:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   138
      /* Random X position outside screen (negative) */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   139
      x = SDLTest_RandomIntegerInRange(-1000, -100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   140
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   141
     case 4:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   142
      /* Centered X position */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   143
      x = SDL_WINDOWPOS_CENTERED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   144
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   145
     case 5:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   146
      /* Undefined X position */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   147
      x = SDL_WINDOWPOS_UNDEFINED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   148
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   149
    }
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
    switch(yVariation) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   152
     case 0:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   153
      /* Zero X Position */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   154
      y = 0;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   155
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   156
     case 1:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   157
      /* Random X position inside screen */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   158
      y = SDLTest_RandomIntegerInRange(1, 100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   159
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   160
     case 2:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   161
      /* Random X position outside screen (positive) */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   162
      y = SDLTest_RandomIntegerInRange(10000, 11000);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   163
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   164
     case 3:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   165
      /* Random Y position outside screen (negative) */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   166
      y = SDLTest_RandomIntegerInRange(-1000, -100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   167
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   168
     case 4:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   169
      /* Centered Y position */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   170
      y = SDL_WINDOWPOS_CENTERED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   171
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   172
     case 5:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   173
      /* Undefined Y position */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   174
      y = SDL_WINDOWPOS_UNDEFINED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   175
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   176
    }
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   177
     
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   178
    w = SDLTest_RandomIntegerInRange(32, 96);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   179
    h = SDLTest_RandomIntegerInRange(32, 96);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   180
    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
   181
    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
   182
    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
   183
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   184
    /* Clean up */    
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   185
    _destroyVideoSuiteTestWindow(window);
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   186
   }
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   187
  } 
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   188
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   189
  return TEST_COMPLETED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   190
}
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
 * @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
   194
 */
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   195
int
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   196
video_createWindowVariousSizes(void *arg)
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   197
{
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   198
  SDL_Window* window;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   199
  const char* title = "video_createWindowVariousSizes Test Window";
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   200
  int x, y, w, h;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   201
  int wVariation, hVariation;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   202
  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   203
  x = SDLTest_RandomIntegerInRange(1, 100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   204
  y = SDLTest_RandomIntegerInRange(1, 100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   205
  for (wVariation = 0; wVariation < 3; wVariation++) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   206
   for (hVariation = 0; hVariation < 3; hVariation++) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   207
    switch(wVariation) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   208
     case 0:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   209
      /* Width of 1 */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   210
      w = 1;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   211
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   212
     case 1:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   213
      /* Random "normal" width */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   214
      w = SDLTest_RandomIntegerInRange(320, 1920);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   215
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   216
     case 2:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   217
      /* Random "large" width */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   218
      w = SDLTest_RandomIntegerInRange(2048, 4095);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   219
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   220
    }
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
    switch(hVariation) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   223
     case 0:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   224
      /* Height of 1 */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   225
      h = 1;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   226
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   227
     case 1:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   228
      /* Random "normal" height */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   229
      h = SDLTest_RandomIntegerInRange(320, 1080);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   230
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   231
     case 2:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   232
      /* Random "large" height */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   233
      h = SDLTest_RandomIntegerInRange(2048, 4095);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   234
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   235
     }
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   236
     
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   237
    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
   238
    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
   239
    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
   240
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   241
    /* Clean up */    
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   242
    _destroyVideoSuiteTestWindow(window);
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   243
   }
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   244
  }  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   245
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   246
  return TEST_COMPLETED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   247
}
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
 * @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
   251
 */
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   252
int
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   253
video_createWindowVariousFlags(void *arg)
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   254
{
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   255
  SDL_Window* window;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   256
  const char* title = "video_createWindowVariousFlags Test Window";
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   257
  int x, y, w, h;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   258
  int fVariation;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   259
  SDL_WindowFlags flags;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   260
  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   261
  /* Standard window */
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   262
  x = SDLTest_RandomIntegerInRange(1, 100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   263
  y = SDLTest_RandomIntegerInRange(1, 100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   264
  w = SDLTest_RandomIntegerInRange(320, 1024);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   265
  h = SDLTest_RandomIntegerInRange(320, 768);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   266
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   267
  for (fVariation = 0; fVariation < 13; fVariation++) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   268
    switch(fVariation) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   269
     case 0:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   270
      flags = SDL_WINDOW_FULLSCREEN;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   271
      /* Skip - blanks screen; comment out next line to run test */
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   272
      continue;   
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   273
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   274
     case 1:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   275
      flags = SDL_WINDOW_FULLSCREEN_DESKTOP;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   276
      /* Skip - blanks screen; comment out next line to run test */
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   277
      continue;  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   278
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   279
     case 2:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   280
      flags = SDL_WINDOW_OPENGL;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   281
      break;  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   282
     case 3:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   283
      flags = SDL_WINDOW_SHOWN;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   284
      break;   
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   285
     case 4:    
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   286
      flags = SDL_WINDOW_HIDDEN;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   287
      break;     
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   288
     case 5:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   289
      flags = SDL_WINDOW_BORDERLESS;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   290
      break;       
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   291
     case 6:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   292
      flags = SDL_WINDOW_RESIZABLE;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   293
      break;         
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   294
     case 7:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   295
      flags = SDL_WINDOW_MINIMIZED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   296
      break;           
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   297
     case 8:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   298
      flags = SDL_WINDOW_MAXIMIZED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   299
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   300
     case 9: 
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   301
      flags = SDL_WINDOW_INPUT_GRABBED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   302
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   303
     case 10:              
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   304
      flags = SDL_WINDOW_INPUT_FOCUS;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   305
      break;                 
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   306
     case 11:                      
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   307
      flags = SDL_WINDOW_MOUSE_FOCUS;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   308
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   309
     case 12: 
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   310
      flags = SDL_WINDOW_FOREIGN;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   311
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   312
    }
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   313
       
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   314
    window = SDL_CreateWindow(title, x, y, w, h, flags);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   315
    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
   316
    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
   317
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   318
    /* Clean up */    
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   319
    _destroyVideoSuiteTestWindow(window);  
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   320
  }
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
  return TEST_COMPLETED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   323
}
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   324
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   325
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   326
/**
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   327
 * @brief Tests the functionality of the SDL_GetWindowFlags function
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   328
 */
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   329
int
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   330
video_getWindowFlags(void *arg)
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   331
{
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   332
  SDL_Window* window;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   333
  const char* title = "video_getWindowFlags Test Window";
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   334
  SDL_WindowFlags flags;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   335
  Uint32 actualFlags;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   336
  
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   337
  /* Reliable flag set always set in test window */
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   338
  flags = SDL_WINDOW_SHOWN;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   339
  
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   340
  /* Call against new test window */ 
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   341
  window = _createVideoSuiteTestWindow(title);
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   342
  if (window != NULL) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   343
      actualFlags = SDL_GetWindowFlags(window);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   344
      SDLTest_AssertPass("Call to SDL_GetWindowFlags");
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   345
      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
   346
  }
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
  /* Clean up */    
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   349
  _destroyVideoSuiteTestWindow(window);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   350
  
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   351
  return TEST_COMPLETED;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   352
}
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
 * @brief Tests the functionality of the SDL_GetNumDisplayModes function
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   356
 */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   357
int
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   358
video_getNumDisplayModes(void *arg)
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   359
{
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   360
  int result;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   361
  int displayNum;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   362
  int i;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   363
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   364
  /* Get number of displays */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   365
  displayNum = SDL_GetNumVideoDisplays();
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   366
  SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays");
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   367
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   368
  /* Make call for each display */  
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   369
  for (i=0; i<displayNum; i++) {
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   370
    result = SDL_GetNumDisplayModes(i);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   371
    SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d)", i);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   372
    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
   373
  }
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
  return TEST_COMPLETED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   376
}
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   377
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   378
/**
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   379
 * @brief Tests negative call to SDL_GetNumDisplayModes function
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   380
 */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   381
int
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   382
video_getNumDisplayModesNegative(void *arg)
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   383
{
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   384
  int result;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   385
  int displayNum;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   386
  int displayIndex;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   387
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   388
  /* Get number of displays */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   389
  displayNum = SDL_GetNumVideoDisplays();
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   390
  SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays");
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   391
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   392
  /* Invalid boundary values */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   393
  displayIndex =  SDLTest_RandomSint32BoundaryValue(0, displayNum, SDL_FALSE);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   394
  result = SDL_GetNumDisplayModes(displayIndex);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   395
  SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/boundary)", displayIndex);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   396
  SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result);  
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   397
  
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   398
  /* Large (out-of-bounds) display index */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   399
  displayIndex = SDLTest_RandomIntegerInRange(-2000, -1000);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   400
  result = SDL_GetNumDisplayModes(displayIndex);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   401
  SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/large negative)", displayIndex);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   402
  SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result);  
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   403
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   404
  displayIndex = SDLTest_RandomIntegerInRange(1000, 2000);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   405
  result = SDL_GetNumDisplayModes(displayIndex);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   406
  SDLTest_AssertPass("Call to SDL_GetNumDisplayModes(%d=out-of-bounds/large positive)", displayIndex);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   407
  SDLTest_AssertCheck(result < 0, "Validate returned value from function; expected: <0; got: %d", result);  
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   408
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   409
  return TEST_COMPLETED;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   410
}
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
 * @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
   414
 */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   415
int
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   416
video_getClosestDisplayModeCurrentResolution(void *arg)
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   417
{
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   418
  int result;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   419
  SDL_DisplayMode current; 
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   420
  SDL_DisplayMode target; 
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   421
  SDL_DisplayMode closest;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   422
  SDL_DisplayMode* dResult;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   423
  int displayNum;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   424
  int i;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   425
  int variation;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   426
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   427
  /* Get number of displays */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   428
  displayNum = SDL_GetNumVideoDisplays();
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   429
  SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays");
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   430
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   431
  /* Make calls for each display */  
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   432
  for (i=0; i<displayNum; i++) {
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   433
    SDLTest_Log("Testing against display: %d", i);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   434
  
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   435
    /* 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
   436
    result = SDL_GetDisplayMode(i, 0, &current);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   437
    SDLTest_AssertPass("Call to SDL_GetDisplayMode");
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   438
    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
   439
    if (result != 0) {
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   440
      return TEST_ABORTED;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   441
    }
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   442
       
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   443
    /* Set the desired resolution equals to current resolution */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   444
    target.w = current.w;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   445
    target.h = current.h;    
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   446
    for (variation = 0; variation < 8; variation ++) {
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   447
      /* Vary constraints on other query parameters */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   448
      target.format = (variation & 1) ? current.format : 0;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   449
      target.refresh_rate = (variation & 2) ? current.refresh_rate : 0;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   450
      target.driverdata = (variation & 4) ? current.driverdata : 0;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   451
          
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   452
      /* Make call */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   453
      dResult = SDL_GetClosestDisplayMode(i, &target, &closest);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   454
      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
   455
      SDLTest_AssertCheck(dResult != NULL, "Verify returned value is not NULL");
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   456
    
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   457
      /* Check that one gets the current resolution back again */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   458
      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
   459
      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
   460
      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
   461
      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
   462
    }
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
  return TEST_COMPLETED;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   466
}
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
 * @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
   470
 */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   471
int
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   472
video_getClosestDisplayModeRandomResolution(void *arg)
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   473
{
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   474
  SDL_DisplayMode target; 
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   475
  SDL_DisplayMode closest;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   476
  SDL_DisplayMode* dResult;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   477
  int displayNum;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   478
  int i;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   479
  int variation;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   480
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   481
  /* Get number of displays */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   482
  displayNum = SDL_GetNumVideoDisplays();
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   483
  SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays");
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   484
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   485
  /* Make calls for each display */  
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   486
  for (i=0; i<displayNum; i++) {
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   487
    SDLTest_Log("Testing against display: %d", i);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   488
         
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   489
    for (variation = 0; variation < 16; variation ++) {
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   490
    
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   491
      /* Set random constraints */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   492
      target.w = (variation & 1) ? SDLTest_RandomIntegerInRange(1, 4096) : 0;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   493
      target.h = (variation & 2) ? SDLTest_RandomIntegerInRange(1, 4096) : 0;    
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   494
      target.format = (variation & 4) ? SDLTest_RandomIntegerInRange(1, 10) : 0;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   495
      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
   496
      target.driverdata = 0;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   497
          
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   498
      /* 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
   499
      dResult = SDL_GetClosestDisplayMode(i, &target, &closest);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   500
      SDLTest_AssertPass("Call to SDL_GetClosestDisplayMode(target=random/variation%d)", variation);      
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   501
    }
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
  return TEST_COMPLETED;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   505
}
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
 * @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
   509
 *
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   510
* @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
   511
 */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   512
int
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   513
video_getWindowBrightness(void *arg)
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   514
{
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   515
  SDL_Window* window;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   516
  const char* title = "video_getWindowBrightness Test Window";
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   517
  float result;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   518
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   519
  /* Call against new test window */ 
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   520
  window = _createVideoSuiteTestWindow(title);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   521
  if (window != NULL) {
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   522
      result = SDL_GetWindowBrightness(window);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   523
      SDLTest_AssertPass("Call to SDL_GetWindowBrightness");
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   524
      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
   525
  }
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
  /* Clean up */    
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   528
  _destroyVideoSuiteTestWindow(window);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   529
  
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   530
  return TEST_COMPLETED;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   531
}
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   532
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   533
/**
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   534
 * @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
   535
 *
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   536
* @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
   537
 */
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   538
int
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   539
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
   540
{
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   541
  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
   542
  char *lastError;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   543
  const char* title = "video_getWindowBrightnessNegative Test Window";
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
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   546
  /* 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
   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
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   581
  /* Call against new test window */ 
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);
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   585
      SDLTest_AssertPass("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
   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
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   592
  /* Clean up */    
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);
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   594
  
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();
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   613
      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
   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
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   632
  /* Call against new test window */ 
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) {
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   642
      	SDLTest_AssertCheck(SDL_strcmp(lastError, expectedError) == 0,
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
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   649
  /* Clean up */    
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);
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   651
  
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
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   676
  /* Call against new test window */ 
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;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   679
  
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
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   716
  /* Clean up */    
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);
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   718
  
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
  const char* title = "video_getWindowGammaRampNegative Test Window";
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   731
  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
   732
  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
   733
  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
   734
  int result;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   735
6984
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   736
  SDL_ClearError();
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   737
  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
   738
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   739
  /* 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
   740
  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
   741
  SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(window=NULL,r,g,b)");
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   742
  SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %f", result);
6984
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   743
  _checkInvalidWindowError();
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   744
  
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   745
  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
   746
}
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   747
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
   748
/* Helper for setting and checking the window grab 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
   749
void 
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
_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
   751
{
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   752
  SDL_bool currentState;
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
  
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
  /* 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
   755
  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
   756
  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
   757
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
  /* 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
   759
  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
   760
  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
   761
  SDLTest_AssertCheck(
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   762
      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
   763
      "Validate returned state; expected: %s, got: %s", 
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
      (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
   765
      (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
   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
/**
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
 * @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
   770
 *
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_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
   772
 * @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
   773
 */
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
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
   775
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
   776
{
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
  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
   778
  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
   779
  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
   780
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
  /* Call against new 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
   782
  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
   783
  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
   784
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
  /* Get 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
   786
  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
   787
  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
   788
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
  /* 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
   790
  _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
   791
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
  /* 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
   793
  _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
   794
  
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
  /* 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
   796
  _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
   797
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
  /* 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
   799
  _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
   800
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
  /* 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
   802
  _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
   803
  
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
  /* 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
   805
  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
   806
  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
   807
  _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
   808
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
  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
   810
  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
   811
  _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
   812
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
  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
   814
  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
   815
  _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
   816
  
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
  /* 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
   818
  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
   819
  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
   820
  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
   821
  SDLTest_AssertCheck(
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   822
      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
   823
      "Validate returned state; expected: %s, got: %s", 
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
      (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
   825
      (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
   826
    
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
  /* Restore 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
   828
  _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
   829
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
  /* Clean up */    
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
  _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
   832
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
  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
   834
}
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   835
6984
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   836
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
   837
/**
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
 * @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
   839
 *
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_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
   841
 * @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
   842
 */
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
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
   844
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
   845
{
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
  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
   847
  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
   848
  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
   849
  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
   850
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
  /* Call against new 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
   852
  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
   853
  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
   854
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
  /* 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
   856
  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
   857
  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
   858
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
  /* 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
   860
  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
   861
  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
   862
  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
   863
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
  /* 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
   865
  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
   866
  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
   867
  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
   868
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
  /* 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
   870
  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
   871
  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
   872
  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
   873
  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
   874
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
  /* Clean up */    
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   876
  _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
   877
    
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
  /* Get window from ID for closed 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
   879
  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
   880
  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
   881
  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
   882
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   883
  /* Negative test */
6984
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   884
  SDL_ClearError();
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   885
  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
   886
  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
   887
  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
   888
  _checkInvalidWindowError();
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   889
  
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
   890
  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
   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
/**
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
 * @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
   895
 *
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
 * @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
   897
 */
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
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
   899
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
   900
{
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
  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
   902
  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
   903
  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
   904
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
  /* Call against new 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
   906
  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
   907
  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
   908
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
  /* 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
   910
  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
   911
  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
   912
  SDLTest_AssertCheck(format != SDL_PIXELFORMAT_UNKNOWN, "Verify that returned format is valid; expected: != %d, got: %d", SDL_PIXELFORMAT_UNKNOWN, 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
   913
   
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
  /* Clean up */    
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   915
  _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
   916
    
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   917
  /* Negative test */
6984
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   918
  SDL_ClearError();
ae9c4b12f3e2 Add parameter checking to SetWindowSize functions; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6956
diff changeset
   919
  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
   920
  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
   921
  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
   922
  _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
   923
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
  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
   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
/**
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
 * @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
   929
 *
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_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
   931
 * @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
   932
 */
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
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
   934
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
   935
{
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
  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
   937
  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
   938
  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
   939
  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
   940
  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
   941
  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
   942
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
  /* Call against new 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
   944
  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
   945
  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
   946
  
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 (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
   948
   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
   949
    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
   950
     case 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
   951
      /* Zero X Position */  
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
      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
   953
      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
   954
     case 1:
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
      /* Random X position inside screen */  
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
      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
   957
      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
   958
     case 2:
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
      /* Random X position outside screen (positive) */  
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
      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
   961
      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
   962
     case 3:
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
      /* Random X position outside screen (negative) */  
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
      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
   965
      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
   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
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
    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
   969
     case 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
   970
      /* Zero X Position */  
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
      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
   972
      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
   973
     case 1:
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
      /* Random X position inside screen */  
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
      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
   976
      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
   977
     case 2:
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
      /* Random X position outside screen (positive) */  
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
      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
   980
      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
   981
     case 3:
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
      /* Random Y position outside screen (negative) */  
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   983
      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
diff changeset
   984
      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
   985
    }
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   986
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   987
    /* Set position */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   988
    SDL_SetWindowPosition(window, 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
   989
    SDLTest_AssertPass("Call to SDL_SetWindowPosition(...,%d,%d)", 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
   990
   
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   991
    /* Get position */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   992
    currentX = desiredX + 1;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   993
    currentY = desiredY + 1;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   994
    SDL_GetWindowPosition(window, &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
   995
    SDLTest_AssertPass("Call to 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
   996
    SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   997
    SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, 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
   998
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: