Rémi Bernon : user32/tests: Add tests for SetKeyboardState / GetKeyState interactions.

Alexandre Julliard julliard at winehq.org
Wed Feb 17 16:23:34 CST 2021


Module: wine
Branch: master
Commit: 9942948097ff6d83010f5ae6d574e95bc6d6676d
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=9942948097ff6d83010f5ae6d574e95bc6d6676d

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Tue Feb  9 11:00:29 2021 +0100

user32/tests: Add tests for SetKeyboardState / GetKeyState interactions.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=26269
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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);
 




More information about the wine-cvs mailing list