test/testautomation_keyboard.c
changeset 6800 26c6795ec1a4
child 6803 fbe83a6d10fa
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/testautomation_keyboard.c	Sun Jan 06 15:17:59 2013 -0800
     1.3 @@ -0,0 +1,61 @@
     1.4 +/**
     1.5 + * Keyboard test suite
     1.6 + */
     1.7 +
     1.8 +#include <stdio.h>
     1.9 +
    1.10 +#include "SDL.h"
    1.11 +#include "SDL_test.h"
    1.12 +
    1.13 +/* ================= Test Case Implementation ================== */
    1.14 +
    1.15 +/*!
    1.16 + * TODO: Add tests for keyboard here
    1.17 + *
    1.18 + */
    1.19 +
    1.20 +/* Test case functions */
    1.21 +
    1.22 +/**
    1.23 + * @brief Check call to SDL_GetKeyboardState
    1.24 + * 
    1.25 + */
    1.26 +int
    1.27 +keyboard_getKeyboardState(void *arg)
    1.28 +{
    1.29 +   int numkeys;
    1.30 +   Uint8 *state;
    1.31 +
    1.32 +   /* Case where numkeys pointer is NULL */    
    1.33 +   state = SDL_GetKeyboardState(NULL);
    1.34 +   SDLTest_AssertPass("Call to SDL_GetKeyboardState(NULL)");
    1.35 +   SDLTest_AssertCheck(state != NULL, "Validate that return value from SDL_GetKeyboardState is not NULL");
    1.36 +
    1.37 +   /* Case where numkeys pointer is not NULL */
    1.38 +   numkeys = -1;
    1.39 +   state = SDL_GetKeyboardState(&numkeys);
    1.40 +   SDLTest_AssertPass("Call to SDL_GetKeyboardState(&numkeys)");
    1.41 +   SDLTest_AssertCheck(state != NULL, "Validate that return value from SDL_GetKeyboardState is not NULL");
    1.42 +   SDLTest_AssertCheck(numkeys >= 0, "Validate that value of numkeys is >= 0, got: %i", numkeys);
    1.43 +   
    1.44 +   return TEST_COMPLETED;
    1.45 +}
    1.46 +
    1.47 +/* ================= Test References ================== */
    1.48 +
    1.49 +/* Keyboard test cases */
    1.50 +static const SDLTest_TestCaseReference keyboardTest1 =
    1.51 +		{ (SDLTest_TestCaseFp)keyboard_getKeyboardState, "keyboard_getKeyboardState", "Check call to SDL_GetKeyboardState", TEST_ENABLED };
    1.52 +
    1.53 +/* Sequence of Keyboard test cases */
    1.54 +static const SDLTest_TestCaseReference *keyboardTests[] =  {
    1.55 +	&keyboardTest1, NULL
    1.56 +};
    1.57 +
    1.58 +/* Keyboard test suite (global) */
    1.59 +SDLTest_TestSuiteReference keyboardTestSuite = {
    1.60 +	"Keyboard",
    1.61 +	NULL,
    1.62 +	keyboardTests,
    1.63 +	NULL
    1.64 +};