Commit 8b8d787d authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

user32/tests: Fix the DBCS WM_CHAR tests in mixed locales.

WM_CHAR interprets the character codes using a code page tied to the keyboard layout, not CP_ACP. Also skip the test if WideCharToMultiByte() used the default character since that breaks the round-trip. Trace the code page when skipping the tests. Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=54424
parent 6fb47669
...@@ -3368,15 +3368,22 @@ static void test_wordbreak_proc(void) ...@@ -3368,15 +3368,22 @@ static void test_wordbreak_proc(void)
static void test_dbcs_WM_CHAR(void) static void test_dbcs_WM_CHAR(void)
{ {
HKL hkl;
UINT cp;
WCHAR textW[] = { 0x4e00, 0x4e8c, 0x4e09, 0 }; /* one, two, three */ WCHAR textW[] = { 0x4e00, 0x4e8c, 0x4e09, 0 }; /* one, two, three */
unsigned char bytes[7]; unsigned char bytes[7];
BOOL hasdefault;
HWND hwnd[2]; HWND hwnd[2];
int i; int i;
WideCharToMultiByte(CP_ACP, 0, textW, -1, (char *)bytes, ARRAY_SIZE(bytes), NULL, NULL); hkl = GetKeyboardLayout( 0 );
if (!IsDBCSLeadByte(bytes[0])) if (!GetLocaleInfoW(LOWORD(hkl), LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER, (WCHAR *)&cp, sizeof(cp) / sizeof(WCHAR)))
cp = CP_ACP;
WideCharToMultiByte(cp, WC_NO_BEST_FIT_CHARS, textW, -1, (char *)bytes, ARRAY_SIZE(bytes), NULL, &hasdefault);
if (hasdefault || !IsDBCSLeadByteEx(cp, bytes[0]))
{ {
skip("Skipping DBCS WM_CHAR test in this codepage\n"); skip("Skipping DBCS WM_CHAR test in the %d codepage\n", cp);
return; return;
} }
hwnd[0] = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); hwnd[0] = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
...@@ -3396,6 +3403,7 @@ static void test_dbcs_WM_CHAR(void) ...@@ -3396,6 +3403,7 @@ static void test_dbcs_WM_CHAR(void)
r = SetWindowTextA(hwnd[i], ""); r = SetWindowTextA(hwnd[i], "");
ok(r, "SetWindowText failed\n"); ok(r, "SetWindowText failed\n");
/* sending the lead byte separately works for DBCS locales */
for (p = bytes; *p; p++) for (p = bytes; *p; p++)
PostMessageA(hwnd[i], WM_CHAR, *p, 1); PostMessageA(hwnd[i], WM_CHAR, *p, 1);
......
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