Add parameter checking to SetWindowSize functions; add tests to video suite
This commit is contained in:
parent
5916b2bc1e
commit
edbf26b139
3 changed files with 545 additions and 148 deletions
|
@ -504,6 +504,9 @@ extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window,
|
||||||
/**
|
/**
|
||||||
* \brief Get the position of a window.
|
* \brief Get the position of a window.
|
||||||
*
|
*
|
||||||
|
* \param x Pointer to variable for storing the x position, may be NULL
|
||||||
|
* \param y Pointer to variable for storing the y position, may be NULL
|
||||||
|
*
|
||||||
* \sa SDL_SetWindowPosition()
|
* \sa SDL_SetWindowPosition()
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window,
|
extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window,
|
||||||
|
@ -512,6 +515,9 @@ extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window,
|
||||||
/**
|
/**
|
||||||
* \brief Set the size of a window's client area.
|
* \brief Set the size of a window's client area.
|
||||||
*
|
*
|
||||||
|
* \param w The width of the window, must be >0
|
||||||
|
* \param h The height of the window, must be >0
|
||||||
|
*
|
||||||
* \note You can't change the size of a fullscreen window, it automatically
|
* \note You can't change the size of a fullscreen window, it automatically
|
||||||
* matches the size of the display mode.
|
* matches the size of the display mode.
|
||||||
*
|
*
|
||||||
|
@ -523,6 +529,9 @@ extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w,
|
||||||
/**
|
/**
|
||||||
* \brief Get the size of a window's client area.
|
* \brief Get the size of a window's client area.
|
||||||
*
|
*
|
||||||
|
* \param w Pointer to variable for storing the width, may be NULL
|
||||||
|
* \param h Pointer to variable for storing the height, may be NULL
|
||||||
|
*
|
||||||
* \sa SDL_SetWindowSize()
|
* \sa SDL_SetWindowSize()
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w,
|
extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w,
|
||||||
|
@ -530,6 +539,9 @@ extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the minimum size of a window's client area.
|
* \brief Set the minimum size of a window's client area.
|
||||||
|
*
|
||||||
|
* \param min_w The minimum width of the window, must be >0
|
||||||
|
* \param min_h The minimum height of the window, must be >0
|
||||||
*
|
*
|
||||||
* \note You can't change the minimum size of a fullscreen window, it
|
* \note You can't change the minimum size of a fullscreen window, it
|
||||||
* automatically matches the size of the display mode.
|
* automatically matches the size of the display mode.
|
||||||
|
@ -542,7 +554,10 @@ extern DECLSPEC void SDLCALL SDL_SetWindowMinimumSize(SDL_Window * window,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Get the minimum size of a window's client area.
|
* \brief Get the minimum size of a window's client area.
|
||||||
*
|
*
|
||||||
|
* \param w Pointer to variable for storing the minimum width, may be NULL
|
||||||
|
* \param h Pointer to variable for storing the minimum height, may be NULL
|
||||||
|
*
|
||||||
* \sa SDL_GetWindowMaximumSize()
|
* \sa SDL_GetWindowMaximumSize()
|
||||||
* \sa SDL_SetWindowMinimumSize()
|
* \sa SDL_SetWindowMinimumSize()
|
||||||
*/
|
*/
|
||||||
|
@ -552,6 +567,9 @@ extern DECLSPEC void SDLCALL SDL_GetWindowMinimumSize(SDL_Window * window,
|
||||||
/**
|
/**
|
||||||
* \brief Set the maximum size of a window's client area.
|
* \brief Set the maximum size of a window's client area.
|
||||||
*
|
*
|
||||||
|
* \param max_w The maximum width of the window, must be >0
|
||||||
|
* \param max_h The maximum height of the window, must be >0
|
||||||
|
*
|
||||||
* \note You can't change the maximum size of a fullscreen window, it
|
* \note You can't change the maximum size of a fullscreen window, it
|
||||||
* automatically matches the size of the display mode.
|
* automatically matches the size of the display mode.
|
||||||
*
|
*
|
||||||
|
@ -563,6 +581,9 @@ extern DECLSPEC void SDLCALL SDL_SetWindowMaximumSize(SDL_Window * window,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Get the maximum size of a window's client area.
|
* \brief Get the maximum size of a window's client area.
|
||||||
|
*
|
||||||
|
* \param w Pointer to variable for storing the maximum width, may be NULL
|
||||||
|
* \param h Pointer to variable for storing the maximum height, may be NULL
|
||||||
*
|
*
|
||||||
* \sa SDL_GetWindowMinimumSize()
|
* \sa SDL_GetWindowMinimumSize()
|
||||||
* \sa SDL_SetWindowMaximumSize()
|
* \sa SDL_SetWindowMaximumSize()
|
||||||
|
|
|
@ -1566,6 +1566,14 @@ void
|
||||||
SDL_SetWindowSize(SDL_Window * window, int w, int h)
|
SDL_SetWindowSize(SDL_Window * window, int w, int h)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window, );
|
||||||
|
if (w <= 0) {
|
||||||
|
SDL_InvalidParamError("w");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (h <= 0) {
|
||||||
|
SDL_InvalidParamError("h");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME: Should this change fullscreen modes? */
|
/* FIXME: Should this change fullscreen modes? */
|
||||||
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
|
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
|
||||||
|
@ -1584,30 +1592,27 @@ SDL_SetWindowSize(SDL_Window * window, int w, int h)
|
||||||
void
|
void
|
||||||
SDL_GetWindowSize(SDL_Window * window, int *w, int *h)
|
SDL_GetWindowSize(SDL_Window * window, int *w, int *h)
|
||||||
{
|
{
|
||||||
int dummy;
|
|
||||||
|
|
||||||
if (!w) {
|
|
||||||
w = &dummy;
|
|
||||||
}
|
|
||||||
if (!h) {
|
|
||||||
h = &dummy;
|
|
||||||
}
|
|
||||||
|
|
||||||
*w = 0;
|
|
||||||
*h = 0;
|
|
||||||
|
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window, );
|
||||||
|
if (w) {
|
||||||
if (_this && window && window->magic == &_this->window_magic) {
|
|
||||||
*w = window->w;
|
*w = window->w;
|
||||||
*h = window->h;
|
|
||||||
}
|
}
|
||||||
|
if (h) {
|
||||||
|
*h = window->h;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h)
|
SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window, );
|
||||||
|
if (min_w <= 0) {
|
||||||
|
SDL_InvalidParamError("min_w");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (min_h <= 0) {
|
||||||
|
SDL_InvalidParamError("min_h");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
|
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
|
||||||
window->min_w = min_w;
|
window->min_w = min_w;
|
||||||
|
@ -1623,22 +1628,11 @@ SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h)
|
||||||
void
|
void
|
||||||
SDL_GetWindowMinimumSize(SDL_Window * window, int *min_w, int *min_h)
|
SDL_GetWindowMinimumSize(SDL_Window * window, int *min_w, int *min_h)
|
||||||
{
|
{
|
||||||
int dummy;
|
|
||||||
|
|
||||||
if (!min_w) {
|
|
||||||
min_w = &dummy;
|
|
||||||
}
|
|
||||||
if (!min_h) {
|
|
||||||
min_h = &dummy;
|
|
||||||
}
|
|
||||||
|
|
||||||
*min_w = 0;
|
|
||||||
*min_h = 0;
|
|
||||||
|
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window, );
|
||||||
|
if (min_w) {
|
||||||
if (_this && window && window->magic == &_this->window_magic) {
|
|
||||||
*min_w = window->min_w;
|
*min_w = window->min_w;
|
||||||
|
}
|
||||||
|
if (min_h) {
|
||||||
*min_h = window->min_h;
|
*min_h = window->min_h;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1647,6 +1641,14 @@ void
|
||||||
SDL_SetWindowMaximumSize(SDL_Window * window, int max_w, int max_h)
|
SDL_SetWindowMaximumSize(SDL_Window * window, int max_w, int max_h)
|
||||||
{
|
{
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window, );
|
||||||
|
if (max_w <= 0) {
|
||||||
|
SDL_InvalidParamError("max_w");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (max_h <= 0) {
|
||||||
|
SDL_InvalidParamError("max_h");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
|
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
|
||||||
window->max_w = max_w;
|
window->max_w = max_w;
|
||||||
|
@ -1662,22 +1664,11 @@ SDL_SetWindowMaximumSize(SDL_Window * window, int max_w, int max_h)
|
||||||
void
|
void
|
||||||
SDL_GetWindowMaximumSize(SDL_Window * window, int *max_w, int *max_h)
|
SDL_GetWindowMaximumSize(SDL_Window * window, int *max_w, int *max_h)
|
||||||
{
|
{
|
||||||
int dummy;
|
|
||||||
|
|
||||||
if (!max_w) {
|
|
||||||
max_w = &dummy;
|
|
||||||
}
|
|
||||||
if (!max_h) {
|
|
||||||
max_h = &dummy;
|
|
||||||
}
|
|
||||||
|
|
||||||
*max_w = 0;
|
|
||||||
*max_h = 0;
|
|
||||||
|
|
||||||
CHECK_WINDOW_MAGIC(window, );
|
CHECK_WINDOW_MAGIC(window, );
|
||||||
|
if (max_w) {
|
||||||
if (_this && window && window->magic == &_this->window_magic) {
|
|
||||||
*max_w = window->max_w;
|
*max_w = window->max_w;
|
||||||
|
}
|
||||||
|
if (max_h) {
|
||||||
*max_h = window->max_h;
|
*max_h = window->max_h;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ SDL_Window *_createVideoSuiteTestWindow(const char *title)
|
||||||
y = SDLTest_RandomIntegerInRange(1, 100);
|
y = SDLTest_RandomIntegerInRange(1, 100);
|
||||||
w = SDLTest_RandomIntegerInRange(320, 1024);
|
w = SDLTest_RandomIntegerInRange(320, 1024);
|
||||||
h = SDLTest_RandomIntegerInRange(320, 768);
|
h = SDLTest_RandomIntegerInRange(320, 768);
|
||||||
flags = SDL_WINDOW_SHOWN;
|
flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS;
|
||||||
|
|
||||||
window = SDL_CreateWindow(title, x, y, w, h, flags);
|
window = SDL_CreateWindow(title, x, y, w, h, flags);
|
||||||
SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
|
SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
|
||||||
|
@ -315,7 +315,6 @@ video_createWindowVariousFlags(void *arg)
|
||||||
SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
|
SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags);
|
||||||
SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
|
SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
|
||||||
|
|
||||||
|
|
||||||
/* Clean up */
|
/* Clean up */
|
||||||
_destroyVideoSuiteTestWindow(window);
|
_destroyVideoSuiteTestWindow(window);
|
||||||
}
|
}
|
||||||
|
@ -596,6 +595,25 @@ video_getWindowDisplayMode(void *arg)
|
||||||
return TEST_COMPLETED;
|
return TEST_COMPLETED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Helper function that checks for an 'Invalid window' error */
|
||||||
|
void _checkInvalidWindowError()
|
||||||
|
{
|
||||||
|
const char *invalidWindowError = "Invalid window";
|
||||||
|
char *lastError;
|
||||||
|
|
||||||
|
lastError = (char *)SDL_GetError();
|
||||||
|
SDLTest_AssertPass("SDL_GetError()");
|
||||||
|
SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
|
||||||
|
if (lastError != NULL) {
|
||||||
|
SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
|
||||||
|
"SDL_GetError(): expected message '%s', was message: '%s'",
|
||||||
|
invalidWindowError,
|
||||||
|
lastError);
|
||||||
|
SDL_ClearError();
|
||||||
|
SDLTest_AssertPass("Call to SDL_ClearError()");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Tests call to SDL_GetWindowDisplayMode with invalid input
|
* @brief Tests call to SDL_GetWindowDisplayMode with invalid input
|
||||||
*
|
*
|
||||||
|
@ -605,7 +623,6 @@ int
|
||||||
video_getWindowDisplayModeNegative(void *arg)
|
video_getWindowDisplayModeNegative(void *arg)
|
||||||
{
|
{
|
||||||
const char *expectedError = "Parameter 'mode' is invalid";
|
const char *expectedError = "Parameter 'mode' is invalid";
|
||||||
const char *invalidWindowError = "Invalid window";
|
|
||||||
char *lastError;
|
char *lastError;
|
||||||
SDL_Window* window;
|
SDL_Window* window;
|
||||||
const char* title = "video_getWindowDisplayModeNegative Test Window";
|
const char* title = "video_getWindowDisplayModeNegative Test Window";
|
||||||
|
@ -636,16 +653,8 @@ video_getWindowDisplayModeNegative(void *arg)
|
||||||
result = SDL_GetWindowDisplayMode(NULL, &mode);
|
result = SDL_GetWindowDisplayMode(NULL, &mode);
|
||||||
SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(window=NULL,...)");
|
SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(window=NULL,...)");
|
||||||
SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result);
|
SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %d", result);
|
||||||
lastError = (char *)SDL_GetError();
|
_checkInvalidWindowError();
|
||||||
SDLTest_AssertPass("SDL_GetError()");
|
|
||||||
SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
|
|
||||||
if (lastError != NULL) {
|
|
||||||
SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
|
|
||||||
"SDL_GetError(): expected message '%s', was message: '%s'",
|
|
||||||
invalidWindowError,
|
|
||||||
lastError);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TEST_COMPLETED;
|
return TEST_COMPLETED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -718,28 +727,21 @@ video_getWindowGammaRamp(void *arg)
|
||||||
int
|
int
|
||||||
video_getWindowGammaRampNegative(void *arg)
|
video_getWindowGammaRampNegative(void *arg)
|
||||||
{
|
{
|
||||||
const char *invalidWindowError = "Invalid window";
|
|
||||||
char *lastError;
|
|
||||||
const char* title = "video_getWindowGammaRampNegative Test Window";
|
const char* title = "video_getWindowGammaRampNegative Test Window";
|
||||||
Uint16 red[256];
|
Uint16 red[256];
|
||||||
Uint16 green[256];
|
Uint16 green[256];
|
||||||
Uint16 blue[256];
|
Uint16 blue[256];
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
SDL_ClearError();
|
||||||
|
SDLTest_AssertPass("Call to SDL_ClearError()");
|
||||||
|
|
||||||
/* Call against invalid window */
|
/* Call against invalid window */
|
||||||
result = SDL_GetWindowGammaRamp(NULL, red, green, blue);
|
result = SDL_GetWindowGammaRamp(NULL, red, green, blue);
|
||||||
SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(window=NULL,r,g,b)");
|
SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(window=NULL,r,g,b)");
|
||||||
SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %f", result);
|
SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %f", result);
|
||||||
lastError = (char *)SDL_GetError();
|
_checkInvalidWindowError();
|
||||||
SDLTest_AssertPass("SDL_GetError()");
|
|
||||||
SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
|
|
||||||
if (lastError != NULL) {
|
|
||||||
SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
|
|
||||||
"SDL_GetError(): expected message '%s', was message: '%s'",
|
|
||||||
invalidWindowError,
|
|
||||||
lastError);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TEST_COMPLETED;
|
return TEST_COMPLETED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -772,8 +774,6 @@ _setAndCheckWindowGrabState(SDL_Window* window, SDL_bool desiredState)
|
||||||
int
|
int
|
||||||
video_getSetWindowGrab(void *arg)
|
video_getSetWindowGrab(void *arg)
|
||||||
{
|
{
|
||||||
const char *invalidWindowError = "Invalid window";
|
|
||||||
char *lastError;
|
|
||||||
const char* title = "video_getSetWindowGrab Test Window";
|
const char* title = "video_getSetWindowGrab Test Window";
|
||||||
SDL_Window* window;
|
SDL_Window* window;
|
||||||
SDL_bool originalState, dummyState, currentState, desiredState;
|
SDL_bool originalState, dummyState, currentState, desiredState;
|
||||||
|
@ -804,39 +804,15 @@ video_getSetWindowGrab(void *arg)
|
||||||
/* Negative tests */
|
/* Negative tests */
|
||||||
dummyState = SDL_GetWindowGrab(NULL);
|
dummyState = SDL_GetWindowGrab(NULL);
|
||||||
SDLTest_AssertPass("Call to SDL_GetWindowGrab(window=NULL)");
|
SDLTest_AssertPass("Call to SDL_GetWindowGrab(window=NULL)");
|
||||||
lastError = (char *)SDL_GetError();
|
_checkInvalidWindowError();
|
||||||
SDLTest_AssertPass("SDL_GetError()");
|
|
||||||
SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
|
|
||||||
if (lastError != NULL) {
|
|
||||||
SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
|
|
||||||
"SDL_GetError(): expected message '%s', was message: '%s'",
|
|
||||||
invalidWindowError,
|
|
||||||
lastError);
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_SetWindowGrab(NULL, SDL_FALSE);
|
SDL_SetWindowGrab(NULL, SDL_FALSE);
|
||||||
SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
|
SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
|
||||||
lastError = (char *)SDL_GetError();
|
_checkInvalidWindowError();
|
||||||
SDLTest_AssertPass("SDL_GetError()");
|
|
||||||
SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
|
|
||||||
if (lastError != NULL) {
|
|
||||||
SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
|
|
||||||
"SDL_GetError(): expected message '%s', was message: '%s'",
|
|
||||||
invalidWindowError,
|
|
||||||
lastError);
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_SetWindowGrab(NULL, SDL_TRUE);
|
SDL_SetWindowGrab(NULL, SDL_TRUE);
|
||||||
SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
|
SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)");
|
||||||
lastError = (char *)SDL_GetError();
|
_checkInvalidWindowError();
|
||||||
SDLTest_AssertPass("SDL_GetError()");
|
|
||||||
SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
|
|
||||||
if (lastError != NULL) {
|
|
||||||
SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
|
|
||||||
"SDL_GetError(): expected message '%s', was message: '%s'",
|
|
||||||
invalidWindowError,
|
|
||||||
lastError);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* State should still be F */
|
/* State should still be F */
|
||||||
desiredState = SDL_FALSE;
|
desiredState = SDL_FALSE;
|
||||||
|
@ -857,6 +833,7 @@ video_getSetWindowGrab(void *arg)
|
||||||
return TEST_COMPLETED;
|
return TEST_COMPLETED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Tests call to SDL_GetWindowID and SDL_GetWindowFromID
|
* @brief Tests call to SDL_GetWindowID and SDL_GetWindowFromID
|
||||||
*
|
*
|
||||||
|
@ -866,8 +843,6 @@ video_getSetWindowGrab(void *arg)
|
||||||
int
|
int
|
||||||
video_getWindowId(void *arg)
|
video_getWindowId(void *arg)
|
||||||
{
|
{
|
||||||
const char *invalidWindowError = "Invalid window";
|
|
||||||
char *lastError;
|
|
||||||
const char* title = "video_getWindowId Test Window";
|
const char* title = "video_getWindowId Test Window";
|
||||||
SDL_Window* window;
|
SDL_Window* window;
|
||||||
SDL_Window* result;
|
SDL_Window* result;
|
||||||
|
@ -906,18 +881,12 @@ video_getWindowId(void *arg)
|
||||||
SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
|
SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
|
||||||
|
|
||||||
/* Negative test */
|
/* Negative test */
|
||||||
|
SDL_ClearError();
|
||||||
|
SDLTest_AssertPass("Call to SDL_ClearError()");
|
||||||
id = SDL_GetWindowID(NULL);
|
id = SDL_GetWindowID(NULL);
|
||||||
SDLTest_AssertPass("Call to SDL_GetWindowID(window=NULL)");
|
SDLTest_AssertPass("Call to SDL_GetWindowID(window=NULL)");
|
||||||
lastError = (char *)SDL_GetError();
|
_checkInvalidWindowError();
|
||||||
SDLTest_AssertPass("SDL_GetError()");
|
|
||||||
SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
|
|
||||||
if (lastError != NULL) {
|
|
||||||
SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
|
|
||||||
"SDL_GetError(): expected message '%s', was message: '%s'",
|
|
||||||
invalidWindowError,
|
|
||||||
lastError);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TEST_COMPLETED;
|
return TEST_COMPLETED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -929,8 +898,6 @@ video_getWindowId(void *arg)
|
||||||
int
|
int
|
||||||
video_getWindowPixelFormat(void *arg)
|
video_getWindowPixelFormat(void *arg)
|
||||||
{
|
{
|
||||||
const char *invalidWindowError = "Invalid window";
|
|
||||||
char *lastError;
|
|
||||||
const char* title = "video_getWindowPixelFormat Test Window";
|
const char* title = "video_getWindowPixelFormat Test Window";
|
||||||
SDL_Window* window;
|
SDL_Window* window;
|
||||||
Uint32 format;
|
Uint32 format;
|
||||||
|
@ -948,17 +915,11 @@ video_getWindowPixelFormat(void *arg)
|
||||||
_destroyVideoSuiteTestWindow(window);
|
_destroyVideoSuiteTestWindow(window);
|
||||||
|
|
||||||
/* Negative test */
|
/* Negative test */
|
||||||
|
SDL_ClearError();
|
||||||
|
SDLTest_AssertPass("Call to SDL_ClearError()");
|
||||||
format = SDL_GetWindowPixelFormat(NULL);
|
format = SDL_GetWindowPixelFormat(NULL);
|
||||||
SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat(window=NULL)");
|
SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat(window=NULL)");
|
||||||
lastError = (char *)SDL_GetError();
|
_checkInvalidWindowError();
|
||||||
SDLTest_AssertPass("SDL_GetError()");
|
|
||||||
SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
|
|
||||||
if (lastError != NULL) {
|
|
||||||
SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
|
|
||||||
"SDL_GetError(): expected message '%s', was message: '%s'",
|
|
||||||
invalidWindowError,
|
|
||||||
lastError);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TEST_COMPLETED;
|
return TEST_COMPLETED;
|
||||||
}
|
}
|
||||||
|
@ -972,8 +933,6 @@ video_getWindowPixelFormat(void *arg)
|
||||||
int
|
int
|
||||||
video_getSetWindowPosition(void *arg)
|
video_getSetWindowPosition(void *arg)
|
||||||
{
|
{
|
||||||
const char *invalidWindowError = "Invalid window";
|
|
||||||
char *lastError;
|
|
||||||
const char* title = "video_getSetWindowPosition Test Window";
|
const char* title = "video_getSetWindowPosition Test Window";
|
||||||
SDL_Window* window;
|
SDL_Window* window;
|
||||||
int xVariation, yVariation;
|
int xVariation, yVariation;
|
||||||
|
@ -1065,8 +1024,10 @@ video_getSetWindowPosition(void *arg)
|
||||||
currentY = referenceY;
|
currentY = referenceY;
|
||||||
desiredX = SDLTest_RandomSint32();
|
desiredX = SDLTest_RandomSint32();
|
||||||
desiredY = SDLTest_RandomSint32();
|
desiredY = SDLTest_RandomSint32();
|
||||||
|
|
||||||
/* Negative tests */
|
/* Negative tests */
|
||||||
|
SDL_ClearError();
|
||||||
|
SDLTest_AssertPass("Call to SDL_ClearError()");
|
||||||
SDL_GetWindowPosition(NULL, ¤tX, ¤tY);
|
SDL_GetWindowPosition(NULL, ¤tX, ¤tY);
|
||||||
SDLTest_AssertPass("Call to SDL_GetWindowPosition(window=NULL)");
|
SDLTest_AssertPass("Call to SDL_GetWindowPosition(window=NULL)");
|
||||||
SDLTest_AssertCheck(
|
SDLTest_AssertCheck(
|
||||||
|
@ -1074,39 +1035,453 @@ video_getSetWindowPosition(void *arg)
|
||||||
"Verify that content of X and Y pointers has not been modified; expected: %d,%d; got: %d,%d",
|
"Verify that content of X and Y pointers has not been modified; expected: %d,%d; got: %d,%d",
|
||||||
referenceX, referenceY,
|
referenceX, referenceY,
|
||||||
currentX, currentY);
|
currentX, currentY);
|
||||||
lastError = (char *)SDL_GetError();
|
_checkInvalidWindowError();
|
||||||
SDLTest_AssertPass("SDL_GetError()");
|
|
||||||
SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
|
|
||||||
if (lastError != NULL) {
|
|
||||||
SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
|
|
||||||
"SDL_GetError(): expected message '%s', was message: '%s'",
|
|
||||||
invalidWindowError,
|
|
||||||
lastError);
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_GetWindowPosition(NULL, NULL, NULL);
|
SDL_GetWindowPosition(NULL, NULL, NULL);
|
||||||
SDLTest_AssertPass("Call to SDL_GetWindowPosition(NULL, NULL, NULL)");
|
SDLTest_AssertPass("Call to SDL_GetWindowPosition(NULL, NULL, NULL)");
|
||||||
lastError = (char *)SDL_GetError();
|
_checkInvalidWindowError();
|
||||||
SDLTest_AssertPass("SDL_GetError()");
|
|
||||||
SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
|
|
||||||
if (lastError != NULL) {
|
|
||||||
SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
|
|
||||||
"SDL_GetError(): expected message '%s', was message: '%s'",
|
|
||||||
invalidWindowError,
|
|
||||||
lastError);
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_SetWindowPosition(NULL, desiredX, desiredY);
|
SDL_SetWindowPosition(NULL, desiredX, desiredY);
|
||||||
SDLTest_AssertPass("Call to SDL_SetWindowPosition(window=NULL)");
|
SDLTest_AssertPass("Call to SDL_SetWindowPosition(window=NULL)");
|
||||||
|
_checkInvalidWindowError();
|
||||||
|
|
||||||
|
return TEST_COMPLETED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Helper function that checks for an 'Invalid parameter' error */
|
||||||
|
void _checkInvalidParameterError()
|
||||||
|
{
|
||||||
|
const char *invalidParameterError = "Parameter";
|
||||||
|
char *lastError;
|
||||||
|
|
||||||
lastError = (char *)SDL_GetError();
|
lastError = (char *)SDL_GetError();
|
||||||
SDLTest_AssertPass("SDL_GetError()");
|
SDLTest_AssertPass("SDL_GetError()");
|
||||||
SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
|
SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
|
||||||
if (lastError != NULL) {
|
if (lastError != NULL) {
|
||||||
SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
|
SDLTest_AssertCheck(SDL_strncmp(lastError, invalidParameterError, SDL_strlen(invalidParameterError)) == 0,
|
||||||
"SDL_GetError(): expected message '%s', was message: '%s'",
|
"SDL_GetError(): expected message starts with '%s', was message: '%s'",
|
||||||
invalidWindowError,
|
invalidParameterError,
|
||||||
lastError);
|
lastError);
|
||||||
|
SDL_ClearError();
|
||||||
|
SDLTest_AssertPass("Call to SDL_ClearError()");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Tests call to SDL_GetWindowSize and SDL_SetWindowSize
|
||||||
|
*
|
||||||
|
* @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowSize
|
||||||
|
* @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowSize
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
video_getSetWindowSize(void *arg)
|
||||||
|
{
|
||||||
|
const char* title = "video_getSetWindowSize Test Window";
|
||||||
|
SDL_Window* window;
|
||||||
|
int result;
|
||||||
|
SDL_Rect display;
|
||||||
|
int wVariation, hVariation;
|
||||||
|
int referenceW, referenceH;
|
||||||
|
int currentW, currentH;
|
||||||
|
int desiredW, desiredH;
|
||||||
|
|
||||||
|
/* Get display bounds for size range */
|
||||||
|
result = SDL_GetDisplayBounds(0, &display);
|
||||||
|
SDLTest_AssertPass("SDL_GetDisplayBounds()");
|
||||||
|
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
|
||||||
|
if (result != 0) return TEST_ABORTED;
|
||||||
|
|
||||||
|
/* Call against new test window */
|
||||||
|
window = _createVideoSuiteTestWindow(title);
|
||||||
|
if (window == NULL) return TEST_ABORTED;
|
||||||
|
|
||||||
|
for (wVariation = 0; wVariation < 4; wVariation++) {
|
||||||
|
for (hVariation = 0; hVariation < 4; hVariation++) {
|
||||||
|
switch(wVariation) {
|
||||||
|
case 0:
|
||||||
|
/* 1 Pixel Wide */
|
||||||
|
desiredW = 1;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
/* Random width inside screen */
|
||||||
|
desiredW = SDLTest_RandomIntegerInRange(1, 100);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
/* Width at screen size */
|
||||||
|
desiredW = display.w;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
/* Width 1 pixel larger than screen */
|
||||||
|
desiredW = display.w + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(hVariation) {
|
||||||
|
case 0:
|
||||||
|
/* 1 Pixel High */
|
||||||
|
desiredH = 1;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
/* Random height inside screen */
|
||||||
|
desiredH = SDLTest_RandomIntegerInRange(1, 100);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
/* Height at screen size */
|
||||||
|
desiredH = display.h;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
/* Height 1 pixel larger than screen */
|
||||||
|
desiredH = display.h + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set size */
|
||||||
|
SDL_SetWindowSize(window, desiredW, desiredH);
|
||||||
|
SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH);
|
||||||
|
|
||||||
|
/* Get size */
|
||||||
|
currentW = desiredW + 1;
|
||||||
|
currentH = desiredH + 1;
|
||||||
|
SDL_GetWindowSize(window, ¤tW, ¤tH);
|
||||||
|
SDLTest_AssertPass("Call to SDL_GetWindowSize()");
|
||||||
|
SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
|
||||||
|
SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
|
||||||
|
|
||||||
|
/* Get just width */
|
||||||
|
currentW = desiredW + 1;
|
||||||
|
SDL_GetWindowSize(window, ¤tW, NULL);
|
||||||
|
SDLTest_AssertPass("Call to SDL_GetWindowSize(&h=NULL)");
|
||||||
|
SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
|
||||||
|
|
||||||
|
/* Get just height */
|
||||||
|
currentH = desiredH + 1;
|
||||||
|
SDL_GetWindowSize(window, NULL, ¤tH);
|
||||||
|
SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL)");
|
||||||
|
SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dummy call with both pointers NULL */
|
||||||
|
SDL_GetWindowSize(window, NULL, NULL);
|
||||||
|
SDLTest_AssertPass("Call to SDL_GetWindowSize(&w=NULL,&h=NULL)");
|
||||||
|
|
||||||
|
/* Negative tests for parameter input */
|
||||||
|
SDL_ClearError();
|
||||||
|
SDLTest_AssertPass("Call to SDL_ClearError()");
|
||||||
|
for (desiredH = -2; desiredH < 2; desiredH++) {
|
||||||
|
for (desiredW = -2; desiredW < 2; desiredW++) {
|
||||||
|
if (desiredW <= 0 || desiredH <= 0) {
|
||||||
|
SDL_SetWindowSize(window, desiredW, desiredH);
|
||||||
|
SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH);
|
||||||
|
_checkInvalidParameterError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clean up */
|
||||||
|
_destroyVideoSuiteTestWindow(window);
|
||||||
|
|
||||||
|
/* Set some 'magic' value for later check that nothing was changed */
|
||||||
|
referenceW = SDLTest_RandomSint32();
|
||||||
|
referenceH = SDLTest_RandomSint32();
|
||||||
|
currentW = referenceW;
|
||||||
|
currentH = referenceH;
|
||||||
|
desiredW = SDLTest_RandomSint32();
|
||||||
|
desiredH = SDLTest_RandomSint32();
|
||||||
|
|
||||||
|
/* Negative tests for window input */
|
||||||
|
SDL_ClearError();
|
||||||
|
SDLTest_AssertPass("Call to SDL_ClearError()");
|
||||||
|
SDL_GetWindowSize(NULL, ¤tW, ¤tH);
|
||||||
|
SDLTest_AssertPass("Call to SDL_GetWindowSize(window=NULL)");
|
||||||
|
SDLTest_AssertCheck(
|
||||||
|
currentW == referenceW && currentH == referenceH,
|
||||||
|
"Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
|
||||||
|
referenceW, referenceH,
|
||||||
|
currentW, currentH);
|
||||||
|
_checkInvalidWindowError();
|
||||||
|
|
||||||
|
SDL_GetWindowSize(NULL, NULL, NULL);
|
||||||
|
SDLTest_AssertPass("Call to SDL_GetWindowSize(NULL, NULL, NULL)");
|
||||||
|
_checkInvalidWindowError();
|
||||||
|
|
||||||
|
SDL_SetWindowSize(NULL, desiredW, desiredH);
|
||||||
|
SDLTest_AssertPass("Call to SDL_SetWindowSize(window=NULL)");
|
||||||
|
_checkInvalidWindowError();
|
||||||
|
|
||||||
|
return TEST_COMPLETED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Tests call to SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
video_getSetWindowMinimumSize(void *arg)
|
||||||
|
{
|
||||||
|
const char* title = "video_getSetWindowMinimumSize Test Window";
|
||||||
|
SDL_Window* window;
|
||||||
|
int result;
|
||||||
|
SDL_Rect display;
|
||||||
|
int wVariation, hVariation;
|
||||||
|
int referenceW, referenceH;
|
||||||
|
int currentW, currentH;
|
||||||
|
int desiredW, desiredH;
|
||||||
|
|
||||||
|
/* Get display bounds for size range */
|
||||||
|
result = SDL_GetDisplayBounds(0, &display);
|
||||||
|
SDLTest_AssertPass("SDL_GetDisplayBounds()");
|
||||||
|
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
|
||||||
|
if (result != 0) return TEST_ABORTED;
|
||||||
|
|
||||||
|
/* Call against new test window */
|
||||||
|
window = _createVideoSuiteTestWindow(title);
|
||||||
|
if (window == NULL) return TEST_ABORTED;
|
||||||
|
|
||||||
|
for (wVariation = 0; wVariation < 5; wVariation++) {
|
||||||
|
for (hVariation = 0; hVariation < 5; hVariation++) {
|
||||||
|
switch(wVariation) {
|
||||||
|
case 0:
|
||||||
|
/* 1 Pixel Wide */
|
||||||
|
desiredW = 1;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
/* Random width inside screen */
|
||||||
|
desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
/* Width at screen size */
|
||||||
|
desiredW = display.w;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(hVariation) {
|
||||||
|
case 0:
|
||||||
|
/* 1 Pixel High */
|
||||||
|
desiredH = 1;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
/* Random height inside screen */
|
||||||
|
desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
/* Height at screen size */
|
||||||
|
desiredH = display.h;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
/* Height 1 pixel larger than screen */
|
||||||
|
desiredH = display.h + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set size */
|
||||||
|
SDL_SetWindowMinimumSize(window, desiredW, desiredH);
|
||||||
|
SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH);
|
||||||
|
|
||||||
|
/* Get size */
|
||||||
|
currentW = desiredW + 1;
|
||||||
|
currentH = desiredH + 1;
|
||||||
|
SDL_GetWindowMinimumSize(window, ¤tW, ¤tH);
|
||||||
|
SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize()");
|
||||||
|
SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
|
||||||
|
SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
|
||||||
|
|
||||||
|
/* Get just width */
|
||||||
|
currentW = desiredW + 1;
|
||||||
|
SDL_GetWindowMinimumSize(window, ¤tW, NULL);
|
||||||
|
SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&h=NULL)");
|
||||||
|
SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
|
||||||
|
|
||||||
|
/* Get just height */
|
||||||
|
currentH = desiredH + 1;
|
||||||
|
SDL_GetWindowMinimumSize(window, NULL, ¤tH);
|
||||||
|
SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL)");
|
||||||
|
SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dummy call with both pointers NULL */
|
||||||
|
SDL_GetWindowMinimumSize(window, NULL, NULL);
|
||||||
|
SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&w=NULL,&h=NULL)");
|
||||||
|
|
||||||
|
/* Negative tests for parameter input */
|
||||||
|
SDL_ClearError();
|
||||||
|
SDLTest_AssertPass("Call to SDL_ClearError()");
|
||||||
|
for (desiredH = -2; desiredH < 2; desiredH++) {
|
||||||
|
for (desiredW = -2; desiredW < 2; desiredW++) {
|
||||||
|
if (desiredW <= 0 || desiredH <= 0) {
|
||||||
|
SDL_SetWindowMinimumSize(window, desiredW, desiredH);
|
||||||
|
SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH);
|
||||||
|
_checkInvalidParameterError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clean up */
|
||||||
|
_destroyVideoSuiteTestWindow(window);
|
||||||
|
|
||||||
|
/* Set some 'magic' value for later check that nothing was changed */
|
||||||
|
referenceW = SDLTest_RandomSint32();
|
||||||
|
referenceH = SDLTest_RandomSint32();
|
||||||
|
currentW = referenceW;
|
||||||
|
currentH = referenceH;
|
||||||
|
desiredW = SDLTest_RandomSint32();
|
||||||
|
desiredH = SDLTest_RandomSint32();
|
||||||
|
|
||||||
|
/* Negative tests for window input */
|
||||||
|
SDL_ClearError();
|
||||||
|
SDLTest_AssertPass("Call to SDL_ClearError()");
|
||||||
|
SDL_GetWindowMinimumSize(NULL, ¤tW, ¤tH);
|
||||||
|
SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(window=NULL)");
|
||||||
|
SDLTest_AssertCheck(
|
||||||
|
currentW == referenceW && currentH == referenceH,
|
||||||
|
"Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
|
||||||
|
referenceW, referenceH,
|
||||||
|
currentW, currentH);
|
||||||
|
_checkInvalidWindowError();
|
||||||
|
|
||||||
|
SDL_GetWindowMinimumSize(NULL, NULL, NULL);
|
||||||
|
SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(NULL, NULL, NULL)");
|
||||||
|
_checkInvalidWindowError();
|
||||||
|
|
||||||
|
SDL_SetWindowMinimumSize(NULL, desiredW, desiredH);
|
||||||
|
SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(window=NULL)");
|
||||||
|
_checkInvalidWindowError();
|
||||||
|
|
||||||
|
return TEST_COMPLETED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Tests call to SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
video_getSetWindowMaximumSize(void *arg)
|
||||||
|
{
|
||||||
|
const char* title = "video_getSetWindowMaximumSize Test Window";
|
||||||
|
SDL_Window* window;
|
||||||
|
int result;
|
||||||
|
SDL_Rect display;
|
||||||
|
int wVariation, hVariation;
|
||||||
|
int referenceW, referenceH;
|
||||||
|
int currentW, currentH;
|
||||||
|
int desiredW, desiredH;
|
||||||
|
|
||||||
|
/* Get display bounds for size range */
|
||||||
|
result = SDL_GetDisplayBounds(0, &display);
|
||||||
|
SDLTest_AssertPass("SDL_GetDisplayBounds()");
|
||||||
|
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
|
||||||
|
if (result != 0) return TEST_ABORTED;
|
||||||
|
|
||||||
|
/* Call against new test window */
|
||||||
|
window = _createVideoSuiteTestWindow(title);
|
||||||
|
if (window == NULL) return TEST_ABORTED;
|
||||||
|
|
||||||
|
for (wVariation = 0; wVariation < 3; wVariation++) {
|
||||||
|
for (hVariation = 0; hVariation < 3; hVariation++) {
|
||||||
|
switch(wVariation) {
|
||||||
|
case 0:
|
||||||
|
/* 1 Pixel Wide */
|
||||||
|
desiredW = 1;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
/* Random width inside screen */
|
||||||
|
desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
/* Width at screen size */
|
||||||
|
desiredW = display.w;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(hVariation) {
|
||||||
|
case 0:
|
||||||
|
/* 1 Pixel High */
|
||||||
|
desiredH = 1;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
/* Random height inside screen */
|
||||||
|
desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
/* Height at screen size */
|
||||||
|
desiredH = display.h;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set size */
|
||||||
|
SDL_SetWindowMaximumSize(window, desiredW, desiredH);
|
||||||
|
SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH);
|
||||||
|
|
||||||
|
/* Get size */
|
||||||
|
currentW = desiredW + 1;
|
||||||
|
currentH = desiredH + 1;
|
||||||
|
SDL_GetWindowMaximumSize(window, ¤tW, ¤tH);
|
||||||
|
SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize()");
|
||||||
|
SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
|
||||||
|
SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
|
||||||
|
|
||||||
|
/* Get just width */
|
||||||
|
currentW = desiredW + 1;
|
||||||
|
SDL_GetWindowMaximumSize(window, ¤tW, NULL);
|
||||||
|
SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&h=NULL)");
|
||||||
|
SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH);
|
||||||
|
|
||||||
|
/* Get just height */
|
||||||
|
currentH = desiredH + 1;
|
||||||
|
SDL_GetWindowMaximumSize(window, NULL, ¤tH);
|
||||||
|
SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL)");
|
||||||
|
SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredW, currentH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dummy call with both pointers NULL */
|
||||||
|
SDL_GetWindowMaximumSize(window, NULL, NULL);
|
||||||
|
SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&w=NULL,&h=NULL)");
|
||||||
|
|
||||||
|
/* Negative tests for parameter input */
|
||||||
|
SDL_ClearError();
|
||||||
|
SDLTest_AssertPass("Call to SDL_ClearError()");
|
||||||
|
for (desiredH = -2; desiredH < 2; desiredH++) {
|
||||||
|
for (desiredW = -2; desiredW < 2; desiredW++) {
|
||||||
|
if (desiredW <= 0 || desiredH <= 0) {
|
||||||
|
SDL_SetWindowMaximumSize(window, desiredW, desiredH);
|
||||||
|
SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH);
|
||||||
|
_checkInvalidParameterError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clean up */
|
||||||
|
_destroyVideoSuiteTestWindow(window);
|
||||||
|
|
||||||
|
/* Set some 'magic' value for later check that nothing was changed */
|
||||||
|
referenceW = SDLTest_RandomSint32();
|
||||||
|
referenceH = SDLTest_RandomSint32();
|
||||||
|
currentW = referenceW;
|
||||||
|
currentH = referenceH;
|
||||||
|
desiredW = SDLTest_RandomSint32();
|
||||||
|
desiredH = SDLTest_RandomSint32();
|
||||||
|
|
||||||
|
/* Negative tests */
|
||||||
|
SDL_ClearError();
|
||||||
|
SDLTest_AssertPass("Call to SDL_ClearError()");
|
||||||
|
SDL_GetWindowMaximumSize(NULL, ¤tW, ¤tH);
|
||||||
|
SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(window=NULL)");
|
||||||
|
SDLTest_AssertCheck(
|
||||||
|
currentW == referenceW && currentH == referenceH,
|
||||||
|
"Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d",
|
||||||
|
referenceW, referenceH,
|
||||||
|
currentW, currentH);
|
||||||
|
_checkInvalidWindowError();
|
||||||
|
|
||||||
|
SDL_GetWindowMaximumSize(NULL, NULL, NULL);
|
||||||
|
SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(NULL, NULL, NULL)");
|
||||||
|
_checkInvalidWindowError();
|
||||||
|
|
||||||
|
SDL_SetWindowMaximumSize(NULL, desiredW, desiredH);
|
||||||
|
SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(window=NULL)");
|
||||||
|
_checkInvalidWindowError();
|
||||||
|
|
||||||
return TEST_COMPLETED;
|
return TEST_COMPLETED;
|
||||||
}
|
}
|
||||||
|
@ -1160,7 +1535,7 @@ static const SDLTest_TestCaseReference videoTest15 =
|
||||||
{ (SDLTest_TestCaseFp)video_getWindowGammaRampNegative, "video_getWindowGammaRampNegative", "Get window gamma ramp against invalid input", TEST_ENABLED };
|
{ (SDLTest_TestCaseFp)video_getWindowGammaRampNegative, "video_getWindowGammaRampNegative", "Get window gamma ramp against invalid input", TEST_ENABLED };
|
||||||
|
|
||||||
static const SDLTest_TestCaseReference videoTest16 =
|
static const SDLTest_TestCaseReference videoTest16 =
|
||||||
{ (SDLTest_TestCaseFp)video_getSetWindowGrab, "video_getSetWindowGrab", "Checks SDL_GetWindowGrab and SDL_SetWindowGrab", TEST_ENABLED };
|
{ (SDLTest_TestCaseFp)video_getSetWindowGrab, "video_getSetWindowGrab", "Checks SDL_GetWindowGrab and SDL_SetWindowGrab positive and negative cases", TEST_ENABLED };
|
||||||
|
|
||||||
static const SDLTest_TestCaseReference videoTest17 =
|
static const SDLTest_TestCaseReference videoTest17 =
|
||||||
{ (SDLTest_TestCaseFp)video_getWindowId, "video_getWindowId", "Checks SDL_GetWindowID and SDL_GetWindowFromID", TEST_ENABLED };
|
{ (SDLTest_TestCaseFp)video_getWindowId, "video_getWindowId", "Checks SDL_GetWindowID and SDL_GetWindowFromID", TEST_ENABLED };
|
||||||
|
@ -1169,14 +1544,24 @@ static const SDLTest_TestCaseReference videoTest18 =
|
||||||
{ (SDLTest_TestCaseFp)video_getWindowPixelFormat, "video_getWindowPixelFormat", "Checks SDL_GetWindowPixelFormat", TEST_ENABLED };
|
{ (SDLTest_TestCaseFp)video_getWindowPixelFormat, "video_getWindowPixelFormat", "Checks SDL_GetWindowPixelFormat", TEST_ENABLED };
|
||||||
|
|
||||||
static const SDLTest_TestCaseReference videoTest19 =
|
static const SDLTest_TestCaseReference videoTest19 =
|
||||||
{ (SDLTest_TestCaseFp)video_getSetWindowPosition, "video_getSetWindowPosition", "Checks SDL_GetWindowPosition and SDL_SetWindowPosition", TEST_ENABLED };
|
{ (SDLTest_TestCaseFp)video_getSetWindowPosition, "video_getSetWindowPosition", "Checks SDL_GetWindowPosition and SDL_SetWindowPosition positive and negative cases", TEST_ENABLED };
|
||||||
|
|
||||||
|
static const SDLTest_TestCaseReference videoTest20 =
|
||||||
|
{ (SDLTest_TestCaseFp)video_getSetWindowSize, "video_getSetWindowSize", "Checks SDL_GetWindowSize and SDL_SetWindowSize positive and negative cases", TEST_ENABLED };
|
||||||
|
|
||||||
|
static const SDLTest_TestCaseReference videoTest21 =
|
||||||
|
{ (SDLTest_TestCaseFp)video_getSetWindowMinimumSize, "video_getSetWindowMinimumSize", "Checks SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize positive and negative cases", TEST_ENABLED };
|
||||||
|
|
||||||
|
static const SDLTest_TestCaseReference videoTest22 =
|
||||||
|
{ (SDLTest_TestCaseFp)video_getSetWindowMaximumSize, "video_getSetWindowMaximumSize", "Checks SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize positive and negative cases", TEST_ENABLED };
|
||||||
|
|
||||||
/* Sequence of Video test cases */
|
/* Sequence of Video test cases */
|
||||||
static const SDLTest_TestCaseReference *videoTests[] = {
|
static const SDLTest_TestCaseReference *videoTests[] = {
|
||||||
&videoTest1, &videoTest2, &videoTest3, &videoTest4, &videoTest5, &videoTest6,
|
&videoTest1, &videoTest2, &videoTest3, &videoTest4, &videoTest5, &videoTest6,
|
||||||
&videoTest7, &videoTest8, &videoTest9, &videoTest10, &videoTest11, &videoTest12,
|
&videoTest7, &videoTest8, &videoTest9, &videoTest10, &videoTest11, &videoTest12,
|
||||||
&videoTest13, &videoTest14, &videoTest15, &videoTest16, &videoTest17,
|
&videoTest13, &videoTest14, &videoTest15, &videoTest16, &videoTest17,
|
||||||
&videoTest18, &videoTest19, NULL
|
&videoTest18, &videoTest19, &videoTest20, &videoTest21, &videoTest22,
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Video test suite (global) */
|
/* Video test suite (global) */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue