Module: wine Branch: master Commit: d5cfbf5da43388fb3a824b51f184a1293a77da47 URL: https://gitlab.winehq.org/wine/wine/-/commit/d5cfbf5da43388fb3a824b51f184a12...
Author: Rémi Bernon rbernon@codeweavers.com Date: Sat Jan 20 15:30:17 2024 +0100
user32/tests: Test that WH_KEYBOARD_LL are blocking SendInput.
---
dlls/user32/tests/input.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index a05b6a441c2..d48440a20be 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -5178,6 +5178,43 @@ static void test_ClipCursor( char **argv ) if (!EqualRect( &rect, &virtual_rect )) ok_ret( 1, ClipCursor( NULL ) ); }
+static HANDLE ll_keyboard_event; + +static LRESULT CALLBACK ll_keyboard_event_wait(int code, WPARAM wparam, LPARAM lparam) +{ + if (code == HC_ACTION) + { + ok_ret( WAIT_TIMEOUT, WaitForSingleObject( ll_keyboard_event, 100 ) ); + return -123; + } + + return CallNextHookEx( 0, code, wparam, lparam ); +} + +static void test_keyboard_ll_hook_blocking(void) +{ + INPUT input = {.type = INPUT_KEYBOARD, .ki = {.wVk = VK_RETURN}}; + HHOOK hook; + HWND hwnd; + + hwnd = CreateWindowW( L"static", NULL, WS_POPUP | WS_VISIBLE, 0, 0, 100, 100, NULL, NULL, NULL, NULL ); + ok_ne( NULL, hwnd, HWND, "%p" ); + wait_messages( 100, FALSE ); + hook = SetWindowsHookExW( WH_KEYBOARD_LL, ll_keyboard_event_wait, GetModuleHandleW( NULL ), 0 ); + ok_ne( NULL, hook, HHOOK, "%p" ); + ll_keyboard_event = CreateEventW( NULL, FALSE, FALSE, NULL ); + ok_ne( NULL, ll_keyboard_event, HANDLE, "%p" ); + + ok_ret( 1, SendInput( 1, &input, sizeof(input) ) ); + input.ki.dwFlags = KEYEVENTF_KEYUP; + ok_ret( 1, SendInput( 1, &input, sizeof(input) ) ); + ok_ret( 1, SetEvent( ll_keyboard_event ) ); + + ok_ret( 1, CloseHandle( ll_keyboard_event ) ); + ok_ret( 1, UnhookWindowsHookEx( hook ) ); + ok_ret( 1, DestroyWindow( hwnd ) ); +} + /* run the tests in a separate desktop to avoid interaction with other * tests, current desktop state, or user actions. */ static void test_input_desktop( char **argv ) @@ -5194,6 +5231,8 @@ static void test_input_desktop( char **argv ) test_SendInput( 'F', wch ); test_SendInput_keyboard_messages( 'F', scan, wch, wch_shift, '\x06' );
+ test_keyboard_ll_hook_blocking(); + ok_ret( 1, SetCursorPos( pos.x, pos.y ) ); }