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

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


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

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

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 at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/user32/tests/input.c | 38 +++++++++++++++++++++++++++++++++++---
 1 file changed, 35 insertions(+), 3 deletions(-)

diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c
index 696dbe12cb7..be274414eea 100644
--- a/dlls/user32/tests/input.c
+++ b/dlls/user32/tests/input.c
@@ -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;
 }
 




More information about the wine-cvs mailing list