2 * Copyright 2011 Louis Lenders
3 * Copyright 2014 Alistair Leslie-Hughes
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #define WIN32_LEAN_AND_MEAN
27 #include "wine/test.h"
29 #include "dpnet_test.h"
31 static IDirectPlay8Server
* server
= NULL
;
32 static IDirectPlay8Peer
* peer
= NULL
;
33 static IDirectPlay8Client
* client
= NULL
;
34 static IDirectPlay8LobbiedApplication
* lobbied
= NULL
;
35 static const GUID appguid
= { 0xcd0c3d4b, 0xe15e, 0x4cf2, { 0x9e, 0xa8, 0x6e, 0x1d, 0x65, 0x48, 0xc5, 0xa5 } };
36 static const WCHAR localhost
[] = L
"127.0.0.1";
38 static HRESULT lastAsyncCode
= E_FAIL
;
39 static DPNHANDLE lastAsyncHandle
= 0xdeadbeef;
40 static HANDLE enumevent
= NULL
;
41 static int handlecnt
= 0;
43 static HRESULT WINAPI
DirectPlayServerHandler(void *context
, DWORD message_id
, void *buffer
)
47 case DPN_MSGID_CREATE_PLAYER
:
48 case DPN_MSGID_DESTROY_PLAYER
:
49 /* These are tested in the server test */
52 trace("DirectPlayServerHandler: 0x%08lx\n", message_id
);
57 static HRESULT WINAPI
DirectPlayMessageHandler(PVOID context
, DWORD message_id
, PVOID buffer
)
61 case DPN_MSGID_ENUM_HOSTS_RESPONSE
:
66 case DPN_MSGID_ASYNC_OP_COMPLETE
:
68 DPNMSG_ASYNC_OP_COMPLETE
*async_msg
= (DPNMSG_ASYNC_OP_COMPLETE
*)buffer
;
69 lastAsyncCode
= async_msg
->hResultCode
;
70 lastAsyncHandle
= async_msg
->hAsyncOp
;
74 trace("DirectPlayMessageHandler: 0x%08lx\n", message_id
);
80 static HRESULT WINAPI
DirectPlayLobbyMessageHandler(PVOID context
, DWORD message_id
, PVOID buffer
)
82 trace("DirectPlayLobbyMessageHandler: 0x%08lx\n", message_id
);
86 static HRESULT WINAPI
DirectPlayLobbyClientMessageHandler(void *context
, DWORD message_id
, void* buffer
)
88 trace("DirectPlayLobbyClientMessageHandler: 0x%08lx\n", message_id
);
92 static void create_server(void)
94 static WCHAR sessionname
[] = L
"winegamesserver";
96 IDirectPlay8Address
*localaddr
= NULL
;
97 DPN_APPLICATION_DESC appdesc
;
99 hr
= CoCreateInstance( &CLSID_DirectPlay8Server
, NULL
, CLSCTX_ALL
, &IID_IDirectPlay8Server
, (void **)&server
);
100 ok(hr
== S_OK
, "Failed to create IDirectPlay8Server object\n");
102 hr
= IDirectPlay8Server_Initialize(server
, NULL
, DirectPlayServerHandler
, 0);
103 ok(hr
== S_OK
, "got 0x%08lx\n", hr
);
105 hr
= CoCreateInstance( &CLSID_DirectPlay8Address
, NULL
, CLSCTX_ALL
, &IID_IDirectPlay8Address
, (void **)&localaddr
);
106 ok(hr
== S_OK
, "Failed to create IDirectPlay8Address object\n");
108 hr
= IDirectPlay8Address_SetSP(localaddr
, &CLSID_DP8SP_TCPIP
);
109 ok(hr
== S_OK
, "got 0x%08lx\n", hr
);
111 memset( &appdesc
, 0, sizeof(DPN_APPLICATION_DESC
) );
112 appdesc
.dwSize
= sizeof( DPN_APPLICATION_DESC
);
113 appdesc
.dwFlags
= DPNSESSION_CLIENT_SERVER
;
114 appdesc
.guidApplication
= appguid
;
115 appdesc
.pwszSessionName
= sessionname
;
117 hr
= IDirectPlay8Server_Host(server
, &appdesc
, &localaddr
, 1, NULL
, NULL
, NULL
, 0);
118 todo_wine
ok(hr
== S_OK
, "got 0x%08lx\n", hr
);
120 IDirectPlay8Address_Release(localaddr
);
123 static BOOL
test_init_dp(void)
127 DPNHANDLE lobbyConnection
;
129 enumevent
= CreateEventA( NULL
, TRUE
, FALSE
, NULL
);
131 hr
= CoCreateInstance(&CLSID_DirectPlay8Client
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectPlay8Client
, (void **)&client
);
132 ok(hr
== S_OK
, "CoCreateInstance failed with 0x%lx\n", hr
);
134 memset(&caps
, 0, sizeof(DPN_SP_CAPS
));
135 caps
.dwSize
= sizeof(DPN_SP_CAPS
);
137 hr
= IDirectPlay8Client_GetSPCaps(client
, &CLSID_DP8SP_TCPIP
, &caps
, 0);
138 ok(hr
== DPNERR_UNINITIALIZED
, "GetSPCaps failed with %lx\n", hr
);
140 hr
= IDirectPlay8Client_Initialize(client
, NULL
, NULL
, 0);
141 ok(hr
== DPNERR_INVALIDPARAM
, "got %lx\n", hr
);
143 hr
= IDirectPlay8Client_SetSPCaps(client
, &CLSID_DP8SP_TCPIP
, &caps
, 0);
144 ok(hr
== DPNERR_INVALIDPARAM
, "SetSPCaps failed with %lx\n", hr
);
146 hr
= IDirectPlay8Client_Initialize(client
, NULL
, DirectPlayMessageHandler
, 0);
147 ok(hr
== S_OK
, "IDirectPlay8Client_Initialize failed with %lx\n", hr
);
149 hr
= CoCreateInstance(&CLSID_DirectPlay8LobbiedApplication
, NULL
, CLSCTX_INPROC_SERVER
,
150 &IID_IDirectPlay8LobbiedApplication
, (void **)&lobbied
);
151 ok(hr
== S_OK
, "CoCreateInstance failed with 0x%lx\n", hr
);
153 hr
= IDirectPlay8LobbiedApplication_Initialize(lobbied
, NULL
, DirectPlayLobbyMessageHandler
,
154 &lobbyConnection
, 0);
155 ok(hr
== S_OK
, "IDirectPlay8LobbiedApplication_Initialize failed with %lx\n", hr
);
157 return client
!= NULL
;
160 static void test_enum_service_providers(void)
162 DPN_SERVICE_PROVIDER_INFO
*serv_prov_info
;
170 hr
= IDirectPlay8Client_EnumServiceProviders(client
, NULL
, NULL
, NULL
, &size
, NULL
, 0);
171 ok(hr
== E_POINTER
, "IDirectPlay8Client_EnumServiceProviders failed with %lx\n", hr
);
173 hr
= IDirectPlay8Client_EnumServiceProviders(client
, NULL
, NULL
, NULL
, NULL
, &items
, 0);
174 ok(hr
== E_POINTER
, "IDirectPlay8Client_EnumServiceProviders failed with %lx\n", hr
);
176 hr
= IDirectPlay8Client_EnumServiceProviders(client
, NULL
, NULL
, NULL
, &size
, &items
, 0);
177 ok(hr
== DPNERR_BUFFERTOOSMALL
, "IDirectPlay8Client_EnumServiceProviders failed with %lx\n", hr
);
178 ok(size
!= 0, "size is unexpectedly 0\n");
180 serv_prov_info
= HeapAlloc(GetProcessHeap(), 0, size
);
182 hr
= IDirectPlay8Client_EnumServiceProviders(client
, NULL
, NULL
, serv_prov_info
, &size
, &items
, 0);
183 ok(hr
== S_OK
, "IDirectPlay8Client_EnumServiceProviders failed with %lx\n", hr
);
184 ok(items
!= 0, "Found unexpectedly no service providers\n");
186 trace("number of items found: %ld\n", items
);
188 for (i
=0;i
<items
;i
++)
190 trace("Found Service Provider: %s\n", wine_dbgstr_w(serv_prov_info
[i
].pwszName
));
191 trace("Found guid: %s\n", wine_dbgstr_guid(&serv_prov_info
[i
].guid
));
194 ok(HeapFree(GetProcessHeap(), 0, serv_prov_info
), "Failed freeing server provider info\n");
199 hr
= IDirectPlay8Client_EnumServiceProviders(client
, &CLSID_DP8SP_TCPIP
, NULL
, NULL
, &size
, &items
, 0);
200 ok(hr
== DPNERR_BUFFERTOOSMALL
, "IDirectPlay8Client_EnumServiceProviders failed with %lx\n", hr
);
201 ok(size
!= 0, "size is unexpectedly 0\n");
203 serv_prov_info
= HeapAlloc(GetProcessHeap(), 0, size
);
205 hr
= IDirectPlay8Client_EnumServiceProviders(client
, &CLSID_DP8SP_TCPIP
, NULL
, serv_prov_info
, &size
, &items
, 0);
206 ok(hr
== S_OK
, "IDirectPlay8Client_EnumServiceProviders failed with %lx\n", hr
);
207 ok(items
!= 0, "Found unexpectedly no adapter\n");
210 for (i
=0;i
<items
;i
++)
212 trace("Found adapter: %s\n", wine_dbgstr_w(serv_prov_info
[i
].pwszName
));
213 trace("Found adapter guid: %s\n", wine_dbgstr_guid(&serv_prov_info
[i
].guid
));
218 hr
= IDirectPlay8Client_EnumServiceProviders(client
, &appguid
, NULL
, serv_prov_info
, &size
, &items
, 0);
219 ok(hr
== DPNERR_DOESNOTEXIST
, "IDirectPlay8Peer_EnumServiceProviders failed with %lx\n", hr
);
220 ok(items
== 88, "Found adapter %ld\n", items
);
222 HeapFree(GetProcessHeap(), 0, serv_prov_info
);
225 static void test_enum_hosts(void)
228 IDirectPlay8Client
*client2
;
229 IDirectPlay8Address
*host
= NULL
;
230 IDirectPlay8Address
*local
= NULL
;
231 DPN_APPLICATION_DESC appdesc
;
232 DPNHANDLE async
= 0, async2
= 0;
236 memset( &appdesc
, 0, sizeof(DPN_APPLICATION_DESC
) );
237 appdesc
.dwSize
= sizeof( DPN_APPLICATION_DESC
);
238 appdesc
.guidApplication
= appguid
;
240 hr
= CoCreateInstance(&CLSID_DirectPlay8Client
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectPlay8Client
, (void **)&client2
);
241 ok(hr
== S_OK
, "CoCreateInstance failed with 0x%lx\n", hr
);
243 hr
= CoCreateInstance( &CLSID_DirectPlay8Address
, NULL
, CLSCTX_ALL
, &IID_IDirectPlay8Address
, (LPVOID
*)&local
);
244 ok(hr
== S_OK
, "IDirectPlay8Address failed with 0x%08lx\n", hr
);
246 hr
= IDirectPlay8Address_SetSP(local
, &CLSID_DP8SP_TCPIP
);
247 ok(hr
== S_OK
, "IDirectPlay8Address_SetSP failed with 0x%08lx\n", hr
);
249 hr
= CoCreateInstance( &CLSID_DirectPlay8Address
, NULL
, CLSCTX_ALL
, &IID_IDirectPlay8Address
, (LPVOID
*)&host
);
250 ok(hr
== S_OK
, "IDirectPlay8Address failed with 0x%08lx\n", hr
);
252 hr
= IDirectPlay8Address_SetSP(host
, &CLSID_DP8SP_TCPIP
);
253 ok(hr
== S_OK
, "IDirectPlay8Address_SetSP failed with 0x%08lx\n", hr
);
255 hr
= IDirectPlay8Address_AddComponent(host
, DPNA_KEY_HOSTNAME
, localhost
, sizeof(localhost
),
256 DPNA_DATATYPE_STRING
);
257 ok(hr
== S_OK
, "IDirectPlay8Address failed with 0x%08lx\n", hr
);
259 caps
.dwSize
= sizeof(DPN_SP_CAPS
);
261 hr
= IDirectPlay8Client_GetSPCaps(client
, &CLSID_DP8SP_TCPIP
, &caps
, 0);
262 ok(hr
== DPN_OK
, "got %lx\n", hr
);
263 data
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, caps
.dwMaxEnumPayloadSize
+ 1);
265 hr
= IDirectPlay8Client_EnumHosts(client
, &appdesc
, host
, local
, NULL
, 0, 2, 1000, 1000, NULL
, &async
, DPNENUMHOSTS_SYNC
);
266 ok(hr
== DPNERR_INVALIDPARAM
, "got 0x%08lx\n", hr
);
268 hr
= IDirectPlay8Client_EnumHosts(client
, &appdesc
, host
, local
, data
, caps
.dwMaxEnumPayloadSize
+ 1,
269 INFINITE
, 0, INFINITE
, NULL
, &async
, DPNENUMHOSTS_SYNC
);
270 ok(hr
== DPNERR_INVALIDPARAM
, "got 0x%08lx\n", hr
);
273 hr
= IDirectPlay8Client_EnumHosts(client
, &appdesc
, host
, local
, data
, caps
.dwMaxEnumPayloadSize
+ 1, INFINITE
, 0,
274 INFINITE
, NULL
, &async
, 0);
275 ok(hr
== DPNERR_ENUMQUERYTOOLARGE
, "got 0x%08lx\n", hr
);
276 ok(!async
, "Handle returned\n");
279 hr
= IDirectPlay8Client_EnumHosts(client
, &appdesc
, host
, local
, data
, caps
.dwMaxEnumPayloadSize
, INFINITE
, 0, INFINITE
,
281 ok(hr
== DPNSUCCESS_PENDING
, "got 0x%08lx\n", hr
);
282 todo_wine
ok(async
, "No Handle returned\n");
284 /* This CancelAsyncOperation doesn't generate a DPN_MSGID_ASYNC_OP_COMPLETE */
285 hr
= IDirectPlay8Client_CancelAsyncOperation(client
, async
, 0);
286 ok(hr
== S_OK
, "got 0x%08lx\n", hr
);
287 HeapFree(GetProcessHeap(), 0, data
);
289 /* No Initialize has been called on client2. */
290 hr
= IDirectPlay8Client_EnumHosts(client2
, &appdesc
, host
, local
, NULL
, 0, INFINITE
, 0, INFINITE
, NULL
, &async
, 0);
291 ok(hr
== DPNERR_UNINITIALIZED
, "IDirectPlay8Client_EnumHosts failed with 0x%08lx\n", hr
);
293 /* Since we are running asynchronously, EnumHosts returns DPNSUCCESS_PENDING. */
294 hr
= IDirectPlay8Client_EnumHosts(client
, &appdesc
, host
, local
, NULL
, 0, INFINITE
, 0, INFINITE
, NULL
, &async
, 0);
295 ok(hr
== DPNSUCCESS_PENDING
, "IDirectPlay8Client_EnumHosts failed with 0x%08lx\n", hr
);
296 todo_wine
ok(async
, "No Handle returned\n");
298 hr
= IDirectPlay8Client_EnumHosts(client
, &appdesc
, host
, local
, NULL
, 0, INFINITE
, 0, INFINITE
, NULL
, &async2
, 0);
299 ok(hr
== DPNSUCCESS_PENDING
, "IDirectPlay8Client_EnumHosts failed with 0x%08lx\n", hr
);
300 todo_wine
ok(async2
, "No Handle returned\n");
301 todo_wine
ok(async2
!= async
, "Same handle returned.\n");
303 WaitForSingleObject(enumevent
, 1000);
305 lastAsyncCode
= E_FAIL
;
306 lastAsyncHandle
= 0xdeadbeef;
307 hr
= IDirectPlay8Client_CancelAsyncOperation(client
, async
, 0);
308 ok(hr
== S_OK
, "IDirectPlay8Client_CancelAsyncOperation failed with 0x%08lx\n", hr
);
309 todo_wine
ok(lastAsyncCode
== DPNERR_USERCANCEL
, "got 0x%08lx\n", lastAsyncCode
);
310 todo_wine
ok(lastAsyncHandle
== async
, "got 0x%08lx\n", async
);
312 hr
= IDirectPlay8Client_Initialize(client2
, NULL
, DirectPlayMessageHandler
, 0);
313 ok(hr
== S_OK
, "got %lx\n", hr
);
315 /* Show that handlers are per object. */
316 hr
= IDirectPlay8Client_CancelAsyncOperation(client2
, async2
, 0);
317 todo_wine
ok(hr
== DPNERR_INVALIDHANDLE
, "IDirectPlay8Client_CancelAsyncOperation failed with 0x%08lx\n", hr
);
319 lastAsyncCode
= E_FAIL
;
320 lastAsyncHandle
= 0xdeadbeef;
321 hr
= IDirectPlay8Client_CancelAsyncOperation(client
, async2
, 0);
322 ok(hr
== S_OK
, "IDirectPlay8Client_CancelAsyncOperation failed with 0x%08lx\n", hr
);
324 todo_wine
ok(lastAsyncCode
== DPNERR_USERCANCEL
, "got 0x%08lx\n", lastAsyncCode
);
325 todo_wine
ok(lastAsyncHandle
== async2
, "got 0x%08lx\n", async2
);
327 IDirectPlay8Address_Release(local
);
328 IDirectPlay8Address_Release(host
);
329 IDirectPlay8Client_Release(client2
);
332 static void test_enum_hosts_sync(void)
335 IDirectPlay8Address
*host
= NULL
;
336 IDirectPlay8Address
*local
= NULL
;
337 DPN_APPLICATION_DESC appdesc
;
338 DWORD port
= 5445, type
= 0, size
;
340 memset( &appdesc
, 0, sizeof(DPN_APPLICATION_DESC
) );
341 appdesc
.dwSize
= sizeof( DPN_APPLICATION_DESC
);
342 appdesc
.guidApplication
= appguid
;
344 hr
= CoCreateInstance( &CLSID_DirectPlay8Address
, NULL
, CLSCTX_ALL
, &IID_IDirectPlay8Address
, (void**)&local
);
345 ok(hr
== S_OK
, "Failed with 0x%08lx\n", hr
);
347 hr
= IDirectPlay8Address_SetSP(local
, &CLSID_DP8SP_TCPIP
);
348 ok(hr
== S_OK
, "Failed with 0x%08lx\n", hr
);
350 hr
= CoCreateInstance( &CLSID_DirectPlay8Address
, NULL
, CLSCTX_ALL
, &IID_IDirectPlay8Address
, (void**)&host
);
351 ok(hr
== S_OK
, "Failed with 0x%08lx\n", hr
);
353 hr
= IDirectPlay8Address_SetSP(host
, &CLSID_DP8SP_TCPIP
);
354 ok(hr
== S_OK
, "Failed with 0x%08lx\n", hr
);
356 hr
= IDirectPlay8Address_AddComponent(host
, DPNA_KEY_HOSTNAME
, localhost
, sizeof(localhost
),
357 DPNA_DATATYPE_STRING
);
358 ok(hr
== S_OK
, "Failed with 0x%08lx\n", hr
);
361 lastAsyncCode
= 0xdeadbeef;
362 hr
= IDirectPlay8Client_EnumHosts(client
, &appdesc
, host
, local
, NULL
, 0, 3, 1500, 1000,
363 NULL
, NULL
, DPNENUMHOSTS_SYNC
);
364 ok(hr
== DPN_OK
, "got 0x%08lx\n", hr
);
365 ok(lastAsyncCode
== 0xdeadbeef, "got 0x%08lx\n", lastAsyncCode
);
366 todo_wine
ok(handlecnt
== 2, "message handler not called\n");
369 hr
= IDirectPlay8Address_GetComponentByName(host
, DPNA_KEY_PORT
, &port
, &size
, &type
);
370 ok(hr
== DPNERR_DOESNOTEXIST
, "got 0x%08lx\n", hr
);
373 hr
= IDirectPlay8Address_GetComponentByName(local
, DPNA_KEY_PORT
, &port
, &size
, &type
);
374 ok(hr
== DPNERR_DOESNOTEXIST
, "got 0x%08lx\n", hr
);
376 /* Try with specific port */
378 hr
= IDirectPlay8Address_AddComponent(host
, DPNA_KEY_PORT
, &port
, sizeof(port
),
379 DPNA_DATATYPE_DWORD
);
382 lastAsyncCode
= 0xbeefdead;
383 ok(hr
== S_OK
, "Failed with 0x%08lx\n", hr
);
384 hr
= IDirectPlay8Client_EnumHosts(client
, &appdesc
, host
, local
, NULL
, 0, 1, 1500, 1000,
385 NULL
, NULL
, DPNENUMHOSTS_SYNC
);
386 ok(hr
== DPN_OK
, "got 0x%08lx\n", hr
);
387 ok(lastAsyncCode
== 0xbeefdead, "got 0x%08lx\n", lastAsyncCode
);
388 ok(handlecnt
== 0, "message handler called\n");
390 IDirectPlay8Address_Release(local
);
391 IDirectPlay8Address_Release(host
);
394 static void test_get_sp_caps(void)
399 memset(&caps
, 0, sizeof(DPN_SP_CAPS
));
401 hr
= IDirectPlay8Client_GetSPCaps(client
, &CLSID_DP8SP_TCPIP
, &caps
, 0);
402 ok(hr
== DPNERR_INVALIDPARAM
, "GetSPCaps unexpectedly returned %lx\n", hr
);
404 caps
.dwSize
= sizeof(DPN_SP_CAPS
);
406 hr
= IDirectPlay8Client_GetSPCaps(client
, &CLSID_DP8SP_TCPIP
, &caps
, 0);
407 ok(hr
== DPN_OK
, "GetSPCaps failed with %lx\n", hr
);
409 ok(caps
.dwSize
== sizeof(DPN_SP_CAPS
), "got %ld\n", caps
.dwSize
);
411 (DPNSPCAPS_SUPPORTSDPNSRV
| DPNSPCAPS_SUPPORTSBROADCAST
| DPNSPCAPS_SUPPORTSALLADAPTERS
)) ==
412 (DPNSPCAPS_SUPPORTSDPNSRV
| DPNSPCAPS_SUPPORTSBROADCAST
| DPNSPCAPS_SUPPORTSALLADAPTERS
),
413 "unexpected flags %lx\n", caps
.dwFlags
);
414 ok(caps
.dwNumThreads
>= 3, "got %ld\n", caps
.dwNumThreads
);
415 ok(caps
.dwDefaultEnumCount
== 5, "expected 5, got %ld\n", caps
.dwDefaultEnumCount
);
416 ok(caps
.dwDefaultEnumRetryInterval
== 1500, "expected 1500, got %ld\n", caps
.dwDefaultEnumRetryInterval
);
417 ok(caps
.dwDefaultEnumTimeout
== 1500, "expected 1500, got %ld\n", caps
.dwDefaultEnumTimeout
);
418 ok(caps
.dwMaxEnumPayloadSize
== 983, "expected 983, got %ld\n", caps
.dwMaxEnumPayloadSize
);
419 ok(caps
.dwBuffersPerThread
== 1, "expected 1, got %ld\n", caps
.dwBuffersPerThread
);
420 ok(caps
.dwSystemBufferSize
== 0x10000 || broken(caps
.dwSystemBufferSize
== 0x2000 /* before Win8 */),
421 "expected 0x10000, got 0x%lx\n", caps
.dwSystemBufferSize
);
423 caps
.dwNumThreads
= 2;
424 caps
.dwDefaultEnumCount
= 3;
425 caps
.dwDefaultEnumRetryInterval
= 1400;
426 caps
.dwDefaultEnumTimeout
= 1400;
427 caps
.dwMaxEnumPayloadSize
= 900;
428 caps
.dwBuffersPerThread
= 2;
429 caps
.dwSystemBufferSize
= 0x0ffff;
430 hr
= IDirectPlay8Client_SetSPCaps(client
, &CLSID_DP8SP_TCPIP
, &caps
, 0);
431 ok(hr
== DPN_OK
, "SetSPCaps failed with %lx\n", hr
);
433 hr
= IDirectPlay8Client_GetSPCaps(client
, &CLSID_DP8SP_TCPIP
, &caps
, 0);
434 ok(hr
== DPN_OK
, "GetSPCaps failed with %lx\n", hr
);
436 ok(caps
.dwSize
== sizeof(DPN_SP_CAPS
), "got %ld\n", caps
.dwSize
);
437 ok(caps
.dwNumThreads
>= 3, "got %ld\n", caps
.dwNumThreads
);
438 ok(caps
.dwDefaultEnumCount
== 5, "expected 5, got %ld\n", caps
.dwDefaultEnumCount
);
439 ok(caps
.dwDefaultEnumRetryInterval
== 1500, "expected 1500, got %ld\n", caps
.dwDefaultEnumRetryInterval
);
440 ok(caps
.dwDefaultEnumTimeout
== 1500, "expected 1500, got %ld\n", caps
.dwDefaultEnumTimeout
);
441 ok(caps
.dwMaxEnumPayloadSize
== 983, "expected 983, got %ld\n", caps
.dwMaxEnumPayloadSize
);
442 ok(caps
.dwBuffersPerThread
== 1, "expected 1, got %ld\n", caps
.dwBuffersPerThread
);
443 ok(caps
.dwSystemBufferSize
== 0x0ffff, "expected 0x0ffff, got 0x%lx\n", caps
.dwSystemBufferSize
);
445 /* Reset the System setting back to its default. */
446 caps
.dwSystemBufferSize
= 0x10000;
447 hr
= IDirectPlay8Client_SetSPCaps(client
, &CLSID_DP8SP_TCPIP
, &caps
, 0);
448 ok(hr
== DPN_OK
, "SetSPCaps failed with %lx\n", hr
);
451 static void test_lobbyclient(void)
454 IDirectPlay8LobbyClient
*client
= NULL
;
456 hr
= CoCreateInstance( &CLSID_DirectPlay8LobbyClient
, NULL
, CLSCTX_ALL
, &IID_IDirectPlay8LobbyClient
, (void**)&client
);
457 ok(hr
== S_OK
, "Failed to create object\n");
460 hr
= IDirectPlay8LobbyClient_Initialize(client
, NULL
, NULL
, 0);
461 ok(hr
== E_POINTER
, "got 0x%08lx\n", hr
);
463 hr
= IDirectPlay8LobbyClient_Initialize(client
, NULL
, DirectPlayLobbyClientMessageHandler
, 0);
464 ok(hr
== S_OK
, "got 0x%08lx\n", hr
);
466 hr
= IDirectPlay8LobbyClient_Close(client
, 0);
467 todo_wine
ok(hr
== S_OK
, "got 0x%08lx\n", hr
);
469 IDirectPlay8LobbyClient_Release(client
);
473 static void test_player_info(void)
476 DPN_PLAYER_INFO info
;
477 WCHAR name
[] = L
"wine";
478 WCHAR name2
[] = L
"wine2";
479 WCHAR data
[] = L
"XXXX";
481 ZeroMemory( &info
, sizeof(DPN_PLAYER_INFO
) );
482 info
.dwSize
= sizeof(DPN_PLAYER_INFO
);
483 info
.dwInfoFlags
= DPNINFO_NAME
;
485 hr
= IDirectPlay8Client_SetClientInfo(client
, NULL
, NULL
, NULL
, DPNSETCLIENTINFO_SYNC
);
486 ok(hr
== E_POINTER
, "got %lx\n", hr
);
488 info
.pwszName
= NULL
;
489 hr
= IDirectPlay8Client_SetClientInfo(client
, &info
, NULL
, NULL
, DPNSETCLIENTINFO_SYNC
);
490 ok(hr
== S_OK
, "got %lx\n", hr
);
492 info
.pwszName
= name
;
493 hr
= IDirectPlay8Client_SetClientInfo(client
, &info
, NULL
, NULL
, DPNSETCLIENTINFO_SYNC
);
494 ok(hr
== S_OK
, "got %lx\n", hr
);
496 info
.dwInfoFlags
= DPNINFO_NAME
;
497 info
.pwszName
= name2
;
498 hr
= IDirectPlay8Client_SetClientInfo(client
, &info
, NULL
, NULL
, DPNSETCLIENTINFO_SYNC
);
499 ok(hr
== S_OK
, "got %lx\n", hr
);
501 info
.dwInfoFlags
= DPNINFO_DATA
;
502 info
.pwszName
= NULL
;
504 info
.dwDataSize
= sizeof(data
);
505 hr
= IDirectPlay8Client_SetClientInfo(client
, &info
, NULL
, NULL
, DPNSETCLIENTINFO_SYNC
);
506 ok(hr
== E_POINTER
, "got %lx\n", hr
);
508 info
.dwInfoFlags
= DPNINFO_DATA
;
509 info
.pwszName
= NULL
;
512 hr
= IDirectPlay8Client_SetClientInfo(client
, &info
, NULL
, NULL
, DPNSETCLIENTINFO_SYNC
);
513 ok(hr
== S_OK
, "got %lx\n", hr
);
515 info
.dwInfoFlags
= DPNINFO_DATA
;
516 info
.pwszName
= NULL
;
518 info
.dwDataSize
= sizeof(data
);
519 hr
= IDirectPlay8Client_SetClientInfo(client
, &info
, NULL
, NULL
, DPNSETCLIENTINFO_SYNC
);
520 ok(hr
== S_OK
, "got %lx\n", hr
);
522 info
.dwInfoFlags
= DPNINFO_DATA
| DPNINFO_NAME
;
523 info
.pwszName
= name
;
525 info
.dwDataSize
= sizeof(data
);
526 hr
= IDirectPlay8Client_SetClientInfo(client
, &info
, NULL
, NULL
, DPNSETCLIENTINFO_SYNC
);
527 ok(hr
== S_OK
, "got %lx\n", hr
);
529 /* Leave ClientInfo with only the name set. */
530 info
.dwInfoFlags
= DPNINFO_DATA
| DPNINFO_NAME
;
531 info
.pwszName
= name
;
534 hr
= IDirectPlay8Client_SetClientInfo(client
, &info
, NULL
, NULL
, DPNSETCLIENTINFO_SYNC
);
535 ok(hr
== S_OK
, "got %lx\n", hr
);
538 static void test_cleanup_dp(void)
542 hr
= IDirectPlay8Client_Close(client
, 0);
543 ok(hr
== S_OK
, "IDirectPlay8Client_Close failed with %lx\n", hr
);
547 hr
= IDirectPlay8LobbiedApplication_Close(lobbied
, 0);
548 ok(hr
== S_OK
, "IDirectPlay8LobbiedApplication_Close failed with %lx\n", hr
);
550 IDirectPlay8LobbiedApplication_Release(lobbied
);
553 IDirectPlay8Client_Release(client
);
556 static void test_close(void)
559 static IDirectPlay8Client
* client2
;
562 hr
= CoCreateInstance(&CLSID_DirectPlay8Client
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectPlay8Client
, (void **)&client2
);
563 ok(hr
== S_OK
, "got 0x%lx\n", hr
);
565 memset(&caps
, 0, sizeof(DPN_SP_CAPS
));
566 caps
.dwSize
= sizeof(DPN_SP_CAPS
);
568 hr
= IDirectPlay8Client_Initialize(client2
, NULL
, DirectPlayMessageHandler
, 0);
569 ok(hr
== S_OK
, "got %lx\n", hr
);
571 hr
= IDirectPlay8Client_GetSPCaps(client2
, &CLSID_DP8SP_TCPIP
, &caps
, 0);
572 ok(hr
== DPN_OK
, "got %lx\n", hr
);
574 hr
= IDirectPlay8Client_Close(client2
, 0);
575 ok(hr
== DPN_OK
, "got %lx\n", hr
);
577 hr
= IDirectPlay8Client_GetSPCaps(client2
, &CLSID_DP8SP_TCPIP
, &caps
, 0);
578 ok(hr
== DPNERR_UNINITIALIZED
, "got %lx\n", hr
);
580 IDirectPlay8Client_Release(client2
);
583 static void test_init_dp_peer(void)
587 DPNHANDLE lobbyConnection
;
589 hr
= CoCreateInstance(&CLSID_DirectPlay8Peer
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectPlay8Peer
, (void **)&peer
);
590 ok(hr
== S_OK
, "CoCreateInstance failed with 0x%lx\n", hr
);
592 memset(&caps
, 0, sizeof(DPN_SP_CAPS
));
593 caps
.dwSize
= sizeof(DPN_SP_CAPS
);
595 hr
= IDirectPlay8Peer_SetSPCaps(peer
, &CLSID_DP8SP_TCPIP
, &caps
, 0);
596 ok(hr
== DPNERR_INVALIDPARAM
, "SetSPCaps failed with %lx\n", hr
);
598 hr
= IDirectPlay8Peer_GetSPCaps(peer
, &CLSID_DP8SP_TCPIP
, &caps
, 0);
599 ok(hr
== DPNERR_UNINITIALIZED
, "GetSPCaps failed with %lx\n", hr
);
601 hr
= IDirectPlay8Peer_Initialize(peer
, NULL
, NULL
, 0);
602 ok(hr
== DPNERR_INVALIDPARAM
, "got %lx\n", hr
);
604 hr
= IDirectPlay8Peer_Initialize(peer
, NULL
, DirectPlayMessageHandler
, 0);
605 ok(hr
== S_OK
, "IDirectPlay8Peer_Initialize failed with %lx\n", hr
);
607 hr
= CoCreateInstance(&CLSID_DirectPlay8LobbiedApplication
, NULL
, CLSCTX_INPROC_SERVER
,
608 &IID_IDirectPlay8LobbiedApplication
, (void **)&lobbied
);
609 ok(hr
== S_OK
, "CoCreateInstance failed with 0x%lx\n", hr
);
611 hr
= IDirectPlay8LobbiedApplication_Initialize(lobbied
, NULL
, NULL
,
612 &lobbyConnection
, 0);
613 ok(hr
== DPNERR_INVALIDPOINTER
, "Failed with %lx\n", hr
);
615 hr
= IDirectPlay8LobbiedApplication_Initialize(lobbied
, NULL
, DirectPlayLobbyMessageHandler
,
616 &lobbyConnection
, 0);
617 ok(hr
== S_OK
, "IDirectPlay8LobbiedApplication_Initialize failed with %lx\n", hr
);
620 static void test_enum_service_providers_peer(void)
622 DPN_SERVICE_PROVIDER_INFO
*serv_prov_info
;
630 hr
= IDirectPlay8Peer_EnumServiceProviders(peer
, NULL
, NULL
, NULL
, &size
, NULL
, 0);
631 ok(hr
== E_POINTER
, "IDirectPlay8Peer_EnumServiceProviders failed with %lx\n", hr
);
633 hr
= IDirectPlay8Peer_EnumServiceProviders(peer
, NULL
, NULL
, NULL
, NULL
, &items
, 0);
634 ok(hr
== E_POINTER
, "IDirectPlay8Peer_EnumServiceProviders failed with %lx\n", hr
);
636 hr
= IDirectPlay8Peer_EnumServiceProviders(peer
, NULL
, NULL
, NULL
, &size
, &items
, 0);
637 ok(hr
== DPNERR_BUFFERTOOSMALL
, "IDirectPlay8Peer_EnumServiceProviders failed with %lx\n", hr
);
638 ok(size
!= 0, "size is unexpectedly 0\n");
640 serv_prov_info
= HeapAlloc(GetProcessHeap(), 0, size
);
642 hr
= IDirectPlay8Peer_EnumServiceProviders(peer
, NULL
, NULL
, serv_prov_info
, &size
, &items
, 0);
643 ok(hr
== S_OK
, "IDirectPlay8Peer_EnumServiceProviders failed with %lx\n", hr
);
644 ok(items
!= 0, "Found unexpectedly no service providers\n");
646 trace("number of items found: %ld\n", items
);
648 for (i
=0;i
<items
;i
++)
650 trace("Found Service Provider: %s\n", wine_dbgstr_w(serv_prov_info
[i
].pwszName
));
651 trace("Found guid: %s\n", wine_dbgstr_guid(&serv_prov_info
[i
].guid
));
654 HeapFree(GetProcessHeap(), 0, serv_prov_info
);
659 hr
= IDirectPlay8Peer_EnumServiceProviders(peer
, &CLSID_DP8SP_TCPIP
, NULL
, NULL
, &size
, &items
, 0);
660 ok(hr
== DPNERR_BUFFERTOOSMALL
, "IDirectPlay8Peer_EnumServiceProviders failed with %lx\n", hr
);
661 ok(size
!= 0, "size is unexpectedly 0\n");
663 serv_prov_info
= HeapAlloc(GetProcessHeap(), 0, size
);
665 hr
= IDirectPlay8Peer_EnumServiceProviders(peer
, &CLSID_DP8SP_TCPIP
, NULL
, serv_prov_info
, &size
, &items
, 0);
666 ok(hr
== S_OK
, "IDirectPlay8Peer_EnumServiceProviders failed with %lx\n", hr
);
667 ok(items
!= 0, "Found unexpectedly no adapter\n");
670 for (i
=0;i
<items
;i
++)
672 trace("Found adapter: %s\n", wine_dbgstr_w(serv_prov_info
[i
].pwszName
));
673 trace("Found adapter guid: %s\n", wine_dbgstr_guid(&serv_prov_info
[i
].guid
));
678 hr
= IDirectPlay8Peer_EnumServiceProviders(peer
, &appguid
, NULL
, serv_prov_info
, &size
, &items
, 0);
679 ok(hr
== DPNERR_DOESNOTEXIST
, "IDirectPlay8Peer_EnumServiceProviders failed with %lx\n", hr
);
680 ok(items
== 88, "Found adapter %ld\n", items
);
682 HeapFree(GetProcessHeap(), 0, serv_prov_info
);
685 static void test_enum_hosts_peer(void)
688 IDirectPlay8Peer
*peer2
;
689 IDirectPlay8Address
*host
= NULL
;
690 IDirectPlay8Address
*local
= NULL
;
691 DPN_APPLICATION_DESC appdesc
;
692 DPNHANDLE async
= 0, async2
= 0;
694 ResetEvent(enumevent
);
697 memset( &appdesc
, 0, sizeof(DPN_APPLICATION_DESC
) );
698 appdesc
.dwSize
= sizeof( DPN_APPLICATION_DESC
);
699 appdesc
.guidApplication
= appguid
;
701 hr
= CoCreateInstance(&CLSID_DirectPlay8Peer
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectPlay8Peer
, (void **)&peer2
);
702 ok(hr
== S_OK
, "CoCreateInstance failed with 0x%lx\n", hr
);
704 hr
= CoCreateInstance( &CLSID_DirectPlay8Address
, NULL
, CLSCTX_ALL
, &IID_IDirectPlay8Address
, (LPVOID
*)&local
);
705 ok(hr
== S_OK
, "IDirectPlay8Address failed with 0x%08lx\n", hr
);
707 hr
= IDirectPlay8Address_SetSP(local
, &CLSID_DP8SP_TCPIP
);
708 ok(hr
== S_OK
, "IDirectPlay8Address_SetSP failed with 0x%08lx\n", hr
);
710 hr
= CoCreateInstance( &CLSID_DirectPlay8Address
, NULL
, CLSCTX_ALL
, &IID_IDirectPlay8Address
, (LPVOID
*)&host
);
711 ok(hr
== S_OK
, "IDirectPlay8Address failed with 0x%08lx\n", hr
);
713 hr
= IDirectPlay8Address_SetSP(host
, &CLSID_DP8SP_TCPIP
);
714 ok(hr
== S_OK
, "IDirectPlay8Address_SetSP failed with 0x%08lx\n", hr
);
716 hr
= IDirectPlay8Address_AddComponent(host
, DPNA_KEY_HOSTNAME
, localhost
, sizeof(localhost
),
717 DPNA_DATATYPE_STRING
);
718 ok(hr
== S_OK
, "IDirectPlay8Address failed with 0x%08lx\n", hr
);
720 hr
= IDirectPlay8Peer_EnumHosts(peer
, &appdesc
, host
, local
, NULL
, 0, INFINITE
, 0, INFINITE
, NULL
, &async
, 0);
721 ok(hr
== DPNSUCCESS_PENDING
, "IDirectPlay8Peer_EnumServiceProviders failed with 0x%08lx\n", hr
);
722 todo_wine
ok(async
, "No Handle returned\n");
724 hr
= IDirectPlay8Peer_CancelAsyncOperation(peer
, async
, 0);
725 todo_wine
ok(hr
== S_OK
, "IDirectPlay8Peer_CancelAsyncOperation failed with 0x%08lx\n", hr
);
727 /* No Initialize has been called on peer2. */
728 hr
= IDirectPlay8Peer_EnumHosts(peer2
, &appdesc
, host
, local
, NULL
, 0, INFINITE
, 0, INFINITE
, NULL
, &async
, 0);
729 ok(hr
== DPNERR_UNINITIALIZED
, "IDirectPlay8Peer_EnumHosts failed with 0x%08lx\n", hr
);
731 /* Since we are running asynchronously, EnumHosts returns DPNSUCCESS_PENDING. */
732 hr
= IDirectPlay8Peer_EnumHosts(peer
, &appdesc
, host
, local
, NULL
, 0, INFINITE
, 0, INFINITE
, NULL
, &async
, 0);
733 ok(hr
== DPNSUCCESS_PENDING
, "IDirectPlay8Peer_EnumHosts failed with 0x%08lx\n", hr
);
734 todo_wine
ok(async
, "No Handle returned\n");
736 hr
= IDirectPlay8Peer_EnumHosts(peer
, &appdesc
, host
, local
, NULL
, 0, INFINITE
, 0, INFINITE
, NULL
, &async2
, 0);
737 ok(hr
== DPNSUCCESS_PENDING
, "IDirectPlay8Peer_EnumHosts failed with 0x%08lx\n", hr
);
738 todo_wine
ok(async2
, "No Handle returned\n");
739 todo_wine
ok(async2
!= async
, "Same handle returned.\n");
741 WaitForSingleObject(enumevent
, 1000);
743 lastAsyncCode
= E_FAIL
;
744 lastAsyncHandle
= 0xdeadbeef;
745 hr
= IDirectPlay8Peer_CancelAsyncOperation(peer
, async
, 0);
746 todo_wine
ok(hr
== S_OK
, "IDirectPlay8Peer_CancelAsyncOperation failed with 0x%08lx\n", hr
);
747 todo_wine
ok(lastAsyncCode
== DPNERR_USERCANCEL
, "got 0x%08lx\n", lastAsyncCode
);
748 todo_wine
ok(lastAsyncHandle
== async
, "got 0x%08lx\n", async
);
750 lastAsyncCode
= E_FAIL
;
751 lastAsyncHandle
= 0xdeadbeef;
752 hr
= IDirectPlay8Peer_CancelAsyncOperation(peer
, async2
, 0);
753 todo_wine
ok(hr
== S_OK
, "IDirectPlay8Peer_CancelAsyncOperation failed with 0x%08lx\n", hr
);
755 todo_wine
ok(lastAsyncCode
== DPNERR_USERCANCEL
, "got 0x%08lx\n", lastAsyncCode
);
757 todo_wine
ok(lastAsyncHandle
== async2
, "got 0x%08lx\n", async2
);
759 IDirectPlay8Peer_Release(peer2
);
760 IDirectPlay8Address_Release(local
);
761 IDirectPlay8Address_Release(host
);
764 static void test_enum_hosts_sync_peer(void)
767 IDirectPlay8Address
*host
= NULL
;
768 IDirectPlay8Address
*local
= NULL
;
769 DPN_APPLICATION_DESC appdesc
;
770 DWORD port
= 5445, type
= 0, size
;
772 memset( &appdesc
, 0, sizeof(DPN_APPLICATION_DESC
) );
773 appdesc
.dwSize
= sizeof( DPN_APPLICATION_DESC
);
774 appdesc
.guidApplication
= appguid
;
776 hr
= CoCreateInstance( &CLSID_DirectPlay8Address
, NULL
, CLSCTX_ALL
, &IID_IDirectPlay8Address
, (void**)&local
);
777 ok(hr
== S_OK
, "Failed with 0x%08lx\n", hr
);
779 hr
= IDirectPlay8Address_SetSP(local
, &CLSID_DP8SP_TCPIP
);
780 ok(hr
== S_OK
, "Failed with 0x%08lx\n", hr
);
782 hr
= CoCreateInstance( &CLSID_DirectPlay8Address
, NULL
, CLSCTX_ALL
, &IID_IDirectPlay8Address
, (void**)&host
);
783 ok(hr
== S_OK
, "Failed with 0x%08lx\n", hr
);
785 hr
= IDirectPlay8Address_SetSP(host
, &CLSID_DP8SP_TCPIP
);
786 ok(hr
== S_OK
, "Failed with 0x%08lx\n", hr
);
788 hr
= IDirectPlay8Address_AddComponent(host
, DPNA_KEY_HOSTNAME
, localhost
, sizeof(localhost
),
789 DPNA_DATATYPE_STRING
);
790 ok(hr
== S_OK
, "Failed with 0x%08lx\n", hr
);
793 lastAsyncCode
= 0xdeadbeef;
794 hr
= IDirectPlay8Peer_EnumHosts(peer
, &appdesc
, host
, local
, NULL
, 0, 3, 1500, 1000,
795 NULL
, NULL
, DPNENUMHOSTS_SYNC
);
796 ok(hr
== DPN_OK
, "got 0x%08lx\n", hr
);
797 ok(lastAsyncCode
== 0xdeadbeef, "got 0x%08lx\n", lastAsyncCode
);
798 todo_wine
ok(handlecnt
== 2, "wrong handle cnt\n");
801 hr
= IDirectPlay8Address_GetComponentByName(host
, DPNA_KEY_PORT
, &port
, &size
, &type
);
802 ok(hr
== DPNERR_DOESNOTEXIST
, "got 0x%08lx\n", hr
);
805 hr
= IDirectPlay8Address_GetComponentByName(local
, DPNA_KEY_PORT
, &port
, &size
, &type
);
806 ok(hr
== DPNERR_DOESNOTEXIST
, "got 0x%08lx\n", hr
);
808 /* Try with specific port */
810 hr
= IDirectPlay8Address_AddComponent(host
, DPNA_KEY_PORT
, &port
, sizeof(port
),
811 DPNA_DATATYPE_DWORD
);
814 lastAsyncCode
= 0xbeefdead;
815 ok(hr
== S_OK
, "Failed with 0x%08lx\n", hr
);
816 hr
= IDirectPlay8Peer_EnumHosts(peer
, &appdesc
, host
, local
, NULL
, 0, 1, 1500, 1000,
817 NULL
, NULL
, DPNENUMHOSTS_SYNC
);
818 ok(hr
== DPN_OK
, "got 0x%08lx\n", hr
);
819 ok(lastAsyncCode
== 0xbeefdead, "got 0x%08lx\n", lastAsyncCode
);
820 ok(handlecnt
== 0, "message handler called\n");
822 IDirectPlay8Address_Release(local
);
823 IDirectPlay8Address_Release(host
);
826 static void test_get_sp_caps_peer(void)
831 memset(&caps
, 0, sizeof(DPN_SP_CAPS
));
833 hr
= IDirectPlay8Peer_GetSPCaps(peer
, &CLSID_DP8SP_TCPIP
, &caps
, 0);
834 ok(hr
== DPNERR_INVALIDPARAM
, "GetSPCaps unexpectedly returned %lx\n", hr
);
836 caps
.dwSize
= sizeof(DPN_SP_CAPS
);
838 hr
= IDirectPlay8Peer_GetSPCaps(peer
, &CLSID_DP8SP_TCPIP
, &caps
, 0);
839 ok(hr
== DPN_OK
, "GetSPCaps failed with %lx\n", hr
);
841 ok(caps
.dwSize
== sizeof(DPN_SP_CAPS
), "got %ld\n", caps
.dwSize
);
843 (DPNSPCAPS_SUPPORTSDPNSRV
| DPNSPCAPS_SUPPORTSBROADCAST
| DPNSPCAPS_SUPPORTSALLADAPTERS
)) ==
844 (DPNSPCAPS_SUPPORTSDPNSRV
| DPNSPCAPS_SUPPORTSBROADCAST
| DPNSPCAPS_SUPPORTSALLADAPTERS
),
845 "unexpected flags %lx\n", caps
.dwFlags
);
846 ok(caps
.dwNumThreads
>= 3, "got %ld\n", caps
.dwNumThreads
);
847 ok(caps
.dwDefaultEnumCount
== 5, "expected 5, got %ld\n", caps
.dwDefaultEnumCount
);
848 ok(caps
.dwDefaultEnumRetryInterval
== 1500, "expected 1500, got %ld\n", caps
.dwDefaultEnumRetryInterval
);
849 ok(caps
.dwDefaultEnumTimeout
== 1500, "expected 1500, got %ld\n", caps
.dwDefaultEnumTimeout
);
850 ok(caps
.dwMaxEnumPayloadSize
== 983, "expected 983, got %ld\n", caps
.dwMaxEnumPayloadSize
);
851 ok(caps
.dwBuffersPerThread
== 1, "expected 1, got %ld\n", caps
.dwBuffersPerThread
);
852 ok(caps
.dwSystemBufferSize
== 0x10000 || broken(caps
.dwSystemBufferSize
== 0x2000 /* before Win8 */),
853 "expected 0x10000, got 0x%lx\n", caps
.dwSystemBufferSize
);
855 caps
.dwNumThreads
= 2;
856 caps
.dwDefaultEnumCount
= 3;
857 caps
.dwDefaultEnumRetryInterval
= 1400;
858 caps
.dwDefaultEnumTimeout
= 1400;
859 caps
.dwMaxEnumPayloadSize
= 900;
860 caps
.dwBuffersPerThread
= 2;
861 caps
.dwSystemBufferSize
= 0x0ffff;
862 hr
= IDirectPlay8Peer_SetSPCaps(peer
, &CLSID_DP8SP_TCPIP
, &caps
, 0);
863 ok(hr
== DPN_OK
, "SetSPCaps failed with %lx\n", hr
);
865 hr
= IDirectPlay8Peer_GetSPCaps(peer
, &CLSID_DP8SP_TCPIP
, &caps
, 0);
866 ok(hr
== DPN_OK
, "GetSPCaps failed with %lx\n", hr
);
868 ok(caps
.dwSize
== sizeof(DPN_SP_CAPS
), "got %ld\n", caps
.dwSize
);
869 ok(caps
.dwNumThreads
>= 3, "got %ld\n", caps
.dwNumThreads
);
870 ok(caps
.dwDefaultEnumCount
== 5, "expected 5, got %ld\n", caps
.dwDefaultEnumCount
);
871 ok(caps
.dwDefaultEnumRetryInterval
== 1500, "expected 1500, got %ld\n", caps
.dwDefaultEnumRetryInterval
);
872 ok(caps
.dwDefaultEnumTimeout
== 1500, "expected 1500, got %ld\n", caps
.dwDefaultEnumTimeout
);
873 ok(caps
.dwMaxEnumPayloadSize
== 983, "expected 983, got %ld\n", caps
.dwMaxEnumPayloadSize
);
874 ok(caps
.dwBuffersPerThread
== 1, "expected 1, got %ld\n", caps
.dwBuffersPerThread
);
875 ok(caps
.dwSystemBufferSize
== 0x0ffff, "expected 0x0ffff, got 0x%lx\n", caps
.dwSystemBufferSize
);
878 static void test_player_info_peer(void)
881 DPN_PLAYER_INFO info
;
882 WCHAR name
[] = L
"wine";
883 WCHAR name2
[] = L
"wine2";
884 WCHAR data
[] = L
"XXXX";
886 ZeroMemory( &info
, sizeof(DPN_PLAYER_INFO
) );
887 info
.dwSize
= sizeof(DPN_PLAYER_INFO
);
888 info
.dwInfoFlags
= DPNINFO_NAME
;
890 hr
= IDirectPlay8Peer_SetPeerInfo(peer
, NULL
, NULL
, NULL
, DPNSETPEERINFO_SYNC
);
891 ok(hr
== E_POINTER
, "got %lx\n", hr
);
893 info
.pwszName
= NULL
;
894 hr
= IDirectPlay8Peer_SetPeerInfo(peer
, &info
, NULL
, NULL
, DPNSETPEERINFO_SYNC
);
895 ok(hr
== S_OK
, "got %lx\n", hr
);
897 info
.pwszName
= name
;
898 hr
= IDirectPlay8Peer_SetPeerInfo(peer
, &info
, NULL
, NULL
, DPNSETPEERINFO_SYNC
);
899 ok(hr
== S_OK
, "got %lx\n", hr
);
901 info
.dwInfoFlags
= DPNINFO_NAME
;
902 info
.pwszName
= name2
;
903 hr
= IDirectPlay8Peer_SetPeerInfo(peer
, &info
, NULL
, NULL
, DPNSETPEERINFO_SYNC
);
904 ok(hr
== S_OK
, "got %lx\n", hr
);
906 if(0) /* Crashes on windows */
908 info
.dwInfoFlags
= DPNINFO_DATA
;
909 info
.pwszName
= NULL
;
911 info
.dwDataSize
= sizeof(data
);
912 hr
= IDirectPlay8Peer_SetPeerInfo(peer
, &info
, NULL
, NULL
, DPNSETPEERINFO_SYNC
);
913 ok(hr
== S_OK
, "got %lx\n", hr
);
916 info
.dwInfoFlags
= DPNINFO_DATA
;
917 info
.pwszName
= NULL
;
920 hr
= IDirectPlay8Peer_SetPeerInfo(peer
, &info
, NULL
, NULL
, DPNSETPEERINFO_SYNC
);
921 ok(hr
== S_OK
, "got %lx\n", hr
);
923 info
.dwInfoFlags
= DPNINFO_DATA
;
924 info
.pwszName
= NULL
;
926 info
.dwDataSize
= sizeof(data
);
927 hr
= IDirectPlay8Peer_SetPeerInfo(peer
, &info
, NULL
, NULL
, DPNSETPEERINFO_SYNC
);
928 ok(hr
== S_OK
, "got %lx\n", hr
);
930 info
.dwInfoFlags
= DPNINFO_DATA
| DPNINFO_NAME
;
931 info
.pwszName
= name
;
933 info
.dwDataSize
= sizeof(data
);
934 hr
= IDirectPlay8Peer_SetPeerInfo(peer
, &info
, NULL
, NULL
, DPNSETPEERINFO_SYNC
);
935 ok(hr
== S_OK
, "got %lx\n", hr
);
937 /* Leave PeerInfo with only the name set. */
938 info
.dwInfoFlags
= DPNINFO_DATA
| DPNINFO_NAME
;
939 info
.pwszName
= name
;
942 hr
= IDirectPlay8Peer_SetPeerInfo(peer
, &info
, NULL
, NULL
, DPNSETPEERINFO_SYNC
);
943 ok(hr
== S_OK
, "got %lx\n", hr
);
946 static void test_cleanup_dp_peer(void)
950 hr
= IDirectPlay8Peer_Close(peer
, 0);
951 ok(hr
== S_OK
, "IDirectPlay8Peer_Close failed with %lx\n", hr
);
955 hr
= IDirectPlay8LobbiedApplication_Close(lobbied
, 0);
956 ok(hr
== S_OK
, "IDirectPlay8LobbiedApplication_Close failed with %lx\n", hr
);
958 IDirectPlay8LobbiedApplication_Release(lobbied
);
961 IDirectPlay8Peer_Release(peer
);
966 BOOL firewall_enabled
;
970 if(!GetSystemDirectoryA(path
, MAX_PATH
))
972 skip("Failed to get systems directory\n");
975 strcat(path
, "\\dpnet.dll");
977 if (!winetest_interactive
&& is_stub_dll(path
))
979 win_skip("dpnet is a stub dll, skipping tests\n");
983 if ((firewall_enabled
= is_firewall_enabled()) && !is_process_elevated())
985 skip("no privileges, skipping tests to avoid firewall dialog\n");
989 if (firewall_enabled
)
991 hr
= set_firewall(APP_ADD
);
994 skip("can't authorize app in firewall %08lx\n", hr
);
999 hr
= CoInitialize(0);
1000 ok(hr
== S_OK
, "CoInitialize failed with %lx\n", hr
);
1002 if (!test_init_dp())
1007 test_enum_service_providers();
1009 test_enum_hosts_sync();
1016 test_init_dp_peer();
1017 test_enum_service_providers_peer();
1018 test_enum_hosts_peer();
1019 test_enum_hosts_sync_peer();
1020 test_get_sp_caps_peer();
1021 test_player_info_peer();
1022 test_cleanup_dp_peer();
1024 hr
= IDirectPlay8Server_Close(server
, 0);
1025 todo_wine
ok(hr
== S_OK
, "got 0x%08lx\n", hr
);
1026 IDirectPlay8Server_Release(server
);
1028 CloseHandle(enumevent
);
1031 if (firewall_enabled
) set_firewall(APP_REMOVE
);