Commit 467bf31e authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

usp10/tests: Cleanup test_ScriptTextOut().

parent 5956b53f
...@@ -2638,14 +2638,11 @@ static void test_ScriptTextOut(HDC hdc) ...@@ -2638,14 +2638,11 @@ static void test_ScriptTextOut(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[] = {'T', 'e', 's', 't', 'a', 0}; WCHAR TestItem1[] = {'T', 'e', 's', 't', 'a', 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];
...@@ -2655,93 +2652,69 @@ static void test_ScriptTextOut(HDC hdc) ...@@ -2655,93 +2652,69 @@ static void test_ScriptTextOut(HDC hdc)
ABC pABC[256]; ABC pABC[256];
RECT rect; RECT rect;
int piX; int piX;
int iCP = 1;
BOOL fTrailing = FALSE;
SCRIPT_LOGATTR *psla;
SCRIPT_LOGATTR sla[256]; SCRIPT_LOGATTR sla[256];
/* This is a valid test that will cause parsing to take place */ /* This is a valid test that will cause parsing to take place. */
cInChars = 5; cInChars = lstrlenW(TestItem1);
cMaxItems = 255; hr = ScriptItemize(TestItem1, cInChars, ARRAY_SIZE(pItem), NULL, NULL, pItem, &pcItems);
hr = ScriptItemize(TestItem1, cInChars, cMaxItems, NULL, NULL, pItem, &pcItems); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
ok (hr == S_OK, "ScriptItemize should return S_OK, returned %08x\n", hr); /* This test is for the interim operation of ScriptItemize() where only
/* This test is for the interim operation of ScriptItemize where only one SCRIPT_ITEM is * * one SCRIPT_ITEM is returned. */
* returned. */ ok(pcItems == 1, "Got unexpected item count %d.\n", pcItems);
ok (pcItems > 0, "The number of SCRIPT_ITEMS should be greater than 0\n"); ok(pItem[0].iCharPos == 0, "Got unexpected character position %d.\n", pItem[0].iCharPos);
if (pcItems > 0) ok(pItem[1].iCharPos == cInChars, "Got unexpected character position %d, expected %d.\n",
ok (pItem[0].iCharPos == 0 && pItem[1].iCharPos == cInChars, pItem[1].iCharPos, cInChars);
"Start pos not = 0 (%d) or end pos not = %d (%d)\n",
pItem[0].iCharPos, cInChars, pItem[1].iCharPos);
/* 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 */
cInChars = 5; cInChars = 5;
if (hr == S_OK) { hr = ScriptShape(hdc, &psc, TestItem1, cInChars, ARRAY_SIZE(pwOutGlyphs1),
psc = NULL; /* must be null on first call */ &pItem[0].a, pwOutGlyphs1, pwLogClust, psva, &pcGlyphs);
cChars = cInChars; ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
cMaxGlyphs = 256; ok(!!psc, "Got unexpected psc %p.\n", psc);
hr = ScriptShape(hdc, &psc, TestItem1, cChars, ok(pcGlyphs == cInChars, "Got unexpected glyph count %d, expected %d.\n", pcGlyphs, cInChars);
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 == S_OK) {
/* 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);
ScriptFreeCache(&psc); /* Get rid of psc for next test set */
ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
hr = ScriptTextOut(NULL, NULL, 0, 0, 0, NULL, NULL, NULL, 0, NULL, 0, NULL, NULL, NULL); /* Note hdc is needed as glyph info is not yet in psc. */
ok (hr == E_INVALIDARG, "Should return 0 not (%08x)\n", hr); hr = ScriptPlace(hdc, &psc, pwOutGlyphs1, pcGlyphs,
psva, &pItem[0].a, piAdvance, pGoffset, pABC);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
/* Get rid of psc for next test set. */
ScriptFreeCache(&psc);
ok(!psc, "Got unexpected psc %p.\n", psc);
hr = ScriptTextOut(NULL, NULL, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs, hr = ScriptTextOut(NULL, NULL, 0, 0, 0, NULL, NULL, NULL, 0, NULL, 0, NULL, NULL, NULL);
piAdvance, NULL, pGoffset); ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
ok( hr == E_INVALIDARG, "(NULL,NULL,TestItem1, cInChars, dwFlags, pwOutGlyphs3), "
"expected E_INVALIDARG, got %08x\n", hr);
/* Set psc to NULL, to be able to check if a pointer is returned in psc */
psc = NULL;
hr = ScriptTextOut(NULL, &psc, 0, 0, 0, NULL, NULL, NULL, 0, NULL, 0,
NULL, NULL, NULL);
ok( hr == E_INVALIDARG, "(NULL,&psc,NULL,0,0,0,NULL,), expected E_INVALIDARG, "
"got %08x\n", hr);
ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
/* hdc is required for this one rather than the usual optional */ hr = ScriptTextOut(NULL, NULL, 0, 0, 0, NULL, &pItem[0].a, NULL, 0,
psc = NULL; pwOutGlyphs1, pcGlyphs, piAdvance, NULL, pGoffset);
hr = ScriptTextOut(NULL, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs, ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
piAdvance, NULL, pGoffset);
ok( hr == E_INVALIDARG, "(NULL,&psc,), expected E_INVALIDARG, got %08x\n", hr);
ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
/* Set that it returns 0 status */ hr = ScriptTextOut(NULL, &psc, 0, 0, 0, NULL, NULL, NULL, 0, NULL, 0, NULL, NULL, NULL);
hr = ScriptTextOut(hdc, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs, ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
piAdvance, NULL, pGoffset); ok(!psc, "Got unexpected psc %p.\n", psc);
ok (hr == S_OK, "ScriptTextOut should return S_OK not (%08x)\n", hr);
/* Test Rect Rgn is acceptable */ /* hdc is required. */
SetRect(&rect, 10, 10, 40, 20); hr = ScriptTextOut(NULL, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0,
hr = ScriptTextOut(hdc, &psc, 0, 0, 0, &rect, &pItem[0].a, NULL, 0, pwOutGlyphs1, pcGlyphs, pwOutGlyphs1, pcGlyphs, piAdvance, NULL, pGoffset);
piAdvance, NULL, pGoffset); ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
ok (hr == S_OK, "ScriptTextOut should return S_OK not (%08x)\n", hr); ok(!psc, "Got unexpected psc %p.\n", psc);
hr = ScriptTextOut(hdc, &psc, 0, 0, 0, NULL, &pItem[0].a, NULL, 0,
pwOutGlyphs1, pcGlyphs, piAdvance, NULL, pGoffset);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
iCP = 1; /* Test Rect Rgn is acceptable. */
hr = ScriptCPtoX(iCP, fTrailing, cChars, pcGlyphs, (const WORD *) &pwLogClust, SetRect(&rect, 10, 10, 40, 20);
(const SCRIPT_VISATTR *) &psva, (const int *)&piAdvance, &pItem[0].a, &piX); hr = ScriptTextOut(hdc, &psc, 0, 0, 0, &rect, &pItem[0].a, NULL, 0,
ok(hr == S_OK, "ScriptCPtoX Stub should return S_OK not %08x\n", hr); pwOutGlyphs1, pcGlyphs, piAdvance, NULL, pGoffset);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
psla = (SCRIPT_LOGATTR *)&sla; hr = ScriptCPtoX(1, FALSE, cInChars, pcGlyphs, pwLogClust, psva, piAdvance, &pItem[0].a, &piX);
hr = ScriptBreak(TestItem1, cChars, &pItem[0].a, psla); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
ok(hr == S_OK, "ScriptBreak Stub should return S_OK not %08x\n", hr);
/* Clean up and go */ hr = ScriptBreak(TestItem1, cInChars, &pItem[0].a, sla);
ScriptFreeCache(&psc); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
ok( psc == NULL, "Expected psc to be NULL, got %p\n", psc);
} ScriptFreeCache(&psc);
} ok(!psc, "Got unexpected psc %p.\n", psc);
} }
static void test_ScriptTextOut2(HDC hdc) static void test_ScriptTextOut2(HDC hdc)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment