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

user32/tests: Add tests for keyboard layout preload list.

parent fbd30fff
......@@ -3072,9 +3072,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 */
......@@ -3087,15 +3088,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) todo_wine_if(HIWORD(id) == 0xe001) 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);
......@@ -3120,7 +3183,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);
......@@ -3128,6 +3191,9 @@ static void test_keyboard_layout_name(void)
}
ActivateKeyboardLayout(layout, 0);
free(layouts);
free(layouts_preload);
}
static void test_key_names(void)
......
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