Module: wine Branch: master Commit: c1480126b10ba3fe5c14242ee15e75eead3e4186 URL: http://source.winehq.org/git/wine.git/?a=commit;h=c1480126b10ba3fe5c14242ee1...
Author: Dan Hipschman dsh@linux.ucla.edu Date: Thu Jun 19 15:59:57 2008 -0700
gdi32: Add tests for GetTextFace.
Currently only GetTextFaceA is tested, and in an ancillary way, and the behavior differs from GetTextFaceW.
---
dlls/gdi32/tests/font.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 91 insertions(+), 2 deletions(-)
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c index 710148a..c67c7b6 100644 --- a/dlls/gdi32/tests/font.c +++ b/dlls/gdi32/tests/font.c @@ -1097,8 +1097,8 @@ static BOOL get_glyph_indices(INT charset, UINT code_page, WORD *idx, UINT count ok(cs == charset, "expected %d, got %d\n", charset, cs);
SetLastError(0xdeadbeef); - ret = GetTextFace(hdc, sizeof(name), name); - ok(ret, "GetTextFace error %u\n", GetLastError()); + ret = GetTextFaceA(hdc, sizeof(name), name); + ok(ret, "GetTextFaceA error %u\n", GetLastError());
if (charset == SYMBOL_CHARSET) { @@ -1930,6 +1930,94 @@ static void test_GdiRealizationInfo(void) ReleaseDC(0, hdc); }
+/* Tests on XP SP2 show that the ANSI version of GetTextFace does NOT include + the nul in the count of characters copied when the face name buffer is not + NULL, whereas it does if the buffer is NULL. Further, the Unicode version + always includes it. */ +static void test_GetTextFace(void) +{ + static const char faceA[] = "Tahoma"; + static const WCHAR faceW[] = {'T','a','h','o','m','a', 0}; + LOGFONTA fA = {0}; + LOGFONTW fW = {0}; + char bufA[LF_FACESIZE]; + WCHAR bufW[LF_FACESIZE]; + HFONT f, g; + HDC dc; + int n; + + /* 'A' case. */ + memcpy(fA.lfFaceName, faceA, sizeof faceA); + f = CreateFontIndirectA(&fA); + ok(f != NULL, "CreateFontIndirectA failed\n"); + + dc = GetDC(NULL); + g = SelectObject(dc, f); + n = GetTextFaceA(dc, sizeof bufA, bufA); + ok(n == sizeof faceA - 1, "GetTextFaceA returned %d\n", n); + ok(lstrcmpA(faceA, bufA) == 0, "GetTextFaceA\n"); + + /* Play with the count arg. */ + bufA[0] = 'x'; + n = GetTextFaceA(dc, 0, bufA); + todo_wine + ok(n == 0, "GetTextFaceA returned %d\n", n); + ok(bufA[0] == 'x', "GetTextFaceA buf[0] == %d\n", bufA[0]); + + bufA[0] = 'x'; + n = GetTextFaceA(dc, 1, bufA); + ok(n == 0, "GetTextFaceA returned %d\n", n); + ok(bufA[0] == '\0', "GetTextFaceA buf[0] == %d\n", bufA[0]); + + bufA[0] = 'x'; bufA[1] = 'y'; + n = GetTextFaceA(dc, 2, bufA); + ok(n == 1, "GetTextFaceA returned %d\n", n); + ok(bufA[0] == faceA[0] && bufA[1] == '\0', "GetTextFaceA didn't copy\n"); + + n = GetTextFaceA(dc, 0, NULL); + ok(n == sizeof faceA, "GetTextFaceA returned %d\n", n); + + DeleteObject(SelectObject(dc, g)); + ReleaseDC(NULL, dc); + + /* 'W' case. */ + memcpy(fW.lfFaceName, faceW, sizeof faceW); + f = CreateFontIndirectW(&fW); + ok(f != NULL, "CreateFontIndirectW failed\n"); + + dc = GetDC(NULL); + g = SelectObject(dc, f); + n = GetTextFaceW(dc, sizeof bufW / sizeof bufW[0], bufW); + todo_wine + ok(n == sizeof faceW / sizeof faceW[0], "GetTextFaceW returned %d\n", n); + ok(lstrcmpW(faceW, bufW) == 0, "GetTextFaceW\n"); + + /* Play with the count arg. */ + bufW[0] = 'x'; + n = GetTextFaceW(dc, 0, bufW); + todo_wine + ok(n == 0, "GetTextFaceW returned %d\n", n); + ok(bufW[0] == 'x', "GetTextFaceW buf[0] == %d\n", bufW[0]); + + bufW[0] = 'x'; + n = GetTextFaceW(dc, 1, bufW); + todo_wine + ok(n == 1, "GetTextFaceW returned %d\n", n); + ok(bufW[0] == '\0', "GetTextFaceW buf[0] == %d\n", bufW[0]); + + bufW[0] = 'x'; bufW[1] = 'y'; + n = GetTextFaceW(dc, 2, bufW); + todo_wine + ok(n == 2, "GetTextFaceW returned %d\n", n); + ok(bufW[0] == faceW[0] && bufW[1] == '\0', "GetTextFaceW didn't copy\n"); + + n = GetTextFaceW(dc, 0, NULL); + ok(n == sizeof faceW / sizeof faceW[0], "GetTextFaceW returned %d\n", n); + + DeleteObject(SelectObject(dc, g)); + ReleaseDC(NULL, dc); +} + START_TEST(font) { init(); @@ -1964,4 +2052,5 @@ START_TEST(font) skip("Arial Black or Symbol/Wingdings is not installed\n"); test_GetTextMetrics(); test_GdiRealizationInfo(); + test_GetTextFace(); }