Akihiro Sagawa : user32/tests: Use EM_SETMARGINS to test EC_USEFONTINFO margins.
Alexandre Julliard
julliard at winehq.org
Mon Mar 18 16:20:16 CDT 2019
Module: wine
Branch: master
Commit: 71523aeae9a729ef64c55f216a76492ac60b9605
URL: https://source.winehq.org/git/wine.git/?a=commit;h=71523aeae9a729ef64c55f216a76492ac60b9605
Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date: Thu Mar 14 23:55:21 2019 +0900
user32/tests: Use EM_SETMARGINS to test EC_USEFONTINFO margins.
Tests assume that WM_SETFONT margins are equal to EM_SETMARGINS with
EC_USEFONTINFO ones. This isn't true when font's charset is CJK.
Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/user32/tests/edit.c | 47 ++++++++++++++++++++++++++++++++++++-----------
1 file changed, 36 insertions(+), 11 deletions(-)
diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c
index 326d7ec..72fad2d 100644
--- a/dlls/user32/tests/edit.c
+++ b/dlls/user32/tests/edit.c
@@ -1435,17 +1435,28 @@ static void test_edit_control_scroll(void)
DestroyWindow (hwEdit);
}
+static BOOL is_cjk_charset(HDC dc)
+{
+ switch (GdiGetCodePage(dc)) {
+ case 932: case 936: case 949: case 950: case 1361:
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
static void test_margins_usefontinfo(UINT charset)
{
HWND hwnd;
HDC hdc;
TEXTMETRICW tm;
SIZE size;
- BOOL cjk = FALSE;
+ BOOL cjk = FALSE, cjk_charset;
LOGFONTA lf;
HFONT hfont;
RECT rect;
- INT margins, threshold, expect, empty_expect, small_expect;
+ INT margins, threshold, expect, empty_expect;
+ const UINT small_margins = MAKELONG(1, 5);
memset(&lf, 0, sizeof(lf));
lf.lfHeight = -11;
@@ -1475,8 +1486,6 @@ static void test_margins_usefontinfo(UINT charset)
return;
}
expect = MAKELONG(size.cx / 2, size.cx / 2);
- small_expect = 0;
- empty_expect = size.cx >= 28 ? small_expect : expect;
charset = GetTextCharset(hdc);
switch (charset)
@@ -1487,26 +1496,35 @@ static void test_margins_usefontinfo(UINT charset)
case CHINESEBIG5_CHARSET:
cjk = TRUE;
}
+ cjk_charset = is_cjk_charset(hdc);
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)
+ if (!cjk_charset)
+ ok(margins == expect, "%d: got %d, %d\n", charset, 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);
+ if (!cjk_charset)
ok(margins == expect, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins));
else
{
- ok(HIWORD(margins) > 0 && LOWORD(margins) > 0, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins));
- expect = empty_expect = small_expect = margins;
+ ok(HIWORD(margins) <= HIWORD(expect), "%d: got %d\n", charset, HIWORD(margins));
+ ok(LOWORD(margins) <= LOWORD(expect), "%d: got %d\n", charset, LOWORD(margins));
+ expect = margins;
}
DestroyWindow(hwnd);
- threshold = (size.cx / 2 + size.cx) * 2;
+ threshold = HIWORD(expect) + LOWORD(expect) + size.cx * 2;
+ empty_expect = threshold > 80 ? small_margins : expect;
- /* Size below which non-cjk margins are zero */
+ /* Size below the threshold, margins remain unchanged */
hwnd = CreateWindowExA(0, "Edit", "A", WS_POPUP, 0, 0, threshold - 1, 100, NULL, NULL, NULL, NULL);
ok(hwnd != NULL, "got %p\n", hwnd);
GetClientRect(hwnd, &rect);
@@ -1516,11 +1534,14 @@ static void test_margins_usefontinfo(UINT charset)
ok(margins == 0, "got %x\n", margins);
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
+ 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 == small_expect, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins));
+ todo_wine_if(cjk)
+ ok(margins == small_margins, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins));
DestroyWindow(hwnd);
- /* Size at which non-cjk margins become non-zero */
+ /* Size at the threshold, margins become non-zero */
hwnd = CreateWindowExA(0, "Edit", "A", WS_POPUP, 0, 0, threshold, 100, NULL, NULL, NULL, NULL);
ok(hwnd != NULL, "got %p\n", hwnd);
GetClientRect(hwnd, &rect);
@@ -1530,6 +1551,8 @@ static void test_margins_usefontinfo(UINT charset)
ok(margins == 0, "got %x\n", margins);
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
+ 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, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins));
DestroyWindow(hwnd);
@@ -1544,6 +1567,8 @@ static void test_margins_usefontinfo(UINT charset)
ok(margins == 0, "got %x\n", margins);
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
+ 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 == empty_expect, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins));
DestroyWindow(hwnd);
More information about the wine-cvs
mailing list