Commit b87c502a authored by Connor McAdams's avatar Connor McAdams Committed by Alexandre Julliard

ole32/tests: Extend test_marshal_channel_buffer() test to include IRpcProxyBufferWrapper checks.

parent 10aaff92
......@@ -351,10 +351,12 @@ static const IClassFactoryVtbl TestClassFactory_Vtbl =
static IClassFactory Test_ClassFactory = { &TestClassFactory_Vtbl };
DEFINE_EXPECT(Invoke);
DEFINE_EXPECT(Connect);
DEFINE_EXPECT(CreateStub);
DEFINE_EXPECT(CreateProxy);
DEFINE_EXPECT(GetWindow);
DEFINE_EXPECT(Disconnect);
DEFINE_EXPECT(RpcStubBuffer_Disconnect);
DEFINE_EXPECT(RpcProxyBuffer_Disconnect);
static HRESULT WINAPI OleWindow_QueryInterface(IOleWindow *iface, REFIID riid, void **ppv)
{
......@@ -476,7 +478,7 @@ static HRESULT WINAPI RpcStubBuffer_Connect(IRpcStubBuffer *iface, IUnknown *pUn
static void WINAPI RpcStubBuffer_Disconnect(IRpcStubBuffer *iface)
{
CHECK_EXPECT(Disconnect);
CHECK_EXPECT(RpcStubBuffer_Disconnect);
}
static HRESULT WINAPI RpcStubBuffer_Invoke(IRpcStubBuffer *iface, RPCOLEMESSAGE *_prpcmsg,
......@@ -533,6 +535,79 @@ static const IRpcStubBufferVtbl RpcStubBufferVtbl = {
RpcStubBuffer_DebugServerRelease
};
typedef struct {
IRpcProxyBuffer IRpcProxyBuffer_iface;
LONG ref;
IRpcProxyBuffer *buffer;
} ProxyBufferWrapper;
static ProxyBufferWrapper *impl_from_IRpcProxyBuffer(IRpcProxyBuffer *iface)
{
return CONTAINING_RECORD(iface, ProxyBufferWrapper, IRpcProxyBuffer_iface);
}
static HRESULT WINAPI RpcProxyBuffer_QueryInterface(IRpcProxyBuffer *iface, REFIID riid, void **ppv)
{
ProxyBufferWrapper *This = impl_from_IRpcProxyBuffer(iface);
if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IRpcProxyBuffer, riid)) {
*ppv = &This->IRpcProxyBuffer_iface;
}else {
*ppv = NULL;
return E_NOINTERFACE;
}
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
static ULONG WINAPI RpcProxyBuffer_AddRef(IRpcProxyBuffer *iface)
{
ProxyBufferWrapper *This = impl_from_IRpcProxyBuffer(iface);
return InterlockedIncrement(&This->ref);
}
static ULONG WINAPI RpcProxyBuffer_Release(IRpcProxyBuffer *iface)
{
ProxyBufferWrapper *This = impl_from_IRpcProxyBuffer(iface);
LONG ref = InterlockedDecrement(&This->ref);
if(!ref) {
IRpcProxyBuffer_Release(This->buffer);
heap_free(This);
}
return ref;
}
static HRESULT WINAPI RpcProxyBuffer_Connect(IRpcProxyBuffer *iface, IRpcChannelBuffer *pRpcChannelBuffer)
{
ProxyBufferWrapper *This = impl_from_IRpcProxyBuffer(iface);
void *dest_context_data;
DWORD dest_context;
HRESULT hr;
CHECK_EXPECT(Connect);
hr = IRpcChannelBuffer_GetDestCtx(pRpcChannelBuffer, &dest_context, &dest_context_data);
ok(hr == S_OK, "GetDestCtx failed: %08lx\n", hr);
todo_wine ok(dest_context == MSHCTX_INPROC, "desc_context = %lx\n", dest_context);
ok(!dest_context_data, "desc_context_data = %p\n", dest_context_data);
return IRpcProxyBuffer_Connect(This->buffer, pRpcChannelBuffer);
}
static void WINAPI RpcProxyBuffer_Disconnect(IRpcProxyBuffer *iface)
{
CHECK_EXPECT(RpcProxyBuffer_Disconnect);
}
static const IRpcProxyBufferVtbl RpcProxyBufferVtbl = {
RpcProxyBuffer_QueryInterface,
RpcProxyBuffer_AddRef,
RpcProxyBuffer_Release,
RpcProxyBuffer_Connect,
RpcProxyBuffer_Disconnect,
};
static IPSFactoryBuffer *ps_factory_buffer;
static HRESULT WINAPI PSFactoryBuffer_QueryInterface(IPSFactoryBuffer *iface, REFIID riid, void **ppv)
......@@ -561,8 +636,20 @@ static ULONG WINAPI PSFactoryBuffer_Release(IPSFactoryBuffer *iface)
static HRESULT WINAPI PSFactoryBuffer_CreateProxy(IPSFactoryBuffer *iface, IUnknown *outer,
REFIID riid, IRpcProxyBuffer **ppProxy, void **ppv)
{
ProxyBufferWrapper *proxy;
HRESULT hr;
CHECK_EXPECT(CreateProxy);
return IPSFactoryBuffer_CreateProxy(ps_factory_buffer, outer, riid, ppProxy, ppv);
proxy = heap_alloc(sizeof(*proxy));
proxy->IRpcProxyBuffer_iface.lpVtbl = &RpcProxyBufferVtbl;
proxy->ref = 1;
hr = IPSFactoryBuffer_CreateProxy(ps_factory_buffer, outer, riid, &proxy->buffer, ppv);
ok(hr == S_OK, "CreateProxy failed: %08lx\n", hr);
*ppProxy = &proxy->IRpcProxyBuffer_iface;
return S_OK;
}
static HRESULT WINAPI PSFactoryBuffer_CreateStub(IPSFactoryBuffer *iface, REFIID riid,
......@@ -1327,10 +1414,12 @@ static void test_marshal_channel_buffer(void)
SET_EXPECT(CreateStub);
SET_EXPECT(CreateProxy);
SET_EXPECT(Connect);
hr = IUnknown_QueryInterface(proxy, &IID_IOleWindow, (void**)&ole_window);
ok(hr == S_OK, "Could not get IOleWindow iface: %08lx\n", hr);
CHECK_CALLED(CreateStub);
CHECK_CALLED(CreateProxy);
CHECK_CALLED(Connect);
SET_EXPECT(Invoke);
SET_EXPECT(GetWindow);
......@@ -1342,10 +1431,13 @@ static void test_marshal_channel_buffer(void)
IOleWindow_Release(ole_window);
SET_EXPECT(Disconnect);
SET_EXPECT(RpcStubBuffer_Disconnect);
SET_EXPECT(RpcProxyBuffer_Disconnect);
IUnknown_Release(proxy);
todo_wine
CHECK_CALLED(Disconnect);
CHECK_CALLED(RpcStubBuffer_Disconnect);
todo_wine
CHECK_CALLED(RpcProxyBuffer_Disconnect);
hr = CoRevokeClassObject(registration_key);
ok(hr == S_OK, "CoRevokeClassObject failed: %08lx\n", hr);
......
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