dpnet: Implement IDirectPlay8Address Duplicate.

This commit is contained in:
Alistair Leslie-Hughes 2014-05-13 12:57:47 +10:00 committed by Alexandre Julliard
parent 0dd5cb1cef
commit 7dcfb9d3e5
3 changed files with 70 additions and 3 deletions

View File

@ -179,9 +179,35 @@ static HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromURLA(IDirectPlay8Address
static HRESULT WINAPI IDirectPlay8AddressImpl_Duplicate(IDirectPlay8Address *iface,
IDirectPlay8Address **ppdpaNewAddress)
{
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
TRACE("(%p, %p): stub\n", This, ppdpaNewAddress);
return DPN_OK;
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
IDirectPlay8Address *dup;
HRESULT hr;
TRACE("(%p, %p)\n", This, ppdpaNewAddress);
if(!ppdpaNewAddress)
return E_POINTER;
hr = DPNET_CreateDirectPlay8Address(NULL, NULL, &IID_IDirectPlay8Address, (LPVOID*)&dup);
if(hr == S_OK)
{
IDirectPlay8AddressImpl *DupThis = impl_from_IDirectPlay8Address(dup);
struct component *entry;
DupThis->SP_guid = This->SP_guid;
DupThis->init = This->init;
LIST_FOR_EACH_ENTRY(entry, &This->components, struct component, entry)
{
hr = IDirectPlay8Address_AddComponent(dup, entry->name, &entry->data, entry->size, entry->type);
if(hr != S_OK)
ERR("Failed to copy component: %s - 0x%08x\n", debugstr_w(entry->name), hr);
}
*ppdpaNewAddress = dup;
}
return hr;
}
static HRESULT WINAPI IDirectPlay8AddressImpl_SetEqual(IDirectPlay8Address *iface,
@ -338,6 +364,7 @@ static HRESULT WINAPI IDirectPlay8AddressImpl_AddComponent(IDirectPlay8Address *
list_add_tail(&This->components, &entry->entry);
}
entry->size = dwDataSize;
switch (dwDataType)
{
case DPNA_DATATYPE_DWORD:

View File

@ -68,6 +68,7 @@ struct component
WCHAR *name;
DWORD type;
DWORD size;
union
{

View File

@ -214,6 +214,44 @@ static void address_setsp(void)
}
}
static void address_duplicate(void)
{
HRESULT hr;
IDirectPlay8Address *localaddr = NULL;
IDirectPlay8Address *duplicate = NULL;
DWORD components, dupcomps;
GUID guid = IID_Random;
hr = CoCreateInstance( &CLSID_DirectPlay8Address, NULL, CLSCTX_ALL, &IID_IDirectPlay8Address, (LPVOID*)&localaddr);
ok(hr == S_OK, "Failed to create IDirectPlay8Address object\n");
if(SUCCEEDED(hr))
{
hr = IDirectPlay8Address_SetSP(localaddr, &CLSID_DP8SP_TCPIP);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDirectPlay8Address_GetNumComponents(localaddr, &components);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(components == 1, "components=%d\n", components);
hr = IDirectPlay8Address_Duplicate(localaddr, &duplicate);
ok(hr == S_OK, "got 0x%08x\n", hr);
if(SUCCEEDED(hr))
{
hr = IDirectPlay8Address_GetSP(duplicate, &guid);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(IsEqualGUID(&guid, &CLSID_DP8SP_TCPIP), "wrong guid\n");
hr = IDirectPlay8Address_GetNumComponents(duplicate, &dupcomps);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(components == dupcomps, "expected %d got %d\n", components, dupcomps);
IDirectPlay8Address_Release(duplicate);
}
IDirectPlay8Address_Release(localaddr);
}
}
START_TEST(address)
{
HRESULT hr;
@ -226,6 +264,7 @@ START_TEST(address)
create_directplay_address();
address_addcomponents();
address_setsp();
address_duplicate();
CoUninitialize();
}