Only test error message when using specific video drivers

The dummy driver does not sen an error message when passing
a NULL rect argument to SDL_SetTextInputRect.
This commit is contained in:
Anonymous Maarten 2023-10-14 01:17:36 +02:00 committed by Anonymous Maarten
parent 5368f45567
commit 811adaa342

View file

@ -463,21 +463,23 @@ int keyboard_setTextInputRect(void *arg)
*/ */
int keyboard_setTextInputRectNegative(void *arg) int keyboard_setTextInputRectNegative(void *arg)
{ {
int platform_sets_error_message = SDL_strcmp(SDL_GetCurrentVideoDriver(), "windows") == 0 ||
SDL_strcmp(SDL_GetCurrentVideoDriver(), "android") == 0 ||
SDL_strcmp(SDL_GetCurrentVideoDriver(), "cococa") == 0;
/* Some platforms set also an error message; prepare for checking it */ /* Some platforms set also an error message; prepare for checking it */
#if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_ANDROID) || defined(SDL_VIDEO_DRIVER_COCOA)
const char *expectedError = "Parameter 'rect' is invalid"; const char *expectedError = "Parameter 'rect' is invalid";
const char *error; const char *error;
SDL_ClearError(); SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()"); SDLTest_AssertPass("Call to SDL_ClearError()");
#endif
/* NULL refRect */ /* NULL refRect */
SDL_SetTextInputRect(NULL); SDL_SetTextInputRect(NULL);
SDLTest_AssertPass("Call to SDL_SetTextInputRect(NULL)"); SDLTest_AssertPass("Call to SDL_SetTextInputRect(NULL)");
/* Some platforms set also an error message; so check it */ /* Some platforms set also an error message; so check it */
#if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_ANDROID) || defined(SDL_VIDEO_DRIVER_COCOA)
if (platform_sets_error_message) {
error = SDL_GetError(); error = SDL_GetError();
SDLTest_AssertPass("Call to SDL_GetError()"); SDLTest_AssertPass("Call to SDL_GetError()");
SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
@ -485,10 +487,10 @@ int keyboard_setTextInputRectNegative(void *arg)
SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
"Validate error message, expected: '%s', got: '%s'", expectedError, error); "Validate error message, expected: '%s', got: '%s'", expectedError, error);
} }
}
SDL_ClearError(); SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()"); SDLTest_AssertPass("Call to SDL_ClearError()");
#endif
return TEST_COMPLETED; return TEST_COMPLETED;
} }