Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com --- dlls/dpnet/server.c | 10 ++++- dlls/dpnet/tests/server.c | 81 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 2 deletions(-)
diff --git a/dlls/dpnet/server.c b/dlls/dpnet/server.c index 977771697ac..bac6f390e01 100644 --- a/dlls/dpnet/server.c +++ b/dlls/dpnet/server.c @@ -126,9 +126,15 @@ static HRESULT WINAPI IDirectPlay8ServerImpl_EnumServiceProviders(IDirectPlay8Se PDWORD pcReturned, DWORD dwFlags) { IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface); - FIXME("(%p)->(%s %s %p %p %p %d)\n", This, debugstr_guid(pguidServiceProvider), debugstr_guid(pguidApplication), + TRACE("(%p)->(%s %s %p %p %p %d)\n", This, debugstr_guid(pguidServiceProvider), debugstr_guid(pguidApplication), pSPInfoBuffer, pcbEnumData, pcReturned, dwFlags); - return E_NOTIMPL; + if(dwFlags) + FIXME("Unhandled flags %x\n", dwFlags); + + if(pguidApplication) + FIXME("Application guid %s is currently being ignored\n", debugstr_guid(pguidApplication)); + + return enum_services_providers(pguidServiceProvider, pSPInfoBuffer, pcbEnumData, pcReturned); }
static HRESULT WINAPI IDirectPlay8ServerImpl_CancelAsyncOperation(IDirectPlay8Server *iface, DPNHANDLE hAsyncHandle, DWORD dwFlags) diff --git a/dlls/dpnet/tests/server.c b/dlls/dpnet/tests/server.c index 74a0e5adfcf..75dc02560d5 100644 --- a/dlls/dpnet/tests/server.c +++ b/dlls/dpnet/tests/server.c @@ -184,6 +184,86 @@ static void test_server_info(void) } }
+static void test_enum_service_providers(void) +{ + DPN_SERVICE_PROVIDER_INFO *serv_prov_info; + IDirectPlay8Server *server = NULL; + DWORD items, size; + DWORD i; + HRESULT hr; + + hr = CoCreateInstance( &CLSID_DirectPlay8Server, NULL, CLSCTX_ALL, &IID_IDirectPlay8Server, (LPVOID*)&server); + ok(hr == S_OK, "Failed to create IDirectPlay8Server object\n"); + if (FAILED(hr)) + return; + + hr = IDirectPlay8Server_Initialize(server, NULL, DirectPlayMessageHandler, 0); + ok(hr == S_OK, "got 0x%08x\n", hr); + if (FAILED(hr)) + { + IDirectPlay8Server_Release(server); + return; + } + + size = 0; + items = 0; + + hr = IDirectPlay8Server_EnumServiceProviders(server, NULL, NULL, NULL, &size, NULL, 0); + ok(hr == E_POINTER, "IDirectPlay8Server_EnumServiceProviders failed with %x\n", hr); + + hr = IDirectPlay8Server_EnumServiceProviders(server, NULL, NULL, NULL, NULL, &items, 0); + ok(hr == E_POINTER, "IDirectPlay8Server_EnumServiceProviders failed with %x\n", hr); + + hr = IDirectPlay8Server_EnumServiceProviders(server, NULL, NULL, NULL, &size, &items, 0); + ok(hr == DPNERR_BUFFERTOOSMALL, "IDirectPlay8Server_EnumServiceProviders failed with %x\n", hr); + ok(size != 0, "size is unexpectedly 0\n"); + + serv_prov_info = HeapAlloc(GetProcessHeap(), 0, size); + + hr = IDirectPlay8Server_EnumServiceProviders(server, NULL, NULL, serv_prov_info, &size, &items, 0); + ok(hr == S_OK, "IDirectPlay8Server_EnumServiceProviders failed with %x\n", hr); + ok(items != 0, "Found unexpectedly no service providers\n"); + + trace("number of items found: %d\n", items); + + for (i=0;i<items;i++) + { + trace("Found Service Provider: %s\n", wine_dbgstr_w(serv_prov_info[i].pwszName)); + trace("Found guid: %s\n", wine_dbgstr_guid(&serv_prov_info[i].guid)); + } + + ok(HeapFree(GetProcessHeap(), 0, serv_prov_info), "Failed freeing server provider info\n"); + + size = 0; + items = 0; + + hr = IDirectPlay8Server_EnumServiceProviders(server, &CLSID_DP8SP_TCPIP, NULL, NULL, &size, &items, 0); + ok(hr == DPNERR_BUFFERTOOSMALL, "IDirectPlay8Server_EnumServiceProviders failed with %x\n", hr); + ok(size != 0, "size is unexpectedly 0\n"); + + serv_prov_info = HeapAlloc(GetProcessHeap(), 0, size); + + hr = IDirectPlay8Server_EnumServiceProviders(server, &CLSID_DP8SP_TCPIP, NULL, serv_prov_info, &size, &items, 0); + ok(hr == S_OK, "IDirectPlay8Server_EnumServiceProviders failed with %x\n", hr); + ok(items != 0, "Found unexpectedly no adapter\n"); + + + for (i=0;i<items;i++) + { + trace("Found adapter: %s\n", wine_dbgstr_w(serv_prov_info[i].pwszName)); + trace("Found adapter guid: %s\n", wine_dbgstr_guid(&serv_prov_info[i].guid)); + } + + /* Invalid GUID */ + items = 88; + hr = IDirectPlay8Server_EnumServiceProviders(server, &appguid, NULL, serv_prov_info, &size, &items, 0); + ok(hr == DPNERR_DOESNOTEXIST, "IDirectPlay8Peer_EnumServiceProviders failed with %x\n", hr); + ok(items == 88, "Found adapter %d\n", items); + + HeapFree(GetProcessHeap(), 0, serv_prov_info); + IDirectPlay8Server_Release(server); +} + BOOL is_process_elevated(void) { HANDLE token; @@ -398,6 +478,7 @@ START_TEST(server)
create_server(); test_server_info(); + test_enum_service_providers();
CoUninitialize();