[PATCH] hlink: Implement IHlinkBrowseContext_GetObject().
Zebediah Figura
z.figura12 at gmail.com
Tue Jan 9 20:59:39 CST 2018
Fixes bug #44332.
Fixes a regression introduced by 00aca1476efd573cbf9d31a45c3d484f6fa6055b.
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
dlls/hlink/browse_ctx.c | 27 ++++++++++++++---
dlls/hlink/tests/browse_ctx.c | 70 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 93 insertions(+), 4 deletions(-)
diff --git a/dlls/hlink/browse_ctx.c b/dlls/hlink/browse_ctx.c
index ee8509d..2038768 100644
--- a/dlls/hlink/browse_ctx.c
+++ b/dlls/hlink/browse_ctx.c
@@ -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,
diff --git a/dlls/hlink/tests/browse_ctx.c b/dlls/hlink/tests/browse_ctx.c
index 40d132b..3193525 100644
--- a/dlls/hlink/tests/browse_ctx.c
+++ b/dlls/hlink/tests/browse_ctx.c
@@ -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();
}
--
2.7.4
More information about the wine-devel
mailing list