user32/tests: Tests default margin size with various font face.
Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
11f0597074
commit
3e61c7127e
|
@ -1549,7 +1549,7 @@ static void test_margins_usefontinfo(UINT charset)
|
||||||
DeleteObject(hfont);
|
DeleteObject(hfont);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_margins_default(UINT charset)
|
static void test_margins_default(const char* facename, UINT charset)
|
||||||
{
|
{
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
|
@ -1567,7 +1567,7 @@ static void test_margins_default(UINT charset)
|
||||||
lf.lfHeight = -11;
|
lf.lfHeight = -11;
|
||||||
lf.lfWeight = FW_NORMAL;
|
lf.lfWeight = FW_NORMAL;
|
||||||
lf.lfCharSet = charset;
|
lf.lfCharSet = charset;
|
||||||
strcpy(lf.lfFaceName, "Tahoma");
|
strcpy(lf.lfFaceName, facename);
|
||||||
|
|
||||||
hfont = CreateFontIndirectA(&lf);
|
hfont = CreateFontIndirectA(&lf);
|
||||||
ok(hfont != NULL, "got %p\n", hfont);
|
ok(hfont != NULL, "got %p\n", hfont);
|
||||||
|
@ -1602,16 +1602,16 @@ static void test_margins_default(UINT charset)
|
||||||
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
|
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
|
||||||
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
||||||
if (!cjk_charset)
|
if (!cjk_charset)
|
||||||
ok(margins == expect, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins));
|
ok(margins == expect, "%s:%d: got %d, %d\n", facename, charset, HIWORD(margins), LOWORD(margins));
|
||||||
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins);
|
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins);
|
||||||
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO, EC_USEFONTINFO));
|
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO, EC_USEFONTINFO));
|
||||||
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
||||||
if (!cjk_charset)
|
if (!cjk_charset)
|
||||||
ok(margins == expect, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins));
|
ok(margins == expect, "%s:%d: got %d, %d\n", facename, charset, HIWORD(margins), LOWORD(margins));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ok(HIWORD(margins) <= HIWORD(expect), "%d: got %d\n", charset, HIWORD(margins));
|
ok(HIWORD(margins) <= HIWORD(expect), "%s:%d: got %d\n", facename, charset, HIWORD(margins));
|
||||||
ok(LOWORD(margins) <= LOWORD(expect), "%d: got %d\n", charset, LOWORD(margins));
|
ok(LOWORD(margins) <= LOWORD(expect), "%s:%d: got %d\n", facename, charset, LOWORD(margins));
|
||||||
}
|
}
|
||||||
DestroyWindow(hwnd);
|
DestroyWindow(hwnd);
|
||||||
|
|
||||||
|
@ -1627,22 +1627,39 @@ static void test_margins_default(UINT charset)
|
||||||
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
|
SendMessageA(hwnd, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
|
||||||
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
||||||
if (!cjk_charset)
|
if (!cjk_charset)
|
||||||
ok(margins == expect, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins));
|
ok(margins == expect, "%s:%d: got %d, %d\n", facename, charset, HIWORD(margins), LOWORD(margins));
|
||||||
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins);
|
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, small_margins);
|
||||||
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO, EC_USEFONTINFO));
|
SendMessageA(hwnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO, EC_USEFONTINFO));
|
||||||
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
margins = SendMessageA(hwnd, EM_GETMARGINS, 0, 0);
|
||||||
if (!cjk_charset)
|
if (!cjk_charset)
|
||||||
ok(margins == expect, "%d: got %d, %d\n", charset, HIWORD(margins), LOWORD(margins));
|
ok(margins == expect, "%s:%d: got %d, %d\n", facename, charset, HIWORD(margins), LOWORD(margins));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ok(HIWORD(margins) <= HIWORD(expect), "%d: got %d\n", charset, HIWORD(margins));
|
ok(HIWORD(margins) <= HIWORD(expect), "%s:%d: got %d\n", facename, charset, HIWORD(margins));
|
||||||
ok(LOWORD(margins) <= LOWORD(expect), "%d: got %d\n", charset, LOWORD(margins));
|
ok(LOWORD(margins) <= LOWORD(expect), "%s:%d: got %d\n", facename, charset, LOWORD(margins));
|
||||||
}
|
}
|
||||||
DestroyWindow(hwnd);
|
DestroyWindow(hwnd);
|
||||||
|
|
||||||
DeleteObject(hfont);
|
DeleteObject(hfont);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static INT CALLBACK find_font_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL is_font_installed(const char*name)
|
||||||
|
{
|
||||||
|
HDC hdc = GetDC(NULL);
|
||||||
|
BOOL ret = FALSE;
|
||||||
|
|
||||||
|
if (!EnumFontFamiliesA(hdc, name, find_font_proc, 0))
|
||||||
|
ret = TRUE;
|
||||||
|
|
||||||
|
ReleaseDC(NULL, hdc);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static void test_margins(void)
|
static void test_margins(void)
|
||||||
{
|
{
|
||||||
HWND hwEdit;
|
HWND hwEdit;
|
||||||
|
@ -1718,17 +1735,26 @@ static void test_margins(void)
|
||||||
|
|
||||||
test_margins_usefontinfo(DEFAULT_CHARSET);
|
test_margins_usefontinfo(DEFAULT_CHARSET);
|
||||||
|
|
||||||
test_margins_default(ANSI_CHARSET);
|
test_margins_default("Tahoma", ANSI_CHARSET);
|
||||||
test_margins_default(EASTEUROPE_CHARSET);
|
test_margins_default("Tahoma", EASTEUROPE_CHARSET);
|
||||||
|
|
||||||
test_margins_default(SHIFTJIS_CHARSET);
|
test_margins_default("Tahoma", HANGUL_CHARSET);
|
||||||
test_margins_default(HANGUL_CHARSET);
|
test_margins_default("Tahoma", CHINESEBIG5_CHARSET);
|
||||||
test_margins_default(CHINESEBIG5_CHARSET);
|
|
||||||
}
|
|
||||||
|
|
||||||
static INT CALLBACK find_font_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
|
if (is_font_installed("MS PGothic"))
|
||||||
{
|
test_margins_default("MS PGothic", SHIFTJIS_CHARSET);
|
||||||
return 0;
|
else
|
||||||
|
skip("MS PGothic is not available, skipping some margin tests\n");
|
||||||
|
|
||||||
|
if (is_font_installed("Ume P Gothic"))
|
||||||
|
test_margins_default("Ume P Gothic", SHIFTJIS_CHARSET);
|
||||||
|
else
|
||||||
|
skip("Ume P Gothic is not available, skipping some margin tests\n");
|
||||||
|
|
||||||
|
if (is_font_installed("SimSun"))
|
||||||
|
test_margins_default("SimSun", GB2312_CHARSET);
|
||||||
|
else
|
||||||
|
skip("SimSun is not available, skipping some margin tests\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_margins_font_change(void)
|
static void test_margins_font_change(void)
|
||||||
|
@ -1737,15 +1763,12 @@ static void test_margins_font_change(void)
|
||||||
DWORD margins, font_margins;
|
DWORD margins, font_margins;
|
||||||
LOGFONTA lf;
|
LOGFONTA lf;
|
||||||
HFONT hfont, hfont2;
|
HFONT hfont, hfont2;
|
||||||
HDC hdc = GetDC(0);
|
|
||||||
|
|
||||||
if(EnumFontFamiliesA(hdc, "Arial", find_font_proc, 0))
|
if (!is_font_installed("Arial"))
|
||||||
{
|
{
|
||||||
trace("Arial not found - skipping font change margin tests\n");
|
skip("Arial not found - skipping font change margin tests\n");
|
||||||
ReleaseDC(0, hdc);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ReleaseDC(0, hdc);
|
|
||||||
|
|
||||||
hwEdit = create_child_editcontrol(0, 0);
|
hwEdit = create_child_editcontrol(0, 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue