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.
-- v3: user32/tests: Remove workaround for SendInput keyboard tests on zh_CN. user32/tests: Skip affected keyboard tests if a spurious layout change is detected.
From: Alexandros Frantzis alexandros.frantzis@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 ) ); }
From: Alexandros Frantzis alexandros.frantzis@collabora.com
The workaround was needed because the zh_CN Win10 testbot 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 )
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 tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=145591
Your paranoid android.
=== w11pro64 (32 bit report) ===
user32: input.c:4089: Test failed: layered 1: button_down_hwnd_todo 0: got MSG_TEST_WIN hwnd 000E01BC, msg WM_LBUTTONDOWN, wparam 0x1, lparam 0x320032 input.c:4089: Test failed: layered 1: button_down_hwnd_todo 1 (missing): MSG_TEST_WIN hwnd 000E01BC, WM_LBUTTONDOWN, wparam 0x1, lparam 0x320032
=== w11pro64_amd (64 bit report) ===
user32: input.c:3849: Test failed: button_up_hwnd 0: got MSG_TEST_WIN hwnd 000000000004025E, msg WM_LBUTTONUP, wparam 0, lparam 0x320032 input.c:3849: Test failed: button_up_hwnd 1 (missing): MSG_TEST_WIN hwnd 000000000004025E, WM_LBUTTONUP, wparam 0, lparam 0x320032
In https://testbot.winehq.org/JobDetails.pl?Key=145554 I have added some debugging information to the SendInput tests.
The spurious layout change happen around the WM_IME_NOTIFY (0x282) message so it's likely that IME is involved.
Below is an excerpt from Win10 JP run (https://testbot.winehq.org/JobDetails.pl?Key=145554&f310=exe64.report#k3...) with some additional inline comments. Notice the spurious layout changes, both after creating the window and also when trying to reactivate the expected layout (0411):
``` ### I was thinking that perhaps the per window layout option is enabled and messing things up, but it doesn't ### seem to be the case. The following is the value of HCKU\Control Panel\Desktop\UserPreferencesMask: input.c:5873: mask=9e 1e 07 80 12 00 00 00 input.c:5876: per-window-layout=0 input.c:5878: hkl=0000000004110411 input.c:5880: hkl=0000000004110411 input.c:4983: hkl=0000000004110411 before create window input.c:5822: hwnd 0000000000010396 msg 0x0081 wp 0000000000000000 lp 0000000000FFECC0 hkl 0000000004110411 input.c:5822: hwnd 0000000000010396 msg 0x0083 wp 0000000000000000 lp 0000000000FFED40 hkl 0000000004110411 input.c:5822: hwnd 0000000000010396 msg 0x0001 wp 0000000000000000 lp 0000000000FFECC0 hkl 0000000004110411 input.c:5822: hwnd 0000000000010396 msg 0x0005 wp 0000000000000000 lp 0000000000640064 hkl 0000000004110411 input.c:5822: hwnd 0000000000010396 msg 0x0003 wp 0000000000000000 lp 0000000000000000 hkl 0000000004110411 input.c:5822: hwnd 0000000000010396 msg 0x0018 wp 0000000000000001 lp 0000000000000000 hkl 0000000004110411 input.c:5822: hwnd 0000000000010396 msg 0x0046 wp 0000000000000000 lp 0000000000FFED20 hkl 0000000004110411 input.c:5822: hwnd 0000000000010396 msg 0x001c wp 0000000000000001 lp 0000000000000000 hkl 0000000004110411 input.c:5822: hwnd 0000000000010396 msg 0x0086 wp 0000000000000001 lp 0000000000000000 hkl 0000000004110411 input.c:5822: hwnd 0000000000010396 msg 0x0006 wp 0000000000000001 lp 0000000000000000 hkl 0000000004110411 input.c:5822: hwnd 0000000000010396 msg 0x0281 wp 0000000000000001 lp 00000000C000000F hkl 0000000004110411 input.c:5822: hwnd 0000000000010396 msg 0x0282 wp 0000000000000002 lp 0000000000000000 hkl 0000000004110411 input.c:5822: hwnd 0000000000010396 msg 0x0007 wp 0000000000000000 lp 0000000000000000 hkl 0000000004110411 input.c:5822: hwnd 0000000000010396 msg 0x0085 wp 0000000000000001 lp 0000000000000000 hkl 0000000004110411 input.c:5822: hwnd 0000000000010396 msg 0x0014 wp FFFFFFFF910107E4 lp 0000000000000000 hkl 0000000004110411 input.c:5822: hwnd 0000000000010396 msg 0x0047 wp 0000000000000000 lp 0000000000FFED20 hkl 0000000004110411 input.c:4985: hkl=0000000004110411 after create window input.c:5822: hwnd 0000000000010396 msg 0x0084 wp 0000000000000000 lp 0000000000320032 hkl 0000000004110411 input.c:5822: hwnd 0000000000010396 msg 0x0020 wp 0000000000010396 lp 0000000002000001 hkl 0000000004110411 input.c:5822: hwnd 0000000000010396 msg 0x0200 wp 0000000000000000 lp 0000000000320032 hkl 0000000004110411 input.c:5822: hwnd 0000000000010396 msg 0x000f wp 0000000000000000 lp 0000000000000000 hkl 0000000004110411 input.c:5822: hwnd 0000000000010396 msg 0x0282 wp 0000000000000001 lp 0000000000000000 hkl 0000000004110411 ### Layout change from 0411 (JP) -> 0412 (KO) during handling of initial window messages input.c:5822: hwnd 0000000000010396 msg 0x0282 wp 0000000000000002 lp 0000000000000000 hkl 0000000004120412 input.c:5822: hwnd 0000000000010396 msg 0x0051 wp 0000000000000081 lp 0000000004120412 hkl 0000000004120412 input.c:5830: hwnd 0000000000010396 got langchange hkl=04120412 input.c:5822: hwnd 0000000000010396 msg 0x0282 wp 0000000000000006 lp 0000000000000000 hkl 0000000004120412 input.c:5822: hwnd 0000000000010396 msg 0x0084 wp 0000000000000000 lp 0000000000320032 hkl 0000000004120412 input.c:5822: hwnd 0000000000010396 msg 0x0020 wp 0000000000010396 lp 0000000002000001 hkl 0000000004120412 input.c:5822: hwnd 0000000000010396 msg 0x0200 wp 0000000000000000 lp 0000000000320032 hkl 0000000004120412 input.c:4988: hkl=0000000004120412 after create window messages ### Here I have added code to reactivate the original layout manually input.c:4991: Activate layout 0000000004110411 input.c:5822: hwnd 0000000000010396 msg 0x0282 wp 0000000000000001 lp 0000000000000000 hkl 0000000004120412 ### Activation of the 0411 layout seems to work temporarily... input.c:5822: hwnd 0000000000010396 msg 0x0282 wp 0000000000000002 lp 0000000000000000 hkl 0000000004110411 input.c:5822: hwnd 0000000000010396 msg 0x0282 wp 0000000000000001 lp 0000000000000000 hkl 0000000004110411 ### But then we get another layout change, from 0411 -> 0416 this time input.c:5822: hwnd 0000000000010396 msg 0x0282 wp 0000000000000002 lp 0000000000000000 hkl 0000000004160416 input.c:5822: hwnd 0000000000010396 msg 0x0051 wp 0000000000000000 lp 0000000004160416 hkl 0000000004160416 input.c:5830: hwnd 0000000000010396 got langchange hkl=04160416 input.c:5822: hwnd 0000000000010396 msg 0x0282 wp 0000000000000006 lp 0000000000000000 hkl 0000000004160416 ### Although we get a langchange message for 0411... input.c:5822: hwnd 0000000000010396 msg 0x0051 wp 0000000000000080 lp 0000000004110411 hkl 0000000004160416 input.c:5830: hwnd 0000000000010396 got langchange hkl=04110411 ### ... the current layout is not really updated input.c:4999: hkl=0000000004160416 ```
Rémi Bernon (@rbernon) commented about dlls/user32/tests/input.c:
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;
You'll need to destroy the window here. Same below.
Rémi Bernon (@rbernon) commented about dlls/user32/tests/input.c:
ok_ret( 1, DestroyWindow( hwnd ) );
}
-static void test_LoadKeyboardLayoutEx(void) +static void test_LoadKeyboardLayoutEx(HKL orig_hkl)
```suggestion:-0+0 static void test_LoadKeyboardLayoutEx( HKL orig_hkl ) ```