From: Akihiro Sagawa sagawa.aki@gmail.com
Comctl32 is different from user32. It doesn't have A-W duality and uses the input codepage in it. --- dlls/comctl32/tests/edit.c | 70 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)
diff --git a/dlls/comctl32/tests/edit.c b/dlls/comctl32/tests/edit.c index f45b898dc12..eae3cae45e0 100644 --- a/dlls/comctl32/tests/edit.c +++ b/dlls/comctl32/tests/edit.c @@ -3764,6 +3764,75 @@ static void test_ime(void) DestroyWindow(hwnd); }
+static DWORD get_input_codepage( void ) +{ + DWORD cp; + int ret; + HKL hkl = GetKeyboardLayout( 0 ); + + ret = GetLocaleInfoW( LOWORD(hkl), LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER, + (WCHAR *)&cp, sizeof(cp) / sizeof(WCHAR) ); + if (!ret) cp = CP_ACP; + return cp; +} + +static void test_WM_CHAR(void) +{ + static const WCHAR textW[] = { 0x4e00, 0x4e8c, 0x00d7, '!', 0 }; /* one, two, x, ! */ + CPINFO cpinfo; + HWND hwnd[2]; + int i; + + GetCPInfo(CP_ACP, &cpinfo); + if (cpinfo.MaxCharSize > 2) + { + skip("Skipping legacy WM_CHAR test in UTF-8 codepage\n"); + return; + } + hwnd[0] = CreateWindowExA(0, "EDIT", "", ES_AUTOHSCROLL, 0, 0, 300, 30, NULL, NULL, hinst, NULL); + hwnd[1] = CreateWindowExW(0, L"EDIT", L"", ES_AUTOHSCROLL, 0, 0, 300, 30, NULL, NULL, hinst, NULL); + + for (i = 0; i < ARRAY_SIZE(hwnd); i++) + { + const unsigned char* p; + WCHAR bufW[10], strW[10]; + char buf[10], str[10]; + DWORD cp; + MSG msg; + int n; + + winetest_push_context("%c", i ? 'W' : 'A'); + + cp = get_input_codepage(); + n = WideCharToMultiByte(cp, 0, textW, -1, buf, ARRAY_SIZE(buf), NULL, NULL); + ok(n > 0, "WideCharToMultiByte failed\n"); + + for (p = (unsigned char*)buf; *p; p++) + PostMessageA(hwnd[i], WM_CHAR, *p, 1); + + while (PeekMessageA(&msg, hwnd[i], 0, 0, PM_REMOVE)) + DispatchMessageA(&msg); + + n = MultiByteToWideChar(cp, 0, buf, -1, bufW, ARRAY_SIZE(bufW)); + ok(n > 0, "MultiByteToWideChar failed\n"); + n = GetWindowTextW(hwnd[i], strW, ARRAY_SIZE(strW)); + ok(n > 0, "GetWindowTextW failed\n"); + ok(!wcscmp(strW, bufW), "got %s, expected %s\n", + wine_dbgstr_w(strW), wine_dbgstr_w(bufW)); + + n = WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, ARRAY_SIZE(buf), NULL, NULL); + ok(n > 0, "WideCharToMultiByte failed\n"); + n = GetWindowTextA(hwnd[i], str, ARRAY_SIZE(str)); + ok(n > 0, "GetWindowText failed\n"); + ok(!strcmp(str, buf), "got %s, expected %s\n", + wine_dbgstr_a(str), wine_dbgstr_a(buf)); + + DestroyWindow(hwnd[i]); + + winetest_pop_context(); + } +} + START_TEST(edit) { ULONG_PTR ctx_cookie; @@ -3811,6 +3880,7 @@ START_TEST(edit) test_change_focus(); test_cue_banner(); test_ime(); + test_WM_CHAR();
UnregisterWindowClasses();