usp10/tests: Cleanup test_ScriptTextOut3().

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Aric Stewart <aric@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2018-02-23 09:48:28 +03:30 committed by Alexandre Julliard
parent daf754cea3
commit d63caf2b76
1 changed files with 31 additions and 43 deletions

View File

@ -2791,14 +2791,11 @@ static void test_ScriptTextOut3(HDC hdc)
HRESULT hr; HRESULT hr;
int cInChars; int cInChars;
int cMaxItems;
SCRIPT_ITEM pItem[255]; SCRIPT_ITEM pItem[255];
int pcItems; int pcItems;
WCHAR TestItem1[] = {' ','\r', 0}; WCHAR TestItem1[] = {' ','\r', 0};
SCRIPT_CACHE psc; SCRIPT_CACHE psc;
int cChars;
int cMaxGlyphs;
unsigned short pwOutGlyphs1[256]; unsigned short pwOutGlyphs1[256];
WORD pwLogClust[256]; WORD pwLogClust[256];
SCRIPT_VISATTR psva[256]; SCRIPT_VISATTR psva[256];
@ -2808,48 +2805,39 @@ static void test_ScriptTextOut3(HDC hdc)
ABC pABC[256]; ABC pABC[256];
RECT rect; RECT rect;
/* This is to ensure that nonexistent glyphs are translated into a valid glyph number */ /* This is to ensure that non-existent glyphs are translated into a valid
cInChars = 2; * glyph number. */
cMaxItems = 255; cInChars = lstrlenW(TestItem1);
hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems); hr = ScriptItemize(TestItem1, cInChars, ARRAY_SIZE(pItem), NULL, NULL, pItem, &pcItems);
ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
/* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is * /* This test is for the interim operation of ScriptItemize() where only
* returned. */ * one SCRIPT_ITEM is returned. */
ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n"); ok(pcItems == 2, "Got unexpected item count %d.\n", pcItems);
if (pcItems > 0) ok(pItem[0].iCharPos == 0, "Got unexpected character position %d.\n", pItem[0].iCharPos);
ok (pItem[0].iCharPos == 0 && pItem[2].iCharPos == cInChars, ok(pItem[1].iCharPos == 1, "Got unexpected character position %d.\n", pItem[0].iCharPos);
"Start pos not = 0 (%d) or end pos not = %d (%d)\n", ok(pItem[2].iCharPos == cInChars, "Got unexpected character position %d, expected %d.\n",
pItem[0].iCharPos, cInChars, pItem[2].iCharPos); pItem[2].iCharPos, cInChars);
/* It would appear that we have a valid SCRIPT_ANALYSIS and can continue psc = NULL;
* ie. ScriptItemize has succeeded and that pItem has been set */ hr = ScriptShape(hdc, &psc, TestItem1, cInChars, ARRAY_SIZE(pwOutGlyphs1),
cInChars = 2; &pItem[0].a, pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
if (hr == S_OK) { ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
psc = NULL; /* must be null on first call */ ok(!!psc, "Got unexpected psc %p.\n", psc);
cChars = cInChars; ok(pcGlyphs == cInChars, "Got unexpected glyph count %d, expected %d.\n", pcGlyphs, cInChars);
cMaxGlyphs = 256;
hr = ScriptShape(hdc, &psc, TestItem1, cChars,
cMaxGlyphs, &pItem[0].a,
pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
ok (hr == S_OK, "ScriptShape should return S_OK not (%08x)\n", hr);
ok (psc != NULL, "psc should not be null and have SCRIPT_CACHE buffer address\n");
ok (pcGlyphs == cChars, "Chars in (%d) should equal Glyphs out (%d)\n", cChars, pcGlyphs);
if (hr ==0) {
/* Note hdc is needed as glyph info is not yet in psc */
hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs, psva, &pItem[0].a, piAdvance,
pGoffset, pABC);
ok (hr == S_OK, "Should return S_OK not (%08x)\n", hr);
/* Test Rect Rgn is acceptable */ /* Note hdc is needed as glyph info is not yet in psc. */
hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs,
psva, &pItem[0].a, piAdvance, pGoffset, pABC);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
/* Test Rect Rgn is acceptable. */
SetRect(&rect, 10, 10, 40, 20); SetRect(&rect, 10, 10, 40, 20);
hr = ScriptTextOut(hdc, &psc, 0, 0, 0, &rect, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs, hr = ScriptTextOut(hdc, &psc, 0, 0, 0, &rect, &pItem[0].a, NULL, 0,
piAdvance, NULL, pGoffset); pwOutGlyphs1, pcGlyphs, piAdvance, NULL, pGoffset);
ok (hr == S_OK, "ScriptTextOut should return S_OK not (%08x)\n", hr); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
}
/* Clean up and go */
ScriptFreeCache(&psc); ScriptFreeCache(&psc);
ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc); ok(!psc, "Got unexpected psc %p.\n", psc);
}
} }
#define test_item_ScriptXtoX(a,b,c,d,e,f) (winetest_set_location(__FILE__,__LINE__), 0) ? 0 : _test_item_ScriptXtoX(a,b,c,d,e,f) #define test_item_ScriptXtoX(a,b,c,d,e,f) (winetest_set_location(__FILE__,__LINE__), 0) ? 0 : _test_item_ScriptXtoX(a,b,c,d,e,f)