Commit c8c29eeb authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

user32/tests: Use calculated WM_SETFONT margins in the CJK case.

parent 6b2c2d39
......@@ -1559,6 +1559,28 @@ static INT get_cjk_fontinfo_margin(INT width, INT side_bearing)
return margin;
}
static DWORD get_cjk_font_margins(HDC hdc, BOOL unicode)
{
ABC abc[256];
SHORT left, right;
UINT i;
left = right = 0;
if (unicode) {
if (!GetCharABCWidthsW(hdc, 0, 255, abc))
return 0;
}
else {
if (!GetCharABCWidthsA(hdc, 0, 255, abc))
return 0;
}
for (i = 0; i < ARRAY_SIZE(abc); i++) {
if (-abc[i].abcA > right) right = -abc[i].abcA;
if (-abc[i].abcC > left) left = -abc[i].abcC;
}
return MAKELONG(left, right);
}
static void test_margins_default(const char* facename, UINT charset)
{
HWND hwnd;
......@@ -1569,7 +1591,7 @@ static void test_margins_default(const char* facename, UINT charset)
LOGFONTA lf;
HFONT hfont;
RECT rect;
INT margins, expect;
INT margins, expect, font_expect;
const UINT small_margins = MAKELONG(1, 5);
const WCHAR EditW[] = {'E','d','i','t',0}, strW[] = {'W',0};
struct char_width_info {
......@@ -1615,9 +1637,14 @@ static void test_margins_default(const char* facename, UINT charset)
left = get_cjk_fontinfo_margin(size.cx, info.lsb);
right = get_cjk_fontinfo_margin(size.cx, info.rsb);
expect = MAKELONG(left, right);
font_expect = get_cjk_font_margins(hdc, TRUE);
if (!font_expect)
/* In this case, margins aren't updated */
font_expect = small_margins;
}
else
expect = MAKELONG(size.cx / 2, size.cx / 2);
font_expect = expect = MAKELONG(size.cx / 2, size.cx / 2);
hfont = SelectObject(hdc, hfont);
ReleaseDC(hwnd, hdc);
......@@ -1627,12 +1654,11 @@ static void test_margins_default(const char* facename, UINT charset)
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins);
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
if (!cjk_charset)
ok(margins == expect, "%s:%d: got %d, %d\n", facename, charset, HIWORD(margins), LOWORD(margins));
todo_wine_if(cjk_charset)
ok(margins == font_expect, "%s:%d: expected %d, %d, got %d, %d\n", facename, charset, HIWORD(font_expect), LOWORD(font_expect), HIWORD(margins), LOWORD(margins));
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins);
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO, EC_USEFONTINFO));
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
ok(margins == expect, "%s:%d: expected %d, %d, got %d, %d\n", facename, charset, HIWORD(expect), LOWORD(expect), HIWORD(margins), LOWORD(margins));
DestroyWindow(hwnd);
......@@ -1642,17 +1668,27 @@ static void test_margins_default(const char* facename, UINT charset)
GetClientRect(hwnd, &rect);
ok(!IsRectEmpty(&rect), "got rect %s\n", wine_dbgstr_rect(&rect));
if (cjk_charset) {
hdc = GetDC(hwnd);
hfont = SelectObject(hdc, hfont);
font_expect = get_cjk_font_margins(hdc, FALSE);
if (!font_expect)
/* In this case, margins aren't updated */
font_expect = small_margins;
hfont = SelectObject(hdc, hfont);
ReleaseDC(hwnd, hdc);
}
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
ok(margins == 0, "got %x\n", margins);
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins);
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
if (!cjk_charset)
ok(margins == expect, "%s:%d: got %d, %d\n", facename, charset, HIWORD(margins), LOWORD(margins));
todo_wine_if(cjk_charset)
ok(margins == font_expect, "%s:%d: expected %d, %d, got %d, %d\n", facename, charset, HIWORD(font_expect), LOWORD(font_expect), HIWORD(margins), LOWORD(margins));
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins);
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO, EC_USEFONTINFO));
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
ok(margins == expect, "%s:%d: expected %d, %d, got %d, %d\n", facename, charset, HIWORD(expect), LOWORD(expect), HIWORD(margins), LOWORD(margins));
DestroyWindow(hwnd);
......
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