1.1 --- a/test/testautomation_keyboard.c Sun Jan 13 14:31:53 2013 -0800
1.2 +++ b/test/testautomation_keyboard.c Sun Jan 13 22:55:26 2013 -0800
1.3 @@ -4,6 +4,7 @@
1.4
1.5 #include <stdio.h>
1.6
1.7 +#include "SDL_config.h"
1.8 #include "SDL.h"
1.9 #include "SDL_test.h"
1.10
1.11 @@ -110,6 +111,8 @@
1.12 int
1.13 keyboard_getKeyFromScancode(void *arg)
1.14 {
1.15 + const char *expectedError = "Parameter 'scancode' is invalid";
1.16 + const char *error;
1.17 SDL_Keycode result;
1.18
1.19 /* Case where input is valid */
1.20 @@ -119,13 +122,41 @@
1.21
1.22 /* Case where input is zero */
1.23 result = SDL_GetKeyFromScancode(0);
1.24 - SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(zero)");
1.25 + SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(0)");
1.26 SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result);
1.27
1.28 - /* Case where input is invalid */
1.29 + SDL_ClearError();
1.30 + SDLTest_AssertPass("Call to SDL_ClearError()");
1.31 +
1.32 + /* Case where input is invalid (too small) */
1.33 result = SDL_GetKeyFromScancode(-999);
1.34 - SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(invalid)");
1.35 + SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(-999)");
1.36 SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result);
1.37 + error = SDL_GetError();
1.38 + SDLTest_AssertPass("Call to SDL_GetError()");
1.39 + SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
1.40 + if (error != NULL) {
1.41 + SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
1.42 + "Validate error message, expected: '%s', got: '%s'", expectedError, error);
1.43 + }
1.44 +
1.45 + SDL_ClearError();
1.46 + SDLTest_AssertPass("Call to SDL_ClearError()");
1.47 +
1.48 + /* Case where input is invalid (too big) */
1.49 + result = SDL_GetKeyFromScancode(999);
1.50 + SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(999)");
1.51 + SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result);
1.52 + error = SDL_GetError();
1.53 + SDLTest_AssertPass("Call to SDL_GetError()");
1.54 + SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
1.55 + if (error != NULL) {
1.56 + SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
1.57 + "Validate error message, expected: '%s', got: '%s'", expectedError, error);
1.58 + }
1.59 +
1.60 + SDL_ClearError();
1.61 + SDLTest_AssertPass("Call to SDL_ClearError()");
1.62
1.63 return TEST_COMPLETED;
1.64 }
1.65 @@ -382,15 +413,21 @@
1.66 int
1.67 keyboard_setTextInputRectNegative(void *arg)
1.68 {
1.69 + /* Some platforms set also an error message; prepare for checking it */
1.70 +#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA
1.71 const char *expectedError = "Parameter 'rect' is invalid";
1.72 const char *error;
1.73
1.74 SDL_ClearError();
1.75 SDLTest_AssertPass("Call to SDL_ClearError()");
1.76 +#endif
1.77
1.78 /* NULL refRect */
1.79 SDL_SetTextInputRect(NULL);
1.80 SDLTest_AssertPass("Call to SDL_SetTextInputRect(NULL)");
1.81 +
1.82 + /* Some platforms set also an error message; so check it */
1.83 +#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA
1.84 error = SDL_GetError();
1.85 SDLTest_AssertPass("Call to SDL_GetError()");
1.86 SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
1.87 @@ -401,6 +438,7 @@
1.88
1.89 SDL_ClearError();
1.90 SDLTest_AssertPass("Call to SDL_ClearError()");
1.91 +#endif
1.92
1.93 return TEST_COMPLETED;
1.94 }