dpnet: Implement IDirectPlay8Client Initialize
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Sun Feb 16 23:22:33 CST 2014
Hi,
The tests are just a copy of peer.c and changed to use interface
IDirectPlay8Client.
Changelog:
dpnet: Implement IDirectPlay8Client Initialize
Best Regards
Alistair Leslie-Hughes
-------------- next part --------------
>From 1cd8ea0869c228ded509d4f00aa751fd64e5e81b Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Fri, 14 Feb 2014 11:06:32 +1100
Subject: [PATCH] Implement IDirectPlay8Client Initialize
To: wine-patches <wine-patches at winehq.org>
---
dlls/dpnet/client.c | 18 +++-
dlls/dpnet/dpnet_private.h | 10 ++-
dlls/dpnet/tests/Makefile.in | 1 +
dlls/dpnet/tests/client.c | 208 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 231 insertions(+), 6 deletions(-)
create mode 100644 dlls/dpnet/tests/client.c
diff --git a/dlls/dpnet/client.c b/dlls/dpnet/client.c
index 9668a68..38ae904 100644
--- a/dlls/dpnet/client.c
+++ b/dlls/dpnet/client.c
@@ -86,9 +86,18 @@ static ULONG WINAPI IDirectPlay8ClientImpl_Release(IDirectPlay8Client *iface)
static HRESULT WINAPI IDirectPlay8ClientImpl_Initialize(IDirectPlay8Client *iface,
void * const pvUserContext, const PFNDPNMESSAGEHANDLER pfn, const DWORD dwFlags)
{
- IDirectPlay8ClientImpl *This = impl_from_IDirectPlay8Client(iface);
- FIXME("(%p):(%p,%p,%x): Stub\n", This, pvUserContext, pfn, dwFlags);
- return DPN_OK;
+ IDirectPlay8ClientImpl *This = impl_from_IDirectPlay8Client(iface);
+
+ TRACE("(%p):(%p,%p,%x)\n", This, pvUserContext, pfn, dwFlags);
+
+ if(!pfn)
+ return DPNERR_INVALIDPARAM;
+
+ This->usercontext = pvUserContext;
+ This->msghandler = pfn;
+ This->flags = dwFlags;
+
+ return DPN_OK;
}
static HRESULT WINAPI IDirectPlay8ClientImpl_EnumServiceProviders(IDirectPlay8Client *iface,
@@ -291,6 +300,9 @@ HRESULT DPNET_CreateDirectPlay8Client(IClassFactory *iface, IUnknown *pUnkOuter,
client->IDirectPlay8Client_iface.lpVtbl = &DirectPlay8Client_Vtbl;
client->ref = 1;
+ client->usercontext = NULL;
+ client->msghandler = NULL;
+ client->flags = 0;
hr = IDirectPlay8ClientImpl_QueryInterface(&client->IDirectPlay8Client_iface, riid, ppv);
IDirectPlay8ClientImpl_Release(&client->IDirectPlay8Client_iface);
diff --git a/dlls/dpnet/dpnet_private.h b/dlls/dpnet/dpnet_private.h
index 4a42eae..54a22f9 100644
--- a/dlls/dpnet/dpnet_private.h
+++ b/dlls/dpnet/dpnet_private.h
@@ -46,9 +46,13 @@ typedef struct IDirectPlay8ThreadPoolImpl IDirectPlay8ThreadPoolImpl;
*/
struct IDirectPlay8ClientImpl
{
- IDirectPlay8Client IDirectPlay8Client_iface;
- LONG ref;
- /* IDirectPlay8Client fields */
+ IDirectPlay8Client IDirectPlay8Client_iface;
+ LONG ref;
+
+ /* IDirectPlay8Client fields */
+ PFNDPNMESSAGEHANDLER msghandler;
+ DWORD flags;
+ void *usercontext;
};
/* ------------------- */
diff --git a/dlls/dpnet/tests/Makefile.in b/dlls/dpnet/tests/Makefile.in
index f97f01d..f7f49ea 100644
--- a/dlls/dpnet/tests/Makefile.in
+++ b/dlls/dpnet/tests/Makefile.in
@@ -3,5 +3,6 @@ IMPORTS = 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 0000000..2da6c06
--- /dev/null
+++ b/dlls/dpnet/tests/client.c
@@ -0,0 +1,208 @@
+/*
+ * 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 <stdio.h>
+
+#include <dplay8.h>
+#include "wine/test.h"
+
+
+static IDirectPlay8Client* client = NULL;
+
+static HRESULT WINAPI DirectPlayMessageHandler(PVOID context, DWORD message_id, PVOID buffer)
+{
+ trace("DirectPlayMessageHandler: 0x%08x\n", message_id);
+ return S_OK;
+}
+
+static void 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);
+ 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);
+}
+
+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<items;i++)
+ {
+ trace("Found Service Provider: %s\n", wine_dbgstr_w(serv_prov_info->pwszName));
+ trace("Found guid: %s\n", wine_dbgstr_guid(&serv_prov_info->guid));
+
+ serv_prov_info++;
+ }
+
+ serv_prov_info -= items; /* set pointer back */
+ ok(HeapFree(GetProcessHeap(), 0, serv_prov_info), "Failed freeing server provider info\n");
+
+ size = 0;
+ items = 0;
+
+ hr = IDirectPlay8Client_EnumServiceProviders(client, &CLSID_DP8SP_TCPIP, 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, &CLSID_DP8SP_TCPIP, 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 adapter\n");
+
+
+ for (i=0;i<items;i++)
+ {
+ trace("Found adapter: %s\n", wine_dbgstr_w(serv_prov_info->pwszName));
+ trace("Found adapter guid: %s\n", wine_dbgstr_guid(&serv_prov_info->guid));
+
+ serv_prov_info++;
+ }
+
+ serv_prov_info -= items; /* set pointer back */
+ ok(HeapFree(GetProcessHeap(), 0, serv_prov_info), "Failed freeing server provider info\n");
+}
+
+static const GUID appguid = { 0xcd0c3d4b, 0xe15e, 0x4cf2, { 0x9e, 0xa8, 0x6e, 0x1d, 0x65, 0x48, 0xc5, 0xa5 } };
+
+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 = IDirectPlay8Client_EnumHosts(client, &appdesc, host, local, NULL, 0, INFINITE, 0, INFINITE, NULL, &async, 0);
+ todo_wine ok(hr == DPNSUCCESS_PENDING, "IDirectPlay8Client_EnumServiceProviders failed with 0x%08x\n", hr);
+ todo_wine ok(async, "No Handle returned\n");
+
+ hr = IDirectPlay8Client_CancelAsyncOperation(client, async, 0);
+ ok(hr == S_OK, "IDirectPlay8Client_CancelAsyncOperation failed with 0x%08x\n", hr);
+
+ IDirectPlay8Address_Release(local);
+ IDirectPlay8Address_Release(host);
+}
+
+static void test_get_sp_caps(void)
+{
+ DPN_SP_CAPS caps;
+ HRESULT hr;
+
+ memset(&caps, 0, sizeof(DPN_SP_CAPS));
+
+ hr = IDirectPlay8Client_GetSPCaps(client, &CLSID_DP8SP_TCPIP, &caps, 0);
+ todo_wine ok(hr == DPNERR_INVALIDPARAM, "GetSPCaps unexpectedly returned %x\n", hr);
+
+ caps.dwSize = sizeof(DPN_SP_CAPS);
+
+ hr = IDirectPlay8Client_GetSPCaps(client, &CLSID_DP8SP_TCPIP, &caps, 0);
+ ok(hr == DPN_OK, "GetSPCaps failed with %x\n", hr);
+
+ todo_wine ok((caps.dwFlags &
+ (DPNSPCAPS_SUPPORTSDPNSRV | DPNSPCAPS_SUPPORTSBROADCAST | DPNSPCAPS_SUPPORTSALLADAPTERS)) ==
+ (DPNSPCAPS_SUPPORTSDPNSRV | DPNSPCAPS_SUPPORTSBROADCAST | DPNSPCAPS_SUPPORTSALLADAPTERS),
+ "unexpected flags %x\n", caps.dwFlags);
+ todo_wine ok(caps.dwNumThreads >= 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)
+{
+ test_init_dp();
+ test_enum_service_providers();
+ test_enum_hosts();
+ test_get_sp_caps();
+ test_cleanup_dp();
+}
--
1.8.3.2
More information about the wine-patches
mailing list