test/testautomation_keyboard.c
author Philipp Wiesemann <philipp.wiesemann@arcor.de>
Wed, 17 Aug 2016 21:04:50 +0200
changeset 10275 ba7dc3ebb81e
parent 7268 b399d0441810
permissions -rw-r--r--
Emscripten: Fixed opening previously closed joystick.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     1
/**
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     2
 * Keyboard test suite
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     3
 */
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     4
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     5
#include <stdio.h>
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
     6
#include <limits.h>
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     7
6813
b21879e67db2 Add input validation to SDL_GetKeyFromScancode; fix compiler warning in testautomation driver on Linux; update keyboard test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
     8
#include "SDL_config.h"
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     9
#include "SDL.h"
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    10
#include "SDL_test.h"
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    11
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    12
/* ================= Test Case Implementation ================== */
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    13
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    14
/* Test case functions */
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    15
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    16
/**
6803
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    17
 * @brief Check call to SDL_GetKeyboardState with and without numkeys reference.
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
    18
 *
6803
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    19
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyboardState
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    20
 */
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    21
int
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    22
keyboard_getKeyboardState(void *arg)
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    23
{
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    24
   int numkeys;
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    25
   Uint8 *state;
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    26
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
    27
   /* Case where numkeys pointer is NULL */
7268
b399d0441810 Add missing VS2012 test projects; update VS2010 and VS2012 solutions; update keybord suite for VS compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7191
diff changeset
    28
   state = (Uint8 *)SDL_GetKeyboardState(NULL);
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    29
   SDLTest_AssertPass("Call to SDL_GetKeyboardState(NULL)");
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    30
   SDLTest_AssertCheck(state != NULL, "Validate that return value from SDL_GetKeyboardState is not NULL");
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    31
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    32
   /* Case where numkeys pointer is not NULL */
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    33
   numkeys = -1;
7268
b399d0441810 Add missing VS2012 test projects; update VS2010 and VS2012 solutions; update keybord suite for VS compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7191
diff changeset
    34
   state = (Uint8 *)SDL_GetKeyboardState(&numkeys);
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    35
   SDLTest_AssertPass("Call to SDL_GetKeyboardState(&numkeys)");
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    36
   SDLTest_AssertCheck(state != NULL, "Validate that return value from SDL_GetKeyboardState is not NULL");
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    37
   SDLTest_AssertCheck(numkeys >= 0, "Validate that value of numkeys is >= 0, got: %i", numkeys);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
    38
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    39
   return TEST_COMPLETED;
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    40
}
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    41
6803
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    42
/**
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    43
 * @brief Check call to SDL_GetKeyboardFocus
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
    44
 *
6803
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    45
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyboardFocus
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    46
 */
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    47
int
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    48
keyboard_getKeyboardFocus(void *arg)
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    49
{
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    50
   SDL_Window* window;
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    51
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    52
   /* Call, but ignore return value */
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    53
   window = SDL_GetKeyboardFocus();
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    54
   SDLTest_AssertPass("Call to SDL_GetKeyboardFocus()");
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    55
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    56
   return TEST_COMPLETED;
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    57
}
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    58
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    59
/**
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    60
 * @brief Check call to SDL_GetKeyFromName for known, unknown and invalid name.
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
    61
 *
6803
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    62
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyFromName
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    63
 */
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    64
int
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    65
keyboard_getKeyFromName(void *arg)
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    66
{
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    67
   SDL_Keycode result;
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    68
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    69
   /* Case where Key is known, 1 character input */
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    70
   result = SDL_GetKeyFromName("A");
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    71
   SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/single)");
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    72
   SDLTest_AssertCheck(result == SDLK_a, "Verify result from call, expected: %i, got: %i", SDLK_a, result);
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    73
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    74
   /* Case where Key is known, 2 character input */
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    75
   result = SDL_GetKeyFromName("F1");
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    76
   SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/double)");
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    77
   SDLTest_AssertCheck(result == SDLK_F1, "Verify result from call, expected: %i, got: %i", SDLK_F1, result);
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    78
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    79
   /* Case where Key is known, 3 character input */
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    80
   result = SDL_GetKeyFromName("End");
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    81
   SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/triple)");
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    82
   SDLTest_AssertCheck(result == SDLK_END, "Verify result from call, expected: %i, got: %i", SDLK_END, result);
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    83
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    84
   /* Case where Key is known, 4 character input */
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    85
   result = SDL_GetKeyFromName("Find");
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    86
   SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/quad)");
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    87
   SDLTest_AssertCheck(result == SDLK_FIND, "Verify result from call, expected: %i, got: %i", SDLK_FIND, result);
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    88
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    89
   /* Case where Key is known, multiple character input */
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    90
   result = SDL_GetKeyFromName("AudioStop");
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    91
   SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/multi)");
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    92
   SDLTest_AssertCheck(result == SDLK_AUDIOSTOP, "Verify result from call, expected: %i, got: %i", SDLK_AUDIOSTOP, result);
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    93
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    94
   /* Case where Key is unknown */
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    95
   result = SDL_GetKeyFromName("NotThere");
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    96
   SDLTest_AssertPass("Call to SDL_GetKeyFromName(unknown)");
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    97
   SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result);
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    98
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
    99
   /* Case where input is NULL/invalid */
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   100
   result = SDL_GetKeyFromName(NULL);
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   101
   SDLTest_AssertPass("Call to SDL_GetKeyFromName(NULL)");
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   102
   SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result);
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   103
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   104
   return TEST_COMPLETED;
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   105
}
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   106
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   107
/*
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   108
 * Local helper to check for the invalid scancode error message
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   109
 */
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   110
void
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   111
_checkInvalidScancodeError()
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   112
{
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   113
   const char *expectedError = "Parameter 'scancode' is invalid";
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   114
   const char *error;
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   115
   error = SDL_GetError();
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   116
   SDLTest_AssertPass("Call to SDL_GetError()");
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   117
   SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   118
   if (error != NULL) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   119
      SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   120
          "Validate error message, expected: '%s', got: '%s'", expectedError, error);
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   121
      SDL_ClearError();
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   122
      SDLTest_AssertPass("Call to SDL_ClearError()");
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   123
   }
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   124
}
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   125
6803
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   126
/**
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   127
 * @brief Check call to SDL_GetKeyFromScancode
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   128
 *
6803
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   129
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyFromScancode
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   130
 */
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   131
int
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   132
keyboard_getKeyFromScancode(void *arg)
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   133
{
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   134
   SDL_Keycode result;
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   135
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   136
   /* Case where input is valid */
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   137
   result = SDL_GetKeyFromScancode(SDL_SCANCODE_A);
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   138
   SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(valid)");
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   139
   SDLTest_AssertCheck(result == SDLK_a, "Verify result from call, expected: %i, got: %i", SDLK_a, result);
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   140
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   141
   /* Case where input is zero */
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   142
   result = SDL_GetKeyFromScancode(0);
6813
b21879e67db2 Add input validation to SDL_GetKeyFromScancode; fix compiler warning in testautomation driver on Linux; update keyboard test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   143
   SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(0)");
6803
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   144
   SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result);
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   145
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   146
   /* Clear error message */
6813
b21879e67db2 Add input validation to SDL_GetKeyFromScancode; fix compiler warning in testautomation driver on Linux; update keyboard test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   147
   SDL_ClearError();
b21879e67db2 Add input validation to SDL_GetKeyFromScancode; fix compiler warning in testautomation driver on Linux; update keyboard test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   148
   SDLTest_AssertPass("Call to SDL_ClearError()");
b21879e67db2 Add input validation to SDL_GetKeyFromScancode; fix compiler warning in testautomation driver on Linux; update keyboard test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   149
b21879e67db2 Add input validation to SDL_GetKeyFromScancode; fix compiler warning in testautomation driver on Linux; update keyboard test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   150
   /* Case where input is invalid (too small) */
6803
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   151
   result = SDL_GetKeyFromScancode(-999);
6813
b21879e67db2 Add input validation to SDL_GetKeyFromScancode; fix compiler warning in testautomation driver on Linux; update keyboard test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   152
   SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(-999)");
6803
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   153
   SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result);
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   154
   _checkInvalidScancodeError();
6813
b21879e67db2 Add input validation to SDL_GetKeyFromScancode; fix compiler warning in testautomation driver on Linux; update keyboard test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   155
b21879e67db2 Add input validation to SDL_GetKeyFromScancode; fix compiler warning in testautomation driver on Linux; update keyboard test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   156
   /* Case where input is invalid (too big) */
b21879e67db2 Add input validation to SDL_GetKeyFromScancode; fix compiler warning in testautomation driver on Linux; update keyboard test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   157
   result = SDL_GetKeyFromScancode(999);
b21879e67db2 Add input validation to SDL_GetKeyFromScancode; fix compiler warning in testautomation driver on Linux; update keyboard test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   158
   SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(999)");
b21879e67db2 Add input validation to SDL_GetKeyFromScancode; fix compiler warning in testautomation driver on Linux; update keyboard test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   159
   SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result);
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   160
   _checkInvalidScancodeError();
6803
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   161
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   162
   return TEST_COMPLETED;
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   163
}
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   164
6807
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   165
/**
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   166
 * @brief Check call to SDL_GetKeyName
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   167
 *
6807
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   168
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyName
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   169
 */
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   170
int
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   171
keyboard_getKeyName(void *arg)
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   172
{
6807
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   173
   char *result;
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   174
   char *expected;
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   175
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   176
   /* Case where key has a 1 character name */
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   177
   expected = "3";
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   178
   result = (char *)SDL_GetKeyName(SDLK_3);
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   179
   SDLTest_AssertPass("Call to SDL_GetKeyName()");
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   180
   SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   181
   SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result);
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   182
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   183
   /* Case where key has a 2 character name */
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   184
   expected = "F1";
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   185
   result = (char *)SDL_GetKeyName(SDLK_F1);
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   186
   SDLTest_AssertPass("Call to SDL_GetKeyName()");
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   187
   SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   188
   SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result);
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   189
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   190
   /* Case where key has a 3 character name */
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   191
   expected = "Cut";
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   192
   result = (char *)SDL_GetKeyName(SDLK_CUT);
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   193
   SDLTest_AssertPass("Call to SDL_GetKeyName()");
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   194
   SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   195
   SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result);
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   196
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   197
   /* Case where key has a 4 character name */
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   198
   expected = "Down";
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   199
   result = (char *)SDL_GetKeyName(SDLK_DOWN);
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   200
   SDLTest_AssertPass("Call to SDL_GetKeyName()");
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   201
   SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   202
   SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result);
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   203
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   204
   /* Case where key has a N character name */
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   205
   expected = "BrightnessUp";
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   206
   result = (char *)SDL_GetKeyName(SDLK_BRIGHTNESSUP);
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   207
   SDLTest_AssertPass("Call to SDL_GetKeyName()");
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   208
   SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   209
   SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result);
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   210
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   211
   /* Case where key has a N character name with space */
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   212
   expected = "Keypad MemStore";
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   213
   result = (char *)SDL_GetKeyName(SDLK_KP_MEMSTORE);
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   214
   SDLTest_AssertPass("Call to SDL_GetKeyName()");
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   215
   SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   216
   SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result);
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   217
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   218
   return TEST_COMPLETED;
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   219
}
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   220
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   221
/**
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   222
 * @brief SDL_GetScancodeName negative cases
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   223
 *
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   224
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeName
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   225
 */
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   226
int
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   227
keyboard_getScancodeNameNegative(void *arg)
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   228
{
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   229
   SDL_Scancode scancode;
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   230
   char *result;
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   231
   char *expected = "";
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   232
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   233
   /* Clear error message */
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   234
   SDL_ClearError();
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   235
   SDLTest_AssertPass("Call to SDL_ClearError()");
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   236
7172
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6983
diff changeset
   237
   /* Out-of-bounds scancode */
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6983
diff changeset
   238
   scancode = (SDL_Scancode)SDL_NUM_SCANCODES;
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   239
   result = (char *)SDL_GetScancodeName(scancode);
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   240
   SDLTest_AssertPass("Call to SDL_GetScancodeName(%d/large)", scancode);
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   241
   SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   242
   SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: '%s', got: '%s'", expected, result);
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   243
   _checkInvalidScancodeError();
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   244
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   245
   return TEST_COMPLETED;
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   246
}
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   247
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   248
/**
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   249
 * @brief SDL_GetKeyName negative cases
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   250
 *
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   251
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyName
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   252
 */
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   253
int
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   254
keyboard_getKeyNameNegative(void *arg)
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   255
{
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   256
   SDL_Keycode keycode;
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   257
   char *result;
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   258
   char *expected = "";
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   259
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   260
   /* Unknown keycode */
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   261
   keycode = SDLK_UNKNOWN;
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   262
   result = (char *)SDL_GetKeyName(keycode);
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   263
   SDLTest_AssertPass("Call to SDL_GetKeyName(%d/unknown)", keycode);
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   264
   SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   265
   SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: '%s', got: '%s'", expected, result);
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   266
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   267
   /* Clear error message */
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   268
   SDL_ClearError();
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   269
   SDLTest_AssertPass("Call to SDL_ClearError()");
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   270
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   271
   /* Negative keycode */
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   272
   keycode = (SDL_Keycode)SDLTest_RandomIntegerInRange(-255, -1);
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   273
   result = (char *)SDL_GetKeyName(keycode);
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   274
   SDLTest_AssertPass("Call to SDL_GetKeyName(%d/negative)", keycode);
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   275
   SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   276
   SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: '%s', got: '%s'", expected, result);
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   277
   _checkInvalidScancodeError();
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   278
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   279
   SDL_ClearError();
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   280
   SDLTest_AssertPass("Call to SDL_ClearError()");
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   281
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   282
   return TEST_COMPLETED;
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   283
}
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   284
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   285
/**
6807
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   286
 * @brief Check call to SDL_GetModState and SDL_SetModState
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   287
 *
6807
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   288
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetModState
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   289
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetModState
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   290
 */
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   291
int
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   292
keyboard_getSetModState(void *arg)
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   293
{
6807
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   294
   SDL_Keymod result;
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   295
   SDL_Keymod currentState;
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   296
   SDL_Keymod newState;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   297
   SDL_Keymod allStates =
6807
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   298
    KMOD_NONE |
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   299
    KMOD_LSHIFT |
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   300
    KMOD_RSHIFT |
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   301
    KMOD_LCTRL |
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   302
    KMOD_RCTRL |
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   303
    KMOD_LALT |
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   304
    KMOD_RALT |
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   305
    KMOD_LGUI |
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   306
    KMOD_RGUI |
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   307
    KMOD_NUM |
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   308
    KMOD_CAPS |
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   309
    KMOD_MODE |
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   310
    KMOD_RESERVED;
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   311
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   312
   /* Get state, cache for later reset */
6807
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   313
   result = SDL_GetModState();
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   314
   SDLTest_AssertPass("Call to SDL_GetModState()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   315
   SDLTest_AssertCheck(result >=0 && result <= allStates, "Verify result from call is valid, expected: 0 <= result <= %i, got: %i", allStates, result);
6807
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   316
   currentState = result;
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   317
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   318
   /* Set random state */
6807
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   319
   newState = SDLTest_RandomIntegerInRange(0, allStates);
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   320
   SDL_SetModState(newState);
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   321
   SDLTest_AssertPass("Call to SDL_SetModState(%i)", newState);
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   322
   result = SDL_GetModState();
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   323
   SDLTest_AssertPass("Call to SDL_GetModState()");
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   324
   SDLTest_AssertCheck(result == newState, "Verify result from call is valid, expected: %i, got: %i", newState, result);
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   325
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   326
   /* Set zero state */
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   327
   SDL_SetModState(0);
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   328
   SDLTest_AssertPass("Call to SDL_SetModState(0)");
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   329
   result = SDL_GetModState();
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   330
   SDLTest_AssertPass("Call to SDL_GetModState()");
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   331
   SDLTest_AssertCheck(result == 0, "Verify result from call is valid, expected: 0, got: %i", result);
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   332
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   333
   /* Revert back to cached current state if needed */
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   334
   if (currentState != 0) {
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   335
     SDL_SetModState(currentState);
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   336
     SDLTest_AssertPass("Call to SDL_SetModState(%i)", currentState);
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   337
     result = SDL_GetModState();
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   338
     SDLTest_AssertPass("Call to SDL_GetModState()");
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   339
     SDLTest_AssertCheck(result == currentState, "Verify result from call is valid, expected: %i, got: %i", currentState, result);
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   340
   }
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   341
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   342
   return TEST_COMPLETED;
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   343
}
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   344
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   345
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   346
/**
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   347
 * @brief Check call to SDL_StartTextInput and SDL_StopTextInput
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   348
 *
6807
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   349
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_StartTextInput
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   350
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_StopTextInput
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   351
 */
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   352
int
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   353
keyboard_startStopTextInput(void *arg)
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   354
{
6807
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   355
   /* Start-Stop */
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   356
   SDL_StartTextInput();
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   357
   SDLTest_AssertPass("Call to SDL_StartTextInput()");
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   358
   SDL_StopTextInput();
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   359
   SDLTest_AssertPass("Call to SDL_StopTextInput()");
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   360
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   361
   /* Stop-Start */
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   362
   SDL_StartTextInput();
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   363
   SDLTest_AssertPass("Call to SDL_StartTextInput()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   364
6807
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   365
   /* Start-Start */
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   366
   SDL_StartTextInput();
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   367
   SDLTest_AssertPass("Call to SDL_StartTextInput()");
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   368
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   369
   /* Stop-Stop */
6807
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   370
   SDL_StopTextInput();
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   371
   SDLTest_AssertPass("Call to SDL_StopTextInput()");
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   372
   SDL_StopTextInput();
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   373
   SDLTest_AssertPass("Call to SDL_StopTextInput()");
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   374
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   375
   return TEST_COMPLETED;
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   376
}
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   377
6808
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   378
/* Internal function to test SDL_SetTextInputRect */
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   379
void _testSetTextInputRect(SDL_Rect refRect)
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   380
{
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   381
   SDL_Rect testRect;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   382
6808
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   383
   testRect = refRect;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   384
   SDL_SetTextInputRect(&testRect);
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   385
   SDLTest_AssertPass("Call to SDL_SetTextInputRect with refRect(x:%i,y:%i,w:%i,h:%i)", refRect.x, refRect.y, refRect.w, refRect.h);
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   386
   SDLTest_AssertCheck(
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   387
      (refRect.x == testRect.x) && (refRect.y == testRect.y) && (refRect.w == testRect.w) && (refRect.h == testRect.h),
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   388
      "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",
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   389
      refRect.x, refRect.y, refRect.w, refRect.h,
6808
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   390
      testRect.x, testRect.y, testRect.w, testRect.h);
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   391
}
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   392
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   393
/**
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   394
 * @brief Check call to SDL_SetTextInputRect
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   395
 *
6808
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   396
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetTextInputRect
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   397
 */
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   398
int
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   399
keyboard_setTextInputRect(void *arg)
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   400
{
6808
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   401
   SDL_Rect refRect;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   402
6808
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   403
   /* Normal visible refRect, origin inside */
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   404
   refRect.x = SDLTest_RandomIntegerInRange(1, 50);;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   405
   refRect.y = SDLTest_RandomIntegerInRange(1, 50);;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   406
   refRect.w = SDLTest_RandomIntegerInRange(10, 50);
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   407
   refRect.h = SDLTest_RandomIntegerInRange(10, 50);
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   408
   _testSetTextInputRect(refRect);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   409
6808
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   410
   /* Normal visible refRect, origin 0,0 */
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   411
   refRect.x = 0;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   412
   refRect.y = 0;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   413
   refRect.w = SDLTest_RandomIntegerInRange(10, 50);
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   414
   refRect.h = SDLTest_RandomIntegerInRange(10, 50);
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   415
   _testSetTextInputRect(refRect);
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   416
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   417
   /* 1Pixel refRect */
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   418
   refRect.x = SDLTest_RandomIntegerInRange(10, 50);;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   419
   refRect.y = SDLTest_RandomIntegerInRange(10, 50);;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   420
   refRect.w = 1;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   421
   refRect.h = 1;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   422
   _testSetTextInputRect(refRect);
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   423
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   424
   /* 0pixel refRect */
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   425
   refRect.x = 1;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   426
   refRect.y = 1;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   427
   refRect.w = 1;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   428
   refRect.h = 0;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   429
   _testSetTextInputRect(refRect);
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   430
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   431
   /* 0pixel refRect */
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   432
   refRect.x = 1;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   433
   refRect.y = 1;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   434
   refRect.w = 0;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   435
   refRect.h = 1;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   436
   _testSetTextInputRect(refRect);
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   437
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   438
   /* 0pixel refRect */
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   439
   refRect.x = 1;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   440
   refRect.y = 1;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   441
   refRect.w = 0;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   442
   refRect.h = 0;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   443
   _testSetTextInputRect(refRect);
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   444
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   445
   /* 0pixel refRect */
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   446
   refRect.x = 0;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   447
   refRect.y = 0;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   448
   refRect.w = 0;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   449
   refRect.h = 0;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   450
   _testSetTextInputRect(refRect);
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   451
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   452
   /* negative refRect */
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   453
   refRect.x = SDLTest_RandomIntegerInRange(-200, -100);;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   454
   refRect.y = SDLTest_RandomIntegerInRange(-200, -100);;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   455
   refRect.w = 50;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   456
   refRect.h = 50;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   457
   _testSetTextInputRect(refRect);
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   458
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   459
   /* oversized refRect */
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   460
   refRect.x = SDLTest_RandomIntegerInRange(1, 50);;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   461
   refRect.y = SDLTest_RandomIntegerInRange(1, 50);;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   462
   refRect.w = 5000;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   463
   refRect.h = 5000;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   464
   _testSetTextInputRect(refRect);
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   465
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   466
   /* NULL refRect */
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   467
   SDL_SetTextInputRect(NULL);
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   468
   SDLTest_AssertPass("Call to SDL_SetTextInputRect(NULL)");
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   469
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   470
   return TEST_COMPLETED;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   471
}
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   472
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   473
/**
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   474
 * @brief Check call to SDL_SetTextInputRect with invalid data
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   475
 *
6808
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   476
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetTextInputRect
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   477
 */
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   478
int
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   479
keyboard_setTextInputRectNegative(void *arg)
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   480
{
6813
b21879e67db2 Add input validation to SDL_GetKeyFromScancode; fix compiler warning in testautomation driver on Linux; update keyboard test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   481
   /* Some platforms set also an error message; prepare for checking it */
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   482
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   483
   const char *expectedError = "Parameter 'rect' is invalid";
6808
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   484
   const char *error;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   485
6808
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   486
   SDL_ClearError();
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   487
   SDLTest_AssertPass("Call to SDL_ClearError()");
6813
b21879e67db2 Add input validation to SDL_GetKeyFromScancode; fix compiler warning in testautomation driver on Linux; update keyboard test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   488
#endif
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   489
6808
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   490
   /* NULL refRect */
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   491
   SDL_SetTextInputRect(NULL);
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   492
   SDLTest_AssertPass("Call to SDL_SetTextInputRect(NULL)");
6813
b21879e67db2 Add input validation to SDL_GetKeyFromScancode; fix compiler warning in testautomation driver on Linux; update keyboard test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   493
b21879e67db2 Add input validation to SDL_GetKeyFromScancode; fix compiler warning in testautomation driver on Linux; update keyboard test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   494
   /* Some platforms set also an error message; so check it */
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   495
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA
6808
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   496
   error = SDL_GetError();
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   497
   SDLTest_AssertPass("Call to SDL_GetError()");
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   498
   SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   499
   if (error != NULL) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   500
      SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
6808
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   501
          "Validate error message, expected: '%s', got: '%s'", expectedError, error);
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   502
   }
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   503
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   504
   SDL_ClearError();
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   505
   SDLTest_AssertPass("Call to SDL_ClearError()");
6813
b21879e67db2 Add input validation to SDL_GetKeyFromScancode; fix compiler warning in testautomation driver on Linux; update keyboard test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   506
#endif
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   507
6808
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   508
   return TEST_COMPLETED;
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   509
}
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   510
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   511
/**
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   512
 * @brief Check call to SDL_GetScancodeFromKey
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   513
 *
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   514
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromKey
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   515
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_Keycode
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   516
 */
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   517
int
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   518
keyboard_getScancodeFromKey(void *arg)
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   519
{
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   520
   SDL_Scancode scancode;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   521
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   522
   /* Regular key */
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   523
   scancode = SDL_GetScancodeFromKey(SDLK_4);
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   524
   SDLTest_AssertPass("Call to SDL_GetScancodeFromKey(SDLK_4)");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   525
   SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromKey, expected: %i, got: %i", SDL_SCANCODE_4, scancode);
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   526
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   527
   /* Virtual key */
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   528
   scancode = SDL_GetScancodeFromKey(SDLK_PLUS);
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   529
   SDLTest_AssertPass("Call to SDL_GetScancodeFromKey(SDLK_PLUS)");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   530
   SDLTest_AssertCheck(scancode == 0, "Validate return value from SDL_GetScancodeFromKey, expected: 0, got: %i", scancode);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   531
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   532
   return TEST_COMPLETED;
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   533
}
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   534
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   535
/**
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   536
 * @brief Check call to SDL_GetScancodeFromName
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   537
 *
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   538
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromName
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   539
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_Keycode
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   540
 */
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   541
int
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   542
keyboard_getScancodeFromName(void *arg)
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   543
{
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   544
   SDL_Scancode scancode;
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   545
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   546
   /* Regular key, 1 character, first name in list */
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   547
   scancode = SDL_GetScancodeFromName("A");
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   548
   SDLTest_AssertPass("Call to SDL_GetScancodeFromName('A')");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   549
   SDLTest_AssertCheck(scancode == SDL_SCANCODE_A, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_A, scancode);
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   550
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   551
   /* Regular key, 1 character */
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   552
   scancode = SDL_GetScancodeFromName("4");
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   553
   SDLTest_AssertPass("Call to SDL_GetScancodeFromName('4')");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   554
   SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_4, scancode);
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   555
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   556
   /* Regular key, 2 characters */
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   557
   scancode = SDL_GetScancodeFromName("F1");
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   558
   SDLTest_AssertPass("Call to SDL_GetScancodeFromName('F1')");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   559
   SDLTest_AssertCheck(scancode == SDL_SCANCODE_F1, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_F1, scancode);
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   560
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   561
   /* Regular key, 3 characters */
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   562
   scancode = SDL_GetScancodeFromName("End");
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   563
   SDLTest_AssertPass("Call to SDL_GetScancodeFromName('End')");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   564
   SDLTest_AssertCheck(scancode == SDL_SCANCODE_END, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_END, scancode);
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   565
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   566
   /* Regular key, 4 characters */
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   567
   scancode = SDL_GetScancodeFromName("Find");
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   568
   SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Find')");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   569
   SDLTest_AssertCheck(scancode == SDL_SCANCODE_FIND, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_FIND, scancode);
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   570
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   571
   /* Regular key, several characters */
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   572
   scancode = SDL_GetScancodeFromName("Backspace");
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   573
   SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Backspace')");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   574
   SDLTest_AssertCheck(scancode == SDL_SCANCODE_BACKSPACE, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_BACKSPACE, scancode);
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   575
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   576
   /* Regular key, several characters with space */
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   577
   scancode = SDL_GetScancodeFromName("Keypad Enter");
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   578
   SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Keypad Enter')");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   579
   SDLTest_AssertCheck(scancode == SDL_SCANCODE_KP_ENTER, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_KP_ENTER, scancode);
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   580
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   581
   /* Regular key, last name in list */
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   582
   scancode = SDL_GetScancodeFromName("Sleep");
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   583
   SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Sleep')");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   584
   SDLTest_AssertCheck(scancode == SDL_SCANCODE_SLEEP, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_SLEEP, scancode);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   585
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   586
   return TEST_COMPLETED;
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   587
}
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   588
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   589
/*
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   590
 * Local helper to check for the invalid scancode error message
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   591
 */
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   592
void
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   593
_checkInvalidNameError()
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   594
{
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   595
   const char *expectedError = "Parameter 'name' is invalid";
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   596
   const char *error;
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   597
   error = SDL_GetError();
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   598
   SDLTest_AssertPass("Call to SDL_GetError()");
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   599
   SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   600
   if (error != NULL) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   601
      SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   602
          "Validate error message, expected: '%s', got: '%s'", expectedError, error);
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   603
      SDL_ClearError();
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   604
      SDLTest_AssertPass("Call to SDL_ClearError()");
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   605
   }
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   606
}
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   607
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   608
/**
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   609
 * @brief Check call to SDL_GetScancodeFromName with invalid data
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   610
 *
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   611
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromName
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   612
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_Keycode
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   613
 */
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   614
int
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   615
keyboard_getScancodeFromNameNegative(void *arg)
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   616
{
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   617
   char *name;
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   618
   SDL_Scancode scancode;
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   619
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   620
   /* Clear error message */
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   621
   SDL_ClearError();
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   622
   SDLTest_AssertPass("Call to SDL_ClearError()");
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   623
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   624
   /* Random string input */
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   625
   name = SDLTest_RandomAsciiStringOfSize(32);
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   626
   SDLTest_Assert(name != NULL, "Check that random name is not NULL");
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   627
   if (name == NULL) {
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   628
      return TEST_ABORTED;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   629
   }
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   630
   scancode = SDL_GetScancodeFromName((const char *)name);
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   631
   SDLTest_AssertPass("Call to SDL_GetScancodeFromName('%s')", name);
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   632
   SDL_free(name);
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   633
   SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode);
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   634
   _checkInvalidNameError();
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   635
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   636
   /* Zero length string input */
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   637
   name = "";
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   638
   scancode = SDL_GetScancodeFromName((const char *)name);
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   639
   SDLTest_AssertPass("Call to SDL_GetScancodeFromName(NULL)");
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   640
   SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode);
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   641
   _checkInvalidNameError();
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   642
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   643
   /* NULL input */
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   644
   name = NULL;
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   645
   scancode = SDL_GetScancodeFromName((const char *)name);
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   646
   SDLTest_AssertPass("Call to SDL_GetScancodeFromName(NULL)");
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   647
   SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode);
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   648
   _checkInvalidNameError();
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   649
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   650
   return TEST_COMPLETED;
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   651
}
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   652
6803
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   653
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   654
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   655
/* ================= Test References ================== */
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   656
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   657
/* Keyboard test cases */
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   658
static const SDLTest_TestCaseReference keyboardTest1 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   659
        { (SDLTest_TestCaseFp)keyboard_getKeyboardState, "keyboard_getKeyboardState", "Check call to SDL_GetKeyboardState with and without numkeys reference", TEST_ENABLED };
6803
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   660
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   661
static const SDLTest_TestCaseReference keyboardTest2 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   662
        { (SDLTest_TestCaseFp)keyboard_getKeyboardFocus, "keyboard_getKeyboardFocus", "Check call to SDL_GetKeyboardFocus", TEST_ENABLED };
6803
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   663
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   664
static const SDLTest_TestCaseReference keyboardTest3 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   665
        { (SDLTest_TestCaseFp)keyboard_getKeyFromName, "keyboard_getKeyFromName", "Check call to SDL_GetKeyFromName for known, unknown and invalid name", TEST_ENABLED };
6803
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   666
fbe83a6d10fa Add a few keyboard tests; fix missing input validation in SDL_GetKeyFromName
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6800
diff changeset
   667
static const SDLTest_TestCaseReference keyboardTest4 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   668
        { (SDLTest_TestCaseFp)keyboard_getKeyFromScancode, "keyboard_getKeyFromScancode", "Check call to SDL_GetKeyFromScancode", TEST_ENABLED };
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   669
6807
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   670
static const SDLTest_TestCaseReference keyboardTest5 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   671
        { (SDLTest_TestCaseFp)keyboard_getKeyName, "keyboard_getKeyName", "Check call to SDL_GetKeyName", TEST_ENABLED };
6807
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   672
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   673
static const SDLTest_TestCaseReference keyboardTest6 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   674
        { (SDLTest_TestCaseFp)keyboard_getSetModState, "keyboard_getSetModState", "Check call to SDL_GetModState and SDL_SetModState", TEST_ENABLED };
6807
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   675
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   676
static const SDLTest_TestCaseReference keyboardTest7 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   677
        { (SDLTest_TestCaseFp)keyboard_startStopTextInput, "keyboard_startStopTextInput", "Check call to SDL_StartTextInput and SDL_StopTextInput", TEST_ENABLED };
6807
e3610bc90cf3 Added 3 more test cases to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6803
diff changeset
   678
6808
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   679
static const SDLTest_TestCaseReference keyboardTest8 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   680
        { (SDLTest_TestCaseFp)keyboard_setTextInputRect, "keyboard_setTextInputRect", "Check call to SDL_SetTextInputRect", TEST_ENABLED };
6808
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   681
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   682
static const SDLTest_TestCaseReference keyboardTest9 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   683
        { (SDLTest_TestCaseFp)keyboard_setTextInputRectNegative, "keyboard_setTextInputRectNegative", "Check call to SDL_SetTextInputRect with invalid data", TEST_ENABLED };
6808
3ad413bd1cd6 Add new internal error message for invalid parameters; add validation of input rect in SDL_SetTextInputRect; add test cases for SDL_SetTextInputRect to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6807
diff changeset
   684
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   685
static const SDLTest_TestCaseReference keyboardTest10 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   686
        { (SDLTest_TestCaseFp)keyboard_getScancodeFromKey, "keyboard_getScancodeFromKey", "Check call to SDL_GetScancodeFromKey", TEST_ENABLED };
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   687
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   688
static const SDLTest_TestCaseReference keyboardTest11 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   689
        { (SDLTest_TestCaseFp)keyboard_getScancodeFromName, "keyboard_getScancodeFromName", "Check call to SDL_GetScancodeFromName", TEST_ENABLED };
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   690
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   691
static const SDLTest_TestCaseReference keyboardTest12 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   692
        { (SDLTest_TestCaseFp)keyboard_getScancodeFromNameNegative, "keyboard_getScancodeFromNameNegative", "Check call to SDL_GetScancodeFromName with invalid data", TEST_ENABLED };
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6808
diff changeset
   693
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   694
static const SDLTest_TestCaseReference keyboardTest13 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   695
        { (SDLTest_TestCaseFp)keyboard_getKeyNameNegative, "keyboard_getKeyNameNegative", "Check call to SDL_GetKeyName with invalid data", TEST_ENABLED };
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   696
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   697
static const SDLTest_TestCaseReference keyboardTest14 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   698
        { (SDLTest_TestCaseFp)keyboard_getScancodeNameNegative, "keyboard_getScancodeNameNegative", "Check call to SDL_GetScancodeName with invalid data", TEST_ENABLED };
6983
b72f56ab9867 Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6813
diff changeset
   699
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   700
/* Sequence of Keyboard test cases */
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   701
static const SDLTest_TestCaseReference *keyboardTests[] =  {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   702
    &keyboardTest1, &keyboardTest2, &keyboardTest3, &keyboardTest4, &keyboardTest5, &keyboardTest6,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   703
    &keyboardTest7, &keyboardTest8, &keyboardTest9, &keyboardTest10, &keyboardTest11, &keyboardTest12,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   704
    &keyboardTest13, &keyboardTest14, NULL
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   705
};
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   706
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   707
/* Keyboard test suite (global) */
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   708
SDLTest_TestSuiteReference keyboardTestSuite = {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   709
    "Keyboard",
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   710
    NULL,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   711
    keyboardTests,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7172
diff changeset
   712
    NULL
6800
26c6795ec1a4 Add new test suites (events, keyboard, syswm, video) with a few new tests each
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   713
};