test/testautomation_video.c
author Andreas Schiffler <aschiffler@ferzkopp.net>
Sun, 03 Mar 2013 17:22:51 -0800
changeset 6956 afdc35fa58e9
parent 6936 76d9c31e823d
child 6984 ae9c4b12f3e2
permissions -rw-r--r--
Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video 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>
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     6
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
     7
/* Visual Studio 2008 doesn't have stdint.h */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
     8
#if defined(_MSC_VER) && _MSC_VER <= 1500
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
     9
#define UINT8_MAX   ~(Uint8)0
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
    10
#define UINT16_MAX  ~(Uint16)0
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
    11
#define UINT32_MAX  ~(Uint32)0
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
    12
#define UINT64_MAX  ~(Uint64)0
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
    13
#else
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
    14
#include <stdint.h>
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
    15
#endif
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
    16
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    17
#include "SDL.h"
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    18
#include "SDL_test.h"
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    19
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    20
/* Private helpers */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    21
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    22
/* 
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    23
 * Create a test window
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    24
 */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    25
SDL_Window *_createVideoSuiteTestWindow(const char *title)
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    26
{
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    27
  SDL_Window* window;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    28
  int x, y, w, h;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    29
  SDL_WindowFlags flags;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    30
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    31
  /* Standard window */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    32
  x = SDLTest_RandomIntegerInRange(1, 100);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    33
  y = SDLTest_RandomIntegerInRange(1, 100);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    34
  w = SDLTest_RandomIntegerInRange(320, 1024);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    35
  h = SDLTest_RandomIntegerInRange(320, 768);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    36
  flags = SDL_WINDOW_SHOWN;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    37
  
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    38
  window = SDL_CreateWindow(title, x, y, w, h, flags);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    39
  SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    40
  SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    41
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    42
  return window;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    43
}
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    44
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    45
/*
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    46
 * Destroy test window  
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    47
 */
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    48
void _destroyVideoSuiteTestWindow(SDL_Window *window)
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    49
{
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    50
  if (window != NULL) {  
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    51
     SDL_DestroyWindow(window);
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    52
     window = NULL;
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    53
     SDLTest_AssertPass("Call to SDL_DestroyWindow");
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    54
  }
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    55
}
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
    56
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    57
/* Test case functions */
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    58
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    59
/**
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    60
 * @brief Enable and disable screensaver while checking state
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    61
 */
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    62
int
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    63
video_enableDisableScreensaver(void *arg)
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    64
{
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    65
	SDL_bool initialResult;
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    66
	SDL_bool result;
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    67
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    68
	/* Get current state and proceed according to current state */
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    69
	initialResult = SDL_IsScreenSaverEnabled();
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    70
	SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    71
	if (initialResult == SDL_TRUE) {
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    72
	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    73
	  /* Currently enabled: disable first, then enable again */
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    74
	  
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    75
	  /* Disable screensaver and check */	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    76
	  SDL_DisableScreenSaver();
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    77
	  SDLTest_AssertPass("Call to SDL_DisableScreenSaver()");	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    78
	  result = SDL_IsScreenSaverEnabled();
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    79
	  SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    80
	  SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    81
	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    82
	  /* Enable screensaver and check */	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    83
	  SDL_EnableScreenSaver();
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    84
	  SDLTest_AssertPass("Call to SDL_EnableScreenSaver()");
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    85
	  result = SDL_IsScreenSaverEnabled();
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    86
	  SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    87
	  SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    88
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    89
	} else {
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    90
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    91
	  /* Currently disabled: enable first, then disable again */
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    92
	  
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    93
	  /* Enable screensaver and check */	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    94
	  SDL_EnableScreenSaver();
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    95
	  SDLTest_AssertPass("Call to SDL_EnableScreenSaver()");
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    96
	  result = SDL_IsScreenSaverEnabled();
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    97
	  SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    98
	  SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    99
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   100
	  /* Disable screensaver and check */	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   101
	  SDL_DisableScreenSaver();
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   102
	  SDLTest_AssertPass("Call to SDL_DisableScreenSaver()");	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   103
	  result = SDL_IsScreenSaverEnabled();
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   104
	  SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   105
	  SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   106
	}	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   107
	
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   108
	return TEST_COMPLETED;
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   109
}
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   110
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   111
/**
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   112
 * @brief Tests the functionality of the SDL_CreateWindow function using different positions
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   113
 */
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   114
int
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   115
video_createWindowVariousPositions(void *arg)
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   116
{
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   117
  SDL_Window* window;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   118
  const char* title = "video_createWindowVariousPositions Test Window";
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   119
  int x, y, w, h;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   120
  int xVariation, yVariation;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   121
  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   122
  for (xVariation = 0; xVariation < 6; xVariation++) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   123
   for (yVariation = 0; yVariation < 6; yVariation++) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   124
    switch(xVariation) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   125
     case 0:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   126
      /* Zero X Position */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   127
      x = 0;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   128
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   129
     case 1:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   130
      /* Random X position inside screen */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   131
      x = SDLTest_RandomIntegerInRange(1, 100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   132
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   133
     case 2:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   134
      /* Random X position outside screen (positive) */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   135
      x = SDLTest_RandomIntegerInRange(10000, 11000);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   136
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   137
     case 3:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   138
      /* Random X position outside screen (negative) */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   139
      x = SDLTest_RandomIntegerInRange(-1000, -100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   140
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   141
     case 4:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   142
      /* Centered X position */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   143
      x = SDL_WINDOWPOS_CENTERED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   144
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   145
     case 5:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   146
      /* Undefined X position */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   147
      x = SDL_WINDOWPOS_UNDEFINED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   148
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   149
    }
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   150
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   151
    switch(yVariation) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   152
     case 0:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   153
      /* Zero X Position */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   154
      y = 0;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   155
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   156
     case 1:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   157
      /* Random X position inside screen */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   158
      y = SDLTest_RandomIntegerInRange(1, 100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   159
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   160
     case 2:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   161
      /* Random X position outside screen (positive) */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   162
      y = SDLTest_RandomIntegerInRange(10000, 11000);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   163
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   164
     case 3:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   165
      /* Random Y position outside screen (negative) */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   166
      y = SDLTest_RandomIntegerInRange(-1000, -100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   167
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   168
     case 4:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   169
      /* Centered Y position */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   170
      y = SDL_WINDOWPOS_CENTERED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   171
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   172
     case 5:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   173
      /* Undefined Y position */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   174
      y = SDL_WINDOWPOS_UNDEFINED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   175
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   176
    }
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   177
     
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   178
    w = SDLTest_RandomIntegerInRange(32, 96);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   179
    h = SDLTest_RandomIntegerInRange(32, 96);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   180
    window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   181
    SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   182
    SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   183
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   184
    /* Clean up */    
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   185
    _destroyVideoSuiteTestWindow(window);
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   186
   }
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   187
  } 
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   188
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   189
  return TEST_COMPLETED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   190
}
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   191
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   192
/**
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   193
 * @brief Tests the functionality of the SDL_CreateWindow function using different sizes
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   194
 */
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   195
int
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   196
video_createWindowVariousSizes(void *arg)
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   197
{
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   198
  SDL_Window* window;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   199
  const char* title = "video_createWindowVariousSizes Test Window";
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   200
  int x, y, w, h;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   201
  int wVariation, hVariation;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   202
  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   203
  x = SDLTest_RandomIntegerInRange(1, 100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   204
  y = SDLTest_RandomIntegerInRange(1, 100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   205
  for (wVariation = 0; wVariation < 3; wVariation++) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   206
   for (hVariation = 0; hVariation < 3; hVariation++) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   207
    switch(wVariation) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   208
     case 0:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   209
      /* Width of 1 */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   210
      w = 1;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   211
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   212
     case 1:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   213
      /* Random "normal" width */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   214
      w = SDLTest_RandomIntegerInRange(320, 1920);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   215
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   216
     case 2:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   217
      /* Random "large" width */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   218
      w = SDLTest_RandomIntegerInRange(2048, 4095);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   219
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   220
    }
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   221
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   222
    switch(hVariation) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   223
     case 0:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   224
      /* Height of 1 */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   225
      h = 1;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   226
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   227
     case 1:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   228
      /* Random "normal" height */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   229
      h = SDLTest_RandomIntegerInRange(320, 1080);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   230
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   231
     case 2:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   232
      /* Random "large" height */  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   233
      h = SDLTest_RandomIntegerInRange(2048, 4095);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   234
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   235
     }
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   236
     
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   237
    window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   238
    SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   239
    SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   240
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   241
    /* Clean up */    
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   242
    _destroyVideoSuiteTestWindow(window);
6891
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   243
   }
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   244
  }  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   245
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   246
  return TEST_COMPLETED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   247
}
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   248
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   249
/**
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   250
 * @brief Tests the functionality of the SDL_CreateWindow function using different flags
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   251
 */
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   252
int
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   253
video_createWindowVariousFlags(void *arg)
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   254
{
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   255
  SDL_Window* window;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   256
  const char* title = "video_createWindowVariousFlags Test Window";
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   257
  int x, y, w, h;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   258
  int fVariation;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   259
  SDL_WindowFlags flags;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   260
  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   261
  /* Standard window */
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   262
  x = SDLTest_RandomIntegerInRange(1, 100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   263
  y = SDLTest_RandomIntegerInRange(1, 100);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   264
  w = SDLTest_RandomIntegerInRange(320, 1024);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   265
  h = SDLTest_RandomIntegerInRange(320, 768);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   266
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   267
  for (fVariation = 0; fVariation < 13; fVariation++) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   268
    switch(fVariation) {
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   269
     case 0:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   270
      flags = SDL_WINDOW_FULLSCREEN;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   271
      /* Skip - blanks screen; comment out next line to run test */
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   272
      continue;   
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   273
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   274
     case 1:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   275
      flags = SDL_WINDOW_FULLSCREEN_DESKTOP;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   276
      /* Skip - blanks screen; comment out next line to run test */
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   277
      continue;  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   278
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   279
     case 2:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   280
      flags = SDL_WINDOW_OPENGL;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   281
      break;  
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   282
     case 3:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   283
      flags = SDL_WINDOW_SHOWN;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   284
      break;   
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   285
     case 4:    
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   286
      flags = SDL_WINDOW_HIDDEN;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   287
      break;     
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   288
     case 5:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   289
      flags = SDL_WINDOW_BORDERLESS;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   290
      break;       
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   291
     case 6:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   292
      flags = SDL_WINDOW_RESIZABLE;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   293
      break;         
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   294
     case 7:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   295
      flags = SDL_WINDOW_MINIMIZED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   296
      break;           
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   297
     case 8:
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   298
      flags = SDL_WINDOW_MAXIMIZED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   299
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   300
     case 9: 
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   301
      flags = SDL_WINDOW_INPUT_GRABBED;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   302
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   303
     case 10:              
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   304
      flags = SDL_WINDOW_INPUT_FOCUS;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   305
      break;                 
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   306
     case 11:                      
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   307
      flags = SDL_WINDOW_MOUSE_FOCUS;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   308
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   309
     case 12: 
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   310
      flags = SDL_WINDOW_FOREIGN;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   311
      break;
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   312
    }
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   313
       
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   314
    window = SDL_CreateWindow(title, x, y, w, h, flags);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   315
    SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
177f29ae5279 Add tests to Video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   316
    SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   317
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6891
diff changeset
   318
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
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   599
/**
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   600
 * @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
   601
 *
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   602
 * @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
   603
 */
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   604
int
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   605
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
   606
{
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   607
  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
   608
  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
   609
  char *lastError;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   610
  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
   611
  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
   612
  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
   613
  int result;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   614
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   615
  /* 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
   616
  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
   617
  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
   618
      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
   619
      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
   620
      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
   621
      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
   622
      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
   623
      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
   624
      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
   625
      	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
   626
             "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
   627
             expectedError,
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   628
             lastError);
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   629
      }
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   630
  }
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   631
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   632
  /* Clean up */    
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   633
  _destroyVideoSuiteTestWindow(window);
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   634
  
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   635
  /* 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
   636
  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
   637
  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
   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, invalidWindowError) == 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
         invalidWindowError,
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
  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
   650
}
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   651
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   652
/**
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   653
 * @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
   654
 *
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   655
 * @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
   656
 */
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   657
int
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   658
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
   659
{
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   660
  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
   661
  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
   662
  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
   663
  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
   664
  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
   665
  int result;
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
  /* 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
   668
  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
   669
  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
   670
  
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   671
  /* 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
   672
  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
   673
  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
   674
  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
   675
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
   676
  /* 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
   677
  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
   678
  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
   679
  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
   680
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
   681
  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
   682
  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
   683
  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   684
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   685
  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
   686
  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
   687
  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
   688
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
   689
  /* 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
   690
  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
   691
  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
   692
  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   693
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   694
  result = SDL_GetWindowGammaRamp(window, NULL, 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
   695
  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
   696
  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   697
6956
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   698
  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
   699
  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
   700
  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
   701
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
  /* 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
   703
  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
   704
  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
   705
  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
6936
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   706
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   707
  /* Clean up */    
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   708
  _destroyVideoSuiteTestWindow(window);
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   709
  
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   710
  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
   711
}
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   712
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   713
/**
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   714
 * @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
   715
 *
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   716
* @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
   717
 */
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   718
int
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   719
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
   720
{
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   721
  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
   722
  char *lastError;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   723
  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
   724
  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
   725
  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
   726
  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
   727
  int result;
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   728
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   729
  /* 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
   730
  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
   731
  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
   732
  SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, 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
   733
  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
   734
  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
   735
  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
   736
  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
   737
      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
   738
         "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
   739
         invalidWindowError,
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   740
         lastError);
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   741
  }
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   742
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   743
  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
   744
}
76d9c31e823d Add additional input validation to SDL_GetWindowDisplayMode; add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6921
diff changeset
   745
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
   746
/* 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
   747
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
   748
_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
   749
{
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
  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
   751
  
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   752
  /* 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
   753
  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
   754
  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
   755
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
  /* 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
   757
  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
   758
  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
   759
  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
   760
      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
   761
      "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
   762
      (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
   763
      (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
   764
}
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   765
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   766
/**
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   767
 * @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
   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
 * @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
   770
 * @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
   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
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
   773
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
   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
  const char *invalidWindowError = "Invalid 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
   776
  char *lastError;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   777
  const char* title = "video_getSetWindowGrab Test Window";
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   778
  SDL_Window* window;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   779
  SDL_bool originalState, dummyState, currentState, desiredState;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   780
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   781
  /* Call against new test window */ 
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   782
  window = _createVideoSuiteTestWindow(title);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   783
  if (window == NULL) return TEST_ABORTED;
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   784
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   785
  /* Get state */  
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   786
  originalState = SDL_GetWindowGrab(window);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   787
  SDLTest_AssertPass("Call to SDL_GetWindowGrab()");
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   788
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   789
  /* F */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   790
  _setAndCheckWindowGrabState(window, SDL_FALSE);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   791
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   792
  /* F --> F */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   793
  _setAndCheckWindowGrabState(window, SDL_FALSE);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   794
  
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   795
  /* F --> T */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   796
  _setAndCheckWindowGrabState(window, SDL_TRUE);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   797
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   798
  /* T --> T */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   799
  _setAndCheckWindowGrabState(window, SDL_TRUE);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   800
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   801
  /* T --> F */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   802
  _setAndCheckWindowGrabState(window, SDL_FALSE);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   803
  
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   804
  /* Negative tests */
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   805
  dummyState = SDL_GetWindowGrab(NULL);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   806
  SDLTest_AssertPass("Call to SDL_GetWindowGrab(window=NULL)");
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
  lastError = (char *)SDL_GetError();
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   808
  SDLTest_AssertPass("SDL_GetError()");
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   809
  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not 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
   810
  if (lastError != 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
   811
      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 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
   812
         "SDL_GetError(): expected message '%s', was message: '%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
   813
         invalidWindowError,
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
         lastError);
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
  }
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   816
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   817
  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
   818
  SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=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
   819
  lastError = (char *)SDL_GetError();
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   820
  SDLTest_AssertPass("SDL_GetError()");
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   821
  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not 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
   822
  if (lastError != 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
   823
      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 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
   824
         "SDL_GetError(): expected message '%s', was message: '%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
         invalidWindowError,
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
         lastError);
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
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
  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
   830
  SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=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
   831
  lastError = (char *)SDL_GetError();
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
  SDLTest_AssertPass("SDL_GetError()");
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
  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not 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
   834
  if (lastError != 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
   835
      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 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
   836
         "SDL_GetError(): expected message '%s', was message: '%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
   837
         invalidWindowError,
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
         lastError);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   839
  }
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   840
  
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
  /* 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
   842
  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
   843
  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
   844
  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
   845
  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
   846
      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
   847
      "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
   848
      (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
   849
      (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
   850
    
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   851
  /* 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
   852
  _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
   853
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   854
  /* 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
   855
  _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
   856
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
  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
   858
}
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   859
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
/**
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
 * @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
   862
 *
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   863
 * @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
   864
 * @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
   865
 */
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
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
   867
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
   868
{
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   869
  const char *invalidWindowError = "Invalid 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
   870
  char *lastError;
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
  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
   872
  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
   873
  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
   874
  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
   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
  /* 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
   877
  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
   878
  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
   879
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
  /* 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
   881
  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
   882
  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
   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
  /* 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
   885
  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
   886
  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
   887
  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
   888
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   889
  /* 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
   890
  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
   891
  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
   892
  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
   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
  /* 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
   895
  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
   896
  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
   897
  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
   898
  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
   899
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   900
  /* 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
   901
  _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
   902
    
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
  /* 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
   904
  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
   905
  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
   906
  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
   907
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   908
  /* Negative test */
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
  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
   910
  SDLTest_AssertPass("Call to SDL_GetWindowID(window=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
   911
  lastError = (char *)SDL_GetError();
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("SDL_GetError()");
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(lastError != NULL, "Verify error message is not 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
   914
  if (lastError != 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
   915
      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 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
   916
         "SDL_GetError(): expected message '%s', was message: '%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
   917
         invalidWindowError,
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
         lastError);
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   919
  }
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   920
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
  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
   922
}
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   923
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
 * @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
   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
 * @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
   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
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
   930
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
   931
{
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   932
  const char *invalidWindowError = "Invalid 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
   933
  char *lastError;
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
  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
   935
  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
   936
  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
   937
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
  /* 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
   939
  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
   940
  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
   941
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
  /* 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
   943
  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
   944
  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
   945
  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
   946
   
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   947
  /* 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
   948
  _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
   949
    
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
  /* Negative test */
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
  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
   952
  SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat(window=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
   953
  lastError = (char *)SDL_GetError();
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
  SDLTest_AssertPass("SDL_GetError()");
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
  SDLTest_AssertCheck(lastError != NULL, "Verify error message is not 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
   956
  if (lastError != 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
   957
      SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 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
   958
         "SDL_GetError(): expected message '%s', was message: '%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
   959
         invalidWindowError,
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
         lastError);
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
  }
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
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
  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
   964
}
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   965
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   966
/**
afdc35fa58e9 Fix behavior of SDL_GetWindowPosition for invalid input; add test cases to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6936
diff changeset
   967
 * @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
   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
 * @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
   970
 * @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
   971
 */
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
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
   973
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
   974
{
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
  const char *invalidWindowError = "Invalid 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
   976
  char *lastError;
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
  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
   978
  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
   979
  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
   980
  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
   981
  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
   982
  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
   983
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
  /* 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
   985
  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
   986
  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
   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
  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
   989
   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
   990
    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
   991
     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
   992
      /* 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
   993
      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
   994
      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
   995
     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
   996
      /* 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
   997
      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
   998
      break;