SDL  2.0
testautomation_keyboard.c File Reference
#include <stdio.h>
#include <limits.h>
#include "SDL_config.h"
#include "SDL.h"
#include "SDL_test.h"
+ Include dependency graph for testautomation_keyboard.c:

Go to the source code of this file.

Functions

int keyboard_getKeyboardState (void *arg)
 Check call to SDL_GetKeyboardState with and without numkeys reference.
int keyboard_getKeyboardFocus (void *arg)
 Check call to SDL_GetKeyboardFocus.
int keyboard_getKeyFromName (void *arg)
 Check call to SDL_GetKeyFromName for known, unknown and invalid name.
void _checkInvalidScancodeError ()
int keyboard_getKeyFromScancode (void *arg)
 Check call to SDL_GetKeyFromScancode.
int keyboard_getKeyName (void *arg)
 Check call to SDL_GetKeyName.
int keyboard_getScancodeNameNegative (void *arg)
 SDL_GetScancodeName negative cases.
int keyboard_getKeyNameNegative (void *arg)
 SDL_GetKeyName negative cases.
int keyboard_getSetModState (void *arg)
 Check call to SDL_GetModState and SDL_SetModState.
int keyboard_startStopTextInput (void *arg)
 Check call to SDL_StartTextInput and SDL_StopTextInput.
void _testSetTextInputRect (SDL_Rect refRect)
int keyboard_setTextInputRect (void *arg)
 Check call to SDL_SetTextInputRect.
int keyboard_setTextInputRectNegative (void *arg)
 Check call to SDL_SetTextInputRect with invalid data.
int keyboard_getScancodeFromKey (void *arg)
 Check call to SDL_GetScancodeFromKey.
int keyboard_getScancodeFromName (void *arg)
 Check call to SDL_GetScancodeFromName.
void _checkInvalidNameError ()
int keyboard_getScancodeFromNameNegative (void *arg)
 Check call to SDL_GetScancodeFromName with invalid data.

Variables

static const
SDLTest_TestCaseReference 
keyboardTest1
static const
SDLTest_TestCaseReference 
keyboardTest2
static const
SDLTest_TestCaseReference 
keyboardTest3
static const
SDLTest_TestCaseReference 
keyboardTest4
static const
SDLTest_TestCaseReference 
keyboardTest5
static const
SDLTest_TestCaseReference 
keyboardTest6
static const
SDLTest_TestCaseReference 
keyboardTest7
static const
SDLTest_TestCaseReference 
keyboardTest8
static const
SDLTest_TestCaseReference 
keyboardTest9
static const
SDLTest_TestCaseReference 
keyboardTest10
static const
SDLTest_TestCaseReference 
keyboardTest11
static const
SDLTest_TestCaseReference 
keyboardTest12
static const
SDLTest_TestCaseReference 
keyboardTest13
static const
SDLTest_TestCaseReference 
keyboardTest14
static const
SDLTest_TestCaseReference
keyboardTests []
SDLTest_TestSuiteReference keyboardTestSuite

Function Documentation

void _checkInvalidNameError ( )

Definition at line 593 of file testautomation_keyboard.c.

References NULL, SDL_ClearError, SDL_GetError, SDL_strcmp, SDLTest_AssertCheck(), and SDLTest_AssertPass().

Referenced by keyboard_getScancodeFromNameNegative().

{
const char *expectedError = "Parameter 'name' is invalid";
const char *error;
error = SDL_GetError();
SDLTest_AssertPass("Call to SDL_GetError()");
SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
if (error != NULL) {
SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
"Validate error message, expected: '%s', got: '%s'", expectedError, error);
SDLTest_AssertPass("Call to SDL_ClearError()");
}
}
void _checkInvalidScancodeError ( )

Definition at line 111 of file testautomation_keyboard.c.

References NULL, SDL_ClearError, SDL_GetError, SDL_strcmp, SDLTest_AssertCheck(), and SDLTest_AssertPass().

Referenced by keyboard_getKeyFromScancode(), keyboard_getKeyNameNegative(), and keyboard_getScancodeNameNegative().

{
const char *expectedError = "Parameter 'scancode' is invalid";
const char *error;
error = SDL_GetError();
SDLTest_AssertPass("Call to SDL_GetError()");
SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
if (error != NULL) {
SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
"Validate error message, expected: '%s', got: '%s'", expectedError, error);
SDLTest_AssertPass("Call to SDL_ClearError()");
}
}
void _testSetTextInputRect ( SDL_Rect  refRect)

Definition at line 379 of file testautomation_keyboard.c.

References SDL_Rect::h, SDL_SetTextInputRect, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

Referenced by keyboard_setTextInputRect().

{
SDL_Rect testRect;
testRect = refRect;
SDLTest_AssertPass("Call to SDL_SetTextInputRect with refRect(x:%i,y:%i,w:%i,h:%i)", refRect.x, refRect.y, refRect.w, refRect.h);
(refRect.x == testRect.x) && (refRect.y == testRect.y) && (refRect.w == testRect.w) && (refRect.h == testRect.h),
"Check that input data was not modified, expected: x:%i,y:%i,w:%i,h:%i, got: x:%i,y:%i,w:%i,h:%i",
refRect.x, refRect.y, refRect.w, refRect.h,
testRect.x, testRect.y, testRect.w, testRect.h);
}
int keyboard_getKeyboardFocus ( void arg)

Check call to SDL_GetKeyboardFocus.

See Also
http://wiki.libsdl.org/moin.cgi/SDL_GetKeyboardFocus

Definition at line 48 of file testautomation_keyboard.c.

References SDL_GetKeyboardFocus, SDLTest_AssertPass(), and TEST_COMPLETED.

{
/* Call, but ignore return value */
SDLTest_AssertPass("Call to SDL_GetKeyboardFocus()");
}
int keyboard_getKeyboardState ( void arg)

Check call to SDL_GetKeyboardState with and without numkeys reference.

Keyboard test suite

See Also
http://wiki.libsdl.org/moin.cgi/SDL_GetKeyboardState

Definition at line 22 of file testautomation_keyboard.c.

References NULL, SDL_GetKeyboardState, SDLTest_AssertCheck(), SDLTest_AssertPass(), state, and TEST_COMPLETED.

{
int numkeys;
/* Case where numkeys pointer is NULL */
SDLTest_AssertPass("Call to SDL_GetKeyboardState(NULL)");
SDLTest_AssertCheck(state != NULL, "Validate that return value from SDL_GetKeyboardState is not NULL");
/* Case where numkeys pointer is not NULL */
numkeys = -1;
state = (Uint8 *)SDL_GetKeyboardState(&numkeys);
SDLTest_AssertPass("Call to SDL_GetKeyboardState(&numkeys)");
SDLTest_AssertCheck(state != NULL, "Validate that return value from SDL_GetKeyboardState is not NULL");
SDLTest_AssertCheck(numkeys >= 0, "Validate that value of numkeys is >= 0, got: %i", numkeys);
}
int keyboard_getKeyFromName ( void arg)

Check call to SDL_GetKeyFromName for known, unknown and invalid name.

See Also
http://wiki.libsdl.org/moin.cgi/SDL_GetKeyFromName

Definition at line 65 of file testautomation_keyboard.c.

References NULL, SDL_GetKeyFromName, SDLK_a, SDLK_AUDIOSTOP, SDLK_END, SDLK_F1, SDLK_FIND, SDLK_UNKNOWN, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

{
/* Case where Key is known, 1 character input */
result = SDL_GetKeyFromName("A");
SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/single)");
SDLTest_AssertCheck(result == SDLK_a, "Verify result from call, expected: %i, got: %i", SDLK_a, result);
/* Case where Key is known, 2 character input */
result = SDL_GetKeyFromName("F1");
SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/double)");
SDLTest_AssertCheck(result == SDLK_F1, "Verify result from call, expected: %i, got: %i", SDLK_F1, result);
/* Case where Key is known, 3 character input */
result = SDL_GetKeyFromName("End");
SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/triple)");
SDLTest_AssertCheck(result == SDLK_END, "Verify result from call, expected: %i, got: %i", SDLK_END, result);
/* Case where Key is known, 4 character input */
result = SDL_GetKeyFromName("Find");
SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/quad)");
SDLTest_AssertCheck(result == SDLK_FIND, "Verify result from call, expected: %i, got: %i", SDLK_FIND, result);
/* Case where Key is known, multiple character input */
result = SDL_GetKeyFromName("AudioStop");
SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/multi)");
SDLTest_AssertCheck(result == SDLK_AUDIOSTOP, "Verify result from call, expected: %i, got: %i", SDLK_AUDIOSTOP, result);
/* Case where Key is unknown */
result = SDL_GetKeyFromName("NotThere");
SDLTest_AssertPass("Call to SDL_GetKeyFromName(unknown)");
SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result);
/* Case where input is NULL/invalid */
SDLTest_AssertPass("Call to SDL_GetKeyFromName(NULL)");
SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result);
}
int keyboard_getKeyFromScancode ( void arg)

Check call to SDL_GetKeyFromScancode.

See Also
http://wiki.libsdl.org/moin.cgi/SDL_GetKeyFromScancode

Definition at line 132 of file testautomation_keyboard.c.

References _checkInvalidScancodeError(), SDL_ClearError, SDL_GetKeyFromScancode, SDL_SCANCODE_A, SDLK_a, SDLK_UNKNOWN, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

{
/* Case where input is valid */
SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(valid)");
SDLTest_AssertCheck(result == SDLK_a, "Verify result from call, expected: %i, got: %i", SDLK_a, result);
/* Case where input is zero */
SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(0)");
SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result);
/* Clear error message */
SDLTest_AssertPass("Call to SDL_ClearError()");
/* Case where input is invalid (too small) */
result = SDL_GetKeyFromScancode(-999);
SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(-999)");
SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result);
/* Case where input is invalid (too big) */
result = SDL_GetKeyFromScancode(999);
SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(999)");
SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result);
}
int keyboard_getKeyName ( void arg)

Check call to SDL_GetKeyName.

See Also
http://wiki.libsdl.org/moin.cgi/SDL_GetKeyName

Definition at line 171 of file testautomation_keyboard.c.

References NULL, SDL_GetKeyName, SDL_strcmp, SDLK_3, SDLK_BRIGHTNESSUP, SDLK_CUT, SDLK_DOWN, SDLK_F1, SDLK_KP_MEMSTORE, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

{
char *result;
char *expected;
/* Case where key has a 1 character name */
expected = "3";
result = (char *)SDL_GetKeyName(SDLK_3);
SDLTest_AssertPass("Call to SDL_GetKeyName()");
SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result);
/* Case where key has a 2 character name */
expected = "F1";
result = (char *)SDL_GetKeyName(SDLK_F1);
SDLTest_AssertPass("Call to SDL_GetKeyName()");
SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result);
/* Case where key has a 3 character name */
expected = "Cut";
result = (char *)SDL_GetKeyName(SDLK_CUT);
SDLTest_AssertPass("Call to SDL_GetKeyName()");
SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result);
/* Case where key has a 4 character name */
expected = "Down";
result = (char *)SDL_GetKeyName(SDLK_DOWN);
SDLTest_AssertPass("Call to SDL_GetKeyName()");
SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result);
/* Case where key has a N character name */
expected = "BrightnessUp";
result = (char *)SDL_GetKeyName(SDLK_BRIGHTNESSUP);
SDLTest_AssertPass("Call to SDL_GetKeyName()");
SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result);
/* Case where key has a N character name with space */
expected = "Keypad MemStore";
result = (char *)SDL_GetKeyName(SDLK_KP_MEMSTORE);
SDLTest_AssertPass("Call to SDL_GetKeyName()");
SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result);
}
int keyboard_getKeyNameNegative ( void arg)

SDL_GetKeyName negative cases.

See Also
http://wiki.libsdl.org/moin.cgi/SDL_GetKeyName

Definition at line 254 of file testautomation_keyboard.c.

References _checkInvalidScancodeError(), NULL, SDL_ClearError, SDL_GetKeyName, SDL_strcmp, SDLK_UNKNOWN, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_RandomIntegerInRange(), and TEST_COMPLETED.

{
SDL_Keycode keycode;
char *result;
char *expected = "";
/* Unknown keycode */
keycode = SDLK_UNKNOWN;
result = (char *)SDL_GetKeyName(keycode);
SDLTest_AssertPass("Call to SDL_GetKeyName(%d/unknown)", keycode);
SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: '%s', got: '%s'", expected, result);
/* Clear error message */
SDLTest_AssertPass("Call to SDL_ClearError()");
/* Negative keycode */
result = (char *)SDL_GetKeyName(keycode);
SDLTest_AssertPass("Call to SDL_GetKeyName(%d/negative)", keycode);
SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: '%s', got: '%s'", expected, result);
SDLTest_AssertPass("Call to SDL_ClearError()");
}
int keyboard_getScancodeFromKey ( void arg)

Check call to SDL_GetScancodeFromKey.

See Also
http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromKey
http://wiki.libsdl.org/moin.cgi/SDL_Keycode

Definition at line 518 of file testautomation_keyboard.c.

References SDL_GetScancodeFromKey, SDL_SCANCODE_4, SDLK_4, SDLK_PLUS, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

{
SDL_Scancode scancode;
/* Regular key */
SDLTest_AssertPass("Call to SDL_GetScancodeFromKey(SDLK_4)");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromKey, expected: %i, got: %i", SDL_SCANCODE_4, scancode);
/* Virtual key */
SDLTest_AssertPass("Call to SDL_GetScancodeFromKey(SDLK_PLUS)");
SDLTest_AssertCheck(scancode == 0, "Validate return value from SDL_GetScancodeFromKey, expected: 0, got: %i", scancode);
}
int keyboard_getScancodeFromName ( void arg)

Check call to SDL_GetScancodeFromName.

See Also
http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromName
http://wiki.libsdl.org/moin.cgi/SDL_Keycode

Definition at line 542 of file testautomation_keyboard.c.

References SDL_GetScancodeFromName, SDL_SCANCODE_4, SDL_SCANCODE_A, SDL_SCANCODE_BACKSPACE, SDL_SCANCODE_END, SDL_SCANCODE_F1, SDL_SCANCODE_FIND, SDL_SCANCODE_KP_ENTER, SDL_SCANCODE_SLEEP, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

{
SDL_Scancode scancode;
/* Regular key, 1 character, first name in list */
scancode = SDL_GetScancodeFromName("A");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('A')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_A, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_A, scancode);
/* Regular key, 1 character */
scancode = SDL_GetScancodeFromName("4");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('4')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_4, scancode);
/* Regular key, 2 characters */
scancode = SDL_GetScancodeFromName("F1");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('F1')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_F1, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_F1, scancode);
/* Regular key, 3 characters */
scancode = SDL_GetScancodeFromName("End");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('End')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_END, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_END, scancode);
/* Regular key, 4 characters */
scancode = SDL_GetScancodeFromName("Find");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Find')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_FIND, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_FIND, scancode);
/* Regular key, several characters */
scancode = SDL_GetScancodeFromName("Backspace");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Backspace')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_BACKSPACE, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_BACKSPACE, scancode);
/* Regular key, several characters with space */
scancode = SDL_GetScancodeFromName("Keypad Enter");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Keypad Enter')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_KP_ENTER, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_KP_ENTER, scancode);
/* Regular key, last name in list */
scancode = SDL_GetScancodeFromName("Sleep");
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Sleep')");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_SLEEP, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_SLEEP, scancode);
}
int keyboard_getScancodeFromNameNegative ( void arg)

Check call to SDL_GetScancodeFromName with invalid data.

See Also
http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromName
http://wiki.libsdl.org/moin.cgi/SDL_Keycode

Definition at line 615 of file testautomation_keyboard.c.

References _checkInvalidNameError(), NULL, SDL_ClearError, SDL_free, SDL_GetScancodeFromName, SDL_SCANCODE_UNKNOWN, SDLTest_Assert(), SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_RandomAsciiStringOfSize(), TEST_ABORTED, and TEST_COMPLETED.

{
char *name;
SDL_Scancode scancode;
/* Clear error message */
SDLTest_AssertPass("Call to SDL_ClearError()");
/* Random string input */
SDLTest_Assert(name != NULL, "Check that random name is not NULL");
if (name == NULL) {
return TEST_ABORTED;
}
scancode = SDL_GetScancodeFromName((const char *)name);
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('%s')", name);
SDL_free(name);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode);
/* Zero length string input */
name = "";
scancode = SDL_GetScancodeFromName((const char *)name);
SDLTest_AssertPass("Call to SDL_GetScancodeFromName(NULL)");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode);
/* NULL input */
name = NULL;
scancode = SDL_GetScancodeFromName((const char *)name);
SDLTest_AssertPass("Call to SDL_GetScancodeFromName(NULL)");
SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode);
}
int keyboard_getScancodeNameNegative ( void arg)

SDL_GetScancodeName negative cases.

See Also
http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeName

Definition at line 227 of file testautomation_keyboard.c.

References _checkInvalidScancodeError(), NULL, SDL_ClearError, SDL_GetScancodeName, SDL_NUM_SCANCODES, SDL_strcmp, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

{
SDL_Scancode scancode;
char *result;
char *expected = "";
/* Clear error message */
SDLTest_AssertPass("Call to SDL_ClearError()");
/* Out-of-bounds scancode */
result = (char *)SDL_GetScancodeName(scancode);
SDLTest_AssertPass("Call to SDL_GetScancodeName(%d/large)", scancode);
SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: '%s', got: '%s'", expected, result);
}
int keyboard_getSetModState ( void arg)

Check call to SDL_GetModState and SDL_SetModState.

See Also
http://wiki.libsdl.org/moin.cgi/SDL_GetModState
http://wiki.libsdl.org/moin.cgi/SDL_SetModState

Definition at line 292 of file testautomation_keyboard.c.

References KMOD_CAPS, KMOD_LALT, KMOD_LCTRL, KMOD_LGUI, KMOD_LSHIFT, KMOD_MODE, KMOD_NONE, KMOD_NUM, KMOD_RALT, KMOD_RCTRL, KMOD_RESERVED, KMOD_RGUI, KMOD_RSHIFT, SDL_GetModState, SDL_SetModState, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_RandomIntegerInRange(), and TEST_COMPLETED.

{
SDL_Keymod currentState;
SDL_Keymod newState;
SDL_Keymod allStates =
/* Get state, cache for later reset */
result = SDL_GetModState();
SDLTest_AssertPass("Call to SDL_GetModState()");
SDLTest_AssertCheck(/*result >= 0 &&*/ result <= allStates, "Verify result from call is valid, expected: 0 <= result <= %i, got: %i", allStates, result);
currentState = result;
/* Set random state */
newState = SDLTest_RandomIntegerInRange(0, allStates);
SDL_SetModState(newState);
SDLTest_AssertPass("Call to SDL_SetModState(%i)", newState);
result = SDL_GetModState();
SDLTest_AssertPass("Call to SDL_GetModState()");
SDLTest_AssertCheck(result == newState, "Verify result from call is valid, expected: %i, got: %i", newState, result);
/* Set zero state */
SDLTest_AssertPass("Call to SDL_SetModState(0)");
result = SDL_GetModState();
SDLTest_AssertPass("Call to SDL_GetModState()");
SDLTest_AssertCheck(result == 0, "Verify result from call is valid, expected: 0, got: %i", result);
/* Revert back to cached current state if needed */
if (currentState != 0) {
SDL_SetModState(currentState);
SDLTest_AssertPass("Call to SDL_SetModState(%i)", currentState);
result = SDL_GetModState();
SDLTest_AssertPass("Call to SDL_GetModState()");
SDLTest_AssertCheck(result == currentState, "Verify result from call is valid, expected: %i, got: %i", currentState, result);
}
}
int keyboard_setTextInputRect ( void arg)

Check call to SDL_SetTextInputRect.

See Also
http://wiki.libsdl.org/moin.cgi/SDL_SetTextInputRect

Definition at line 399 of file testautomation_keyboard.c.

References _testSetTextInputRect(), SDL_Rect::h, NULL, SDL_SetTextInputRect, SDLTest_AssertPass(), SDLTest_RandomIntegerInRange(), TEST_COMPLETED, SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

{
SDL_Rect refRect;
/* Normal visible refRect, origin inside */
refRect.x = SDLTest_RandomIntegerInRange(1, 50);
refRect.y = SDLTest_RandomIntegerInRange(1, 50);
refRect.w = SDLTest_RandomIntegerInRange(10, 50);
refRect.h = SDLTest_RandomIntegerInRange(10, 50);
/* Normal visible refRect, origin 0,0 */
refRect.x = 0;
refRect.y = 0;
refRect.w = SDLTest_RandomIntegerInRange(10, 50);
refRect.h = SDLTest_RandomIntegerInRange(10, 50);
/* 1Pixel refRect */
refRect.x = SDLTest_RandomIntegerInRange(10, 50);
refRect.y = SDLTest_RandomIntegerInRange(10, 50);
refRect.w = 1;
refRect.h = 1;
/* 0pixel refRect */
refRect.x = 1;
refRect.y = 1;
refRect.w = 1;
refRect.h = 0;
/* 0pixel refRect */
refRect.x = 1;
refRect.y = 1;
refRect.w = 0;
refRect.h = 1;
/* 0pixel refRect */
refRect.x = 1;
refRect.y = 1;
refRect.w = 0;
refRect.h = 0;
/* 0pixel refRect */
refRect.x = 0;
refRect.y = 0;
refRect.w = 0;
refRect.h = 0;
/* negative refRect */
refRect.x = SDLTest_RandomIntegerInRange(-200, -100);
refRect.y = SDLTest_RandomIntegerInRange(-200, -100);
refRect.w = 50;
refRect.h = 50;
/* oversized refRect */
refRect.x = SDLTest_RandomIntegerInRange(1, 50);
refRect.y = SDLTest_RandomIntegerInRange(1, 50);
refRect.w = 5000;
refRect.h = 5000;
/* NULL refRect */
SDLTest_AssertPass("Call to SDL_SetTextInputRect(NULL)");
}
int keyboard_setTextInputRectNegative ( void arg)

Check call to SDL_SetTextInputRect with invalid data.

See Also
http://wiki.libsdl.org/moin.cgi/SDL_SetTextInputRect

Definition at line 479 of file testautomation_keyboard.c.

References NULL, SDL_ClearError, SDL_GetError, SDL_SetTextInputRect, SDL_strcmp, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

{
/* Some platforms set also an error message; prepare for checking it */
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA
const char *expectedError = "Parameter 'rect' is invalid";
const char *error;
SDLTest_AssertPass("Call to SDL_ClearError()");
#endif
/* NULL refRect */
SDLTest_AssertPass("Call to SDL_SetTextInputRect(NULL)");
/* Some platforms set also an error message; so check it */
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA
error = SDL_GetError();
SDLTest_AssertPass("Call to SDL_GetError()");
SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
if (error != NULL) {
SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
"Validate error message, expected: '%s', got: '%s'", expectedError, error);
}
SDLTest_AssertPass("Call to SDL_ClearError()");
#endif
}
int keyboard_startStopTextInput ( void arg)

Check call to SDL_StartTextInput and SDL_StopTextInput.

See Also
http://wiki.libsdl.org/moin.cgi/SDL_StartTextInput
http://wiki.libsdl.org/moin.cgi/SDL_StopTextInput

Definition at line 353 of file testautomation_keyboard.c.

References SDL_StartTextInput, SDL_StopTextInput, SDLTest_AssertPass(), and TEST_COMPLETED.

{
/* Start-Stop */
SDLTest_AssertPass("Call to SDL_StartTextInput()");
SDLTest_AssertPass("Call to SDL_StopTextInput()");
/* Stop-Start */
SDLTest_AssertPass("Call to SDL_StartTextInput()");
/* Start-Start */
SDLTest_AssertPass("Call to SDL_StartTextInput()");
/* Stop-Stop */
SDLTest_AssertPass("Call to SDL_StopTextInput()");
SDLTest_AssertPass("Call to SDL_StopTextInput()");
}

Variable Documentation

const SDLTest_TestCaseReference keyboardTest1
static
Initial value:
{ (SDLTest_TestCaseFp)keyboard_getKeyboardState, "keyboard_getKeyboardState", "Check call to SDL_GetKeyboardState with and without numkeys reference", TEST_ENABLED }

Definition at line 658 of file testautomation_keyboard.c.

const SDLTest_TestCaseReference keyboardTest10
static
Initial value:
{ (SDLTest_TestCaseFp)keyboard_getScancodeFromKey, "keyboard_getScancodeFromKey", "Check call to SDL_GetScancodeFromKey", TEST_ENABLED }

Definition at line 685 of file testautomation_keyboard.c.

const SDLTest_TestCaseReference keyboardTest11
static
Initial value:
{ (SDLTest_TestCaseFp)keyboard_getScancodeFromName, "keyboard_getScancodeFromName", "Check call to SDL_GetScancodeFromName", TEST_ENABLED }

Definition at line 688 of file testautomation_keyboard.c.

const SDLTest_TestCaseReference keyboardTest12
static
Initial value:
{ (SDLTest_TestCaseFp)keyboard_getScancodeFromNameNegative, "keyboard_getScancodeFromNameNegative", "Check call to SDL_GetScancodeFromName with invalid data", TEST_ENABLED }

Definition at line 691 of file testautomation_keyboard.c.

const SDLTest_TestCaseReference keyboardTest13
static
Initial value:
{ (SDLTest_TestCaseFp)keyboard_getKeyNameNegative, "keyboard_getKeyNameNegative", "Check call to SDL_GetKeyName with invalid data", TEST_ENABLED }

Definition at line 694 of file testautomation_keyboard.c.

const SDLTest_TestCaseReference keyboardTest14
static
Initial value:
{ (SDLTest_TestCaseFp)keyboard_getScancodeNameNegative, "keyboard_getScancodeNameNegative", "Check call to SDL_GetScancodeName with invalid data", TEST_ENABLED }

Definition at line 697 of file testautomation_keyboard.c.

const SDLTest_TestCaseReference keyboardTest2
static
Initial value:
{ (SDLTest_TestCaseFp)keyboard_getKeyboardFocus, "keyboard_getKeyboardFocus", "Check call to SDL_GetKeyboardFocus", TEST_ENABLED }

Definition at line 661 of file testautomation_keyboard.c.

const SDLTest_TestCaseReference keyboardTest3
static
Initial value:
{ (SDLTest_TestCaseFp)keyboard_getKeyFromName, "keyboard_getKeyFromName", "Check call to SDL_GetKeyFromName for known, unknown and invalid name", TEST_ENABLED }

Definition at line 664 of file testautomation_keyboard.c.

const SDLTest_TestCaseReference keyboardTest4
static
Initial value:
{ (SDLTest_TestCaseFp)keyboard_getKeyFromScancode, "keyboard_getKeyFromScancode", "Check call to SDL_GetKeyFromScancode", TEST_ENABLED }

Definition at line 667 of file testautomation_keyboard.c.

const SDLTest_TestCaseReference keyboardTest5
static
Initial value:
{ (SDLTest_TestCaseFp)keyboard_getKeyName, "keyboard_getKeyName", "Check call to SDL_GetKeyName", TEST_ENABLED }

Definition at line 670 of file testautomation_keyboard.c.

const SDLTest_TestCaseReference keyboardTest6
static
Initial value:
{ (SDLTest_TestCaseFp)keyboard_getSetModState, "keyboard_getSetModState", "Check call to SDL_GetModState and SDL_SetModState", TEST_ENABLED }

Definition at line 673 of file testautomation_keyboard.c.

const SDLTest_TestCaseReference keyboardTest7
static
Initial value:
{ (SDLTest_TestCaseFp)keyboard_startStopTextInput, "keyboard_startStopTextInput", "Check call to SDL_StartTextInput and SDL_StopTextInput", TEST_ENABLED }

Definition at line 676 of file testautomation_keyboard.c.

const SDLTest_TestCaseReference keyboardTest8
static
Initial value:
{ (SDLTest_TestCaseFp)keyboard_setTextInputRect, "keyboard_setTextInputRect", "Check call to SDL_SetTextInputRect", TEST_ENABLED }

Definition at line 679 of file testautomation_keyboard.c.

const SDLTest_TestCaseReference keyboardTest9
static
Initial value:
{ (SDLTest_TestCaseFp)keyboard_setTextInputRectNegative, "keyboard_setTextInputRectNegative", "Check call to SDL_SetTextInputRect with invalid data", TEST_ENABLED }

Definition at line 682 of file testautomation_keyboard.c.

SDLTest_TestSuiteReference keyboardTestSuite
Initial value:
{
"Keyboard",
}

Definition at line 708 of file testautomation_keyboard.c.