Sebastian Lackner : user32/tests: Add tests for calling GetKeyState from thread without message queue.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Jul 10 08:50:49 CDT 2015
Module: wine
Branch: master
Commit: 6019da2355dee9adb1e0e9146dcabaf9b0248690
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6019da2355dee9adb1e0e9146dcabaf9b0248690
Author: Sebastian Lackner <sebastian at fds-team.de>
Date: Wed Jul 8 13:31:08 2015 +0200
user32/tests: Add tests for calling GetKeyState from thread without message queue.
---
dlls/user32/tests/input.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c
index cb130e8..83f99ad 100644
--- a/dlls/user32/tests/input.c
+++ b/dlls/user32/tests/input.c
@@ -2427,6 +2427,70 @@ static void test_attach_input(void)
DestroyWindow(Wnd2);
}
+static DWORD WINAPI get_key_state_thread(void *arg)
+{
+ HANDLE *semaphores = arg;
+ DWORD result;
+
+ ReleaseSemaphore(semaphores[0], 1, NULL);
+ result = WaitForSingleObject(semaphores[1], 1000);
+ ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
+
+ result = GetKeyState('X');
+ todo_wine
+ ok((result & 0x8000) || broken(!(result & 0x8000)), /* > Win 2003 */
+ "expected that highest bit is set, got %x\n", result);
+
+ ReleaseSemaphore(semaphores[0], 1, NULL);
+ result = WaitForSingleObject(semaphores[1], 1000);
+ ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
+
+ result = GetKeyState('X');
+ ok(!(result & 0x8000), "expected that highest bit is unset, got %x\n", result);
+
+ return 0;
+}
+
+static void test_GetKeyState(void)
+{
+ HANDLE semaphores[2];
+ HANDLE thread;
+ DWORD result;
+ HWND hwnd;
+
+ semaphores[0] = CreateSemaphoreA(NULL, 0, 1, NULL);
+ ok(semaphores[0] != NULL, "CreateSemaphoreA failed %u\n", GetLastError());
+ semaphores[1] = CreateSemaphoreA(NULL, 0, 1, NULL);
+ ok(semaphores[1] != NULL, "CreateSemaphoreA failed %u\n", GetLastError());
+
+ hwnd = CreateWindowA("static", "Title", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+ 10, 10, 200, 200, NULL, NULL, NULL, NULL);
+ ok(hwnd != NULL, "CreateWindowA failed %u\n", GetLastError());
+
+ thread = CreateThread(NULL, 0, get_key_state_thread, semaphores, 0, NULL);
+ ok(thread != NULL, "CreateThread failed %u\n", GetLastError());
+ result = WaitForSingleObject(semaphores[0], 1000);
+ ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
+
+ SetFocus(hwnd);
+ keybd_event('X', 0, 0, 0);
+
+ ReleaseSemaphore(semaphores[1], 1, NULL);
+ result = WaitForSingleObject(semaphores[0], 1000);
+ ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
+
+ keybd_event('X', 0, KEYEVENTF_KEYUP, 0);
+
+ ReleaseSemaphore(semaphores[1], 1, NULL);
+ result = WaitForSingleObject(thread, 1000);
+ ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
+ CloseHandle(thread);
+
+ DestroyWindow(hwnd);
+ CloseHandle(semaphores[0]);
+ CloseHandle(semaphores[1]);
+}
+
START_TEST(input)
{
init_function_pointers();
@@ -2449,6 +2513,7 @@ START_TEST(input)
test_keyboard_layout_name();
test_key_names();
test_attach_input();
+ test_GetKeyState();
if(pGetMouseMovePointsEx)
test_GetMouseMovePointsEx();
More information about the wine-cvs
mailing list