[PATCH v2 0/2] MR5652: Draft: user32: Skip SendInput keyboard tests if a layout change is detected.
In some Win10 testbot images (notably jp and cn), we can get a spurious layout change after creating the test window. Detect this and skip the tests since the test expectations (e.g., wchar mappings) are now invalid. -- v2: user32: Remove workaround for SendInput keyboard tests on zh_CN. user32: Skip affected keyboard tests if a spurious layout change is detected. https://gitlab.winehq.org/wine/wine/-/merge_requests/5652
From: Alexandros Frantzis <alexandros.frantzis(a)collabora.com> In some Win10 testbot images (notably jp and cn), we can get a spurious layout change after creating the test window and also when explicitly activating the offending layout. Detect such behavior and skip tests whose assumptions are invalidate by this spurious change. --- dlls/user32/tests/input.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 81af2aa5f28..da076e5dcd9 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -714,7 +714,7 @@ static void get_test_scan( WORD vkey, WORD *scan, WCHAR *wch, WCHAR *wch_shift ) } } -static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, WCHAR wch_shift, WCHAR wch_control ) +static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, WCHAR wch_shift, WCHAR wch_control, HKL hkl ) { #define WIN_MSG(m, w, l, ...) {.func = MSG_TEST_WIN, .message = {.msg = m, .wparam = w, .lparam = l}, ## __VA_ARGS__} #define KBD_HOOK(m, s, v, f, ...) {.func = LL_HOOK_KEYBD, .ll_hook_kbd = {.msg = m, .scan = s, .vkey = v, .flags = f}, ## __VA_ARGS__} @@ -1163,6 +1163,14 @@ static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, W ok_ne( NULL, hwnd, HWND, "%p" ); wait_messages( 100, FALSE ); + /* If we have had a spurious layout change, wch(_shift) may be incorrect. */ + if (GetKeyboardLayout( 0 ) != hkl) + { + win_skip( "Spurious keyboard layout changed detected (expected: %p got: %p)\n", + hkl, GetKeyboardLayout( 0 ) ); + return; + } + hook = SetWindowsHookExW( WH_KEYBOARD_LL, ll_hook_kbd_proc, GetModuleHandleW( NULL ), 0 ); ok_ne( NULL, hook, HHOOK, "%p" ); @@ -4918,7 +4926,7 @@ static void test_UnregisterDeviceNotification(void) ok(ret == FALSE, "Unregistering NULL Device Notification returned: %d\n", ret); } -static void test_SendInput( WORD vkey, WCHAR wch ) +static void test_SendInput( WORD vkey, WCHAR wch, HKL hkl ) { const struct user_call broken_sequence[] = { @@ -4936,6 +4944,14 @@ static void test_SendInput( WORD vkey, WCHAR wch ) ok_ne( NULL, hwnd, HWND, "%p" ); wait_messages( 100, FALSE ); + /* If we have had a spurious layout change, wch may be incorrect. */ + if (GetKeyboardLayout( 0 ) != hkl) + { + win_skip( "Spurious keyboard layout changed detected (expected: %p got: %p)\n", + hkl, GetKeyboardLayout( 0 ) ); + return; + } + SetLastError( 0xdeadbeef ); ok_ret( 0, SendInput( 0, NULL, 0 ) ); ok_ret( ERROR_INVALID_PARAMETER, GetLastError() ); @@ -5649,7 +5665,7 @@ static void test_keyboard_ll_hook_blocking(void) ok_ret( 1, DestroyWindow( hwnd ) ); } -static void test_LoadKeyboardLayoutEx(void) +static void test_LoadKeyboardLayoutEx(HKL orig_hkl) { static const WCHAR test_layout_name[] = L"00000429"; static const HKL test_hkl = (HKL)0x04290429; @@ -5661,6 +5677,16 @@ static void test_LoadKeyboardLayoutEx(void) old_hkl = GetKeyboardLayout( 0 ); ok_ne( 0, old_hkl, HKL, "%p" ); + /* If we are dealing with a testbot setup that is prone to spurious + * layout changes, layout activations in this test are likely to + * not have the expected effect, invalidating the test assumptions. */ + if (orig_hkl != old_hkl) + { + win_skip( "Spurious keyboard layout changed detected (expected: %p got: %p)\n", + orig_hkl, old_hkl ); + return; + } + hkl = pLoadKeyboardLayoutEx( NULL, test_layout_name, 0 ); ok_eq( 0, hkl, HKL, "%p" ); @@ -5758,8 +5784,8 @@ static void test_input_desktop( char **argv ) test_SetCursorPos(); get_test_scan( 'F', &scan, &wch, &wch_shift ); - test_SendInput( 'F', wch ); - test_SendInput_keyboard_messages( 'F', scan, wch, wch_shift, '\x06' ); + test_SendInput( 'F', wch, hkl ); + test_SendInput_keyboard_messages( 'F', scan, wch, wch_shift, '\x06', hkl ); test_SendInput_mouse_messages(); test_keyboard_ll_hook_blocking(); @@ -5768,7 +5794,7 @@ static void test_input_desktop( char **argv ) test_GetRawInputData(); test_GetRawInputBuffer(); - test_LoadKeyboardLayoutEx(); + test_LoadKeyboardLayoutEx( hkl ); ok_ret( 1, SetCursorPos( pos.x, pos.y ) ); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/5652
From: Alexandros Frantzis <alexandros.frantzis(a)collabora.com> The workaround was needed because the zh_CN Win10 testbot image may spuriously change to the ru_RU keyboard layout during testing. We now detect such changes and skip the tests, so the workaround is not needed. --- dlls/user32/tests/input.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index da076e5dcd9..5ba641222a9 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -705,13 +705,6 @@ static void get_test_scan( WORD vkey, WORD *scan, WCHAR *wch, WCHAR *wch_shift ) ok_ret( 1, ToUnicodeEx( vkey, *scan, state, wch, 1, 0, hkl ) ); state[VK_SHIFT] = 0x80; ok_ret( 1, ToUnicodeEx( vkey, *scan, state, wch_shift, 1, 0, hkl ) ); - - /* zh_CN returns a different WM_(SYS)CHAR, possibly coming from IME */ - if (HIWORD(hkl) == 0x0804) - { - *wch = 0x430; - *wch_shift = 0x410; - } } static void test_SendInput_keyboard_messages( WORD vkey, WORD scan, WCHAR wch, WCHAR wch_shift, WCHAR wch_control, HKL hkl ) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/5652
Hi, It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated. The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=145593 Your paranoid android. === build (build log) === error: patch failed: dlls/user32/tests/input.c:705 Task: Patch failed to apply === debian11 (build log) === error: patch failed: dlls/user32/tests/input.c:705 Task: Patch failed to apply === debian11b (build log) === error: patch failed: dlls/user32/tests/input.c:705 Task: Patch failed to apply
participants (3)
-
Alexandros Frantzis -
Alexandros Frantzis (@afrantzis) -
Marvin