hlink: Implement IHlinkBrowseContext_GetObject().

Fixes a regression introduced by 00aca1476e.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2018-01-09 20:59:39 -06:00 committed by Alexandre Julliard
parent 221708d64e
commit c2953ba457
2 changed files with 93 additions and 4 deletions

View File

@ -98,10 +98,11 @@ static ULONG WINAPI IHlinkBC_fnRelease (IHlinkBrowseContext* iface)
return ref;
}
static const WCHAR szIdent[] = {'W','I','N','E','H','L','I','N','K',0};
static HRESULT WINAPI IHlinkBC_Register(IHlinkBrowseContext* iface,
DWORD dwReserved, IUnknown *piunk, IMoniker *pimk, DWORD *pdwRegister)
{
static const WCHAR szIdent[] = {'W','I','N','E','H','L','I','N','K',0};
HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
IMoniker *mon;
IMoniker *composite;
@ -125,11 +126,29 @@ static HRESULT WINAPI IHlinkBC_Register(IHlinkBrowseContext* iface,
return S_OK;
}
static HRESULT WINAPI IHlinkBC_GetObject(IHlinkBrowseContext* face,
static HRESULT WINAPI IHlinkBC_GetObject(IHlinkBrowseContext* iface,
IMoniker *pimk, BOOL fBindifRootRegistered, IUnknown **ppiunk)
{
FIXME("\n");
return E_NOTIMPL;
HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
IMoniker *mon;
IMoniker *composite;
IRunningObjectTable *ROT;
HRESULT hr;
TRACE("(%p)->(%p, %d, %p)\n", This, pimk, fBindifRootRegistered, ppiunk);
hr = CreateItemMoniker(NULL, szIdent, &mon);
if (FAILED(hr)) return hr;
CreateGenericComposite(mon, pimk, &composite);
GetRunningObjectTable(0, &ROT);
hr = IRunningObjectTable_GetObject(ROT, composite, ppiunk);
IRunningObjectTable_Release(ROT);
IMoniker_Release(composite);
IMoniker_Release(mon);
return hr;
}
static HRESULT WINAPI IHlinkBC_Revoke(IHlinkBrowseContext* iface,

View File

@ -131,12 +131,82 @@ static void test_BrowseWindowInfo(void)
IHlinkBrowseContext_Release(bc);
}
static HRESULT WINAPI Unknown_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
{
*ppv = NULL;
if (IsEqualIID(riid, &IID_IUnknown))
{
*ppv = iface;
return S_OK;
}
return E_NOINTERFACE;
}
static ULONG WINAPI Unknown_AddRef(IUnknown *iface)
{
return 2;
}
static ULONG WINAPI Unknown_Release(IUnknown *iface)
{
return 1;
}
static IUnknownVtbl UnknownVtbl = {
Unknown_QueryInterface,
Unknown_AddRef,
Unknown_Release,
};
static IUnknown Unknown = { &UnknownVtbl };
static void test_GetObject(void)
{
IHlinkBrowseContext *bc;
IMoniker *dummy;
IBindCtx *bindctx;
IUnknown *unk;
WCHAR one[] = {'1',0};
WCHAR five[] = {'5',0};
DWORD cookie;
HRESULT hres;
hres = CreateBindCtx(0, &bindctx);
ok(hres == S_OK, "CreateBindCtx() failed: 0x%08x\n", hres);
hres = CreateItemMoniker(one, five, &dummy);
ok(hres == S_OK, "CreateItemMoniker() failed: 0x%08x\n", hres);
hres = HlinkCreateBrowseContext(NULL, &IID_IHlinkBrowseContext, (void **)&bc);
ok(hres == S_OK, "HlinkCreateBrowseContext() failed: 0x%08x\n", hres);
hres = IHlinkBrowseContext_GetObject(bc, dummy, FALSE, &unk);
ok(hres == MK_E_UNAVAILABLE, "expected MK_E_UNAVAILABLE, got 0x%08x\n", hres);
hres = IHlinkBrowseContext_Register(bc, 0, &Unknown, dummy, &cookie);
ok(hres == S_OK, "Register() failed: 0x%08x\n", hres);
hres = IHlinkBrowseContext_GetObject(bc, dummy, FALSE, &unk);
ok(hres == S_OK, "GetObject() failed: 0x%08x\n", hres);
ok(unk == &Unknown, "wrong object returned\n");
hres = IHlinkBrowseContext_Revoke(bc, cookie);
ok(hres == S_OK, "Revoke() failed: 0x%08x\n", hres);
hres = IHlinkBrowseContext_GetObject(bc, dummy, FALSE, &unk);
ok(hres == MK_E_UNAVAILABLE, "expected MK_E_UNAVAILABLE, got 0x%08x\n", hres);
IHlinkBrowseContext_Release(bc);
}
START_TEST(browse_ctx)
{
CoInitialize(NULL);
test_SetInitialHlink();
test_BrowseWindowInfo();
test_GetObject();
CoUninitialize();
}