Added RegisterFormatEnumerator and RevokeFormatEnumerator

implementation.
This commit is contained in:
Jacek Caban 2005-09-03 15:03:06 +00:00 committed by Alexandre Julliard
parent 3bf9c165fa
commit 74138a028f
3 changed files with 107 additions and 2 deletions

View File

@ -31,6 +31,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
static WCHAR wszEnumFORMATETC[] = {'_','E','n','u','m','F','O','R','M','A','T','E','T','C','_',0};
typedef struct {
const IEnumFORMATETCVtbl *lpEnumFORMATETCVtbl;
@ -189,3 +191,32 @@ HRESULT WINAPI CreateFormatEnumerator(UINT cfmtetc, FORMATETC *rgfmtetc,
*ppenumfmtetc = EnumFORMATETC_Create(cfmtetc, rgfmtetc, 0);
return S_OK;
}
/**********************************************************
* RegisterFormatEnumerator (urlmon.@)
*/
HRESULT WINAPI RegisterFormatEnumerator(LPBC pBC, IEnumFORMATETC *pEFetc, DWORD reserved)
{
TRACE("(%p %p %ld)\n", pBC, pEFetc, reserved);
if(reserved)
WARN("reserved != 0\n");
if(!pBC || !pEFetc)
return E_INVALIDARG;
return IBindCtx_RegisterObjectParam(pBC, wszEnumFORMATETC, (IUnknown*)pEFetc);
}
/**********************************************************
* RevokeFormatEnumerator (urlmon.@)
*/
HRESULT WINAPI RevokeFormatEnumerator(LPBC pbc, IEnumFORMATETC *pEFetc)
{
TRACE("(%p %p)\n", pbc, pEFetc);
if(!pbc)
return E_INVALIDARG;
return IBindCtx_RevokeObjectParam(pbc, wszEnumFORMATETC);
}

View File

@ -129,7 +129,81 @@ static void test_CreateFormatEnum(void)
IEnumFORMATETC_Release(fenum);
}
static void test_RegisterFormatEnumerator(void)
{
IBindCtx *bctx = NULL;
IEnumFORMATETC *format = NULL, *format2 = NULL;
IUnknown *unk = NULL;
HRESULT hres;
static FORMATETC formatetc = {0,NULL,0,0,0};
static WCHAR wszEnumFORMATETC[] =
{'_','E','n','u','m','F','O','R','M','A','T','E','T','C','_',0};
CreateBindCtx(0, &bctx);
hres = CreateFormatEnumerator(1, &formatetc, &format);
ok(hres == S_OK, "CreateFormatEnumerator failed: %08lx\n", hres);
if(FAILED(hres))
return;
hres = RegisterFormatEnumerator(NULL, format, 0);
ok(hres == E_INVALIDARG,
"RegisterFormatEnumerator failed: %08lx, expected E_INVALIDARG\n", hres);
hres = RegisterFormatEnumerator(bctx, NULL, 0);
ok(hres == E_INVALIDARG,
"RegisterFormatEnumerator failed: %08lx, expected E_INVALIDARG\n", hres);
hres = RegisterFormatEnumerator(bctx, format, 0);
ok(hres == S_OK, "RegisterFormatEnumerator failed: %08lx\n", hres);
hres = IBindCtx_GetObjectParam(bctx, wszEnumFORMATETC, &unk);
ok(hres == S_OK, "GetObjectParam failed: %08lx\n", hres);
ok(unk == (IUnknown*)format, "unk != format\n");
hres = RevokeFormatEnumerator(NULL, format);
ok(hres == E_INVALIDARG,
"RevokeFormatEnumerator failed: %08lx, expected E_INVALIDARG\n", hres);
hres = RevokeFormatEnumerator(bctx, format);
ok(hres == S_OK, "RevokeFormatEnumerator failed: %08lx\n", hres);
hres = RevokeFormatEnumerator(bctx, format);
ok(hres == E_FAIL, "RevokeFormatEnumerator failed: %08lx, expected E_FAIL\n", hres);
hres = IBindCtx_GetObjectParam(bctx, wszEnumFORMATETC, &unk);
ok(hres == E_FAIL, "GetObjectParam failed: %08lx, expected E_FAIL\n", hres);
hres = RegisterFormatEnumerator(bctx, format, 0);
ok(hres == S_OK, "RegisterFormatEnumerator failed: %08lx\n", hres);
hres = CreateFormatEnumerator(1, &formatetc, &format2);
ok(hres == S_OK, "CreateFormatEnumerator failed: %08lx\n", hres);
if(SUCCEEDED(hres)) {
hres = RevokeFormatEnumerator(bctx, format);
ok(hres == S_OK, "RevokeFormatEnumerator failed: %08lx\n", hres);
IEnumFORMATETC_Release(format2);
}
hres = IBindCtx_GetObjectParam(bctx, wszEnumFORMATETC, &unk);
ok(hres == E_FAIL, "GetObjectParam failed: %08lx, expected E_FAIL\n", hres);
IEnumFORMATETC_Release(format);
hres = RegisterFormatEnumerator(bctx, format, 0);
ok(hres == S_OK, "RegisterFormatEnumerator failed: %08lx\n", hres);
hres = RevokeFormatEnumerator(bctx, NULL);
ok(hres == S_OK, "RevokeFormatEnumerator failed: %08lx\n", hres);
hres = IBindCtx_GetObjectParam(bctx, wszEnumFORMATETC, &unk);
ok(hres == E_FAIL, "GetObjectParam failed: %08lx, expected E_FAIL\n", hres);
IBindCtx_Release(bctx);
}
START_TEST(misc)
{
test_CreateFormatEnum();
test_RegisterFormatEnumerator();
}

View File

@ -56,12 +56,12 @@
@ stdcall ObtainUserAgentString(long str ptr)
@ stub PrivateCoInstall
@ stdcall RegisterBindStatusCallback(ptr ptr ptr long)
@ stub RegisterFormatEnumerator
@ stdcall RegisterFormatEnumerator(ptr ptr long)
@ stub RegisterMediaTypeClass
@ stub RegisterMediaTypes
@ stdcall ReleaseBindInfo(ptr)
@ stdcall RevokeBindStatusCallback(ptr ptr)
@ stub RevokeFormatEnumerator
@ stdcall RevokeFormatEnumerator(ptr ptr)
@ stub SetSoftwareUpdateAdvertisementState
@ stub URLDownloadA
@ stub URLDownloadToCacheFileA