riched20/tests: Plug a few memory leaks and make failure messages more meaningful.
This commit is contained in:
parent
66e1ad8a96
commit
d08fc66732
|
@ -612,7 +612,7 @@ static BOOL init_texthost(void)
|
||||||
ITextServices object. */
|
ITextServices object. */
|
||||||
pCreateTextServices = (void*)GetProcAddress(hmoduleRichEdit, "CreateTextServices");
|
pCreateTextServices = (void*)GetProcAddress(hmoduleRichEdit, "CreateTextServices");
|
||||||
result = (*pCreateTextServices)(NULL,(ITextHost*)dummyTextHost, &init);
|
result = (*pCreateTextServices)(NULL,(ITextHost*)dummyTextHost, &init);
|
||||||
ok(result == S_OK, "Did not return OK when created. Returned %x\n", result);
|
ok(result == S_OK, "Did not return S_OK when created (result = %x)\n", result);
|
||||||
if (result != S_OK) {
|
if (result != S_OK) {
|
||||||
CoTaskMemFree(dummyTextHost);
|
CoTaskMemFree(dummyTextHost);
|
||||||
skip("CreateTextServices failed.\n");
|
skip("CreateTextServices failed.\n");
|
||||||
|
@ -621,7 +621,7 @@ static BOOL init_texthost(void)
|
||||||
|
|
||||||
result = IUnknown_QueryInterface(init, &IID_ITextServices,
|
result = IUnknown_QueryInterface(init, &IID_ITextServices,
|
||||||
(void **)&txtserv);
|
(void **)&txtserv);
|
||||||
ok((result == S_OK) && (txtserv != NULL), "Querying interface failed\n");
|
ok((result == S_OK) && (txtserv != NULL), "Querying interface failed (result = %x, txtserv = %p)\n", result, txtserv);
|
||||||
IUnknown_Release(init);
|
IUnknown_Release(init);
|
||||||
if (!((result == S_OK) && (txtserv != NULL))) {
|
if (!((result == S_OK) && (txtserv != NULL))) {
|
||||||
CoTaskMemFree(dummyTextHost);
|
CoTaskMemFree(dummyTextHost);
|
||||||
|
@ -632,6 +632,12 @@ static BOOL init_texthost(void)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void free_texthost(void)
|
||||||
|
{
|
||||||
|
IUnknown_Release(txtserv);
|
||||||
|
CoTaskMemFree(dummyTextHost);
|
||||||
|
}
|
||||||
|
|
||||||
static void test_TxGetText(void)
|
static void test_TxGetText(void)
|
||||||
{
|
{
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
@ -641,10 +647,9 @@ static void test_TxGetText(void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
hres = ITextServices_TxGetText(txtserv, &rettext);
|
hres = ITextServices_TxGetText(txtserv, &rettext);
|
||||||
ok(hres == S_OK, "ITextServices_TxGetText failed\n");
|
ok(hres == S_OK, "ITextServices_TxGetText failed (result = %x)\n", hres);
|
||||||
|
|
||||||
IUnknown_Release(txtserv);
|
free_texthost();
|
||||||
CoTaskMemFree(dummyTextHost);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_TxSetText(void)
|
static void test_TxSetText(void)
|
||||||
|
@ -657,19 +662,18 @@ static void test_TxSetText(void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
hres = ITextServices_TxSetText(txtserv, settext);
|
hres = ITextServices_TxSetText(txtserv, settext);
|
||||||
ok(hres == S_OK, "ITextServices_TxSetText failed\n");
|
ok(hres == S_OK, "ITextServices_TxSetText failed (result = %x)\n", hres);
|
||||||
|
|
||||||
hres = ITextServices_TxGetText(txtserv, &rettext);
|
hres = ITextServices_TxGetText(txtserv, &rettext);
|
||||||
ok(hres == S_OK, "ITextServices_TxGetText failed\n");
|
ok(hres == S_OK, "ITextServices_TxGetText failed (result = %x)\n", hres);
|
||||||
|
|
||||||
ok(SysStringLen(rettext) == 4,
|
ok(SysStringLen(rettext) == 4,
|
||||||
"String returned of wrong length\n");
|
"String returned of wrong length (expected 4, got %d)\n", SysStringLen(rettext));
|
||||||
ok(memcmp(rettext,settext,SysStringByteLen(rettext)) == 0,
|
ok(memcmp(rettext,settext,SysStringByteLen(rettext)) == 0,
|
||||||
"String returned differs\n");
|
"String returned differs\n");
|
||||||
|
|
||||||
SysFreeString(rettext);
|
SysFreeString(rettext);
|
||||||
IUnknown_Release(txtserv);
|
free_texthost();
|
||||||
CoTaskMemFree(dummyTextHost);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_TxGetNaturalSize(void) {
|
static void test_TxGetNaturalSize(void) {
|
||||||
|
@ -708,9 +712,7 @@ static void test_TxGetNaturalSize(void) {
|
||||||
ret = GetCharWidth32(hdcDraw,'A','Z',charwidth_caps_text);
|
ret = GetCharWidth32(hdcDraw,'A','Z',charwidth_caps_text);
|
||||||
if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) {
|
if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) {
|
||||||
win_skip("GetCharWidth32 is not available\n");
|
win_skip("GetCharWidth32 is not available\n");
|
||||||
RestoreDC(hdcDraw,1);
|
goto cleanup;
|
||||||
ReleaseDC(NULL,hdcDraw);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make measurements in MM_TEXT */
|
/* Make measurements in MM_TEXT */
|
||||||
|
@ -718,13 +720,21 @@ static void test_TxGetNaturalSize(void) {
|
||||||
xdim = 0; ydim = 0;
|
xdim = 0; ydim = 0;
|
||||||
|
|
||||||
result = ITextServices_TxSetText(txtserv, oneA);
|
result = ITextServices_TxSetText(txtserv, oneA);
|
||||||
ok(result == S_OK, "ITextServices_TxSetText failed\n");
|
ok(result == S_OK, "ITextServices_TxSetText failed (result = %x)\n", result);
|
||||||
|
if (result != S_OK) {
|
||||||
|
skip("Could not set text\n");
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
result = ITextServices_TxGetNaturalSize(txtserv, DVASPECT_CONTENT,
|
result = ITextServices_TxGetNaturalSize(txtserv, DVASPECT_CONTENT,
|
||||||
hdcDraw, NULL, NULL,
|
hdcDraw, NULL, NULL,
|
||||||
TXTNS_FITTOCONTENT, &psizelExtent,
|
TXTNS_FITTOCONTENT, &psizelExtent,
|
||||||
&xdim, &ydim);
|
&xdim, &ydim);
|
||||||
todo_wine ok(result == S_OK, "TxGetNaturalSize failed\n");
|
todo_wine ok(result == S_OK, "TxGetNaturalSize failed (result = %x)\n", result);
|
||||||
|
if (result != S_OK) {
|
||||||
|
skip("TxGetNaturalSize measurements failed\n");
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
todo_wine ok(ydim == tmInfo_text.tmHeight,
|
todo_wine ok(ydim == tmInfo_text.tmHeight,
|
||||||
"Height calculated incorrectly (expected %d, got %d)\n",
|
"Height calculated incorrectly (expected %d, got %d)\n",
|
||||||
tmInfo_text.tmHeight, ydim);
|
tmInfo_text.tmHeight, ydim);
|
||||||
|
@ -733,11 +743,10 @@ static void test_TxGetNaturalSize(void) {
|
||||||
"Width calculated incorrectly (expected %d {+1}, got %d)\n",
|
"Width calculated incorrectly (expected %d {+1}, got %d)\n",
|
||||||
charwidth_caps_text[0], xdim);
|
charwidth_caps_text[0], xdim);
|
||||||
|
|
||||||
|
cleanup:
|
||||||
RestoreDC(hdcDraw,1);
|
RestoreDC(hdcDraw,1);
|
||||||
ReleaseDC(NULL,hdcDraw);
|
ReleaseDC(NULL,hdcDraw);
|
||||||
|
free_texthost();
|
||||||
IUnknown_Release(txtserv);
|
|
||||||
CoTaskMemFree(dummyTextHost);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_TxDraw(void)
|
static void test_TxDraw(void)
|
||||||
|
@ -757,11 +766,10 @@ static void test_TxDraw(void)
|
||||||
result = ITextServices_TxDraw(txtserv, dwAspect, 0, pvAspect, ptd,
|
result = ITextServices_TxDraw(txtserv, dwAspect, 0, pvAspect, ptd,
|
||||||
tmphdc, hicTargetDev, &client, NULL,
|
tmphdc, hicTargetDev, &client, NULL,
|
||||||
NULL, NULL, 0, 0);
|
NULL, NULL, 0, 0);
|
||||||
ok(result == S_OK, "TxDraw failed\n");
|
ok(result == S_OK, "TxDraw failed (result = %x)\n", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
IUnknown_Release(txtserv);
|
free_texthost();
|
||||||
CoTaskMemFree(dummyTextHost);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -776,8 +784,7 @@ START_TEST( txtsrv )
|
||||||
|
|
||||||
if (init_texthost())
|
if (init_texthost())
|
||||||
{
|
{
|
||||||
IUnknown_Release(txtserv);
|
free_texthost();
|
||||||
CoTaskMemFree(dummyTextHost);
|
|
||||||
|
|
||||||
test_TxGetText();
|
test_TxGetText();
|
||||||
test_TxSetText();
|
test_TxSetText();
|
||||||
|
|
Loading…
Reference in New Issue