rpcrt4: Add tests for CreateStub and fix up CStdStubBuffer_Construct to match.
This commit is contained in:
parent
6a0fccd3a9
commit
cadc39842b
|
@ -54,7 +54,8 @@ HRESULT WINAPI CStdStubBuffer_Construct(REFIID riid,
|
||||||
LPRPCSTUBBUFFER *ppStub)
|
LPRPCSTUBBUFFER *ppStub)
|
||||||
{
|
{
|
||||||
CStdStubBuffer *This;
|
CStdStubBuffer *This;
|
||||||
|
IUnknown *pvServer;
|
||||||
|
HRESULT r;
|
||||||
TRACE("(%p,%p,%p,%p) %s\n", pUnkServer, vtbl, pPSFactory, ppStub, name);
|
TRACE("(%p,%p,%p,%p) %s\n", pUnkServer, vtbl, pPSFactory, ppStub, name);
|
||||||
TRACE("iid=%s\n", debugstr_guid(vtbl->header.piid));
|
TRACE("iid=%s\n", debugstr_guid(vtbl->header.piid));
|
||||||
TRACE("vtbl=%p\n", &vtbl->Vtbl);
|
TRACE("vtbl=%p\n", &vtbl->Vtbl);
|
||||||
|
@ -64,16 +65,22 @@ HRESULT WINAPI CStdStubBuffer_Construct(REFIID riid,
|
||||||
return RPC_E_UNEXPECTED;
|
return RPC_E_UNEXPECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r = IUnknown_QueryInterface(pUnkServer, riid, (void**)&pvServer);
|
||||||
|
if(FAILED(r))
|
||||||
|
return r;
|
||||||
|
|
||||||
This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(CStdStubBuffer));
|
This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(CStdStubBuffer));
|
||||||
if (!This) return E_OUTOFMEMORY;
|
if (!This) {
|
||||||
|
IUnknown_Release(pvServer);
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
This->lpVtbl = &vtbl->Vtbl;
|
This->lpVtbl = &vtbl->Vtbl;
|
||||||
This->RefCount = 1;
|
This->RefCount = 1;
|
||||||
This->pvServerObject = pUnkServer;
|
This->pvServerObject = pvServer;
|
||||||
This->pPSFactory = pPSFactory;
|
This->pPSFactory = pPSFactory;
|
||||||
*ppStub = (LPRPCSTUBBUFFER)This;
|
*ppStub = (LPRPCSTUBBUFFER)This;
|
||||||
|
|
||||||
IUnknown_AddRef(This->pvServerObject);
|
|
||||||
IPSFactoryBuffer_AddRef(pPSFactory);
|
IPSFactoryBuffer_AddRef(pPSFactory);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#define PROXY_DELEGATION
|
#define PROXY_DELEGATION
|
||||||
|
#define COBJMACROS
|
||||||
|
|
||||||
#include "wine/test.h"
|
#include "wine/test.h"
|
||||||
#include <windef.h>
|
#include <windef.h>
|
||||||
|
@ -426,7 +427,7 @@ const ProxyFileInfo *proxy_file_list[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static void test_NdrDllGetClassObject(void)
|
static IPSFactoryBuffer *test_NdrDllGetClassObject(void)
|
||||||
{
|
{
|
||||||
IPSFactoryBuffer *ppsf = NULL;
|
IPSFactoryBuffer *ppsf = NULL;
|
||||||
const CLSID PSDispatch = {0x20420, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46}};
|
const CLSID PSDispatch = {0x20420, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46}};
|
||||||
|
@ -524,6 +525,7 @@ todo_wine {
|
||||||
#undef VTBL_TEST_ZERO
|
#undef VTBL_TEST_ZERO
|
||||||
|
|
||||||
ok(PSFactoryBuffer.RefCount == 1, "ref count %ld\n", PSFactoryBuffer.RefCount);
|
ok(PSFactoryBuffer.RefCount == 1, "ref count %ld\n", PSFactoryBuffer.RefCount);
|
||||||
|
return ppsf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int base_buffer_invoke_called;
|
static int base_buffer_invoke_called;
|
||||||
|
@ -570,12 +572,72 @@ todo_wine {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static IRpcStubBuffer *create_stub(IPSFactoryBuffer *ppsf, REFIID iid, IUnknown *obj, HRESULT expected_result)
|
||||||
|
{
|
||||||
|
IRpcStubBuffer *pstub = NULL;
|
||||||
|
HRESULT r;
|
||||||
|
|
||||||
|
r = IPSFactoryBuffer_CreateStub(ppsf, iid, obj, &pstub);
|
||||||
|
ok(r == expected_result, "CreateStub returned %08lx expected %08lx\n", r, expected_result);
|
||||||
|
return pstub;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI create_stub_test_QI(IUnknown *This, REFIID iid, void **ppv)
|
||||||
|
{
|
||||||
|
ok(IsEqualIID(iid, &IID_if1), "incorrect iid\n");
|
||||||
|
*ppv = (void*)0xdeadbeef;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static IUnknownVtbl create_stub_test_vtbl =
|
||||||
|
{
|
||||||
|
create_stub_test_QI,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static HRESULT WINAPI create_stub_test_fail_QI(IUnknown *This, REFIID iid, void **ppv)
|
||||||
|
{
|
||||||
|
ok(IsEqualIID(iid, &IID_if1), "incorrect iid\n");
|
||||||
|
*ppv = NULL;
|
||||||
|
return E_NOINTERFACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static IUnknownVtbl create_stub_test_fail_vtbl =
|
||||||
|
{
|
||||||
|
create_stub_test_fail_QI,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static void test_CreateStub(IPSFactoryBuffer *ppsf)
|
||||||
|
{
|
||||||
|
IUnknownVtbl *vtbl = &create_stub_test_vtbl;
|
||||||
|
IUnknown *obj = (IUnknown*)&vtbl;
|
||||||
|
IRpcStubBuffer *pstub = create_stub(ppsf, &IID_if1, obj, S_OK);
|
||||||
|
CStdStubBuffer *cstd_stub = (CStdStubBuffer*)pstub;
|
||||||
|
CInterfaceStubHeader *header = ((CInterfaceStubHeader *)cstd_stub->lpVtbl) - 1;
|
||||||
|
|
||||||
|
ok(IsEqualIID(header->piid, &IID_if1), "header iid differs\n");
|
||||||
|
ok(cstd_stub->RefCount == 1, "ref count %ld\n", cstd_stub->RefCount);
|
||||||
|
/* 0xdeadbeef returned from create_stub_test_QI */
|
||||||
|
ok(cstd_stub->pvServerObject == (void*)0xdeadbeef, "pvServerObject %p", cstd_stub->pvServerObject);
|
||||||
|
ok(cstd_stub->pPSFactory == ppsf, "pPSFactory %p\n", cstd_stub->pPSFactory);
|
||||||
|
|
||||||
|
vtbl = &create_stub_test_fail_vtbl;
|
||||||
|
pstub = create_stub(ppsf, &IID_if1, obj, E_NOINTERFACE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST( cstub )
|
START_TEST( cstub )
|
||||||
{
|
{
|
||||||
|
IPSFactoryBuffer *ppsf;
|
||||||
|
|
||||||
OleInitialize(NULL);
|
OleInitialize(NULL);
|
||||||
|
|
||||||
test_NdrDllGetClassObject();
|
ppsf = test_NdrDllGetClassObject();
|
||||||
test_NdrStubForwardingFunction();
|
test_NdrStubForwardingFunction();
|
||||||
|
test_CreateStub(ppsf);
|
||||||
|
|
||||||
OleUninitialize();
|
OleUninitialize();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue