diff --git a/dlls/dpnet/tests/Makefile.in b/dlls/dpnet/tests/Makefile.in index 69339dc007..f6e45ea22e 100644 --- a/dlls/dpnet/tests/Makefile.in +++ b/dlls/dpnet/tests/Makefile.in @@ -3,5 +3,6 @@ IMPORTS = dxguid uuid dpnet ole32 C_SRCS = \ address.c \ + client.c \ peer.c \ server.c diff --git a/dlls/dpnet/tests/client.c b/dlls/dpnet/tests/client.c new file mode 100644 index 0000000000..890f218927 --- /dev/null +++ b/dlls/dpnet/tests/client.c @@ -0,0 +1,206 @@ +/* + * Copyright 2011 Louis Lenders + * Copyright 2014 Alistair Leslie-Hughes + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define WIN32_LEAN_AND_MEAN +#include + +#include +#include "wine/test.h" + + +static IDirectPlay8Client* client = NULL; +static const GUID appguid = { 0xcd0c3d4b, 0xe15e, 0x4cf2, { 0x9e, 0xa8, 0x6e, 0x1d, 0x65, 0x48, 0xc5, 0xa5 } }; + +static HRESULT WINAPI DirectPlayMessageHandler(PVOID context, DWORD message_id, PVOID buffer) +{ + trace("DirectPlayMessageHandler: 0x%08x\n", message_id); + return S_OK; +} + +static BOOL test_init_dp(void) +{ + HRESULT hr; + + hr = CoInitialize(0); + ok(hr == S_OK, "CoInitialize failed with %x\n", hr); + + hr = CoCreateInstance(&CLSID_DirectPlay8Client, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectPlay8Client, (void **)&client); + ok(hr == S_OK, "CoCreateInstance failed with 0x%x\n", hr); + + hr = IDirectPlay8Client_Initialize(client, NULL, NULL, 0); + todo_wine ok(hr == DPNERR_INVALIDPARAM, "got %x\n", hr); + + hr = IDirectPlay8Client_Initialize(client, NULL, DirectPlayMessageHandler, 0); + ok(hr == S_OK, "IDirectPlay8Client_Initialize failed with %x\n", hr); + + return client != NULL; +} + +static void test_enum_service_providers(void) +{ + DPN_SERVICE_PROVIDER_INFO *serv_prov_info; + DWORD items, size; + DWORD i; + HRESULT hr; + + size = 0; + items = 0; + + hr = IDirectPlay8Client_EnumServiceProviders(client, NULL, NULL, NULL, &size, NULL, 0); + todo_wine ok(hr == E_POINTER, "IDirectPlay8Client_EnumServiceProviders failed with %x\n", hr); + + hr = IDirectPlay8Client_EnumServiceProviders(client, NULL, NULL, NULL, NULL, &items, 0); + todo_wine ok(hr == E_POINTER, "IDirectPlay8Client_EnumServiceProviders failed with %x\n", hr); + + hr = IDirectPlay8Client_EnumServiceProviders(client, NULL, NULL, NULL, &size, &items, 0); + todo_wine ok(hr == DPNERR_BUFFERTOOSMALL, "IDirectPlay8Client_EnumServiceProviders failed with %x\n", hr); + todo_wine ok(size != 0, "size is unexpectedly 0\n"); + + serv_prov_info = HeapAlloc(GetProcessHeap(), 0, size); + + hr = IDirectPlay8Client_EnumServiceProviders(client, NULL, NULL, serv_prov_info, &size, &items, 0); + ok(hr == S_OK, "IDirectPlay8Client_EnumServiceProviders failed with %x\n", hr); + todo_wine ok(items != 0, "Found unexpectedly no service providers\n"); + + trace("number of items found: %d\n", items); + + for (i=0;i= 3, "got %d\n", caps.dwNumThreads); + todo_wine ok(caps.dwDefaultEnumCount == 5, "expected 5, got %d\n", caps.dwDefaultEnumCount); + todo_wine ok(caps.dwDefaultEnumRetryInterval == 1500, "expected 1500, got %d\n", caps.dwDefaultEnumRetryInterval); + todo_wine ok(caps.dwDefaultEnumTimeout == 1500, "expected 1500, got %d\n", caps.dwDefaultEnumTimeout); + todo_wine ok(caps.dwMaxEnumPayloadSize == 983, "expected 983, got %d\n", caps.dwMaxEnumPayloadSize); + todo_wine ok(caps.dwBuffersPerThread == 1, "expected 1, got %d\n", caps.dwBuffersPerThread); + todo_wine ok(caps.dwSystemBufferSize == 0x10000 || broken(caps.dwSystemBufferSize == 0x2000 /* before Win8 */), + "expected 0x10000, got 0x%x\n", caps.dwSystemBufferSize); +} + +static void test_cleanup_dp(void) +{ + HRESULT hr; + + hr = IDirectPlay8Client_Close(client, 0); + ok(hr == S_OK, "IDirectPlay8Client_Close failed with %x\n", hr); + + hr = IDirectPlay8Client_Release(client); + ok(hr == S_OK, "IDirectPlay8Client_Release failed with %x\n", hr); + + CoUninitialize(); +} + +START_TEST(client) +{ + if(!test_init_dp()) + return; + + test_enum_service_providers(); + test_enum_hosts(); + test_get_sp_caps(); + test_cleanup_dp(); +}