Commit 99429480 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

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

parent 70e67d1d
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment