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_AddComponent(localaddr, DPNA_KEY_HOSTNAME, &localhost, sizeof(localhost), DPNA_DATATYPE_STRING); 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 == 2, "components=%d\n", components); hr = IDirectPlay8Address_Duplicate(localaddr, &duplicate); ok(hr == S_OK, "got 0x%08x\n", hr); if(SUCCEEDED(hr)) { DWORD size, type; WCHAR buffer[256]; 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); size = sizeof(buffer); hr = IDirectPlay8Address_GetComponentByName(duplicate, DPNA_KEY_HOSTNAME, buffer, &size, &type); ok(hr == S_OK, "got 0x%08x\n", hr); ok(type == DPNA_DATATYPE_STRING, "incorrect type %d\n", type); ok(!lstrcmpW(buffer, localhost), "Invalid string: %s\n", wine_dbgstr_w(buffer)); IDirectPlay8Address_Release(duplicate); } IDirectPlay8Address_Release(localaddr); } }
static void test_enum_hosts(void) { HRESULT hr; IDirectPlay8Address *host = NULL; IDirectPlay8Address *local = NULL; DPN_APPLICATION_DESC appdesc; DPNHANDLE async = 0; static const WCHAR localhost[] = {'1','2','7','.','0','.','0','.','1',0}; memset( &appdesc, 0, sizeof(DPN_APPLICATION_DESC) ); appdesc.dwSize = sizeof( DPN_APPLICATION_DESC ); appdesc.guidApplication = appguid; hr = CoCreateInstance( &CLSID_DirectPlay8Address, NULL, CLSCTX_ALL, &IID_IDirectPlay8Address, (LPVOID*)&local); ok(hr == S_OK, "IDirectPlay8Address failed with 0x%08x\n", hr); hr = IDirectPlay8Address_SetSP(local, &CLSID_DP8SP_TCPIP); ok(hr == S_OK, "IDirectPlay8Address_SetSP failed with 0x%08x\n", hr); hr = CoCreateInstance( &CLSID_DirectPlay8Address, NULL, CLSCTX_ALL, &IID_IDirectPlay8Address, (LPVOID*)&host); ok(hr == S_OK, "IDirectPlay8Address failed with 0x%08x\n", hr); hr = IDirectPlay8Address_SetSP(host, &CLSID_DP8SP_TCPIP); ok(hr == S_OK, "IDirectPlay8Address_SetSP failed with 0x%08x\n", hr); hr = IDirectPlay8Address_AddComponent(host, DPNA_KEY_HOSTNAME, localhost, sizeof(localhost), DPNA_DATATYPE_STRING); ok(hr == S_OK, "IDirectPlay8Address failed with 0x%08x\n", hr); hr = IDirectPlay8Peer_EnumHosts(peer, &appdesc, host, local, NULL, 0, INFINITE, 0, INFINITE, NULL, &async, 0); todo_wine ok(hr == DPNSUCCESS_PENDING, "IDirectPlay8Peer_EnumServiceProviders failed with 0x%08x\n", hr); todo_wine ok(async, "No Handle returned\n"); hr = IDirectPlay8Peer_CancelAsyncOperation(peer, async, 0); todo_wine ok(hr == S_OK, "IDirectPlay8Peer_CancelAsyncOperation failed with 0x%08x\n", hr); IDirectPlay8Address_Release(local); IDirectPlay8Address_Release(host); }
static void address_addcomponents(void) { static const WCHAR UNKNOWN[] = { 'u','n','k','n','o','w','n',0 }; static const char testing[] = "testing"; HRESULT hr; IDirectPlay8Address *localaddr = NULL; hr = CoCreateInstance( &CLSID_DirectPlay8Address, NULL, CLSCTX_ALL, &IID_IDirectPlay8Address, (LPVOID*)&localaddr); ok(hr == S_OK, "Failed to create IDirectPlay8Address object\n"); if(SUCCEEDED(hr)) { GUID compguid; DWORD size, type; DWORD components; DWORD i; DWORD namelen = 0; DWORD bufflen = 0; DWORD port = 8888; WCHAR buffer[256]; WCHAR *name = NULL; /* We can add any Component to the Address interface not just the predefined ones. */ hr = IDirectPlay8Address_AddComponent(localaddr, UNKNOWN, &IID_Random, sizeof(GUID), DPNA_DATATYPE_GUID); ok(hr == S_OK, "got 0x%08x\n", hr); hr = IDirectPlay8Address_AddComponent(localaddr, UNKNOWN, &IID_Random, sizeof(GUID)+1, DPNA_DATATYPE_GUID); ok(hr == DPNERR_INVALIDPARAM, "got 0x%08x\n", hr); hr = IDirectPlay8Address_AddComponent(localaddr, DPNA_KEY_HOSTNAME, &localhost, sizeof(localhost)+2, DPNA_DATATYPE_STRING); ok(hr == DPNERR_INVALIDPARAM, "got 0x%08x\n", hr); hr = IDirectPlay8Address_AddComponent(localaddr, DPNA_KEY_HOSTNAME, &localhost, sizeof(localhost)/2, DPNA_DATATYPE_STRING); ok(hr == DPNERR_INVALIDPARAM, "got 0x%08x\n", hr); hr = IDirectPlay8Address_AddComponent(localaddr, DPNA_KEY_HOSTNAME, testing, sizeof(testing)+2, DPNA_DATATYPE_STRING_ANSI); ok(hr == DPNERR_INVALIDPARAM, "got 0x%08x\n", hr); /* Show that on error, nothing is added. */ size = sizeof(buffer); hr = IDirectPlay8Address_GetComponentByName(localaddr, DPNA_KEY_HOSTNAME, buffer, &size, &type); ok(hr == DPNERR_DOESNOTEXIST, "got 0x%08x\n", hr); hr = IDirectPlay8Address_AddComponent(localaddr, DPNA_KEY_HOSTNAME, testing, sizeof(testing), DPNA_DATATYPE_STRING_ANSI); ok(hr == S_OK, "got 0x%08x\n", hr); hr = IDirectPlay8Address_AddComponent(localaddr, DPNA_KEY_PORT, &port, sizeof(DWORD)+2, DPNA_DATATYPE_DWORD); ok(hr == DPNERR_INVALIDPARAM, "got 0x%08x\n", hr); hr = IDirectPlay8Address_AddComponent(localaddr, DPNA_KEY_HOSTNAME, &localhost, sizeof(localhost), DPNA_DATATYPE_STRING); ok(hr == S_OK, "got 0x%08x\n", hr); /* The information doesn't get removed when invalid parameters are used.*/ hr = IDirectPlay8Address_AddComponent(localaddr, DPNA_KEY_HOSTNAME, &localhost, sizeof(localhost)+2, DPNA_DATATYPE_STRING); ok(hr == DPNERR_INVALIDPARAM, "got 0x%08x\n", hr); size = 0; hr = IDirectPlay8Address_GetComponentByName(localaddr, DPNA_KEY_HOSTNAME, NULL, &size, &type); ok(hr == DPNERR_BUFFERTOOSMALL, "got 0x%08x\n", hr); ok(size == sizeof(localhost), "Invalid string length: %d\n", size); size = 1; hr = IDirectPlay8Address_GetComponentByName(localaddr, DPNA_KEY_HOSTNAME, NULL, &size, &type); ok(hr == E_POINTER, "got 0x%08x\n", hr); size = sizeof(buffer); hr = IDirectPlay8Address_GetComponentByName(localaddr, DPNA_KEY_HOSTNAME, buffer, &size, &type); ok(hr == S_OK, "got 0x%08x\n", hr); ok(type == DPNA_DATATYPE_STRING, "incorrect type %d\n", type); ok(!lstrcmpW(buffer, localhost), "Invalid string: %s\n", wine_dbgstr_w(buffer)); hr = IDirectPlay8Address_AddComponent(localaddr, DPNA_KEY_PORT, &port, sizeof(DWORD)+2, DPNA_DATATYPE_DWORD); ok(hr == DPNERR_INVALIDPARAM, "got 0x%08x\n", hr); hr = IDirectPlay8Address_AddComponent(localaddr, DPNA_KEY_PORT, &port, sizeof(DWORD), DPNA_DATATYPE_DWORD); ok(hr == S_OK, "got 0x%08x\n", hr); hr = IDirectPlay8Address_GetComponentByName(localaddr, NULL, &compguid, &size, &type); ok(hr == E_POINTER, "got 0x%08x\n", hr); size = sizeof(GUID)-1; hr = IDirectPlay8Address_GetComponentByName(localaddr, UNKNOWN, NULL, &size, &type); ok(hr == E_POINTER, "got 0x%08x\n", hr); size = sizeof(GUID); hr = IDirectPlay8Address_GetComponentByName(localaddr, UNKNOWN, NULL, &size, &type); ok(hr == E_POINTER, "got 0x%08x\n", hr); hr = IDirectPlay8Address_GetComponentByName(localaddr, UNKNOWN, &compguid, NULL, &type); ok(hr == E_POINTER, "got 0x%08x\n", hr); size = sizeof(GUID)-1; hr = IDirectPlay8Address_GetComponentByName(localaddr, UNKNOWN, &compguid, &size, NULL); ok(hr == E_POINTER, "got 0x%08x\n", hr); size = sizeof(GUID); hr = IDirectPlay8Address_GetComponentByName(localaddr, UNKNOWN, &compguid, &size, NULL); ok(hr == E_POINTER, "got 0x%08x\n", hr); size = sizeof(GUID)-1; hr = IDirectPlay8Address_GetComponentByName(localaddr, UNKNOWN, &compguid, &size, &type); ok(hr == DPNERR_BUFFERTOOSMALL, "got 0x%08x\n", hr); ok(size == sizeof(GUID), "got %d\n", size); size = sizeof(GUID); hr = IDirectPlay8Address_GetComponentByName(localaddr, UNKNOWN, &compguid, &size, &type); ok(IsEqualGUID(&compguid, &IID_Random), "incorrect guid\n"); ok(size == sizeof(GUID), "incorrect size got %d\n", size); ok(type == DPNA_DATATYPE_GUID, "incorrect type\n"); ok(hr == S_OK, "got 0x%08x\n", hr); hr = IDirectPlay8Address_GetNumComponents(localaddr, NULL); ok(hr == DPNERR_INVALIDPOINTER, "got 0x%08x\n", hr); hr = IDirectPlay8Address_GetNumComponents(localaddr, &components); ok(hr == S_OK, "got 0x%08x\n", hr); hr = IDirectPlay8Address_GetComponentByIndex(localaddr, 100, NULL, &namelen, NULL, &bufflen, &type); ok(hr == DPNERR_DOESNOTEXIST, "got 0x%08x\n", hr); hr = IDirectPlay8Address_GetComponentByIndex(localaddr, 1, NULL, &namelen, NULL, &bufflen, NULL); ok(hr == DPNERR_INVALIDPOINTER, "got 0x%08x\n", hr); bufflen = 100; namelen = 0; hr = IDirectPlay8Address_GetComponentByIndex(localaddr, 1, name, &namelen, buffer, &bufflen, &type); ok(hr == DPNERR_BUFFERTOOSMALL, "got 0x%08x\n", hr); namelen = 100; hr = IDirectPlay8Address_GetComponentByIndex(localaddr, 1, NULL, &namelen, NULL, &bufflen, &type); ok(hr == DPNERR_INVALIDPOINTER, "got 0x%08x\n", hr); hr = IDirectPlay8Address_GetComponentByIndex(localaddr, 100, NULL, NULL, NULL, &bufflen, &type); ok(hr == DPNERR_INVALIDPOINTER, "got 0x%08x\n", hr); hr = IDirectPlay8Address_GetComponentByIndex(localaddr, 100, NULL, &namelen, NULL, NULL, &type); ok(hr == DPNERR_INVALIDPOINTER, "got 0x%08x\n", hr); bufflen = 0; namelen = 0; type = 0; hr = IDirectPlay8Address_GetComponentByIndex(localaddr, 0, NULL, &namelen, NULL, &bufflen, &type); ok(hr == DPNERR_BUFFERTOOSMALL, "got 0x%08x\n", hr); ok(namelen == 8, "namelen expected 8 got %d\n", namelen); ok(bufflen == 16, "bufflen expected 16 got %d\n", bufflen); ok(type == DPNA_DATATYPE_GUID, "type expected DPNA_DATATYPE_GUID got %d\n", type); trace("GetNumComponents=%d\n", components); for(i=0; i < components; i++) { void *buffer; bufflen = 0; namelen = 0; hr = IDirectPlay8Address_GetComponentByIndex(localaddr, i, NULL, &namelen, NULL, &bufflen, &type); ok(hr == DPNERR_BUFFERTOOSMALL, "got 0x%08x\n", hr); name = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, namelen * sizeof(WCHAR)); buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, bufflen); hr = IDirectPlay8Address_GetComponentByIndex(localaddr, i, name, &namelen, buffer, &bufflen, &type); ok(hr == S_OK, "got 0x%08x\n", hr); if(hr == S_OK) { switch(type) { case DPNA_DATATYPE_STRING: trace("%d: %s: %s\n", i, wine_dbgstr_w(name), wine_dbgstr_w(buffer)); break; case DPNA_DATATYPE_DWORD: trace("%d: %s: %d\n", i, wine_dbgstr_w(name), *(DWORD*)buffer); break; case DPNA_DATATYPE_GUID: trace("%d: %s: %s\n", i, wine_dbgstr_w(name), wine_dbgstr_guid( (GUID*)buffer)); break; case DPNA_DATATYPE_BINARY: trace("%d: %s: Binary Data %d\n", i, wine_dbgstr_w(name), bufflen); break; default: trace(" Unknown\n"); break; } } HeapFree(GetProcessHeap(), 0, name); HeapFree(GetProcessHeap(), 0, buffer); } IDirectPlay8Address_Release(localaddr); } }