Signed-off-by: Sven Baars sbaars@codeweavers.com --- dlls/gdi32/tests/font.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c index ea1bb960df..48f0710bf6 100644 --- a/dlls/gdi32/tests/font.c +++ b/dlls/gdi32/tests/font.c @@ -4926,6 +4926,7 @@ static void test_GetCharacterPlacement(void) GCP_RESULTSA result; DWORD size, size2; WCHAR glyphs[20]; + int pos[20]; HDC hdc;
hdc = CreateCompatibleDC(0); @@ -4933,23 +4934,56 @@ static void test_GetCharacterPlacement(void)
memset(&result, 0, sizeof(result)); result.lStructSize = sizeof(result); + result.lpCaretPos = pos; result.lpGlyphs = glyphs; result.nGlyphs = 20;
+ pos[0] = -1; + glyphs[0] = '!'; size = GetCharacterPlacementA(hdc, "Wine Test", 9, 0, &result, 0); ok(size, "GetCharacterPlacementA failed!\n"); - + ok(result.nGlyphs == 9, "Unexpected number of glyphs %u\n", result.nGlyphs); + ok(glyphs[0] == 'W', "Unexpected first glyph %s\n", wine_dbgstr_wn(glyphs, 1)); + ok(pos[0] == 0, "Unexpected caret position %d\n", pos[0]); + + pos[0] = -1; + glyphs[0] = '!'; + result.nGlyphs = 20; + size2 = GetCharacterPlacementA(hdc, "Wine Test", 0, 0, &result, 0); + ok(!size2, "Expected GetCharacterPlacementA to fail\n"); + todo_wine ok(result.nGlyphs == 20, "Unexpected number of glyphs %u\n", result.nGlyphs); + ok(glyphs[0] == '!', "Unexpected first glyph %s\n", wine_dbgstr_wn(glyphs, 1)); + todo_wine ok(pos[0] == -1, "Unexpected caret position %d\n", pos[0]); + + pos[0] = -1; + glyphs[0] = '!'; + result.nGlyphs = 20; size2 = GetCharacterPlacementA(hdc, "Wine Test", 9, 0, NULL, 0); ok(size2, "GetCharacterPlacementA failed!\n"); ok(size == size2, "GetCharacterPlacementA returned different result: %u vs %u\n", size2, size); + ok(result.nGlyphs == 20, "Unexpected number of glyphs %u\n", result.nGlyphs); + ok(glyphs[0] == '!', "Unexpected first glyph %s\n", wine_dbgstr_wn(glyphs, 1)); + ok(pos[0] == -1, "Unexpected caret position %d\n", pos[0]);
+ pos[0] = -1; + glyphs[0] = '!'; + result.nGlyphs = 20; size2 = GetCharacterPlacementA(hdc, "Wine Test", 9, 1024, NULL, GCP_REORDER); ok(size2, "GetCharacterPlacementA failed!\n"); ok(size == size2, "GetCharacterPlacementA returned different result: %u vs %u\n", size2, size); + ok(result.nGlyphs == 20, "Unexpected number of glyphs %u\n", result.nGlyphs); + ok(glyphs[0] == '!', "Unexpected first glyph %s\n", wine_dbgstr_wn(glyphs, 1)); + ok(pos[0] == -1, "Unexpected caret position %d\n", pos[0]);
+ pos[0] = -1; + glyphs[0] = '!'; + result.nGlyphs = 20; size = GetCharacterPlacementA(hdc, "Wine Test", 9, 1024, &result, GCP_REORDER); ok(size, "GetCharacterPlacementA failed!\n"); ok(size == size2, "GetCharacterPlacementA returned different result: %u vs %u\n", size2, size); + ok(result.nGlyphs == 9, "Unexpected number of glyphs %u\n", result.nGlyphs); + ok(glyphs[0] == 'W', "Unexpected first glyph %s\n", wine_dbgstr_wn(glyphs, 1)); + todo_wine ok(pos[0] == 0, "Unexpected caret position %d\n", pos[0]);
DeleteDC(hdc); }
Signed-off-by: Sven Baars sbaars@codeweavers.com --- v2: Now with some tests.
dlls/gdi32/font.c | 3 +++ dlls/gdi32/tests/font.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c index d451f30c3e..8788426a2c 100644 --- a/dlls/gdi32/font.c +++ b/dlls/gdi32/font.c @@ -3313,6 +3313,9 @@ GetCharacterPlacementW( TRACE("%s, %d, %d, 0x%08x\n", debugstr_wn(lpString, uCount), uCount, nMaxExtent, dwFlags);
+ if (!uCount) + return 0; + if (!lpResults) return GetTextExtentPoint32W(hdc, lpString, uCount, &size) ? MAKELONG(size.cx, size.cy) : 0;
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c index 48f0710bf6..93b6ef8c08 100644 --- a/dlls/gdi32/tests/font.c +++ b/dlls/gdi32/tests/font.c @@ -4951,9 +4951,9 @@ static void test_GetCharacterPlacement(void) result.nGlyphs = 20; size2 = GetCharacterPlacementA(hdc, "Wine Test", 0, 0, &result, 0); ok(!size2, "Expected GetCharacterPlacementA to fail\n"); - todo_wine ok(result.nGlyphs == 20, "Unexpected number of glyphs %u\n", result.nGlyphs); + ok(result.nGlyphs == 20, "Unexpected number of glyphs %u\n", result.nGlyphs); ok(glyphs[0] == '!', "Unexpected first glyph %s\n", wine_dbgstr_wn(glyphs, 1)); - todo_wine ok(pos[0] == -1, "Unexpected caret position %d\n", pos[0]); + ok(pos[0] == -1, "Unexpected caret position %d\n", pos[0]);
pos[0] = -1; glyphs[0] = '!';
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=65302
Your paranoid android.
=== wxppro (32 bit report) ===
gdi32: font.c:7346: Test failed: CreateProcess failed.
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=65301
Your paranoid android.
=== wxppro (32 bit report) ===
gdi32: font.c:7346: Test failed: CreateProcess failed.
On Mon, Feb 17, 2020 at 10:01:04AM +0100, Sven Baars wrote:
Signed-off-by: Sven Baars sbaars@codeweavers.com
dlls/gdi32/tests/font.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c index ea1bb960df..48f0710bf6 100644 --- a/dlls/gdi32/tests/font.c +++ b/dlls/gdi32/tests/font.c @@ -4926,6 +4926,7 @@ static void test_GetCharacterPlacement(void) GCP_RESULTSA result; DWORD size, size2; WCHAR glyphs[20];
int pos[20]; HDC hdc;
hdc = CreateCompatibleDC(0);
@@ -4933,23 +4934,56 @@ static void test_GetCharacterPlacement(void)
memset(&result, 0, sizeof(result)); result.lStructSize = sizeof(result);
result.lpCaretPos = pos; result.lpGlyphs = glyphs; result.nGlyphs = 20;
pos[0] = -1;
glyphs[0] = '!'; size = GetCharacterPlacementA(hdc, "Wine Test", 9, 0, &result, 0); ok(size, "GetCharacterPlacementA failed!\n");
- ok(result.nGlyphs == 9, "Unexpected number of glyphs %u\n", result.nGlyphs);
- ok(glyphs[0] == 'W', "Unexpected first glyph %s\n", wine_dbgstr_wn(glyphs, 1));
- ok(pos[0] == 0, "Unexpected caret position %d\n", pos[0]);
- pos[0] = -1;
- glyphs[0] = '!';
- result.nGlyphs = 20;
- size2 = GetCharacterPlacementA(hdc, "Wine Test", 0, 0, &result, 0);
- ok(!size2, "Expected GetCharacterPlacementA to fail\n");
- todo_wine ok(result.nGlyphs == 20, "Unexpected number of glyphs %u\n", result.nGlyphs);
- ok(glyphs[0] == '!', "Unexpected first glyph %s\n", wine_dbgstr_wn(glyphs, 1));
- todo_wine ok(pos[0] == -1, "Unexpected caret position %d\n", pos[0]);
- pos[0] = -1;
- glyphs[0] = '!';
- result.nGlyphs = 20; size2 = GetCharacterPlacementA(hdc, "Wine Test", 9, 0, NULL, 0); ok(size2, "GetCharacterPlacementA failed!\n"); ok(size == size2, "GetCharacterPlacementA returned different result: %u vs %u\n", size2, size);
- ok(result.nGlyphs == 20, "Unexpected number of glyphs %u\n", result.nGlyphs);
- ok(glyphs[0] == '!', "Unexpected first glyph %s\n", wine_dbgstr_wn(glyphs, 1));
- ok(pos[0] == -1, "Unexpected caret position %d\n", pos[0]);
There's little point in testing the values from the results structure if it's not passed to the function. So leave these additional tests and initialisations out.
- pos[0] = -1;
- glyphs[0] = '!';
- result.nGlyphs = 20; size2 = GetCharacterPlacementA(hdc, "Wine Test", 9, 1024, NULL, GCP_REORDER); ok(size2, "GetCharacterPlacementA failed!\n"); ok(size == size2, "GetCharacterPlacementA returned different result: %u vs %u\n", size2, size);
- ok(result.nGlyphs == 20, "Unexpected number of glyphs %u\n", result.nGlyphs);
- ok(glyphs[0] == '!', "Unexpected first glyph %s\n", wine_dbgstr_wn(glyphs, 1));
- ok(pos[0] == -1, "Unexpected caret position %d\n", pos[0]);
And the same for these.
Huw.
On 17-02-2020 16:24, Huw Davies wrote:
On Mon, Feb 17, 2020 at 10:01:04AM +0100, Sven Baars wrote:
- pos[0] = -1;
- glyphs[0] = '!';
- result.nGlyphs = 20; size2 = GetCharacterPlacementA(hdc, "Wine Test", 9, 0, NULL, 0); ok(size2, "GetCharacterPlacementA failed!\n"); ok(size == size2, "GetCharacterPlacementA returned different result: %u vs %u\n", size2, size);
- ok(result.nGlyphs == 20, "Unexpected number of glyphs %u\n", result.nGlyphs);
- ok(glyphs[0] == '!', "Unexpected first glyph %s\n", wine_dbgstr_wn(glyphs, 1));
- ok(pos[0] == -1, "Unexpected caret position %d\n", pos[0]);
There's little point in testing the values from the results structure if it's not passed to the function. So leave these additional tests and initialisations out.
Of course. Those tests didn't make any sense. Sorry for that. I sent the updated patches.
Sven