8 #include "SDL_config.h"
12 /* ================= Test Case Implementation ================== */
14 /* Test case functions */
17 * @brief Check call to SDL_GetKeyboardState with and without numkeys reference.
19 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyboardState
22 keyboard_getKeyboardState(void *arg)
27 /* Case where numkeys pointer is NULL */
28 state = (Uint8 *)SDL_GetKeyboardState(NULL);
29 SDLTest_AssertPass("Call to SDL_GetKeyboardState(NULL)");
30 SDLTest_AssertCheck(state != NULL, "Validate that return value from SDL_GetKeyboardState is not NULL");
32 /* Case where numkeys pointer is not NULL */
34 state = (Uint8 *)SDL_GetKeyboardState(&numkeys);
35 SDLTest_AssertPass("Call to SDL_GetKeyboardState(&numkeys)");
36 SDLTest_AssertCheck(state != NULL, "Validate that return value from SDL_GetKeyboardState is not NULL");
37 SDLTest_AssertCheck(numkeys >= 0, "Validate that value of numkeys is >= 0, got: %i", numkeys);
39 return TEST_COMPLETED;
43 * @brief Check call to SDL_GetKeyboardFocus
45 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyboardFocus
48 keyboard_getKeyboardFocus(void *arg)
52 /* Call, but ignore return value */
53 window = SDL_GetKeyboardFocus();
54 SDLTest_AssertPass("Call to SDL_GetKeyboardFocus()");
56 return TEST_COMPLETED;
60 * @brief Check call to SDL_GetKeyFromName for known, unknown and invalid name.
62 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyFromName
65 keyboard_getKeyFromName(void *arg)
69 /* Case where Key is known, 1 character input */
70 result = SDL_GetKeyFromName("A");
71 SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/single)");
72 SDLTest_AssertCheck(result == SDLK_a, "Verify result from call, expected: %i, got: %i", SDLK_a, result);
74 /* Case where Key is known, 2 character input */
75 result = SDL_GetKeyFromName("F1");
76 SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/double)");
77 SDLTest_AssertCheck(result == SDLK_F1, "Verify result from call, expected: %i, got: %i", SDLK_F1, result);
79 /* Case where Key is known, 3 character input */
80 result = SDL_GetKeyFromName("End");
81 SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/triple)");
82 SDLTest_AssertCheck(result == SDLK_END, "Verify result from call, expected: %i, got: %i", SDLK_END, result);
84 /* Case where Key is known, 4 character input */
85 result = SDL_GetKeyFromName("Find");
86 SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/quad)");
87 SDLTest_AssertCheck(result == SDLK_FIND, "Verify result from call, expected: %i, got: %i", SDLK_FIND, result);
89 /* Case where Key is known, multiple character input */
90 result = SDL_GetKeyFromName("AudioStop");
91 SDLTest_AssertPass("Call to SDL_GetKeyFromName(known/multi)");
92 SDLTest_AssertCheck(result == SDLK_AUDIOSTOP, "Verify result from call, expected: %i, got: %i", SDLK_AUDIOSTOP, result);
94 /* Case where Key is unknown */
95 result = SDL_GetKeyFromName("NotThere");
96 SDLTest_AssertPass("Call to SDL_GetKeyFromName(unknown)");
97 SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result);
99 /* Case where input is NULL/invalid */
100 result = SDL_GetKeyFromName(NULL);
101 SDLTest_AssertPass("Call to SDL_GetKeyFromName(NULL)");
102 SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result);
104 return TEST_COMPLETED;
108 * Local helper to check for the invalid scancode error message
111 _checkInvalidScancodeError()
113 const char *expectedError = "Parameter 'scancode' is invalid";
115 error = SDL_GetError();
116 SDLTest_AssertPass("Call to SDL_GetError()");
117 SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
119 SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
120 "Validate error message, expected: '%s', got: '%s'", expectedError, error);
122 SDLTest_AssertPass("Call to SDL_ClearError()");
127 * @brief Check call to SDL_GetKeyFromScancode
129 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyFromScancode
132 keyboard_getKeyFromScancode(void *arg)
136 /* Case where input is valid */
137 result = SDL_GetKeyFromScancode(SDL_SCANCODE_A);
138 SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(valid)");
139 SDLTest_AssertCheck(result == SDLK_a, "Verify result from call, expected: %i, got: %i", SDLK_a, result);
141 /* Case where input is zero */
142 result = SDL_GetKeyFromScancode(0);
143 SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(0)");
144 SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result);
146 /* Clear error message */
148 SDLTest_AssertPass("Call to SDL_ClearError()");
150 /* Case where input is invalid (too small) */
151 result = SDL_GetKeyFromScancode(-999);
152 SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(-999)");
153 SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result);
154 _checkInvalidScancodeError();
156 /* Case where input is invalid (too big) */
157 result = SDL_GetKeyFromScancode(999);
158 SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(999)");
159 SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result);
160 _checkInvalidScancodeError();
162 return TEST_COMPLETED;
166 * @brief Check call to SDL_GetKeyName
168 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyName
171 keyboard_getKeyName(void *arg)
176 /* Case where key has a 1 character name */
178 result = (char *)SDL_GetKeyName(SDLK_3);
179 SDLTest_AssertPass("Call to SDL_GetKeyName()");
180 SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
181 SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result);
183 /* Case where key has a 2 character name */
185 result = (char *)SDL_GetKeyName(SDLK_F1);
186 SDLTest_AssertPass("Call to SDL_GetKeyName()");
187 SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
188 SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result);
190 /* Case where key has a 3 character name */
192 result = (char *)SDL_GetKeyName(SDLK_CUT);
193 SDLTest_AssertPass("Call to SDL_GetKeyName()");
194 SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
195 SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result);
197 /* Case where key has a 4 character name */
199 result = (char *)SDL_GetKeyName(SDLK_DOWN);
200 SDLTest_AssertPass("Call to SDL_GetKeyName()");
201 SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
202 SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result);
204 /* Case where key has a N character name */
205 expected = "BrightnessUp";
206 result = (char *)SDL_GetKeyName(SDLK_BRIGHTNESSUP);
207 SDLTest_AssertPass("Call to SDL_GetKeyName()");
208 SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
209 SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result);
211 /* Case where key has a N character name with space */
212 expected = "Keypad MemStore";
213 result = (char *)SDL_GetKeyName(SDLK_KP_MEMSTORE);
214 SDLTest_AssertPass("Call to SDL_GetKeyName()");
215 SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
216 SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: %s, got: %s", expected, result);
218 return TEST_COMPLETED;
222 * @brief SDL_GetScancodeName negative cases
224 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeName
227 keyboard_getScancodeNameNegative(void *arg)
229 SDL_Scancode scancode;
233 /* Clear error message */
235 SDLTest_AssertPass("Call to SDL_ClearError()");
237 /* Out-of-bounds scancode */
238 scancode = (SDL_Scancode)SDL_NUM_SCANCODES;
239 result = (char *)SDL_GetScancodeName(scancode);
240 SDLTest_AssertPass("Call to SDL_GetScancodeName(%d/large)", scancode);
241 SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
242 SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: '%s', got: '%s'", expected, result);
243 _checkInvalidScancodeError();
245 return TEST_COMPLETED;
249 * @brief SDL_GetKeyName negative cases
251 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyName
254 keyboard_getKeyNameNegative(void *arg)
260 /* Unknown keycode */
261 keycode = SDLK_UNKNOWN;
262 result = (char *)SDL_GetKeyName(keycode);
263 SDLTest_AssertPass("Call to SDL_GetKeyName(%d/unknown)", keycode);
264 SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
265 SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: '%s', got: '%s'", expected, result);
267 /* Clear error message */
269 SDLTest_AssertPass("Call to SDL_ClearError()");
271 /* Negative keycode */
272 keycode = (SDL_Keycode)SDLTest_RandomIntegerInRange(-255, -1);
273 result = (char *)SDL_GetKeyName(keycode);
274 SDLTest_AssertPass("Call to SDL_GetKeyName(%d/negative)", keycode);
275 SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
276 SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: '%s', got: '%s'", expected, result);
277 _checkInvalidScancodeError();
280 SDLTest_AssertPass("Call to SDL_ClearError()");
282 return TEST_COMPLETED;
286 * @brief Check call to SDL_GetModState and SDL_SetModState
288 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetModState
289 * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetModState
292 keyboard_getSetModState(void *arg)
295 SDL_Keymod currentState;
297 SDL_Keymod allStates =
312 /* Get state, cache for later reset */
313 result = SDL_GetModState();
314 SDLTest_AssertPass("Call to SDL_GetModState()");
315 SDLTest_AssertCheck(result >=0 && result <= allStates, "Verify result from call is valid, expected: 0 <= result <= %i, got: %i", allStates, result);
316 currentState = result;
318 /* Set random state */
319 newState = SDLTest_RandomIntegerInRange(0, allStates);
320 SDL_SetModState(newState);
321 SDLTest_AssertPass("Call to SDL_SetModState(%i)", newState);
322 result = SDL_GetModState();
323 SDLTest_AssertPass("Call to SDL_GetModState()");
324 SDLTest_AssertCheck(result == newState, "Verify result from call is valid, expected: %i, got: %i", newState, result);
328 SDLTest_AssertPass("Call to SDL_SetModState(0)");
329 result = SDL_GetModState();
330 SDLTest_AssertPass("Call to SDL_GetModState()");
331 SDLTest_AssertCheck(result == 0, "Verify result from call is valid, expected: 0, got: %i", result);
333 /* Revert back to cached current state if needed */
334 if (currentState != 0) {
335 SDL_SetModState(currentState);
336 SDLTest_AssertPass("Call to SDL_SetModState(%i)", currentState);
337 result = SDL_GetModState();
338 SDLTest_AssertPass("Call to SDL_GetModState()");
339 SDLTest_AssertCheck(result == currentState, "Verify result from call is valid, expected: %i, got: %i", currentState, result);
342 return TEST_COMPLETED;
347 * @brief Check call to SDL_StartTextInput and SDL_StopTextInput
349 * @sa http://wiki.libsdl.org/moin.cgi/SDL_StartTextInput
350 * @sa http://wiki.libsdl.org/moin.cgi/SDL_StopTextInput
353 keyboard_startStopTextInput(void *arg)
356 SDL_StartTextInput();
357 SDLTest_AssertPass("Call to SDL_StartTextInput()");
359 SDLTest_AssertPass("Call to SDL_StopTextInput()");
362 SDL_StartTextInput();
363 SDLTest_AssertPass("Call to SDL_StartTextInput()");
366 SDL_StartTextInput();
367 SDLTest_AssertPass("Call to SDL_StartTextInput()");
371 SDLTest_AssertPass("Call to SDL_StopTextInput()");
373 SDLTest_AssertPass("Call to SDL_StopTextInput()");
375 return TEST_COMPLETED;
378 /* Internal function to test SDL_SetTextInputRect */
379 void _testSetTextInputRect(SDL_Rect refRect)
384 SDL_SetTextInputRect(&testRect);
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);
387 (refRect.x == testRect.x) && (refRect.y == testRect.y) && (refRect.w == testRect.w) && (refRect.h == testRect.h),
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",
389 refRect.x, refRect.y, refRect.w, refRect.h,
390 testRect.x, testRect.y, testRect.w, testRect.h);
394 * @brief Check call to SDL_SetTextInputRect
396 * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetTextInputRect
399 keyboard_setTextInputRect(void *arg)
403 /* Normal visible refRect, origin inside */
404 refRect.x = SDLTest_RandomIntegerInRange(1, 50);;
405 refRect.y = SDLTest_RandomIntegerInRange(1, 50);;
406 refRect.w = SDLTest_RandomIntegerInRange(10, 50);
407 refRect.h = SDLTest_RandomIntegerInRange(10, 50);
408 _testSetTextInputRect(refRect);
410 /* Normal visible refRect, origin 0,0 */
413 refRect.w = SDLTest_RandomIntegerInRange(10, 50);
414 refRect.h = SDLTest_RandomIntegerInRange(10, 50);
415 _testSetTextInputRect(refRect);
418 refRect.x = SDLTest_RandomIntegerInRange(10, 50);;
419 refRect.y = SDLTest_RandomIntegerInRange(10, 50);;
422 _testSetTextInputRect(refRect);
429 _testSetTextInputRect(refRect);
436 _testSetTextInputRect(refRect);
443 _testSetTextInputRect(refRect);
450 _testSetTextInputRect(refRect);
452 /* negative refRect */
453 refRect.x = SDLTest_RandomIntegerInRange(-200, -100);;
454 refRect.y = SDLTest_RandomIntegerInRange(-200, -100);;
457 _testSetTextInputRect(refRect);
459 /* oversized refRect */
460 refRect.x = SDLTest_RandomIntegerInRange(1, 50);;
461 refRect.y = SDLTest_RandomIntegerInRange(1, 50);;
464 _testSetTextInputRect(refRect);
467 SDL_SetTextInputRect(NULL);
468 SDLTest_AssertPass("Call to SDL_SetTextInputRect(NULL)");
470 return TEST_COMPLETED;
474 * @brief Check call to SDL_SetTextInputRect with invalid data
476 * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetTextInputRect
479 keyboard_setTextInputRectNegative(void *arg)
481 /* Some platforms set also an error message; prepare for checking it */
482 #if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA
483 const char *expectedError = "Parameter 'rect' is invalid";
487 SDLTest_AssertPass("Call to SDL_ClearError()");
491 SDL_SetTextInputRect(NULL);
492 SDLTest_AssertPass("Call to SDL_SetTextInputRect(NULL)");
494 /* Some platforms set also an error message; so check it */
495 #if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA
496 error = SDL_GetError();
497 SDLTest_AssertPass("Call to SDL_GetError()");
498 SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
500 SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
501 "Validate error message, expected: '%s', got: '%s'", expectedError, error);
505 SDLTest_AssertPass("Call to SDL_ClearError()");
508 return TEST_COMPLETED;
512 * @brief Check call to SDL_GetScancodeFromKey
514 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromKey
515 * @sa http://wiki.libsdl.org/moin.cgi/SDL_Keycode
518 keyboard_getScancodeFromKey(void *arg)
520 SDL_Scancode scancode;
523 scancode = SDL_GetScancodeFromKey(SDLK_4);
524 SDLTest_AssertPass("Call to SDL_GetScancodeFromKey(SDLK_4)");
525 SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromKey, expected: %i, got: %i", SDL_SCANCODE_4, scancode);
528 scancode = SDL_GetScancodeFromKey(SDLK_PLUS);
529 SDLTest_AssertPass("Call to SDL_GetScancodeFromKey(SDLK_PLUS)");
530 SDLTest_AssertCheck(scancode == 0, "Validate return value from SDL_GetScancodeFromKey, expected: 0, got: %i", scancode);
532 return TEST_COMPLETED;
536 * @brief Check call to SDL_GetScancodeFromName
538 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromName
539 * @sa http://wiki.libsdl.org/moin.cgi/SDL_Keycode
542 keyboard_getScancodeFromName(void *arg)
544 SDL_Scancode scancode;
546 /* Regular key, 1 character, first name in list */
547 scancode = SDL_GetScancodeFromName("A");
548 SDLTest_AssertPass("Call to SDL_GetScancodeFromName('A')");
549 SDLTest_AssertCheck(scancode == SDL_SCANCODE_A, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_A, scancode);
551 /* Regular key, 1 character */
552 scancode = SDL_GetScancodeFromName("4");
553 SDLTest_AssertPass("Call to SDL_GetScancodeFromName('4')");
554 SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_4, scancode);
556 /* Regular key, 2 characters */
557 scancode = SDL_GetScancodeFromName("F1");
558 SDLTest_AssertPass("Call to SDL_GetScancodeFromName('F1')");
559 SDLTest_AssertCheck(scancode == SDL_SCANCODE_F1, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_F1, scancode);
561 /* Regular key, 3 characters */
562 scancode = SDL_GetScancodeFromName("End");
563 SDLTest_AssertPass("Call to SDL_GetScancodeFromName('End')");
564 SDLTest_AssertCheck(scancode == SDL_SCANCODE_END, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_END, scancode);
566 /* Regular key, 4 characters */
567 scancode = SDL_GetScancodeFromName("Find");
568 SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Find')");
569 SDLTest_AssertCheck(scancode == SDL_SCANCODE_FIND, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_FIND, scancode);
571 /* Regular key, several characters */
572 scancode = SDL_GetScancodeFromName("Backspace");
573 SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Backspace')");
574 SDLTest_AssertCheck(scancode == SDL_SCANCODE_BACKSPACE, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_BACKSPACE, scancode);
576 /* Regular key, several characters with space */
577 scancode = SDL_GetScancodeFromName("Keypad Enter");
578 SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Keypad Enter')");
579 SDLTest_AssertCheck(scancode == SDL_SCANCODE_KP_ENTER, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_KP_ENTER, scancode);
581 /* Regular key, last name in list */
582 scancode = SDL_GetScancodeFromName("Sleep");
583 SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Sleep')");
584 SDLTest_AssertCheck(scancode == SDL_SCANCODE_SLEEP, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_SLEEP, scancode);
586 return TEST_COMPLETED;
590 * Local helper to check for the invalid scancode error message
593 _checkInvalidNameError()
595 const char *expectedError = "Parameter 'name' is invalid";
597 error = SDL_GetError();
598 SDLTest_AssertPass("Call to SDL_GetError()");
599 SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
601 SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
602 "Validate error message, expected: '%s', got: '%s'", expectedError, error);
604 SDLTest_AssertPass("Call to SDL_ClearError()");
609 * @brief Check call to SDL_GetScancodeFromName with invalid data
611 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromName
612 * @sa http://wiki.libsdl.org/moin.cgi/SDL_Keycode
615 keyboard_getScancodeFromNameNegative(void *arg)
618 SDL_Scancode scancode;
620 /* Clear error message */
622 SDLTest_AssertPass("Call to SDL_ClearError()");
624 /* Random string input */
625 name = SDLTest_RandomAsciiStringOfSize(32);
626 SDLTest_Assert(name != NULL, "Check that random name is not NULL");
630 scancode = SDL_GetScancodeFromName((const char *)name);
631 SDLTest_AssertPass("Call to SDL_GetScancodeFromName('%s')", name);
633 SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode);
634 _checkInvalidNameError();
636 /* Zero length string input */
638 scancode = SDL_GetScancodeFromName((const char *)name);
639 SDLTest_AssertPass("Call to SDL_GetScancodeFromName(NULL)");
640 SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode);
641 _checkInvalidNameError();
645 scancode = SDL_GetScancodeFromName((const char *)name);
646 SDLTest_AssertPass("Call to SDL_GetScancodeFromName(NULL)");
647 SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode);
648 _checkInvalidNameError();
650 return TEST_COMPLETED;
655 /* ================= Test References ================== */
657 /* Keyboard test cases */
658 static const SDLTest_TestCaseReference keyboardTest1 =
659 { (SDLTest_TestCaseFp)keyboard_getKeyboardState, "keyboard_getKeyboardState", "Check call to SDL_GetKeyboardState with and without numkeys reference", TEST_ENABLED };
661 static const SDLTest_TestCaseReference keyboardTest2 =
662 { (SDLTest_TestCaseFp)keyboard_getKeyboardFocus, "keyboard_getKeyboardFocus", "Check call to SDL_GetKeyboardFocus", TEST_ENABLED };
664 static const SDLTest_TestCaseReference keyboardTest3 =
665 { (SDLTest_TestCaseFp)keyboard_getKeyFromName, "keyboard_getKeyFromName", "Check call to SDL_GetKeyFromName for known, unknown and invalid name", TEST_ENABLED };
667 static const SDLTest_TestCaseReference keyboardTest4 =
668 { (SDLTest_TestCaseFp)keyboard_getKeyFromScancode, "keyboard_getKeyFromScancode", "Check call to SDL_GetKeyFromScancode", TEST_ENABLED };
670 static const SDLTest_TestCaseReference keyboardTest5 =
671 { (SDLTest_TestCaseFp)keyboard_getKeyName, "keyboard_getKeyName", "Check call to SDL_GetKeyName", TEST_ENABLED };
673 static const SDLTest_TestCaseReference keyboardTest6 =
674 { (SDLTest_TestCaseFp)keyboard_getSetModState, "keyboard_getSetModState", "Check call to SDL_GetModState and SDL_SetModState", TEST_ENABLED };
676 static const SDLTest_TestCaseReference keyboardTest7 =
677 { (SDLTest_TestCaseFp)keyboard_startStopTextInput, "keyboard_startStopTextInput", "Check call to SDL_StartTextInput and SDL_StopTextInput", TEST_ENABLED };
679 static const SDLTest_TestCaseReference keyboardTest8 =
680 { (SDLTest_TestCaseFp)keyboard_setTextInputRect, "keyboard_setTextInputRect", "Check call to SDL_SetTextInputRect", TEST_ENABLED };
682 static const SDLTest_TestCaseReference keyboardTest9 =
683 { (SDLTest_TestCaseFp)keyboard_setTextInputRectNegative, "keyboard_setTextInputRectNegative", "Check call to SDL_SetTextInputRect with invalid data", TEST_ENABLED };
685 static const SDLTest_TestCaseReference keyboardTest10 =
686 { (SDLTest_TestCaseFp)keyboard_getScancodeFromKey, "keyboard_getScancodeFromKey", "Check call to SDL_GetScancodeFromKey", TEST_ENABLED };
688 static const SDLTest_TestCaseReference keyboardTest11 =
689 { (SDLTest_TestCaseFp)keyboard_getScancodeFromName, "keyboard_getScancodeFromName", "Check call to SDL_GetScancodeFromName", TEST_ENABLED };
691 static const SDLTest_TestCaseReference keyboardTest12 =
692 { (SDLTest_TestCaseFp)keyboard_getScancodeFromNameNegative, "keyboard_getScancodeFromNameNegative", "Check call to SDL_GetScancodeFromName with invalid data", TEST_ENABLED };
694 static const SDLTest_TestCaseReference keyboardTest13 =
695 { (SDLTest_TestCaseFp)keyboard_getKeyNameNegative, "keyboard_getKeyNameNegative", "Check call to SDL_GetKeyName with invalid data", TEST_ENABLED };
697 static const SDLTest_TestCaseReference keyboardTest14 =
698 { (SDLTest_TestCaseFp)keyboard_getScancodeNameNegative, "keyboard_getScancodeNameNegative", "Check call to SDL_GetScancodeName with invalid data", TEST_ENABLED };
700 /* Sequence of Keyboard test cases */
701 static const SDLTest_TestCaseReference *keyboardTests[] = {
702 &keyboardTest1, &keyboardTest2, &keyboardTest3, &keyboardTest4, &keyboardTest5, &keyboardTest6,
703 &keyboardTest7, &keyboardTest8, &keyboardTest9, &keyboardTest10, &keyboardTest11, &keyboardTest12,
704 &keyboardTest13, &keyboardTest14, NULL
707 /* Keyboard test suite (global) */
708 SDLTest_TestSuiteReference keyboardTestSuite = {