From 9942948097ff6d83010f5ae6d574e95bc6d6676d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Tue, 9 Feb 2021 11:00:29 +0100 Subject: [PATCH] user32/tests: Add tests for SetKeyboardState / GetKeyState interactions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=26269 Signed-off-by: RĂ©mi Bernon Signed-off-by: Alexandre Julliard --- dlls/user32/tests/input.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index be274414eea..9d75daa0bd5 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -3777,11 +3777,18 @@ static DWORD WINAPI get_key_state_thread(void *arg) todo_wine_if(!has_queue) ok(!result, "%d: expected that keystate is not set, got %#x\n", i, result); + result = keystate['C']; + ok(!result, "%d: expected that C 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); + result = GetKeyState('C'); + ok(!(result & 0x8000), "%d: expected that C highest bit is unset, got %#x\n", i, result); + ok(!(result & 0x007e), "%d: expected that C undefined bits are unset, got %#x\n", i, result); + memset(keystate, 0, sizeof(keystate)); ret = GetKeyboardState(keystate); ok(ret, "GetKeyboardState failed, %u\n", GetLastError()); @@ -3789,6 +3796,9 @@ static DWORD WINAPI get_key_state_thread(void *arg) 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); + result = keystate['C']; + ok(!result, "%d: expected that C keystate is not set, got %#x\n", i, result); + /* key released */ ReleaseSemaphore(semaphores[0], 1, NULL); result = WaitForSingleObject(semaphores[1], 1000); @@ -3801,10 +3811,17 @@ static DWORD WINAPI get_key_state_thread(void *arg) 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 = keystate['C']; + ok(!result, "%d: expected that C keystate is not 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); + result = GetKeyState('C'); + ok(!(result & 0x8000), "%d: expected that C highest bit is unset, got %#x\n", i, result); + ok(!(result & 0x007e), "%d: expected that C undefined bits are unset, got %#x\n", i, result); + memset(keystate, 0, sizeof(keystate)); ret = GetKeyboardState(keystate); ok(ret, "GetKeyboardState failed, %u\n", GetLastError()); @@ -3812,6 +3829,9 @@ static DWORD WINAPI get_key_state_thread(void *arg) 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); + result = keystate['C']; + ok(!result, "%d: expected that C keystate is not set, got %#x\n", i, result); + return 0; } @@ -3820,6 +3840,7 @@ static void test_GetKeyState(void) struct get_key_state_thread_params params; HANDLE thread; DWORD result; + BYTE keystate[256]; HWND hwnd; MSG msg; int i; @@ -3831,6 +3852,7 @@ static void test_GetKeyState(void) return; } + memset(keystate, 0, sizeof(keystate)); params.semaphores[0] = CreateSemaphoreA(NULL, 0, 1, NULL); ok(params.semaphores[0] != NULL, "CreateSemaphoreA failed %u\n", GetLastError()); params.semaphores[1] = CreateSemaphoreA(NULL, 0, 1, NULL); @@ -3864,8 +3886,12 @@ static void test_GetKeyState(void) ok(result == WAIT_OBJECT_0, "%d: WaitForSingleObject returned %u\n", i, result); keybd_event('X', 0, 0, 0); + keystate['C'] = 0xff; + SetKeyboardState(keystate); if (test->peek_message_main) while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); + result = GetKeyState('C'); + ok((result & 0x8000), "%d: expected that highest bit is set, got %#x\n", i, result); result = GetKeyState('X'); if (test->peek_message_main) ok((result & 0x8000), "%d: expected that highest bit is set, got %#x\n", i, result); else ok(!(result & 0x8000), "%d: expected that highest bit is unset, got %#x\n", i, result); @@ -3877,8 +3903,12 @@ static void test_GetKeyState(void) ok(result == WAIT_OBJECT_0, "%d: WaitForSingleObject returned %u\n", i, result); keybd_event('X', 0, KEYEVENTF_KEYUP, 0); + keystate['C'] = 0x00; + SetKeyboardState(keystate); if (test->peek_message_main) while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); + result = GetKeyState('C'); + ok(!(result & 0x8000), "%d: expected that highest bit is unset, got %#x\n", i, result); result = GetKeyState('X'); ok(!(result & 0x8000), "%d: expected that highest bit is unset, got %#x\n", i, result);