user32/tests: Add tests for GetKeyState / GetKeyboardState interactions.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=26269 Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e10cf973d5
commit
70e67d1d20
|
@ -3723,11 +3723,13 @@ struct get_key_state_test_desc
|
|||
|
||||
struct get_key_state_test_desc get_key_state_tests[] =
|
||||
{
|
||||
/* 0: not peeking in thread, no msg queue: GetKeyState misses key press */
|
||||
/* 0: not peeking in thread, no msg queue: GetKeyState / GetKeyboardState miss key press */
|
||||
{FALSE, TRUE},
|
||||
/* 1: peeking on thread init, not in main: GetKeyState catches key press */
|
||||
/* 1: peeking on thread init, not in main: GetKeyState / GetKeyboardState catch key press */
|
||||
/* - GetKeyboardState misses key press if called before GetKeyState */
|
||||
/* - GetKeyboardState catches key press, if called after GetKeyState */
|
||||
{ TRUE, FALSE},
|
||||
/* 2: peeking on thread init, and in main: GetKeyState catches key press */
|
||||
/* 2: peeking on thread init, and in main: GetKeyState / GetKeyboardState catch key press */
|
||||
{ TRUE, TRUE},
|
||||
};
|
||||
|
||||
|
@ -3743,7 +3745,9 @@ static DWORD WINAPI get_key_state_thread(void *arg)
|
|||
struct get_key_state_test_desc* test;
|
||||
HANDLE *semaphores = params->semaphores;
|
||||
DWORD result;
|
||||
BYTE keystate[256];
|
||||
BOOL has_queue;
|
||||
BOOL ret;
|
||||
MSG msg;
|
||||
int i = params->index;
|
||||
|
||||
|
@ -3766,20 +3770,48 @@ static DWORD WINAPI get_key_state_thread(void *arg)
|
|||
result = WaitForSingleObject(semaphores[1], 1000);
|
||||
ok(result == WAIT_OBJECT_0, "%d: WaitForSingleObject returned %u\n", i, result);
|
||||
|
||||
memset(keystate, 0, sizeof(keystate));
|
||||
ret = GetKeyboardState(keystate);
|
||||
ok(ret, "GetKeyboardState failed, %u\n", GetLastError());
|
||||
result = keystate['X'];
|
||||
todo_wine_if(!has_queue)
|
||||
ok(!result, "%d: expected that keystate is not set, got %#x\n", i, result);
|
||||
|
||||
result = GetKeyState('X');
|
||||
if (!has_queue) todo_wine ok(!(result & 0x8000), "%d: expected that highest bit is unset, got %#x\n", i, result);
|
||||
else todo_wine ok((result & 0x8000), "%d: expected that highest bit is set, got %#x\n", i, result);
|
||||
ok(!(result & 0x007e), "%d: expected that undefined bits are unset, got %#x\n", i, result);
|
||||
|
||||
memset(keystate, 0, sizeof(keystate));
|
||||
ret = GetKeyboardState(keystate);
|
||||
ok(ret, "GetKeyboardState failed, %u\n", GetLastError());
|
||||
result = keystate['X'];
|
||||
if (!has_queue) todo_wine ok(!result, "%d: expected that keystate is unset, got %#x\n", i, result);
|
||||
else todo_wine ok(result, "%d: expected that keystate is set, got %#x\n", i, result);
|
||||
|
||||
/* key released */
|
||||
ReleaseSemaphore(semaphores[0], 1, NULL);
|
||||
result = WaitForSingleObject(semaphores[1], 1000);
|
||||
ok(result == WAIT_OBJECT_0, "%d: WaitForSingleObject returned %u\n", i, result);
|
||||
|
||||
memset(keystate, 0, sizeof(keystate));
|
||||
ret = GetKeyboardState(keystate);
|
||||
ok(ret, "GetKeyboardState failed, %u\n", GetLastError());
|
||||
result = keystate['X'];
|
||||
if (!has_queue) ok(!result, "%d: expected that keystate is unset, got %#x\n", i, result);
|
||||
else todo_wine ok(result, "%d: expected that keystate is set, got %#x\n", i, result);
|
||||
|
||||
result = GetKeyState('X');
|
||||
ok(!(result & 0x8000), "%d: expected that highest bit is unset, got %#x\n", i, result);
|
||||
ok(!(result & 0x007e), "%d: expected that undefined bits are unset, got %#x\n", i, result);
|
||||
|
||||
memset(keystate, 0, sizeof(keystate));
|
||||
ret = GetKeyboardState(keystate);
|
||||
ok(ret, "GetKeyboardState failed, %u\n", GetLastError());
|
||||
result = keystate['X'];
|
||||
if (!has_queue) ok(!result || broken(result) /* w2008 */, "%d: expected that keystate is unset, got %#x\n", i, result);
|
||||
else todo_wine ok(result || broken(!result) /* w2008 */, "%d: expected that keystate is set, got %#x\n", i, result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue