Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
Sending this instead, as GetKeyboardLayout(Name) looks harder to fix properly than anticipated.
dlls/user32/tests/input.c | 78 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 72 insertions(+), 6 deletions(-)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 382e124e1f4..a0c31dcf607 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -3036,9 +3036,10 @@ static void test_get_async_key_state(void) static void test_keyboard_layout_name(void) { WCHAR klid[KL_NAMELENGTH], tmpklid[KL_NAMELENGTH], layout_path[MAX_PATH], value[5]; - HKL layout, tmplayout, layouts[64]; - DWORD status, value_size; - int i, len; + HKL layout, tmplayout, *layouts, *layouts_preload; + DWORD status, value_size, klid_size, type, id; + int i, j, len; + HKEY hkey; BOOL ret;
if (0) /* crashes on native system */ @@ -3051,15 +3052,77 @@ static void test_keyboard_layout_name(void)
layout = GetKeyboardLayout(0);
- len = GetKeyboardLayoutList(ARRAY_SIZE(layouts), layouts); + len = GetKeyboardLayoutList(0, NULL); + ok(len > 0, "GetKeyboardLayoutList returned %d\n", len); + + layouts = malloc(len * sizeof(HKL)); + ok(layouts != NULL, "Could not allocate memory\n"); + + len = GetKeyboardLayoutList(len, layouts); ok(len > 0, "GetKeyboardLayoutList returned %d\n", len);
+ layouts_preload = calloc(len, sizeof(HKL)); + ok(layouts_preload != NULL, "Could not allocate memory\n"); + + if (!RegOpenKeyW( HKEY_CURRENT_USER, L"Keyboard Layout\Preload", &hkey )) + { + i = 0; + type = REG_SZ; + klid_size = sizeof(klid); + value_size = ARRAY_SIZE(value); + while (i < len && !RegEnumValueW( hkey, i++, value, &value_size, NULL, &type, (void *)&klid, &klid_size )) + { + klid_size = sizeof(klid); + value_size = ARRAY_SIZE(value); + layouts_preload[i - 1] = UlongToHandle( wcstoul( klid, NULL, 16 ) ); + + id = (DWORD_PTR)layouts_preload[i - 1]; + if (id & 0x80000000) ok((id & 0xf0000000) == 0xd0000000, "Unexpected preloaded keyboard layout high bits %#x\n", id); + else ok(!(id & 0xf0000000), "Unexpected preloaded keyboard layout high bits %#x\n", id); + } + + ok(i <= len, "Unexpected keyboard count %d in preload list\n", i); + RegCloseKey( hkey ); + } + + if (!RegOpenKeyW( HKEY_CURRENT_USER, L"Keyboard Layout\Substitutes", &hkey )) + { + for (i = 0; i < len && layouts_preload[i]; ++i) + { + type = REG_SZ; + klid_size = sizeof(klid); + swprintf( tmpklid, KL_NAMELENGTH, L"%08x", HandleToUlong( layouts_preload[i] ) ); + if (!RegQueryValueExW( hkey, tmpklid, NULL, &type, (void *)&klid, &klid_size )) + { + layouts_preload[i] = UlongToHandle( wcstoul( klid, NULL, 16 ) ); + + /* Substitute should contain the keyboard layout id, not the HKL high word */ + id = (DWORD_PTR)layouts_preload[i]; + ok(!(id & 0xf0000000), "Unexpected substitute keyboard layout high bits %#x\n", id); + } + else + { + id = (DWORD_PTR)layouts_preload[i]; + ok(!(id & 0xf0000000), "Unexpected preloaded keyboard layout high bits %#x\n", id); + } + } + + RegCloseKey( hkey ); + } + for (i = len - 1; i >= 0; --i) { - UINT id = (UINT_PTR)layouts[i]; + id = (DWORD_PTR)layouts[i]; ActivateKeyboardLayout(layouts[i], 0); GetKeyboardLayoutNameW(klid);
+ for (j = 0; j < len; ++j) + { + swprintf( tmpklid, KL_NAMELENGTH, L"%08X", layouts_preload[j] ); + if (!wcscmp( tmpklid, klid )) break; + } + ok(j < len, "Could not find keyboard layout %p in preload list\n", layout); + if (id & 0x80000000) { todo_wine ok((id >> 28) == 0xf, "hkl high bits %#x, expected 0xf\n", id >> 28); @@ -3084,7 +3147,7 @@ static void test_keyboard_layout_name(void) tmplayout = LoadKeyboardLayoutW(klid, KLF_ACTIVATE);
/* The low word of HKL is the selected user lang and may be different as LoadKeyboardLayoutW also selects the default lang from the layout */ - ok(((UINT_PTR)tmplayout & ~0xffff) == ((UINT_PTR)layouts[i] & ~0xffff), "GetKeyboardLayout returned %p, expected %p\n", tmplayout, layouts[i]); + ok(((UINT_PTR)tmplayout & ~0xffff) == ((UINT_PTR)layouts[i] & ~0xffff), "LoadKeyboardLayoutW returned %p, expected %p\n", tmplayout, layouts[i]);
/* The layout name only depends on the keyboard layout: the high word of HKL. */ GetKeyboardLayoutNameW(tmpklid); @@ -3092,6 +3155,9 @@ static void test_keyboard_layout_name(void) }
ActivateKeyboardLayout(layout, 0); + + free(layouts); + free(layouts_preload); }
static void test_key_names(void)
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=89907
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
user32: input.c:757: Test failed: 0 (a4/0): 00 from 00 -> 80 unexpected input.c:757: Test failed: 0 (a4/0): 41 from 01 -> 00 unexpected
=== wvistau64 (64 bit report) ===
user32: input.c:757: Test failed: 0 (a4/0): 01 from 01 -> 00 unexpected input.c:757: Test failed: 0 (a4/0): 11 from 01 -> 00 unexpected input.c:757: Test failed: 0 (a4/0): a2 from 01 -> 00 unexpected
=== w10pro64_zh_CN (64 bit report) ===
user32: input.c:3393: Test failed: expected WM_NCHITTEST message input.c:3394: Test failed: expected WM_RBUTTONDOWN message input.c:3395: Test failed: expected WM_RBUTTONUP message input.c:3424: Test failed: expected WM_LBUTTONDOWN message input.c:3425: Test failed: expected WM_LBUTTONUP message input.c:3478: Test failed: expected loop with WM_NCHITTEST messages input.c:3531: Test failed: expected WM_LBUTTONDOWN message input.c:3532: Test failed: expected WM_LBUTTONUP message
=== debiant2 (32 bit French report) ===
user32: input.c:3124: Test failed: Could not find keyboard layout 040C040C in preload list
=== debiant2 (32 bit Japanese:Japan report) ===
user32: input.c:3080: Test failed: Unexpected preloaded keyboard layout high bits 0xe0010411 input.c:3124: Test failed: Could not find keyboard layout E0010411 in preload list
=== debiant2 (32 bit Chinese:China report) ===
user32: input.c:3080: Test failed: Unexpected preloaded keyboard layout high bits 0xe0010804 input.c:3124: Test failed: Could not find keyboard layout E0010804 in preload list
On 5/4/21 5:08 PM, Marvin wrote:
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=89907
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
user32: input.c:757: Test failed: 0 (a4/0): 00 from 00 -> 80 unexpected input.c:757: Test failed: 0 (a4/0): 41 from 01 -> 00 unexpected
=== wvistau64 (64 bit report) ===
user32: input.c:757: Test failed: 0 (a4/0): 01 from 01 -> 00 unexpected input.c:757: Test failed: 0 (a4/0): 11 from 01 -> 00 unexpected input.c:757: Test failed: 0 (a4/0): a2 from 01 -> 00 unexpected
=== w10pro64_zh_CN (64 bit report) ===
user32: input.c:3393: Test failed: expected WM_NCHITTEST message input.c:3394: Test failed: expected WM_RBUTTONDOWN message input.c:3395: Test failed: expected WM_RBUTTONUP message input.c:3424: Test failed: expected WM_LBUTTONDOWN message input.c:3425: Test failed: expected WM_LBUTTONUP message input.c:3478: Test failed: expected loop with WM_NCHITTEST messages input.c:3531: Test failed: expected WM_LBUTTONDOWN message input.c:3532: Test failed: expected WM_LBUTTONUP message
=== debiant2 (32 bit French report) ===
user32: input.c:3124: Test failed: Could not find keyboard layout 040C040C in preload list
=== debiant2 (32 bit Japanese:Japan report) ===
user32: input.c:3080: Test failed: Unexpected preloaded keyboard layout high bits 0xe0010411 input.c:3124: Test failed: Could not find keyboard layout E0010411 in preload list
=== debiant2 (32 bit Chinese:China report) ===
user32: input.c:3080: Test failed: Unexpected preloaded keyboard layout high bits 0xe0010804 input.c:3124: Test failed: Could not find keyboard layout E0010804 in preload list
I missed these failures, I'll resend the test later as the GetKeyboardLayoutNameW refactor fixes some of the wine failures.