[PATCH 2/7] d3dx9/tests: Add some more ID3DXFont tests.
Sven Baars
sbaars at codeweavers.com
Sat Jan 4 05:59:47 CST 2020
Signed-off-by: Sven Baars <sbaars at codeweavers.com>
---
dlls/d3dx9_36/tests/core.c | 127 ++++++++++++++++++++++++++++++-------
1 file changed, 104 insertions(+), 23 deletions(-)
diff --git a/dlls/d3dx9_36/tests/core.c b/dlls/d3dx9_36/tests/core.c
index 8b90f0ef5f..7edc47eb77 100644
--- a/dlls/d3dx9_36/tests/core.c
+++ b/dlls/d3dx9_36/tests/core.c
@@ -306,19 +306,34 @@ static void test_ID3DXSprite(IDirect3DDevice9 *device)
static void test_ID3DXFont(IDirect3DDevice9 *device)
{
static const WCHAR testW[] = {'t','e','s','t',0};
+ static const WCHAR emptyW[] = {0};
+ static const char longText[] = "Example text to test clipping and other related things";
+ static const WCHAR longTextW[] = {'E', 'x', 'a', 'm', 'p', 'l', 'e', ' ',
+ 't', 'e', 'x', 't', ' ', 't', 'o', ' ',
+ 't', 'e', 's', 't', ' ', 'c', 'l', 'i', 'p', 'p', 'i', 'n', 'g', ' ',
+ 'a', 'n', 'd', ' ', 'o', 't', 'h', 'e', 'r', ' ',
+ 'r', 'e', 'l', 'a', 't', 'e', 'd', ' ', 't', 'h', 'i', 'n', 'g', 's', 0};
+
static const struct
{
int font_height;
+ unsigned int expected_height;
unsigned int expected_size;
unsigned int expected_levels;
}
tests[] =
{
- { 6, 128, 4 },
- { 8, 128, 4 },
- { 10, 256, 5 },
- { 12, 256, 5 },
- { 72, 256, 8 },
+ { 2, 2, 32, 2 },
+ { 4, 4, 64, 3 },
+ { 6, 6, 128, 4 },
+ { 8, 8, 128, 4 },
+ { 10, 10, 256, 5 },
+ { 12, 12, 256, 5 },
+ { 72, 72, 256, 8 },
+ { 256, 255, 256, 9 },
+ { 257, 255, 256, 9 },
+ { 258, 258, 512, 10 },
+ { 512, 512, 512, 10 },
};
const unsigned int size = ARRAY_SIZE(testW);
D3DXFONT_DESCA desc;
@@ -477,6 +492,10 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
hr = ID3DXFont_PreloadTextA(font, "test", -1);
ok(hr == D3D_OK, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3D_OK);
+ hr = ID3DXFont_PreloadTextA(font, "", 0);
+ ok(hr == D3D_OK, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3D_OK);
+ hr = ID3DXFont_PreloadTextA(font, "", -1);
+ ok(hr == D3D_OK, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3D_OK);
hr = ID3DXFont_PreloadTextW(font, NULL, -1);
ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
@@ -486,6 +505,10 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
hr = ID3DXFont_PreloadTextW(font, testW, -1);
ok(hr == D3D_OK, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3D_OK);
+ hr = ID3DXFont_PreloadTextW(font, emptyW, 0);
+ ok(hr == D3D_OK, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3D_OK);
+ hr = ID3DXFont_PreloadTextW(font, emptyW, -1);
+ ok(hr == D3D_OK, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3D_OK);
}
check_release((IUnknown*)font, 0);
@@ -498,6 +521,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
char c;
HDC hdc;
DWORD ret;
+ WORD glyph;
HRESULT hr;
RECT blackbox;
POINT cellinc;
@@ -524,26 +548,42 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
ok(hr == D3D_OK, "ID3DXFont_PreloadCharacters returned %#x, expected %#x\n", hr, D3D_OK);
for(c = 'b'; c <= 'z'; c++) {
- WORD glyph;
-
ret = GetGlyphIndicesA(hdc, &c, 1, &glyph, 0);
ok(ret != GDI_ERROR, "GetGlyphIndicesA failed\n");
hr = ID3DXFont_GetGlyphData(font, glyph, &texture, &blackbox, &cellinc);
todo_wine ok(hr == D3D_OK, "ID3DXFont_GetGlyphData returned %#x, expected %#x\n", hr, D3D_OK);
if(SUCCEEDED(hr)) {
- DWORD levels;
+ DWORD ret, levels;
+ TEXTMETRICW tm;
D3DSURFACE_DESC desc;
+ GLYPHMETRICS metrics;
+ MAT2 mat = { {0,1}, {0,0}, {0,0}, {0,1} };
levels = IDirect3DTexture9_GetLevelCount(texture);
- ok(levels == 5, "Got levels %u, expected %u\n", levels, 5);
+ todo_wine ok(levels == 5, "Character %c, got levels %u, expected %u\n", c, levels, 5);
hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &desc);
ok(hr == D3D_OK, "IDirect3DTexture9_GetLevelDesc failed\n");
- ok(desc.Format == D3DFMT_A8R8G8B8, "Got format %#x, expected %#x\n", desc.Format, D3DFMT_A8R8G8B8);
- ok(desc.Usage == 0, "Got usage %#x, expected %#x\n", desc.Usage, 0);
- ok(desc.Width == 256, "Got width %u, expected %u\n", desc.Width, 256);
- ok(desc.Height == 256, "Got height %u, expected %u\n", desc.Height, 256);
- ok(desc.Pool == D3DPOOL_MANAGED, "Got pool %u, expected %u\n", desc.Pool, D3DPOOL_MANAGED);
+ ok(desc.Format == D3DFMT_A8R8G8B8, "Character %c, got format %#x, expected %#x\n", c, desc.Format, D3DFMT_A8R8G8B8);
+ ok(desc.Usage == 0, "Character %c, got usage %#x, expected %#x\n", c, desc.Usage, 0);
+ ok(desc.Width == 256, "Character %c, got width %u, expected %u\n", c, desc.Width, 256);
+ ok(desc.Height == 256, "Character %c, got height %u, expected %u\n", c, desc.Height, 256);
+ ok(desc.Pool == D3DPOOL_MANAGED, "Character %c, got pool %u, expected %u\n", c, desc.Pool, D3DPOOL_MANAGED);
+
+ /* Check blackbox and cellinc, but skip f, j and t, because these
+ are apparently smaller */
+ ret = GetGlyphOutlineW(hdc, glyph, GGO_GLYPH_INDEX | GGO_GRAY8_BITMAP | GGO_METRICS, &metrics, 0, NULL, &mat);
+ if (ret != GDI_ERROR && c != 'f' && c != 'j' && c != 't') {
+ ID3DXFont_GetTextMetricsW(font, &tm);
+ todo_wine ok(blackbox.right - blackbox.left == metrics.gmBlackBoxX + 2, "Character %c, got %d, expected %d\n",
+ c, blackbox.right - blackbox.left, metrics.gmBlackBoxX + 2);
+ todo_wine ok(blackbox.bottom - blackbox.top == metrics.gmBlackBoxY + 2, "Character %c, got %d, expected %d\n",
+ c, blackbox.bottom - blackbox.top, metrics.gmBlackBoxY + 2);
+ ok(cellinc.x == metrics.gmptGlyphOrigin.x - 1, "Character %c, got %d, expected %d\n",
+ c, cellinc.x, metrics.gmptGlyphOrigin.x - 1);
+ ok(cellinc.y == tm.tmAscent - metrics.gmptGlyphOrigin.y - 1, "Character %c, got %d, expected %d\n",
+ c, cellinc.y, tm.tmAscent - metrics.gmptGlyphOrigin.y - 1);
+ } else if (ret == GDI_ERROR) skip("Failed to obtain glyph metrics\n");
check_release((IUnknown*)texture, 1);
}
@@ -552,6 +592,18 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
hr = ID3DXFont_PreloadCharacters(font, 'a', 'z');
ok(hr == D3D_OK, "ID3DXFont_PreloadCharacters returned %#x, expected %#x\n", hr, D3D_OK);
+ /* Test multiple textures */
+ hr = ID3DXFont_PreloadGlyphs(font, 0, 1000);
+ todo_wine ok(hr == D3D_OK, "ID3DXFont_PreloadGlyphs returned %#x, expected %#x\n", hr, D3D_OK);
+
+ /* Test glyphs that are not rendered */
+ for (glyph = 1; glyph < 4; glyph++)
+ {
+ hr = ID3DXFont_GetGlyphData(font, glyph, &texture, &blackbox, &cellinc);
+ todo_wine ok(hr == D3D_OK, "ID3DXFont_GetGlyphData returned %#x, expected %#x\n", hr, D3D_OK);
+ ok(!texture, "Got unexpected texture\n");
+ }
+
check_release((IUnknown*)font, 0);
} else skip("Failed to create a ID3DXFont object\n");
@@ -608,27 +660,26 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
hr = ID3DXSprite_Begin(sprite, D3DXSPRITE_ALPHABLEND);
ok (hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
- todo_wine
- {
+ todo_wine {
height = ID3DXFont_DrawTextW(font, sprite, testW, -1, &rect, DT_TOP, 0xffffffff);
- ok(height == tests[i].font_height, "Got unexpected height %u.\n", height);
+ ok(height == tests[i].expected_height, "Got unexpected height %u.\n", height);
height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_TOP, 0xffffffff);
- ok(height == tests[i].font_height, "Got unexpected height %u.\n", height);
+ ok(height == tests[i].expected_height, "Got unexpected height %u.\n", height);
height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_RIGHT, 0xffffffff);
- ok(height == tests[i].font_height, "Got unexpected height %u.\n", height);
+ ok(height == tests[i].expected_height, "Got unexpected height %u.\n", height);
height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_LEFT | DT_NOCLIP,
0xffffffff);
- ok(height == tests[i].font_height, "Got unexpected height %u.\n", height);
+ ok(height == tests[i].expected_height, "Got unexpected height %u.\n", height);
}
SetRectEmpty(&rect);
height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect,
DT_LEFT | DT_CALCRECT, 0xffffffff);
- todo_wine ok(height == tests[i].font_height, "Got unexpected height %u.\n", height);
+ todo_wine ok(height == tests[i].expected_height, "Got unexpected height %u.\n", height);
ok(!rect.left, "Got unexpected rect left %d.\n", rect.left);
ok(!rect.top, "Got unexpected rect top %d.\n", rect.top);
todo_wine ok(rect.right, "Got unexpected rect right %d.\n", rect.right);
- todo_wine ok(rect.bottom == tests[i].font_height, "Got unexpected rect bottom %d.\n", rect.bottom);
+ todo_wine ok(rect.bottom == tests[i].expected_height, "Got unexpected rect bottom %d.\n", rect.bottom);
hr = ID3DXSprite_End(sprite);
ok (hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
@@ -662,6 +713,12 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
height = ID3DXFont_DrawTextA(font, NULL, "test", 2, &rect, 0, 0xFF00FF);
ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
+ height = ID3DXFont_DrawTextA(font, NULL, "", 0, &rect, 0, 0xFF00FF);
+ ok(height == 0, "DrawTextA returned %d, expected 0.\n", height);
+
+ height = ID3DXFont_DrawTextA(font, NULL, "", -1, &rect, 0, 0xFF00FF);
+ ok(height == 0, "DrawTextA returned %d, expected 0.\n", height);
+
height = ID3DXFont_DrawTextA(font, NULL, "test", -1, NULL, 0, 0xFF00FF);
ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
@@ -671,7 +728,17 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
height = ID3DXFont_DrawTextA(font, NULL, NULL, -1, NULL, 0, 0xFF00FF);
ok(height == 0, "DrawTextA returned %d, expected 0.\n", height);
-if (0) { /* Causes a lockup on windows 7. */
+ SetRect(&rect, 10, 10, 50, 50);
+
+ height = ID3DXFont_DrawTextA(font, NULL, longText, -1, &rect, DT_WORDBREAK, 0xFF00FF);
+ ok(height == 60, "DrawTextA returned %d, expected 60.\n", height);
+
+ height = ID3DXFont_DrawTextA(font, NULL, longText, -1, &rect, DT_WORDBREAK | DT_NOCLIP, 0xFF00FF);
+ ok(height == 96, "DrawTextA returned %d, expected 96.\n", height);
+
+ SetRect(&rect, 10, 10, 200, 200);
+
+if (0) { /* Causes a lockup on Windows 7+ */
height = ID3DXFont_DrawTextW(font, NULL, testW, -2, &rect, 0, 0xFF00FF);
ok(height == 12, "DrawTextW returned %d, expected 12.\n", height);
}
@@ -688,6 +755,12 @@ if (0) { /* Causes a lockup on windows 7. */
height = ID3DXFont_DrawTextW(font, NULL, testW, 2, &rect, 0, 0xFF00FF);
ok(height == 12, "DrawTextW returned %d, expected 12.\n", height);
+ height = ID3DXFont_DrawTextW(font, NULL, emptyW, 0, &rect, 0, 0xFF00FF);
+ ok(height == 0, "DrawTextW returned %d, expected 0.\n", height);
+
+ height = ID3DXFont_DrawTextW(font, NULL, emptyW, -1, &rect, 0, 0xFF00FF);
+ ok(height == 0, "DrawTextW returned %d, expected 0.\n", height);
+
height = ID3DXFont_DrawTextW(font, NULL, testW, -1, NULL, 0, 0xFF00FF);
ok(height == 12, "DrawTextW returned %d, expected 12.\n", height);
@@ -696,6 +769,14 @@ if (0) { /* Causes a lockup on windows 7. */
height = ID3DXFont_DrawTextW(font, NULL, NULL, -1, NULL, 0, 0xFF00FF);
ok(height == 0, "DrawTextW returned %d, expected 0.\n", height);
+
+ SetRect(&rect, 10, 10, 50, 50);
+
+ height = ID3DXFont_DrawTextW(font, NULL, longTextW, -1, &rect, DT_WORDBREAK, 0xFF00FF);
+ ok(height == 60, "DrawTextW returned %d, expected 60.\n", height);
+
+ height = ID3DXFont_DrawTextW(font, NULL, longTextW, -1, &rect, DT_WORDBREAK | DT_NOCLIP, 0xFF00FF);
+ ok(height == 96, "DrawTextW returned %d, expected 96.\n", height);
}
ID3DXFont_Release(font);
--
2.24.0
More information about the wine-devel
mailing list