gdi32/tests: Refactor test_fake_bold_font() to avoid code duplications.

Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Akihiro Sagawa 2015-12-31 13:33:12 +09:00 committed by Alexandre Julliard
parent f6998ea4ce
commit 6cd42f3df7
1 changed files with 34 additions and 32 deletions

View File

@ -6304,12 +6304,14 @@ static void test_GetCharWidth32(void)
static void test_fake_bold_font(void) static void test_fake_bold_font(void)
{ {
HDC hdc; HDC hdc;
HFONT hfont, hfont_old;
LOGFONTA lf; LOGFONTA lf;
BOOL ret; BOOL ret;
TEXTMETRICA tm[2]; struct glyph_data {
ABC abc[2]; TEXTMETRICA tm;
INT w[2]; ABC abc;
INT w;
} data[2];
int i;
if (!pGetCharWidth32A || !pGetCharABCWidthsA) { if (!pGetCharWidth32A || !pGetCharABCWidthsA) {
win_skip("GetCharWidth32A/GetCharABCWidthA is not available on this platform\n"); win_skip("GetCharWidth32A/GetCharABCWidthA is not available on this platform\n");
@ -6319,44 +6321,44 @@ static void test_fake_bold_font(void)
/* Test outline font */ /* Test outline font */
memset(&lf, 0, sizeof(lf)); memset(&lf, 0, sizeof(lf));
strcpy(lf.lfFaceName, "Wingdings"); strcpy(lf.lfFaceName, "Wingdings");
lf.lfWeight = FW_NORMAL;
lf.lfCharSet = SYMBOL_CHARSET; lf.lfCharSet = SYMBOL_CHARSET;
hfont = CreateFontIndirectA(&lf);
hdc = GetDC(NULL); hdc = GetDC(NULL);
hfont_old = SelectObject(hdc, hfont);
/* base metrics */ for (i = 0; i <= 1; i++)
ret = GetTextMetricsA(hdc, &tm[0]); {
ok(ret, "got %d\n", ret); HFONT hfont, hfont_old;
ret = pGetCharABCWidthsA(hdc, 0x76, 0x76, &abc[0]);
ok(ret, "got %d\n", ret);
lf.lfWeight = FW_BOLD; lf.lfWeight = i ? FW_BOLD : FW_NORMAL;
hfont = CreateFontIndirectA(&lf); hfont = CreateFontIndirectA(&lf);
DeleteObject(SelectObject(hdc, hfont)); hfont_old = SelectObject(hdc, hfont);
/* bold metrics */ ret = GetTextMetricsA(hdc, &data[i].tm);
ret = GetTextMetricsA(hdc, &tm[1]); ok(ret, "got %d\n", ret);
ok(ret, "got %d\n", ret); ret = pGetCharABCWidthsA(hdc, 0x76, 0x76, &data[i].abc);
ret = pGetCharABCWidthsA(hdc, 0x76, 0x76, &abc[1]); ok(ret, "got %d\n", ret);
ok(ret, "got %d\n", ret); data[i].w = data[i].abc.abcA + data[i].abc.abcB + data[i].abc.abcC;
DeleteObject(SelectObject(hdc, hfont_old)); SelectObject(hdc, hfont_old);
DeleteObject(hfont);
}
ReleaseDC(NULL, hdc); ReleaseDC(NULL, hdc);
/* compare results (outline) */ /* compare results (outline) */
ok(tm[0].tmHeight == tm[1].tmHeight, "expected %d, got %d\n", tm[0].tmHeight, tm[1].tmHeight); ok(data[0].tm.tmHeight == data[1].tm.tmHeight,
ok(tm[0].tmAscent == tm[1].tmAscent, "expected %d, got %d\n", tm[0].tmAscent, tm[1].tmAscent); "expected %d, got %d\n", data[0].tm.tmHeight, data[1].tm.tmHeight);
ok(tm[0].tmDescent == tm[1].tmDescent, "expected %d, got %d\n", tm[0].tmDescent, tm[1].tmDescent); ok(data[0].tm.tmAscent == data[1].tm.tmAscent,
ok((tm[0].tmAveCharWidth + 1) == tm[1].tmAveCharWidth, "expected %d, got %d\n", data[0].tm.tmAscent, data[1].tm.tmAscent);
"expected %d, got %d\n", tm[0].tmAveCharWidth + 1, tm[1].tmAveCharWidth); ok(data[0].tm.tmDescent == data[1].tm.tmDescent,
ok((tm[0].tmMaxCharWidth + 1) == tm[1].tmMaxCharWidth, "expected %d, got %d\n", data[0].tm.tmDescent, data[1].tm.tmDescent);
"expected %d, got %d\n", tm[0].tmMaxCharWidth + 1, tm[1].tmMaxCharWidth); ok(data[0].tm.tmAveCharWidth + 1 == data[1].tm.tmAveCharWidth,
ok(tm[0].tmOverhang == tm[1].tmOverhang, "expected %d, got %d\n", tm[0].tmOverhang, tm[1].tmOverhang); "expected %d, got %d\n", data[0].tm.tmAveCharWidth + 1, data[1].tm.tmAveCharWidth);
w[0] = abc[0].abcA + abc[0].abcB + abc[0].abcC; ok(data[0].tm.tmMaxCharWidth + 1 == data[1].tm.tmMaxCharWidth,
w[1] = abc[1].abcA + abc[1].abcB + abc[1].abcC; "expected %d, got %d\n", data[0].tm.tmMaxCharWidth + 1, data[1].tm.tmMaxCharWidth);
ok((w[0] + 1) == w[1], "expected %d, got %d\n", w[0] + 1, w[1]); ok(data[0].tm.tmOverhang == data[1].tm.tmOverhang,
"expected %d, got %d\n", data[0].tm.tmOverhang, data[1].tm.tmOverhang);
ok(data[0].w + 1 == data[1].w,
"expected %d, got %d\n", data[0].w + 1, data[1].w);
} }