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