1 /* DirectPlay Conformance Tests
3 * Copyright 2007 - Alessandro Pignotti
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
21 #include "wine/test.h"
28 static HRESULT (WINAPI
*pDirectPlayEnumerateA
)( LPDPENUMDPCALLBACKA
, void* );
29 static HRESULT (WINAPI
*pDirectPlayEnumerateW
)( LPDPENUMDPCALLBACKW
, void* );
30 static HRESULT (WINAPI
*pDirectPlayCreate
)( GUID
*GUID
, LPDIRECTPLAY
*lplpDP
, IUnknown
*pUnk
);
32 #define check(expected, result) \
33 ok( (expected) == (result), \
34 "expected=%d got=%d\n", \
35 (int)(expected), (int)(result) );
36 #define checkLP(expected, result) \
37 ok( (expected) == (result), \
38 "expected=%p got=%p\n", \
40 #define checkHR(expected, result) \
41 ok( (expected) == (result), \
42 "expected=%s got=%s\n", \
43 dpResult2str(expected), dpResult2str(result) );
44 #define checkStr(expected, result) \
45 ok( (result != NULL) && (!strcmp(expected, result)), \
46 "expected=%s got=%s\n", \
48 static LPCSTR
dwFlags2str(DWORD dwFlags
, DWORD flagType
);
49 #define checkFlags(expected, result, flags) checkFlags_(__LINE__, expected, result, flags)
50 static void checkFlags_(unsigned line
, DWORD expected
, DWORD result
, DWORD flags
)
52 ok_(__FILE__
, line
)( expected
== result
,
53 "expected=0x%08lx(%s) got=0x%08lx(%s)\n",
54 expected
, dwFlags2str(expected
, flags
),
55 result
, dwFlags2str(result
, flags
) );
57 #define checkGuid(expected, result) \
58 ok( IsEqualGUID(expected, result), \
59 "expected=%s got=%s\n", \
60 Guid2str(expected), Guid2str(result) );
61 #define checkConv(expected, result, function) \
62 ok( (expected) == (result), \
63 "expected=0x%08x(%s) got=0x%08lx(%s)\n", \
64 expected, function(expected), \
65 result, function(result) );
68 DEFINE_GUID(appGuid
, 0xbdcfe03e, 0xf0ec, 0x415b, 0x82, 0x11, 0x6f, 0x86, 0xd8, 0x19, 0x7f, 0xe1);
69 DEFINE_GUID(appGuid2
, 0x93417d3f, 0x7d26, 0x46ba, 0xb5, 0x76, 0xfe, 0x4b, 0x20, 0xbb, 0xad, 0x70);
70 DEFINE_GUID(GUID_NULL
,0,0,0,0,0,0,0,0,0,0,0);
71 DEFINE_GUID(invalid_guid
, 0x7b48b707, 0x0034, 0xc000, 0x02, 0x00, 0x00, 0x00, 0xec, 0xf6, 0x32, 0x00);
74 typedef struct tagCallbackData
77 UINT dwCounter1
, dwCounter2
;
79 char szTrace1
[1024], szTrace2
[1024];
82 } CallbackData
, *lpCallbackData
;
92 static LPSTR
get_temp_buffer(void)
94 static UINT index
= 0;
95 static char buff
[10][256];
97 index
= (index
+ 1) % 10;
104 static LPCSTR
Guid2str(const GUID
*guid
)
106 if (!guid
) return "(null)";
108 /* Service providers */
109 if (IsEqualGUID(guid
, &DPSPGUID_IPX
))
110 return "DPSPGUID_IPX";
111 if (IsEqualGUID(guid
, &DPSPGUID_TCPIP
))
112 return "DPSPGUID_TCPIP";
113 if (IsEqualGUID(guid
, &DPSPGUID_SERIAL
))
114 return "DPSPGUID_SERIAL";
115 if (IsEqualGUID(guid
, &DPSPGUID_MODEM
))
116 return "DPSPGUID_MODEM";
117 /* DirectPlay Address IDs */
118 if (IsEqualGUID(guid
, &DPAID_TotalSize
))
119 return "DPAID_TotalSize";
120 if (IsEqualGUID(guid
, &DPAID_ServiceProvider
))
121 return "DPAID_ServiceProvider";
122 if (IsEqualGUID(guid
, &DPAID_LobbyProvider
))
123 return "DPAID_LobbyProvider";
124 if (IsEqualGUID(guid
, &DPAID_Phone
))
125 return "DPAID_Phone";
126 if (IsEqualGUID(guid
, &DPAID_PhoneW
))
127 return "DPAID_PhoneW";
128 if (IsEqualGUID(guid
, &DPAID_Modem
))
129 return "DPAID_Modem";
130 if (IsEqualGUID(guid
, &DPAID_ModemW
))
131 return "DPAID_ModemW";
132 if (IsEqualGUID(guid
, &DPAID_INet
))
134 if (IsEqualGUID(guid
, &DPAID_INetW
))
135 return "DPAID_INetW";
136 if (IsEqualGUID(guid
, &DPAID_INetPort
))
137 return "DPAID_INetPort";
138 if (IsEqualGUID(guid
, &DPAID_ComPort
))
139 return "DPAID_ComPort";
141 return wine_dbgstr_guid(guid
);
145 static LPCSTR
dpResult2str(HRESULT hr
)
149 case DP_OK
: return "DP_OK";
150 case DPERR_ALREADYINITIALIZED
: return "DPERR_ALREADYINITIALIZED";
151 case DPERR_ACCESSDENIED
: return "DPERR_ACCESSDENIED";
152 case DPERR_ACTIVEPLAYERS
: return "DPERR_ACTIVEPLAYERS";
153 case DPERR_BUFFERTOOSMALL
: return "DPERR_BUFFERTOOSMALL";
154 case DPERR_CANTADDPLAYER
: return "DPERR_CANTADDPLAYER";
155 case DPERR_CANTCREATEGROUP
: return "DPERR_CANTCREATEGROUP";
156 case DPERR_CANTCREATEPLAYER
: return "DPERR_CANTCREATEPLAYER";
157 case DPERR_CANTCREATESESSION
: return "DPERR_CANTCREATESESSION";
158 case DPERR_CAPSNOTAVAILABLEYET
: return "DPERR_CAPSNOTAVAILABLEYET";
159 case DPERR_EXCEPTION
: return "DPERR_EXCEPTION";
160 case DPERR_GENERIC
: return "DPERR_GENERIC";
161 case DPERR_INVALIDFLAGS
: return "DPERR_INVALIDFLAGS";
162 case DPERR_INVALIDOBJECT
: return "DPERR_INVALIDOBJECT";
163 case DPERR_INVALIDPARAMS
: return "DPERR_INVALIDPARAMS";
164 /* symbol with the same value: DPERR_INVALIDPARAM */
165 case DPERR_INVALIDPLAYER
: return "DPERR_INVALIDPLAYER";
166 case DPERR_INVALIDGROUP
: return "DPERR_INVALIDGROUP";
167 case DPERR_NOCAPS
: return "DPERR_NOCAPS";
168 case DPERR_NOCONNECTION
: return "DPERR_NOCONNECTION";
169 case DPERR_NOMEMORY
: return "DPERR_NOMEMORY";
170 /* symbol with the same value: DPERR_OUTOFMEMORY */
171 case DPERR_NOMESSAGES
: return "DPERR_NOMESSAGES";
172 case DPERR_NONAMESERVERFOUND
: return "DPERR_NONAMESERVERFOUND";
173 case DPERR_NOPLAYERS
: return "DPERR_NOPLAYERS";
174 case DPERR_NOSESSIONS
: return "DPERR_NOSESSIONS";
175 case DPERR_PENDING
: return "DPERR_PENDING";
176 case DPERR_SENDTOOBIG
: return "DPERR_SENDTOOBIG";
177 case DPERR_TIMEOUT
: return "DPERR_TIMEOUT";
178 case DPERR_UNAVAILABLE
: return "DPERR_UNAVAILABLE";
179 case DPERR_UNSUPPORTED
: return "DPERR_UNSUPPORTED";
180 case DPERR_BUSY
: return "DPERR_BUSY";
181 case DPERR_USERCANCEL
: return "DPERR_USERCANCEL";
182 case DPERR_NOINTERFACE
: return "DPERR_NOINTERFACE";
183 case DPERR_CANNOTCREATESERVER
: return "DPERR_CANNOTCREATESERVER";
184 case DPERR_PLAYERLOST
: return "DPERR_PLAYERLOST";
185 case DPERR_SESSIONLOST
: return "DPERR_SESSIONLOST";
186 case DPERR_UNINITIALIZED
: return "DPERR_UNINITIALIZED";
187 case DPERR_NONEWPLAYERS
: return "DPERR_NONEWPLAYERS";
188 case DPERR_INVALIDPASSWORD
: return "DPERR_INVALIDPASSWORD";
189 case DPERR_CONNECTING
: return "DPERR_CONNECTING";
190 case DPERR_CONNECTIONLOST
: return "DPERR_CONNECTIONLOST";
191 case DPERR_UNKNOWNMESSAGE
: return "DPERR_UNKNOWNMESSAGE";
192 case DPERR_CANCELFAILED
: return "DPERR_CANCELFAILED";
193 case DPERR_INVALIDPRIORITY
: return "DPERR_INVALIDPRIORITY";
194 case DPERR_NOTHANDLED
: return "DPERR_NOTHANDLED";
195 case DPERR_CANCELLED
: return "DPERR_CANCELLED";
196 case DPERR_ABORTED
: return "DPERR_ABORTED";
197 case DPERR_BUFFERTOOLARGE
: return "DPERR_BUFFERTOOLARGE";
198 case DPERR_CANTCREATEPROCESS
: return "DPERR_CANTCREATEPROCESS";
199 case DPERR_APPNOTSTARTED
: return "DPERR_APPNOTSTARTED";
200 case DPERR_INVALIDINTERFACE
: return "DPERR_INVALIDINTERFACE";
201 case DPERR_NOSERVICEPROVIDER
: return "DPERR_NOSERVICEPROVIDER";
202 case DPERR_UNKNOWNAPPLICATION
: return "DPERR_UNKNOWNAPPLICATION";
203 case DPERR_NOTLOBBIED
: return "DPERR_NOTLOBBIED";
204 case DPERR_SERVICEPROVIDERLOADED
: return "DPERR_SERVICEPROVIDERLOADED";
205 case DPERR_ALREADYREGISTERED
: return "DPERR_ALREADYREGISTERED";
206 case DPERR_NOTREGISTERED
: return "DPERR_NOTREGISTERED";
207 case DPERR_AUTHENTICATIONFAILED
: return "DPERR_AUTHENTICATIONFAILED";
208 case DPERR_CANTLOADSSPI
: return "DPERR_CANTLOADSSPI";
209 case DPERR_ENCRYPTIONFAILED
: return "DPERR_ENCRYPTIONFAILED";
210 case DPERR_SIGNFAILED
: return "DPERR_SIGNFAILED";
211 case DPERR_CANTLOADSECURITYPACKAGE
: return "DPERR_CANTLOADSECURITYPACKAGE";
212 case DPERR_ENCRYPTIONNOTSUPPORTED
: return "DPERR_ENCRYPTIONNOTSUPPORTED";
213 case DPERR_CANTLOADCAPI
: return "DPERR_CANTLOADCAPI";
214 case DPERR_NOTLOGGEDIN
: return "DPERR_NOTLOGGEDIN";
215 case DPERR_LOGONDENIED
: return "DPERR_LOGONDENIED";
216 case CLASS_E_NOAGGREGATION
: return "CLASS_E_NOAGGREGATION";
220 LPSTR buffer
= get_temp_buffer();
221 sprintf( buffer
, "%ld", HRESULT_CODE(hr
) );
227 static LPCSTR
dpMsgType2str(DWORD dwType
)
231 case DPSYS_CREATEPLAYERORGROUP
: return "DPSYS_CREATEPLAYERORGROUP";
232 case DPSYS_DESTROYPLAYERORGROUP
: return "DPSYS_DESTROYPLAYERORGROUP";
233 case DPSYS_ADDPLAYERTOGROUP
: return "DPSYS_ADDPLAYERTOGROUP";
234 case DPSYS_DELETEPLAYERFROMGROUP
: return "DPSYS_DELETEPLAYERFROMGROUP";
235 case DPSYS_SESSIONLOST
: return "DPSYS_SESSIONLOST";
236 case DPSYS_HOST
: return "DPSYS_HOST";
237 case DPSYS_SETPLAYERORGROUPDATA
: return "DPSYS_SETPLAYERORGROUPDATA";
238 case DPSYS_SETPLAYERORGROUPNAME
: return "DPSYS_SETPLAYERORGROUPNAME";
239 case DPSYS_SETSESSIONDESC
: return "DPSYS_SETSESSIONDESC";
240 case DPSYS_ADDGROUPTOGROUP
: return "DPSYS_ADDGROUPTOGROUP";
241 case DPSYS_DELETEGROUPFROMGROUP
: return "DPSYS_DELETEGROUPFROMGROUP";
242 case DPSYS_SECUREMESSAGE
: return "DPSYS_SECUREMESSAGE";
243 case DPSYS_STARTSESSION
: return "DPSYS_STARTSESSION";
244 case DPSYS_CHAT
: return "DPSYS_DPSYS_CHAT";
245 case DPSYS_SETGROUPOWNER
: return "DPSYS_SETGROUPOWNER";
246 case DPSYS_SENDCOMPLETE
: return "DPSYS_SENDCOMPLETE";
248 default: return "UNKNOWN";
252 static LPCSTR
dwFlags2str(DWORD dwFlags
, DWORD flagType
)
255 #define FLAGS_DPCONNECTION (1<<0)
256 #define FLAGS_DPENUMPLAYERS (1<<1)
257 #define FLAGS_DPENUMGROUPS (1<<2)
258 #define FLAGS_DPPLAYER (1<<3)
259 #define FLAGS_DPGROUP (1<<4)
260 #define FLAGS_DPENUMSESSIONS (1<<5)
261 #define FLAGS_DPGETCAPS (1<<6)
262 #define FLAGS_DPGET (1<<7)
263 #define FLAGS_DPRECEIVE (1<<8)
264 #define FLAGS_DPSEND (1<<9)
265 #define FLAGS_DPSET (1<<10)
266 #define FLAGS_DPMESSAGEQUEUE (1<<11)
267 #define FLAGS_DPCONNECT (1<<12)
268 #define FLAGS_DPOPEN (1<<13)
269 #define FLAGS_DPSESSION (1<<14)
270 #define FLAGS_DPLCONNECTION (1<<15)
271 #define FLAGS_DPESC (1<<16)
272 #define FLAGS_DPCAPS (1<<17)
274 LPSTR flags
= get_temp_buffer();
276 /* EnumConnections */
278 if (flagType
& FLAGS_DPCONNECTION
)
280 if (dwFlags
& DPCONNECTION_DIRECTPLAY
)
281 strcat(flags
, "DPCONNECTION_DIRECTPLAY,");
282 if (dwFlags
& DPCONNECTION_DIRECTPLAYLOBBY
)
283 strcat(flags
, "DPCONNECTION_DIRECTPLAYLOBBY,");
289 if (flagType
& FLAGS_DPENUMPLAYERS
)
291 if (dwFlags
== DPENUMPLAYERS_ALL
)
292 strcat(flags
, "DPENUMPLAYERS_ALL,");
293 if (dwFlags
& DPENUMPLAYERS_LOCAL
)
294 strcat(flags
, "DPENUMPLAYERS_LOCAL,");
295 if (dwFlags
& DPENUMPLAYERS_REMOTE
)
296 strcat(flags
, "DPENUMPLAYERS_REMOTE,");
297 if (dwFlags
& DPENUMPLAYERS_GROUP
)
298 strcat(flags
, "DPENUMPLAYERS_GROUP,");
299 if (dwFlags
& DPENUMPLAYERS_SESSION
)
300 strcat(flags
, "DPENUMPLAYERS_SESSION,");
301 if (dwFlags
& DPENUMPLAYERS_SERVERPLAYER
)
302 strcat(flags
, "DPENUMPLAYERS_SERVERPLAYER,");
303 if (dwFlags
& DPENUMPLAYERS_SPECTATOR
)
304 strcat(flags
, "DPENUMPLAYERS_SPECTATOR,");
305 if (dwFlags
& DPENUMPLAYERS_OWNER
)
306 strcat(flags
, "DPENUMPLAYERS_OWNER,");
308 if (flagType
& FLAGS_DPENUMGROUPS
)
310 if (dwFlags
== DPENUMGROUPS_ALL
)
311 strcat(flags
, "DPENUMGROUPS_ALL,");
312 if (dwFlags
& DPENUMPLAYERS_LOCAL
)
313 strcat(flags
, "DPENUMGROUPS_LOCAL,");
314 if (dwFlags
& DPENUMPLAYERS_REMOTE
)
315 strcat(flags
, "DPENUMGROUPS_REMOTE,");
316 if (dwFlags
& DPENUMPLAYERS_GROUP
)
317 strcat(flags
, "DPENUMGROUPS_GROUP,");
318 if (dwFlags
& DPENUMPLAYERS_SESSION
)
319 strcat(flags
, "DPENUMGROUPS_SESSION,");
320 if (dwFlags
& DPENUMGROUPS_SHORTCUT
)
321 strcat(flags
, "DPENUMGROUPS_SHORTCUT,");
322 if (dwFlags
& DPENUMGROUPS_STAGINGAREA
)
323 strcat(flags
, "DPENUMGROUPS_STAGINGAREA,");
324 if (dwFlags
& DPENUMGROUPS_HIDDEN
)
325 strcat(flags
, "DPENUMGROUPS_HIDDEN,");
330 if (flagType
& FLAGS_DPPLAYER
)
332 if (dwFlags
& DPPLAYER_SERVERPLAYER
)
333 strcat(flags
, "DPPLAYER_SERVERPLAYER,");
334 if (dwFlags
& DPPLAYER_SPECTATOR
)
335 strcat(flags
, "DPPLAYER_SPECTATOR,");
336 if (dwFlags
& DPPLAYER_LOCAL
)
337 strcat(flags
, "DPPLAYER_LOCAL,");
338 if (dwFlags
& DPPLAYER_OWNER
)
339 strcat(flags
, "DPPLAYER_OWNER,");
344 if (flagType
& FLAGS_DPGROUP
)
346 if (dwFlags
& DPGROUP_STAGINGAREA
)
347 strcat(flags
, "DPGROUP_STAGINGAREA,");
348 if (dwFlags
& DPGROUP_LOCAL
)
349 strcat(flags
, "DPGROUP_LOCAL,");
350 if (dwFlags
& DPGROUP_HIDDEN
)
351 strcat(flags
, "DPGROUP_HIDDEN,");
356 if (flagType
& FLAGS_DPENUMSESSIONS
)
358 if (dwFlags
& DPENUMSESSIONS_AVAILABLE
)
359 strcat(flags
, "DPENUMSESSIONS_AVAILABLE,");
360 if (dwFlags
& DPENUMSESSIONS_ALL
)
361 strcat(flags
, "DPENUMSESSIONS_ALL,");
362 if (dwFlags
& DPENUMSESSIONS_ASYNC
)
363 strcat(flags
, "DPENUMSESSIONS_ASYNC,");
364 if (dwFlags
& DPENUMSESSIONS_STOPASYNC
)
365 strcat(flags
, "DPENUMSESSIONS_STOPASYNC,");
366 if (dwFlags
& DPENUMSESSIONS_PASSWORDREQUIRED
)
367 strcat(flags
, "DPENUMSESSIONS_PASSWORDREQUIRED,");
368 if (dwFlags
& DPENUMSESSIONS_RETURNSTATUS
)
369 strcat(flags
, "DPENUMSESSIONS_RETURNSTATUS,");
375 if (flagType
& FLAGS_DPGETCAPS
)
377 if (dwFlags
& DPGETCAPS_GUARANTEED
)
378 strcat(flags
, "DPGETCAPS_GUARANTEED,");
384 if (flagType
& FLAGS_DPGET
)
386 if (dwFlags
== DPGET_REMOTE
)
387 strcat(flags
, "DPGET_REMOTE,");
388 if (dwFlags
& DPGET_LOCAL
)
389 strcat(flags
, "DPGET_LOCAL,");
394 if (flagType
& FLAGS_DPRECEIVE
)
396 if (dwFlags
& DPRECEIVE_ALL
)
397 strcat(flags
, "DPRECEIVE_ALL,");
398 if (dwFlags
& DPRECEIVE_TOPLAYER
)
399 strcat(flags
, "DPRECEIVE_TOPLAYER,");
400 if (dwFlags
& DPRECEIVE_FROMPLAYER
)
401 strcat(flags
, "DPRECEIVE_FROMPLAYER,");
402 if (dwFlags
& DPRECEIVE_PEEK
)
403 strcat(flags
, "DPRECEIVE_PEEK,");
408 if (flagType
& FLAGS_DPSEND
)
410 /*if (dwFlags == DPSEND_NONGUARANTEED)
411 strcat(flags, "DPSEND_NONGUARANTEED,");*/
412 if (dwFlags
== DPSEND_MAX_PRIORITY
) /* = DPSEND_MAX_PRI */
414 strcat(flags
, "DPSEND_MAX_PRIORITY,");
418 if (dwFlags
& DPSEND_GUARANTEED
)
419 strcat(flags
, "DPSEND_GUARANTEED,");
420 if (dwFlags
& DPSEND_HIGHPRIORITY
)
421 strcat(flags
, "DPSEND_HIGHPRIORITY,");
422 if (dwFlags
& DPSEND_OPENSTREAM
)
423 strcat(flags
, "DPSEND_OPENSTREAM,");
424 if (dwFlags
& DPSEND_CLOSESTREAM
)
425 strcat(flags
, "DPSEND_CLOSESTREAM,");
426 if (dwFlags
& DPSEND_SIGNED
)
427 strcat(flags
, "DPSEND_SIGNED,");
428 if (dwFlags
& DPSEND_ENCRYPTED
)
429 strcat(flags
, "DPSEND_ENCRYPTED,");
430 if (dwFlags
& DPSEND_LOBBYSYSTEMMESSAGE
)
431 strcat(flags
, "DPSEND_LOBBYSYSTEMMESSAGE,");
432 if (dwFlags
& DPSEND_ASYNC
)
433 strcat(flags
, "DPSEND_ASYNC,");
434 if (dwFlags
& DPSEND_NOSENDCOMPLETEMSG
)
435 strcat(flags
, "DPSEND_NOSENDCOMPLETEMSG,");
445 if (flagType
& FLAGS_DPSET
)
447 if (dwFlags
== DPSET_REMOTE
)
448 strcat(flags
, "DPSET_REMOTE,");
449 if (dwFlags
& DPSET_LOCAL
)
450 strcat(flags
, "DPSET_LOCAL,");
451 if (dwFlags
& DPSET_GUARANTEED
)
452 strcat(flags
, "DPSET_GUARANTEED,");
455 /* GetMessageQueue */
457 if (flagType
& FLAGS_DPMESSAGEQUEUE
)
459 if (dwFlags
& DPMESSAGEQUEUE_SEND
)
460 strcat(flags
, "DPMESSAGEQUEUE_SEND,");
461 if (dwFlags
& DPMESSAGEQUEUE_RECEIVE
)
462 strcat(flags
, "DPMESSAGEQUEUE_RECEIVE,");
467 if (flagType
& FLAGS_DPCONNECT
)
469 if (dwFlags
& DPCONNECT_RETURNSTATUS
)
470 strcat(flags
, "DPCONNECT_RETURNSTATUS,");
475 if (flagType
& FLAGS_DPOPEN
)
477 if (dwFlags
& DPOPEN_JOIN
)
478 strcat(flags
, "DPOPEN_JOIN,");
479 if (dwFlags
& DPOPEN_CREATE
)
480 strcat(flags
, "DPOPEN_CREATE,");
481 if (dwFlags
& DPOPEN_RETURNSTATUS
)
482 strcat(flags
, "DPOPEN_RETURNSTATUS,");
487 if (flagType
& FLAGS_DPSESSION
)
489 if (dwFlags
& DPSESSION_NEWPLAYERSDISABLED
)
490 strcat(flags
, "DPSESSION_NEWPLAYERSDISABLED,");
491 if (dwFlags
& DPSESSION_MIGRATEHOST
)
492 strcat(flags
, "DPSESSION_MIGRATEHOST,");
493 if (dwFlags
& DPSESSION_NOMESSAGEID
)
494 strcat(flags
, "DPSESSION_NOMESSAGEID,");
495 if (dwFlags
& DPSESSION_JOINDISABLED
)
496 strcat(flags
, "DPSESSION_JOINDISABLED,");
497 if (dwFlags
& DPSESSION_KEEPALIVE
)
498 strcat(flags
, "DPSESSION_KEEPALIVE,");
499 if (dwFlags
& DPSESSION_NODATAMESSAGES
)
500 strcat(flags
, "DPSESSION_NODATAMESSAGES,");
501 if (dwFlags
& DPSESSION_SECURESERVER
)
502 strcat(flags
, "DPSESSION_SECURESERVER,");
503 if (dwFlags
& DPSESSION_PRIVATE
)
504 strcat(flags
, "DPSESSION_PRIVATE,");
505 if (dwFlags
& DPSESSION_PASSWORDREQUIRED
)
506 strcat(flags
, "DPSESSION_PASSWORDREQUIRED,");
507 if (dwFlags
& DPSESSION_MULTICASTSERVER
)
508 strcat(flags
, "DPSESSION_MULTICASTSERVER,");
509 if (dwFlags
& DPSESSION_CLIENTSERVER
)
510 strcat(flags
, "DPSESSION_CLIENTSERVER,");
512 if (dwFlags
& DPSESSION_DIRECTPLAYPROTOCOL
)
513 strcat(flags
, "DPSESSION_DIRECTPLAYPROTOCOL,");
514 if (dwFlags
& DPSESSION_NOPRESERVEORDER
)
515 strcat(flags
, "DPSESSION_NOPRESERVEORDER,");
516 if (dwFlags
& DPSESSION_OPTIMIZELATENCY
)
517 strcat(flags
, "DPSESSION_OPTIMIZELATENCY,");
523 if (flagType
& FLAGS_DPLCONNECTION
)
525 if (dwFlags
& DPLCONNECTION_CREATESESSION
)
526 strcat(flags
, "DPLCONNECTION_CREATESESSION,");
527 if (dwFlags
& DPLCONNECTION_JOINSESSION
)
528 strcat(flags
, "DPLCONNECTION_JOINSESSION,");
531 /* EnumSessionsCallback2 */
533 if (flagType
& FLAGS_DPESC
)
535 if (dwFlags
& DPESC_TIMEDOUT
)
536 strcat(flags
, "DPESC_TIMEDOUT,");
542 if (flagType
& FLAGS_DPCAPS
)
544 if (dwFlags
& DPCAPS_ISHOST
)
545 strcat(flags
, "DPCAPS_ISHOST,");
546 if (dwFlags
& DPCAPS_GROUPOPTIMIZED
)
547 strcat(flags
, "DPCAPS_GROUPOPTIMIZED,");
548 if (dwFlags
& DPCAPS_KEEPALIVEOPTIMIZED
)
549 strcat(flags
, "DPCAPS_KEEPALIVEOPTIMIZED,");
550 if (dwFlags
& DPCAPS_GUARANTEEDOPTIMIZED
)
551 strcat(flags
, "DPCAPS_GUARANTEEDOPTIMIZED,");
552 if (dwFlags
& DPCAPS_GUARANTEEDSUPPORTED
)
553 strcat(flags
, "DPCAPS_GUARANTEEDSUPPORTED,");
554 if (dwFlags
& DPCAPS_SIGNINGSUPPORTED
)
555 strcat(flags
, "DPCAPS_SIGNINGSUPPORTED,");
556 if (dwFlags
& DPCAPS_ENCRYPTIONSUPPORTED
)
557 strcat(flags
, "DPCAPS_ENCRYPTIONSUPPORTED,");
558 if (dwFlags
& DPCAPS_ASYNCCANCELSUPPORTED
)
559 strcat(flags
, "DPCAPS_ASYNCCANCELSUPPORTED,");
560 if (dwFlags
& DPCAPS_ASYNCCANCELALLSUPPORTED
)
561 strcat(flags
, "DPCAPS_ASYNCCANCELALLSUPPORTED,");
562 if (dwFlags
& DPCAPS_SENDTIMEOUTSUPPORTED
)
563 strcat(flags
, "DPCAPS_SENDTIMEOUTSUPPORTED,");
564 if (dwFlags
& DPCAPS_SENDPRIORITYSUPPORTED
)
565 strcat(flags
, "DPCAPS_SENDPRIORITYSUPPORTED,");
566 if (dwFlags
& DPCAPS_ASYNCSUPPORTED
)
567 strcat(flags
, "DPCAPS_ASYNCSUPPORTED,");
569 if (dwFlags
& DPPLAYERCAPS_LOCAL
)
570 strcat(flags
, "DPPLAYERCAPS_LOCAL,");
573 if ((strlen(flags
) == 0) && (dwFlags
!= 0))
574 strcpy(flags
, "UNKNOWN");
576 flags
[strlen(flags
)-1] = '\0';
581 static char dpid2char(DPID
* dpid
, DWORD dpidSize
, DPID idPlayer
)
584 if ( idPlayer
== DPID_SYSMSG
)
586 for (i
=0; i
<dpidSize
; i
++)
588 if ( idPlayer
== dpid
[i
] )
594 static void check_messages( IDirectPlay4
*pDP
, DPID
*dpid
, DWORD dpidSize
,
595 lpCallbackData callbackData
)
597 /* Retrieves all messages from the queue of pDP, performing tests
598 * to check if we are receiving what we expect.
600 * Information about the messages is stores in callbackData:
602 * callbackData->dwCounter1: Number of messages received.
603 * callbackData->szTrace1: Traces for sender and receiver.
604 * We store the position a dpid holds in the dpid array.
607 * trace string: "01,02,03,14"
608 * expanded: [ '01', '02', '03', '14' ]
610 * \ \ \ ) message 3: from 1 to 4
611 * \ \ ) message 2: from 0 to 3
612 * \ ) message 1: from 0 to 2
613 * ) message 0: from 0 to 1
616 * sender of message i = character in place 3*i of the array
617 * receiver of message i = character in place 3*i+1 of the array
619 * A sender value of 'S' means DPID_SYSMSG, this is, a system message.
621 * callbackData->szTrace2: Traces for message sizes.
626 DWORD dwDataSize
= 1024;
627 LPVOID lpData
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, dwDataSize
);
631 callbackData
->szTrace2
[0] = '\0';
634 while ( DP_OK
== (hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0,
635 lpData
, &dwDataSize
)) )
638 callbackData
->szTrace1
[ 3*i
] = dpid2char( dpid
, dpidSize
, idFrom
);
639 callbackData
->szTrace1
[ 3*i
+1 ] = dpid2char( dpid
, dpidSize
, idTo
);
640 callbackData
->szTrace1
[ 3*i
+2 ] = ',';
642 sprintf( temp
, "%ld,", dwDataSize
);
643 strcat( callbackData
->szTrace2
, temp
);
649 checkHR( DPERR_NOMESSAGES
, hr
);
651 callbackData
->szTrace1
[ 3*i
] = '\0';
652 callbackData
->dwCounter1
= i
;
655 HeapFree( GetProcessHeap(), 0, lpData
);
658 static void init_TCPIP_provider( IDirectPlay4
*pDP
, LPCSTR strIPAddressString
, WORD port
)
661 DPCOMPOUNDADDRESSELEMENT addressElements
[3];
662 LPVOID pAddress
= NULL
;
663 DWORD dwAddressSize
= 0;
664 IDirectPlayLobby3
*pDPL
;
667 hr
= CoCreateInstance( &CLSID_DirectPlayLobby
, NULL
, CLSCTX_ALL
,
668 &IID_IDirectPlayLobby3A
, (LPVOID
*) &pDPL
);
669 ok (SUCCEEDED (hr
), "CCI of CLSID_DirectPlayLobby / IID_IDirectPlayLobby3A failed\n");
670 if (FAILED (hr
)) return;
672 /* Service provider */
673 addressElements
[0].guidDataType
= DPAID_ServiceProvider
;
674 addressElements
[0].dwDataSize
= sizeof(GUID
);
675 addressElements
[0].lpData
= (LPVOID
) &DPSPGUID_TCPIP
;
677 /* IP address string */
678 addressElements
[1].guidDataType
= DPAID_INet
;
679 addressElements
[1].dwDataSize
= lstrlenA(strIPAddressString
) + 1;
680 addressElements
[1].lpData
= (LPVOID
) strIPAddressString
;
682 /* Optional Port number */
685 addressElements
[2].guidDataType
= DPAID_INetPort
;
686 addressElements
[2].dwDataSize
= sizeof(WORD
);
687 addressElements
[2].lpData
= &port
;
691 hr
= IDirectPlayLobby_CreateCompoundAddress( pDPL
, addressElements
, 2,
692 NULL
, &dwAddressSize
);
693 checkHR( DPERR_BUFFERTOOSMALL
, hr
);
695 if( hr
== DPERR_BUFFERTOOSMALL
)
697 pAddress
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, dwAddressSize
);
698 hr
= IDirectPlayLobby_CreateCompoundAddress( pDPL
, addressElements
, 2,
699 pAddress
, &dwAddressSize
);
700 checkHR( DP_OK
, hr
);
703 hr
= IDirectPlayX_InitializeConnection( pDP
, pAddress
, 0 );
704 checkHR( DP_OK
, hr
);
706 HeapFree( GetProcessHeap(), 0, pAddress
);
707 IDirectPlayLobby_Release(pDPL
);
710 static BOOL CALLBACK
EnumSessions_cb_join( LPCDPSESSIONDESC2 lpThisSD
,
715 IDirectPlay4
*pDP
= lpContext
;
719 if (dwFlags
& DPESC_TIMEDOUT
)
724 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
725 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
726 dpsd
.guidApplication
= appGuid
;
727 dpsd
.guidInstance
= lpThisSD
->guidInstance
;
729 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_JOIN
);
730 checkHR( DP_OK
, hr
);
736 /* DirectPlayCreate */
738 static void test_DirectPlayCreate(void)
744 /* TODO: Check how it behaves with pUnk!=NULL */
747 hr
= pDirectPlayCreate( NULL
, NULL
, NULL
);
748 checkHR( DPERR_INVALIDPARAMS
, hr
);
749 hr
= pDirectPlayCreate( (LPGUID
) &GUID_NULL
, NULL
, NULL
);
750 checkHR( DPERR_INVALIDPARAMS
, hr
);
751 hr
= pDirectPlayCreate( (LPGUID
) &DPSPGUID_TCPIP
, NULL
, NULL
);
752 checkHR( DPERR_INVALIDPARAMS
, hr
);
754 /* pUnk==NULL, pDP!=NULL */
755 hr
= pDirectPlayCreate( NULL
, &pDP
, NULL
);
756 checkHR( DPERR_INVALIDPARAMS
, hr
);
757 hr
= pDirectPlayCreate( (LPGUID
) &GUID_NULL
, &pDP
, NULL
);
758 checkHR( DP_OK
, hr
);
760 IDirectPlayX_Release( pDP
);
761 hr
= pDirectPlayCreate( (LPGUID
) &DPSPGUID_TCPIP
, &pDP
, NULL
);
762 checkHR( DP_OK
, hr
);
764 IDirectPlayX_Release( pDP
);
768 static BOOL CALLBACK
callback_providersA(GUID
* guid
, char *name
, DWORD major
, DWORD minor
, void *arg
)
770 struct provider_data
*prov
= arg
;
772 if (!prov
) return TRUE
;
774 if (prov
->call_count
< ARRAY_SIZE(prov
->guid_data
))
776 prov
->guid_ptr
[prov
->call_count
] = guid
;
777 prov
->guid_data
[prov
->call_count
] = *guid
;
782 if (prov
->ret_value
) /* Only trace when looping all providers */
783 trace("Provider #%d '%s' (%ld.%ld)\n", prov
->call_count
, name
, major
, minor
);
784 return prov
->ret_value
;
787 static BOOL CALLBACK
callback_providersW(GUID
* guid
, WCHAR
*name
, DWORD major
, DWORD minor
, void *arg
)
789 struct provider_data
*prov
= arg
;
791 if (!prov
) return TRUE
;
793 if (prov
->call_count
< ARRAY_SIZE(prov
->guid_data
))
795 prov
->guid_ptr
[prov
->call_count
] = guid
;
796 prov
->guid_data
[prov
->call_count
] = *guid
;
801 return prov
->ret_value
;
804 static void test_EnumerateProviders(void)
808 struct provider_data arg
;
810 memset(&arg
, 0, sizeof(arg
));
811 arg
.ret_value
= TRUE
;
813 hr
= pDirectPlayEnumerateA(callback_providersA
, NULL
);
814 ok(SUCCEEDED(hr
), "DirectPlayEnumerateA failed\n");
816 SetLastError(0xdeadbeef);
817 hr
= pDirectPlayEnumerateA(NULL
, &arg
);
818 ok(FAILED(hr
), "DirectPlayEnumerateA expected to fail\n");
819 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got 0x%lx\n", GetLastError());
821 SetLastError(0xdeadbeef);
822 hr
= pDirectPlayEnumerateA(NULL
, NULL
);
823 ok(FAILED(hr
), "DirectPlayEnumerateA expected to fail\n");
824 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got 0x%lx\n", GetLastError());
826 hr
= pDirectPlayEnumerateA(callback_providersA
, &arg
);
827 ok(SUCCEEDED(hr
), "DirectPlayEnumerateA failed\n");
828 ok(arg
.call_count
> 0, "Expected at least one valid provider\n");
829 trace("Found %d providers\n", arg
.call_count
);
831 /* The returned GUID values must have persisted after enumeration (bug 37185) */
832 for(i
= 0; i
< arg
.call_count
; i
++)
834 ok(IsEqualGUID(arg
.guid_ptr
[i
], &arg
.guid_data
[i
]), "#%d Expected equal GUID values\n", i
);
837 memset(&arg
, 0, sizeof(arg
));
838 arg
.ret_value
= FALSE
;
839 hr
= pDirectPlayEnumerateA(callback_providersA
, &arg
);
840 ok(SUCCEEDED(hr
), "DirectPlayEnumerateA failed\n");
841 ok(arg
.call_count
== 1, "Expected 1, got %d\n", arg
.call_count
);
843 hr
= pDirectPlayEnumerateW(callback_providersW
, NULL
);
844 ok(SUCCEEDED(hr
), "DirectPlayEnumerateW failed\n");
846 SetLastError(0xdeadbeef);
847 hr
= pDirectPlayEnumerateW(NULL
, &arg
);
848 ok(FAILED(hr
), "DirectPlayEnumerateW expected to fail\n");
849 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got 0x%lx\n", GetLastError());
851 SetLastError(0xdeadbeef);
852 hr
= pDirectPlayEnumerateW(NULL
, NULL
);
853 ok(FAILED(hr
), "DirectPlayEnumerateW expected to fail\n");
854 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got 0x%lx\n", GetLastError());
856 memset(&arg
, 0, sizeof(arg
));
857 arg
.ret_value
= TRUE
;
858 hr
= pDirectPlayEnumerateW(callback_providersW
, &arg
);
859 ok(SUCCEEDED(hr
), "DirectPlayEnumerateW failed\n");
860 ok(arg
.call_count
> 0, "Expected at least one valid provider\n");
862 /* The returned GUID values must have persisted after enumeration (bug 37185) */
863 for(i
= 0; i
< arg
.call_count
; i
++)
865 ok(IsEqualGUID(arg
.guid_ptr
[i
], &arg
.guid_data
[i
]), "#%d Expected equal GUID values\n", i
);
868 memset(&arg
, 0, sizeof(arg
));
869 arg
.ret_value
= FALSE
;
870 hr
= pDirectPlayEnumerateW(callback_providersW
, &arg
);
871 ok(SUCCEEDED(hr
), "DirectPlayEnumerateW failed\n");
872 ok(arg
.call_count
== 1, "Expected 1, got %d\n", arg
.call_count
);
875 /* EnumConnections */
877 static BOOL CALLBACK
EnumAddress_cb2( REFGUID guidDataType
,
882 lpCallbackData callbackData
= lpContext
;
884 static REFGUID types
[] = { &DPAID_TotalSize
,
885 &DPAID_ServiceProvider
,
887 static DWORD sizes
[] = { 4, 16, 0 };
888 static REFGUID sps
[] = { &DPSPGUID_SERIAL
, &DPSPGUID_MODEM
,
889 &DPSPGUID_IPX
, &DPSPGUID_TCPIP
};
892 checkGuid( types
[ callbackData
->dwCounter2
], guidDataType
);
893 check( sizes
[ callbackData
->dwCounter2
], dwDataSize
);
895 if ( IsEqualGUID( types
[0], guidDataType
) )
897 todo_wine
check( 80, *((LPDWORD
) lpData
) );
899 else if ( IsEqualGUID( types
[1], guidDataType
) )
903 for( i
=0; i
< ARRAY_SIZE(sps
) && !found
; i
++ )
904 found
= IsEqualGUID( sps
[i
], lpData
);
905 ok( found
, "Unknown Address type found %s\n", wine_dbgstr_guid(lpData
) );
908 callbackData
->dwCounter2
++;
913 static BOOL CALLBACK
EnumConnections_cb( LPCGUID lpguidSP
,
915 DWORD dwConnectionSize
,
921 lpCallbackData callbackData
= lpContext
;
922 IDirectPlayLobby
*pDPL
;
926 if (!callbackData
->dwFlags
)
928 callbackData
->dwFlags
= DPCONNECTION_DIRECTPLAY
;
931 checkFlags( callbackData
->dwFlags
, dwFlags
, FLAGS_DPCONNECTION
);
933 /* Get info from lpConnection */
934 hr
= CoCreateInstance( &CLSID_DirectPlayLobby
, NULL
, CLSCTX_ALL
,
935 &IID_IDirectPlayLobby3A
, (LPVOID
*) &pDPL
);
936 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlayLobby / IID_IDirectPlayLobby3A failed\n");
940 callbackData
->dwCounter2
= 0;
941 IDirectPlayLobby_EnumAddress( pDPL
, EnumAddress_cb2
, lpConnection
,
942 dwConnectionSize
, callbackData
);
943 todo_wine
check( 3, callbackData
->dwCounter2
);
945 callbackData
->dwCounter1
++;
947 IDirectPlayLobby_Release(pDPL
);
952 static void test_EnumConnections(void)
956 CallbackData callbackData
;
960 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
961 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
);
963 ok (SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n");
964 if (FAILED(hr
)) return;
966 callbackData
.dwCounter1
= 0;
967 callbackData
.dwFlags
= 0;
968 hr
= IDirectPlayX_EnumConnections( pDP
, &appGuid
, EnumConnections_cb
,
969 &callbackData
, callbackData
.dwFlags
);
970 checkHR( DP_OK
, hr
);
971 ok( callbackData
.dwCounter1
== 4 || callbackData
.dwCounter1
== 3, "got=%d\n", callbackData
.dwCounter1
);
973 callbackData
.dwCounter1
= 0;
974 callbackData
.dwFlags
= 0;
975 hr
= IDirectPlayX_EnumConnections( pDP
, NULL
, EnumConnections_cb
,
976 &callbackData
, callbackData
.dwFlags
);
977 checkHR( DP_OK
, hr
);
978 ok( callbackData
.dwCounter1
== 4 || callbackData
.dwCounter1
== 3, "got=%d\n", callbackData
.dwCounter1
);
980 callbackData
.dwCounter1
= 0;
981 callbackData
.dwFlags
= 0;
982 hr
= IDirectPlayX_EnumConnections( pDP
, &appGuid
, NULL
,
983 &callbackData
, callbackData
.dwFlags
);
984 checkHR( DPERR_INVALIDPARAMS
, hr
);
985 check( 0, callbackData
.dwCounter1
);
989 callbackData
.dwCounter1
= 0;
990 callbackData
.dwFlags
= DPCONNECTION_DIRECTPLAY
;
991 hr
= IDirectPlayX_EnumConnections( pDP
, &appGuid
, EnumConnections_cb
,
992 &callbackData
, callbackData
.dwFlags
);
993 checkHR( DP_OK
, hr
);
994 ok( callbackData
.dwCounter1
== 4 || callbackData
.dwCounter1
== 3, "got=%d\n", callbackData
.dwCounter1
);
996 callbackData
.dwCounter1
= 0;
997 callbackData
.dwFlags
= DPCONNECTION_DIRECTPLAYLOBBY
;
998 hr
= IDirectPlayX_EnumConnections( pDP
, &appGuid
, EnumConnections_cb
,
999 &callbackData
, callbackData
.dwFlags
);
1000 checkHR( DP_OK
, hr
);
1001 check( 0, callbackData
.dwCounter1
);
1003 callbackData
.dwCounter1
= 0;
1004 callbackData
.dwFlags
= ( DPCONNECTION_DIRECTPLAY
|
1005 DPCONNECTION_DIRECTPLAYLOBBY
);
1006 hr
= IDirectPlayX_EnumConnections( pDP
, &appGuid
, EnumConnections_cb
,
1007 &callbackData
, callbackData
.dwFlags
);
1008 checkHR( DP_OK
, hr
);
1009 ok( callbackData
.dwCounter1
== 4 || callbackData
.dwCounter1
== 3, "got=%d\n", callbackData
.dwCounter1
);
1011 callbackData
.dwCounter1
= 0;
1012 callbackData
.dwFlags
= ~( DPCONNECTION_DIRECTPLAY
|
1013 DPCONNECTION_DIRECTPLAYLOBBY
);
1014 hr
= IDirectPlayX_EnumConnections( pDP
, &appGuid
, EnumConnections_cb
,
1015 &callbackData
, callbackData
.dwFlags
);
1016 checkHR( DPERR_INVALIDFLAGS
, hr
);
1017 check( 0, callbackData
.dwCounter1
);
1020 IDirectPlayX_Release( pDP
);
1023 /* InitializeConnection */
1025 static BOOL CALLBACK
EnumConnections_cb2( LPCGUID lpguidSP
,
1026 LPVOID lpConnection
,
1027 DWORD dwConnectionSize
,
1032 IDirectPlay4
*pDP
= lpContext
;
1035 /* Incorrect parameters */
1036 hr
= IDirectPlayX_InitializeConnection( pDP
, NULL
, 1 );
1037 checkHR( DPERR_INVALIDPARAMS
, hr
);
1038 hr
= IDirectPlayX_InitializeConnection( pDP
, lpConnection
, 1 );
1039 checkHR( DPERR_INVALIDFLAGS
, hr
);
1041 /* Normal operation.
1042 We're only interested in ensuring that the TCP/IP provider works */
1044 if( IsEqualGUID(lpguidSP
, &DPSPGUID_TCPIP
) )
1046 hr
= IDirectPlayX_InitializeConnection( pDP
, lpConnection
, 0 );
1047 checkHR( DP_OK
, hr
);
1048 hr
= IDirectPlayX_InitializeConnection( pDP
, lpConnection
, 0 );
1049 checkHR( DPERR_ALREADYINITIALIZED
, hr
);
1055 static void test_InitializeConnection(void)
1061 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
1062 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
);
1064 ok (SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n");
1065 if (FAILED(hr
)) return;
1067 IDirectPlayX_EnumConnections( pDP
, &appGuid
, EnumConnections_cb2
, pDP
, 0 );
1069 IDirectPlayX_Release( pDP
);
1074 static void test_GetCaps(void)
1083 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
1084 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
);
1085 ok (SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n");
1086 if (FAILED(hr
)) return;
1088 ZeroMemory( &dpcaps
, sizeof(DPCAPS
) );
1090 /* Service provider not ininitialized */
1091 hr
= IDirectPlayX_GetCaps( pDP
, &dpcaps
, 0 );
1092 checkHR( DPERR_UNINITIALIZED
, hr
);
1094 init_TCPIP_provider( pDP
, "127.0.0.1", 0 );
1096 /* dpcaps not ininitialized */
1097 hr
= IDirectPlayX_GetCaps( pDP
, &dpcaps
, 0 );
1098 checkHR( DPERR_INVALIDPARAMS
, hr
);
1100 dpcaps
.dwSize
= sizeof(DPCAPS
);
1103 dwFlags
<=DPGETCAPS_GUARANTEED
;
1104 dwFlags
+=DPGETCAPS_GUARANTEED
)
1107 hr
= IDirectPlayX_GetCaps( pDP
, &dpcaps
, dwFlags
);
1108 checkHR( DP_OK
, hr
);
1109 check( sizeof(DPCAPS
), dpcaps
.dwSize
);
1110 check( DPCAPS_ASYNCSUPPORTED
|
1111 DPCAPS_GUARANTEEDOPTIMIZED
|
1112 DPCAPS_GUARANTEEDSUPPORTED
,
1114 check( 0, dpcaps
.dwMaxQueueSize
);
1115 check( 0, dpcaps
.dwHundredBaud
);
1116 check( 500, dpcaps
.dwLatency
);
1117 check( 65536, dpcaps
.dwMaxLocalPlayers
);
1118 check( 20, dpcaps
.dwHeaderLength
);
1119 check( 5000, dpcaps
.dwTimeout
);
1124 check( 65479, dpcaps
.dwMaxBufferSize
);
1125 check( 65536, dpcaps
.dwMaxPlayers
);
1127 case DPGETCAPS_GUARANTEED
:
1128 check( 1048547, dpcaps
.dwMaxBufferSize
);
1129 check( 64, dpcaps
.dwMaxPlayers
);
1135 IDirectPlayX_Release( pDP
);
1138 static void test_EnumAddressTypes(void)
1142 DPCOMPOUNDADDRESSELEMENT addressElements
[2];
1143 LPVOID pAddress
= NULL
;
1144 DWORD dwAddressSize
= 0;
1145 IDirectPlayLobby3
*pDPL
;
1148 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
1149 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
);
1150 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
1154 hr
= CoCreateInstance( &CLSID_DirectPlayLobby
, NULL
, CLSCTX_ALL
,
1155 &IID_IDirectPlayLobby3A
, (LPVOID
*) &pDPL
);
1156 ok (SUCCEEDED (hr
), "CCI of CLSID_DirectPlayLobby / IID_IDirectPlayLobby3A failed\n");
1157 if (FAILED (hr
)) return;
1159 addressElements
[0].guidDataType
= DPAID_ServiceProvider
;
1160 addressElements
[0].dwDataSize
= sizeof(GUID
);
1161 addressElements
[0].lpData
= (void*) &DPSPGUID_TCPIP
;
1163 addressElements
[1].guidDataType
= invalid_guid
;
1164 addressElements
[1].dwDataSize
= sizeof(WORD
);
1165 addressElements
[1].lpData
= &port
;
1167 hr
= IDirectPlayLobby_CreateCompoundAddress( pDPL
, addressElements
, 2, NULL
, &dwAddressSize
);
1168 checkHR( DPERR_BUFFERTOOSMALL
, hr
);
1170 if( hr
== DPERR_BUFFERTOOSMALL
)
1172 pAddress
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, dwAddressSize
);
1173 hr
= IDirectPlayLobby_CreateCompoundAddress( pDPL
, addressElements
, 2,
1174 pAddress
, &dwAddressSize
);
1175 checkHR( DP_OK
, hr
);
1178 IDirectPlayX_Close(pDP
);
1179 IDirectPlayX_Release(pDP
);
1180 IDirectPlayLobby_Release(pDPL
);
1182 HeapFree( GetProcessHeap(), 0, pAddress
);
1187 static BOOL CALLBACK
EnumSessions_cb2( LPCDPSESSIONDESC2 lpThisSD
,
1188 LPDWORD lpdwTimeOut
,
1192 IDirectPlay4
*pDP
= lpContext
;
1193 DPSESSIONDESC2 dpsd
;
1196 if (dwFlags
& DPESC_TIMEDOUT
)
1200 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
1201 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
1202 dpsd
.guidApplication
= appGuid
;
1203 dpsd
.guidInstance
= lpThisSD
->guidInstance
;
1205 if ( lpThisSD
->dwFlags
& DPSESSION_PASSWORDREQUIRED
)
1207 /* Incorrect password */
1208 dpsd
.lpszPasswordA
= (LPSTR
) "sonic boom";
1209 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_JOIN
);
1210 checkHR( DPERR_INVALIDPASSWORD
, hr
);
1212 /* Correct password */
1213 dpsd
.lpszPasswordA
= (LPSTR
) "hadouken";
1214 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_JOIN
);
1215 checkHR( DP_OK
, hr
);
1219 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_JOIN
);
1220 checkHR( DP_OK
, hr
);
1223 hr
= IDirectPlayX_Close( pDP
);
1224 checkHR( DP_OK
, hr
);
1229 static void test_Open(void)
1232 IDirectPlay4
*pDP
, *pDP_server
;
1233 DPSESSIONDESC2 dpsd
, dpsd_server
;
1237 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
1238 &IID_IDirectPlay4A
, (LPVOID
*) &pDP_server
);
1239 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
1240 if (FAILED(hr
)) return;
1242 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
1243 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
);
1244 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
1245 if (FAILED(hr
)) return;
1247 ZeroMemory( &dpsd_server
, sizeof(DPSESSIONDESC2
) );
1248 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
1250 /* Service provider not initialized */
1251 hr
= IDirectPlayX_Open( pDP_server
, &dpsd_server
, DPOPEN_CREATE
);
1252 todo_wine
checkHR( DPERR_INVALIDPARAMS
, hr
);
1254 init_TCPIP_provider( pDP_server
, "127.0.0.1", 0 );
1255 init_TCPIP_provider( pDP
, "127.0.0.1", 0 );
1257 /* Uninitialized dpsd */
1258 hr
= IDirectPlayX_Open( pDP_server
, &dpsd_server
, DPOPEN_CREATE
);
1259 checkHR( DPERR_INVALIDPARAMS
, hr
);
1262 dpsd_server
.dwSize
= sizeof(DPSESSIONDESC2
);
1263 dpsd_server
.guidApplication
= appGuid
;
1264 dpsd_server
.dwMaxPlayers
= 10;
1267 /* Regular operation */
1268 hr
= IDirectPlayX_Open( pDP_server
, &dpsd_server
, DPOPEN_CREATE
);
1269 todo_wine
checkHR( DP_OK
, hr
);
1272 hr
= IDirectPlayX_Open( pDP_server
, &dpsd_server
, DPOPEN_CREATE
);
1273 todo_wine
checkHR( DPERR_ALREADYINITIALIZED
, hr
);
1276 IDirectPlayX_Close( pDP_server
);
1278 dpsd_server
.dwFlags
= DPSESSION_CLIENTSERVER
| DPSESSION_MIGRATEHOST
;
1279 hr
= IDirectPlayX_Open( pDP_server
, &dpsd_server
, DPOPEN_CREATE
);
1280 todo_wine
checkHR( DPERR_INVALIDFLAGS
, hr
);
1282 dpsd_server
.dwFlags
= DPSESSION_MULTICASTSERVER
| DPSESSION_MIGRATEHOST
;
1283 hr
= IDirectPlayX_Open( pDP_server
, &dpsd_server
, DPOPEN_CREATE
);
1284 todo_wine
checkHR( DPERR_INVALIDFLAGS
, hr
);
1286 dpsd_server
.dwFlags
= DPSESSION_SECURESERVER
| DPSESSION_MIGRATEHOST
;
1287 hr
= IDirectPlayX_Open( pDP_server
, &dpsd_server
, DPOPEN_CREATE
);
1288 todo_wine
checkHR( DPERR_INVALIDFLAGS
, hr
);
1291 /* Joining sessions */
1292 /* - Checking how strict dplay is with sizes */
1294 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_JOIN
);
1295 checkHR( DPERR_INVALIDPARAMS
, hr
);
1297 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
)-1;
1298 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_JOIN
);
1299 checkHR( DPERR_INVALIDPARAMS
, hr
);
1301 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
)+1;
1302 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_JOIN
);
1303 checkHR( DPERR_INVALIDPARAMS
, hr
);
1305 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
1306 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_JOIN
);
1307 todo_wine
checkHR( DPERR_NOSESSIONS
, hr
); /* Only checks for size, not guids */
1310 dpsd
.guidApplication
= appGuid
;
1311 dpsd
.guidInstance
= appGuid
;
1314 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_JOIN
);
1315 todo_wine
checkHR( DPERR_NOSESSIONS
, hr
);
1316 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_JOIN
| DPOPEN_CREATE
);
1317 todo_wine
checkHR( DPERR_NOSESSIONS
, hr
); /* Second flag is ignored */
1319 dpsd_server
.dwFlags
= 0;
1322 /* Join to normal session */
1323 hr
= IDirectPlayX_Open( pDP_server
, &dpsd_server
, DPOPEN_CREATE
);
1324 todo_wine
checkHR( DP_OK
, hr
);
1326 IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb2
, pDP
, 0 );
1329 /* Already initialized session */
1330 hr
= IDirectPlayX_Open( pDP_server
, &dpsd_server
, DPOPEN_CREATE
);
1331 todo_wine
checkHR( DPERR_ALREADYINITIALIZED
, hr
);
1334 /* Checking which is the error checking order */
1335 dpsd_server
.dwSize
= 0;
1337 hr
= IDirectPlayX_Open( pDP_server
, &dpsd_server
, DPOPEN_CREATE
);
1338 checkHR( DPERR_INVALIDPARAMS
, hr
);
1340 dpsd_server
.dwSize
= sizeof(DPSESSIONDESC2
);
1343 /* Join to protected session */
1344 IDirectPlayX_Close( pDP_server
);
1345 dpsd_server
.lpszPasswordA
= (LPSTR
) "hadouken";
1346 hr
= IDirectPlayX_Open( pDP_server
, &dpsd_server
, DPOPEN_CREATE
);
1347 todo_wine
checkHR( DP_OK
, hr
);
1349 IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb2
,
1350 pDP
, DPENUMSESSIONS_PASSWORDREQUIRED
);
1353 IDirectPlayX_Release( pDP
);
1354 IDirectPlayX_Release( pDP_server
);
1360 static BOOL CALLBACK
EnumSessions_cb( LPCDPSESSIONDESC2 lpThisSD
,
1361 LPDWORD lpdwTimeOut
,
1365 lpCallbackData callbackData
= lpContext
;
1366 callbackData
->dwCounter1
++;
1368 if ( dwFlags
& DPESC_TIMEDOUT
)
1370 check( TRUE
, lpThisSD
== NULL
);
1373 check( FALSE
, lpThisSD
== NULL
);
1376 if ( lpThisSD
->lpszPasswordA
!= NULL
)
1378 check( TRUE
, (lpThisSD
->dwFlags
& DPSESSION_PASSWORDREQUIRED
) != 0 );
1381 if ( lpThisSD
->dwFlags
& DPSESSION_NEWPLAYERSDISABLED
)
1383 check( 0, lpThisSD
->dwCurrentPlayers
);
1386 check( sizeof(*lpThisSD
), lpThisSD
->dwSize
);
1387 checkLP( NULL
, lpThisSD
->lpszPasswordA
);
1392 static IDirectPlay4
*create_session(DPSESSIONDESC2
*lpdpsd
)
1400 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
1401 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
);
1402 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
1403 if (FAILED(hr
)) return NULL
;
1405 init_TCPIP_provider( pDP
, "127.0.0.1", 0 );
1407 hr
= IDirectPlayX_Open( pDP
, lpdpsd
, DPOPEN_CREATE
);
1408 todo_wine
checkHR( DP_OK
, hr
);
1410 if ( ! (lpdpsd
->dwFlags
& DPSESSION_NEWPLAYERSDISABLED
) )
1412 ZeroMemory( &name
, sizeof(DPNAME
) );
1413 name
.dwSize
= sizeof(DPNAME
);
1414 name
.lpszShortNameA
= (LPSTR
) "bofh";
1416 hr
= IDirectPlayX_CreatePlayer( pDP
, &dpid
, &name
, NULL
, NULL
,
1417 0, DPPLAYER_SERVERPLAYER
);
1418 todo_wine
checkHR( DP_OK
, hr
);
1425 static void test_EnumSessions(void)
1428 #define N_SESSIONS 6
1430 IDirectPlay4
*pDP
, *pDPserver
[N_SESSIONS
];
1431 DPSESSIONDESC2 dpsd
, dpsd_server
[N_SESSIONS
];
1432 CallbackData callbackData
;
1437 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
1438 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
);
1439 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
1440 if (FAILED(hr
)) return;
1442 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
1443 callbackData
.dwCounter1
= -1; /* So that after a call to EnumSessions
1444 we get the exact number of sessions */
1445 callbackData
.dwFlags
= 0;
1448 /* Service provider not initialized */
1449 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1451 checkHR( DPERR_UNINITIALIZED
, hr
);
1454 init_TCPIP_provider( pDP
, "127.0.0.1", 0 );
1457 /* Session with no size */
1458 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1460 todo_wine
checkHR( DPERR_INVALIDPARAMS
, hr
);
1462 if ( hr
== DPERR_UNINITIALIZED
)
1464 todo_wine
win_skip( "EnumSessions not implemented\n" );
1468 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
1472 callbackData
.dwCounter1
= -1;
1473 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1475 checkHR( DP_OK
, hr
);
1476 check( 0, callbackData
.dwCounter1
);
1479 dpsd
.guidApplication
= appGuid
;
1481 /* Set up sessions */
1482 for (i
=0; i
<N_SESSIONS
; i
++)
1484 memcpy( &dpsd_server
[i
], &dpsd
, sizeof(DPSESSIONDESC2
) );
1487 dpsd_server
[0].lpszSessionNameA
= (LPSTR
) "normal";
1488 dpsd_server
[0].dwFlags
= ( DPSESSION_CLIENTSERVER
|
1489 DPSESSION_DIRECTPLAYPROTOCOL
);
1490 dpsd_server
[0].dwMaxPlayers
= 10;
1492 dpsd_server
[1].lpszSessionNameA
= (LPSTR
) "full";
1493 dpsd_server
[1].dwFlags
= ( DPSESSION_CLIENTSERVER
|
1494 DPSESSION_DIRECTPLAYPROTOCOL
);
1495 dpsd_server
[1].dwMaxPlayers
= 1;
1497 dpsd_server
[2].lpszSessionNameA
= (LPSTR
) "no new";
1498 dpsd_server
[2].dwFlags
= ( DPSESSION_CLIENTSERVER
|
1499 DPSESSION_DIRECTPLAYPROTOCOL
|
1500 DPSESSION_NEWPLAYERSDISABLED
);
1501 dpsd_server
[2].dwMaxPlayers
= 10;
1503 dpsd_server
[3].lpszSessionNameA
= (LPSTR
) "no join";
1504 dpsd_server
[3].dwFlags
= ( DPSESSION_CLIENTSERVER
|
1505 DPSESSION_DIRECTPLAYPROTOCOL
|
1506 DPSESSION_JOINDISABLED
);
1507 dpsd_server
[3].dwMaxPlayers
= 10;
1509 dpsd_server
[4].lpszSessionNameA
= (LPSTR
) "private";
1510 dpsd_server
[4].dwFlags
= ( DPSESSION_CLIENTSERVER
|
1511 DPSESSION_DIRECTPLAYPROTOCOL
|
1512 DPSESSION_PRIVATE
);
1513 dpsd_server
[4].dwMaxPlayers
= 10;
1514 dpsd_server
[4].lpszPasswordA
= (LPSTR
) "password";
1516 dpsd_server
[5].lpszSessionNameA
= (LPSTR
) "protected";
1517 dpsd_server
[5].dwFlags
= ( DPSESSION_CLIENTSERVER
|
1518 DPSESSION_DIRECTPLAYPROTOCOL
|
1519 DPSESSION_PASSWORDREQUIRED
);
1520 dpsd_server
[5].dwMaxPlayers
= 10;
1521 dpsd_server
[5].lpszPasswordA
= (LPSTR
) "password";
1524 for (i
=0; i
<N_SESSIONS
; i
++)
1526 pDPserver
[i
] = create_session( &dpsd_server
[i
] );
1527 if (!pDPserver
[i
]) return;
1531 /* Invalid params */
1532 callbackData
.dwCounter1
= -1;
1533 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1534 &callbackData
, -1 );
1535 checkHR( DPERR_INVALIDPARAMS
, hr
);
1537 hr
= IDirectPlayX_EnumSessions( pDP
, NULL
, 0, EnumSessions_cb
,
1539 checkHR( DPERR_INVALIDPARAMS
, hr
);
1541 check( -1, callbackData
.dwCounter1
);
1545 callbackData
.dwFlags
= DPENUMSESSIONS_ALL
; /* Doesn't list private,
1547 callbackData
.dwCounter1
= -1;
1548 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1549 &callbackData
, callbackData
.dwFlags
);
1550 checkHR( DP_OK
, hr
);
1551 check( N_SESSIONS
-2, callbackData
.dwCounter1
);
1553 /* Doesn't list private */
1554 callbackData
.dwFlags
= ( DPENUMSESSIONS_ALL
|
1555 DPENUMSESSIONS_PASSWORDREQUIRED
);
1556 callbackData
.dwCounter1
= -1;
1557 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1558 &callbackData
, callbackData
.dwFlags
);
1559 checkHR( DP_OK
, hr
);
1560 check( N_SESSIONS
-1, callbackData
.dwCounter1
);
1562 /* Doesn't list full, no new, no join, private, protected */
1563 callbackData
.dwFlags
= DPENUMSESSIONS_AVAILABLE
;
1564 callbackData
.dwCounter1
= -1;
1565 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1566 &callbackData
, callbackData
.dwFlags
);
1567 checkHR( DP_OK
, hr
);
1568 check( N_SESSIONS
-5, callbackData
.dwCounter1
);
1570 /* Like with DPENUMSESSIONS_AVAILABLE */
1571 callbackData
.dwFlags
= 0;
1572 callbackData
.dwCounter1
= -1;
1573 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1574 &callbackData
, callbackData
.dwFlags
);
1575 checkHR( DP_OK
, hr
);
1576 check( N_SESSIONS
-5, callbackData
.dwCounter1
);
1578 /* Doesn't list full, no new, no join, private */
1579 callbackData
.dwFlags
= DPENUMSESSIONS_PASSWORDREQUIRED
;
1580 callbackData
.dwCounter1
= -1;
1581 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1582 &callbackData
, callbackData
.dwFlags
);
1583 checkHR( DP_OK
, hr
);
1584 check( N_SESSIONS
-4, callbackData
.dwCounter1
);
1587 /* Async enumeration */
1588 callbackData
.dwFlags
= DPENUMSESSIONS_ASYNC
;
1589 callbackData
.dwCounter1
= -1;
1590 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1591 &callbackData
, callbackData
.dwFlags
);
1592 checkHR( DP_OK
, hr
);
1593 check( N_SESSIONS
-4, callbackData
.dwCounter1
); /* Read cache of last
1596 callbackData
.dwFlags
= DPENUMSESSIONS_STOPASYNC
;
1597 callbackData
.dwCounter1
= -1;
1598 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1599 &callbackData
, callbackData
.dwFlags
);
1600 checkHR( DP_OK
, hr
);
1601 check( 0, callbackData
.dwCounter1
); /* Stop enumeration */
1603 callbackData
.dwFlags
= DPENUMSESSIONS_ASYNC
;
1604 callbackData
.dwCounter1
= -1;
1605 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1606 &callbackData
, callbackData
.dwFlags
);
1607 checkHR( DP_OK
, hr
);
1608 check( 0, callbackData
.dwCounter1
); /* Start enumeration */
1610 Sleep(500); /* Give time to fill the cache */
1612 callbackData
.dwFlags
= DPENUMSESSIONS_ASYNC
;
1613 callbackData
.dwCounter1
= -1;
1614 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1615 &callbackData
, callbackData
.dwFlags
);
1616 checkHR( DP_OK
, hr
);
1617 check( N_SESSIONS
-5, callbackData
.dwCounter1
); /* Retrieve results */
1619 callbackData
.dwFlags
= DPENUMSESSIONS_STOPASYNC
;
1620 callbackData
.dwCounter1
= -1;
1621 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1622 &callbackData
, callbackData
.dwFlags
);
1623 checkHR( DP_OK
, hr
);
1624 check( 0, callbackData
.dwCounter1
); /* Stop enumeration */
1627 /* Specific tests for passworded sessions */
1629 for (i
=0; i
<N_SESSIONS
; i
++)
1631 IDirectPlayX_Release( pDPserver
[i
] );
1634 /* - Only session password set */
1637 dpsd_server
[i
].lpszPasswordA
= (LPSTR
) "password";
1638 dpsd_server
[i
].dwFlags
= 0;
1639 pDPserver
[i
] = create_session( &dpsd_server
[i
] );
1642 callbackData
.dwFlags
= 0;
1643 callbackData
.dwCounter1
= -1;
1644 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1645 &callbackData
, callbackData
.dwFlags
);
1646 checkHR( DP_OK
, hr
);
1647 check( 0, callbackData
.dwCounter1
);
1649 callbackData
.dwFlags
= DPENUMSESSIONS_PASSWORDREQUIRED
;
1650 callbackData
.dwCounter1
= -1;
1651 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1652 &callbackData
, callbackData
.dwFlags
);
1653 checkHR( DP_OK
, hr
);
1654 check( 2, callbackData
.dwCounter1
); /* Both sessions automatically
1655 set DPSESSION_PASSWORDREQUIRED */
1657 /* - Only session flag set */
1658 for (i
=4; i
<=5; i
++)
1660 IDirectPlayX_Release( pDPserver
[i
] );
1661 dpsd_server
[i
].lpszPasswordA
= NULL
;
1663 dpsd_server
[4].dwFlags
= DPSESSION_PRIVATE
;
1664 dpsd_server
[5].dwFlags
= DPSESSION_PASSWORDREQUIRED
;
1665 for (i
=4; i
<=5; i
++)
1667 pDPserver
[i
] = create_session( &dpsd_server
[i
] );
1670 callbackData
.dwFlags
= 0;
1671 callbackData
.dwCounter1
= -1;
1672 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1673 &callbackData
, callbackData
.dwFlags
);
1674 checkHR( DP_OK
, hr
);
1675 check( 2, callbackData
.dwCounter1
); /* Without password,
1676 the flag is ignored */
1678 /* - Both session flag and password set */
1679 for (i
=4; i
<=5; i
++)
1681 IDirectPlayX_Release( pDPserver
[i
] );
1682 dpsd_server
[i
].lpszPasswordA
= (LPSTR
) "password";
1684 dpsd_server
[4].dwFlags
= DPSESSION_PRIVATE
;
1685 dpsd_server
[5].dwFlags
= DPSESSION_PASSWORDREQUIRED
;
1686 for (i
=4; i
<=5; i
++)
1688 pDPserver
[i
] = create_session( &dpsd_server
[i
] );
1691 /* - Listing without password */
1692 callbackData
.dwCounter1
= -1;
1693 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1694 &callbackData
, callbackData
.dwFlags
);
1695 checkHR( DP_OK
, hr
);
1696 check( 0, callbackData
.dwCounter1
);
1698 callbackData
.dwFlags
= DPENUMSESSIONS_PASSWORDREQUIRED
;
1699 callbackData
.dwCounter1
= -1;
1700 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1701 &callbackData
, callbackData
.dwFlags
);
1702 checkHR( DP_OK
, hr
);
1703 check( 1, callbackData
.dwCounter1
);
1705 /* - Listing with incorrect password */
1706 dpsd
.lpszPasswordA
= (LPSTR
) "bad_password";
1707 callbackData
.dwFlags
= 0;
1708 callbackData
.dwCounter1
= -1;
1709 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1710 &callbackData
, callbackData
.dwFlags
);
1711 checkHR( DP_OK
, hr
);
1712 check( 0, callbackData
.dwCounter1
);
1714 callbackData
.dwFlags
= DPENUMSESSIONS_PASSWORDREQUIRED
;
1715 callbackData
.dwCounter1
= -1;
1716 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1717 &callbackData
, callbackData
.dwFlags
);
1718 checkHR( DP_OK
, hr
);
1719 check( 1, callbackData
.dwCounter1
);
1721 /* - Listing with correct password */
1722 dpsd
.lpszPasswordA
= (LPSTR
) "password";
1723 callbackData
.dwCounter1
= -1;
1724 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1725 &callbackData
, callbackData
.dwFlags
);
1726 checkHR( DP_OK
, hr
);
1727 check( 2, callbackData
.dwCounter1
);
1730 dpsd
.lpszPasswordA
= NULL
;
1731 callbackData
.dwFlags
= DPENUMSESSIONS_ASYNC
;
1732 callbackData
.dwCounter1
= -1;
1733 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1734 &callbackData
, callbackData
.dwFlags
);
1735 checkHR( DP_OK
, hr
);
1736 check( 2, callbackData
.dwCounter1
); /* Read cache of last sync enumeration,
1737 even private sessions */
1742 /* - Creating two servers with different application GUIDs */
1743 for (i
=4; i
<=5; i
++)
1745 IDirectPlayX_Release( pDPserver
[i
] );
1746 dpsd_server
[i
].dwFlags
= ( DPSESSION_CLIENTSERVER
|
1747 DPSESSION_DIRECTPLAYPROTOCOL
);
1748 dpsd_server
[i
].lpszPasswordA
= NULL
;
1749 dpsd_server
[i
].dwMaxPlayers
= 10;
1751 dpsd_server
[4].lpszSessionNameA
= (LPSTR
) "normal1";
1752 dpsd_server
[4].guidApplication
= appGuid
;
1753 dpsd_server
[5].lpszSessionNameA
= (LPSTR
) "normal2";
1754 dpsd_server
[5].guidApplication
= appGuid2
;
1755 for (i
=4; i
<=5; i
++)
1757 pDPserver
[i
] = create_session( &dpsd_server
[i
] );
1760 callbackData
.dwFlags
= 0;
1762 dpsd
.guidApplication
= appGuid2
;
1763 callbackData
.dwCounter1
= -1;
1764 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1765 &callbackData
, callbackData
.dwFlags
);
1766 checkHR( DP_OK
, hr
);
1767 check( 1, callbackData
.dwCounter1
); /* Only one of the sessions */
1769 dpsd
.guidApplication
= appGuid
;
1770 callbackData
.dwCounter1
= -1;
1771 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1772 &callbackData
, callbackData
.dwFlags
);
1773 checkHR( DP_OK
, hr
);
1774 check( 1, callbackData
.dwCounter1
); /* The other session */
1776 For some reason, if we enum 1st with appGuid and 2nd with appGuid2,
1777 in the second enum we get the 2 sessions. Dplay fault? Elves? */
1779 dpsd
.guidApplication
= GUID_NULL
;
1780 callbackData
.dwCounter1
= -1;
1781 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1782 &callbackData
, callbackData
.dwFlags
);
1783 checkHR( DP_OK
, hr
);
1784 check( 2, callbackData
.dwCounter1
); /* Both sessions */
1786 for (i
=4; i
<=5; i
++)
1788 IDirectPlayX_Release( pDPserver
[i
] );
1790 IDirectPlayX_Release( pDP
);
1797 static void test_SessionDesc(void)
1800 IDirectPlay4
*pDP
[2];
1801 DPSESSIONDESC2 dpsd
;
1802 LPDPSESSIONDESC2 lpData
[2];
1808 CallbackData callbackData
;
1813 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
1814 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
1815 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
1816 if (FAILED(hr
)) return;
1818 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
1820 /* Service provider not initialized */
1821 hr
= IDirectPlayX_SetSessionDesc( pDP
[0], NULL
, 0 );
1822 checkHR( DPERR_UNINITIALIZED
, hr
);
1824 hr
= IDirectPlayX_GetSessionDesc( pDP
[0], NULL
, NULL
);
1825 checkHR( DPERR_UNINITIALIZED
, hr
);
1828 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
1829 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
1832 /* No sessions open */
1833 hr
= IDirectPlayX_SetSessionDesc( pDP
[0], NULL
, 0 );
1834 todo_wine
checkHR( DPERR_NOSESSIONS
, hr
);
1836 if ( hr
== DPERR_UNINITIALIZED
)
1838 todo_wine
win_skip("Get/SetSessionDesc not implemented\n");
1842 hr
= IDirectPlayX_GetSessionDesc( pDP
[0], NULL
, NULL
);
1843 checkHR( DPERR_NOSESSIONS
, hr
);
1846 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
1847 dpsd
.guidApplication
= appGuid
;
1848 dpsd
.dwMaxPlayers
= 10;
1852 IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
1854 IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
1859 /* Players, only to receive messages */
1860 IDirectPlayX_CreatePlayer( pDP
[i
], &dpid
[i
], NULL
, NULL
, NULL
, 0, 0 );
1862 lpData
[i
] = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, 1024 );
1864 lpDataMsg
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, 1024 );
1867 /* Incorrect parameters */
1868 hr
= IDirectPlayX_SetSessionDesc( pDP
[0], NULL
, 0 );
1869 checkHR( DPERR_INVALIDPARAMS
, hr
);
1870 hr
= IDirectPlayX_GetSessionDesc( pDP
[0], NULL
, NULL
);
1871 checkHR( DPERR_INVALIDPARAM
, hr
);
1874 /* Crashes under Win7 */
1875 hr
= IDirectPlayX_GetSessionDesc( pDP
[0], lpData
[0], NULL
);
1876 checkHR( DPERR_INVALIDPARAM
, hr
);
1878 hr
= IDirectPlayX_GetSessionDesc( pDP
[0], lpData
[0], &dwDataSize
);
1879 checkHR( DPERR_INVALIDPARAMS
, hr
);
1880 check( -1, dwDataSize
);
1883 /* Get: Insufficient buffer size */
1885 hr
= IDirectPlayX_GetSessionDesc( pDP
[0], lpData
[0], &dwDataSize
);
1886 checkHR( DPERR_BUFFERTOOSMALL
, hr
);
1887 check( dpsd
.dwSize
, dwDataSize
);
1889 hr
= IDirectPlayX_GetSessionDesc( pDP
[0], lpData
[0], &dwDataSize
);
1890 checkHR( DPERR_BUFFERTOOSMALL
, hr
);
1891 check( dpsd
.dwSize
, dwDataSize
);
1893 hr
= IDirectPlayX_GetSessionDesc( pDP
[0], NULL
, &dwDataSize
);
1894 checkHR( DPERR_BUFFERTOOSMALL
, hr
);
1895 check( dpsd
.dwSize
, dwDataSize
);
1897 /* Get: Regular operation
1898 * i=0: Local session
1899 * i=1: Remote session */
1902 hr
= IDirectPlayX_GetSessionDesc( pDP
[i
], lpData
[i
], &dwDataSize
);
1903 checkHR( DP_OK
, hr
);
1904 check( sizeof(DPSESSIONDESC2
), dwDataSize
);
1905 check( sizeof(DPSESSIONDESC2
), lpData
[i
]->dwSize
);
1906 checkGuid( &appGuid
, &lpData
[i
]->guidApplication
);
1907 check( dpsd
.dwMaxPlayers
, lpData
[i
]->dwMaxPlayers
);
1910 checkGuid( &lpData
[0]->guidInstance
, &lpData
[1]->guidInstance
);
1912 /* Set: Regular operation */
1913 dpsd
.lpszSessionNameA
= (LPSTR
) "Wahaa";
1914 hr
= IDirectPlayX_SetSessionDesc( pDP
[0], &dpsd
, 0 );
1915 checkHR( DP_OK
, hr
);
1918 hr
= IDirectPlayX_GetSessionDesc( pDP
[1], lpData
[1], &dwDataSize
);
1919 checkHR( DP_OK
, hr
);
1920 checkStr( dpsd
.lpszSessionNameA
, lpData
[1]->lpszSessionNameA
);
1923 /* Set: Failing to modify a remote session */
1924 hr
= IDirectPlayX_SetSessionDesc( pDP
[1], &dpsd
, 0 );
1925 checkHR( DPERR_ACCESSDENIED
, hr
);
1927 /* Trying to change immutable properties */
1929 hr
= IDirectPlayX_SetSessionDesc( pDP
[0], &dpsd
, 0 );
1930 checkHR( DP_OK
, hr
);
1931 dpsd
.dwFlags
= DPSESSION_SECURESERVER
;
1932 hr
= IDirectPlayX_SetSessionDesc( pDP
[0], &dpsd
, 0 );
1933 checkHR( DPERR_INVALIDPARAMS
, hr
);
1935 hr
= IDirectPlayX_SetSessionDesc( pDP
[0], &dpsd
, 0 );
1936 checkHR( DP_OK
, hr
);
1939 hr
= IDirectPlayX_SetSessionDesc( pDP
[0], &dpsd
, 0 );
1940 checkHR( DPERR_INVALIDPARAMS
, hr
);
1941 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
1942 hr
= IDirectPlayX_SetSessionDesc( pDP
[0], &dpsd
, 0 );
1943 checkHR( DP_OK
, hr
);
1945 /* Changing the GUIDs and size is ignored */
1946 dpsd
.guidApplication
= appGuid2
;
1947 hr
= IDirectPlayX_SetSessionDesc( pDP
[0], &dpsd
, 0 );
1948 checkHR( DP_OK
, hr
);
1949 dpsd
.guidInstance
= appGuid2
;
1950 hr
= IDirectPlayX_SetSessionDesc( pDP
[0], &dpsd
, 0 );
1951 checkHR( DP_OK
, hr
);
1953 hr
= IDirectPlayX_GetSessionDesc( pDP
[0], lpData
[0], &dwDataSize
);
1954 checkHR( DP_OK
, hr
);
1955 checkGuid( &appGuid
, &lpData
[0]->guidApplication
);
1956 checkGuid( &lpData
[1]->guidInstance
, &lpData
[0]->guidInstance
);
1957 check( sizeof(DPSESSIONDESC2
), lpData
[0]->dwSize
);
1960 /* Checking system messages */
1961 check_messages( pDP
[0], dpid
, 2, &callbackData
);
1962 checkStr( "S0,S0,S0,S0,S0,S0,S0,", callbackData
.szTrace1
);
1963 checkStr( "48,90,90,90,90,90,90,", callbackData
.szTrace2
);
1964 check_messages( pDP
[1], dpid
, 2, &callbackData
);
1965 checkStr( "S1,S1,S1,S1,S1,S1,", callbackData
.szTrace1
);
1966 checkStr( "90,90,90,90,90,90,", callbackData
.szTrace2
);
1968 HeapFree( GetProcessHeap(), 0, lpDataMsg
);
1971 HeapFree( GetProcessHeap(), 0, lpData
[i
] );
1972 IDirectPlayX_Release( pDP
[i
] );
1979 static void test_CreatePlayer(void)
1982 IDirectPlay4
*pDP
[2];
1983 DPSESSIONDESC2 dpsd
;
1989 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
1990 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[0] );
1991 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
1992 if (FAILED(hr
)) return;
1994 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
1995 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[1] );
1996 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
1997 if (FAILED(hr
)) return;
1999 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
2000 ZeroMemory( &name
, sizeof(DPNAME
) );
2003 /* Connection not initialized */
2004 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
, 0, 0 );
2005 checkHR( DPERR_UNINITIALIZED
, hr
);
2008 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
2009 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
2012 /* Session not open */
2013 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
, 0, 0 );
2014 todo_wine
checkHR( DPERR_INVALIDPARAMS
, hr
);
2016 if ( hr
== DPERR_UNINITIALIZED
)
2018 todo_wine
win_skip( "CreatePlayer not implemented\n" );
2022 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
2023 dpsd
.guidApplication
= appGuid
;
2024 IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
2028 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
, 0, 0 );
2029 checkHR( DP_OK
, hr
);
2035 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, &name
, NULL
, NULL
, 0, 0 );
2036 checkHR( DP_OK
, hr
);
2039 name
.dwSize
= sizeof(DPNAME
);
2040 name
.lpszShortNameA
= (LPSTR
) "test";
2041 name
.lpszLongNameA
= NULL
;
2044 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, &name
, NULL
, NULL
,
2046 checkHR( DP_OK
, hr
);
2050 hr
= IDirectPlayX_CreatePlayer( pDP
[0], NULL
, NULL
, NULL
, NULL
,
2052 checkHR( DPERR_INVALIDPARAMS
, hr
);
2055 /* There can only be one server player */
2056 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2057 0, DPPLAYER_SERVERPLAYER
);
2058 checkHR( DP_OK
, hr
);
2059 check( DPID_SERVERPLAYER
, dpid
);
2061 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2062 0, DPPLAYER_SERVERPLAYER
);
2063 checkHR( DPERR_CANTCREATEPLAYER
, hr
);
2065 IDirectPlayX_DestroyPlayer( pDP
[0], dpid
);
2067 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2068 0, DPPLAYER_SERVERPLAYER
);
2069 checkHR( DP_OK
, hr
);
2070 check( DPID_SERVERPLAYER
, dpid
);
2071 IDirectPlayX_DestroyPlayer( pDP
[0], dpid
);
2075 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2077 checkHR( DP_OK
, hr
);
2079 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2080 0, DPPLAYER_SERVERPLAYER
);
2081 checkHR( DP_OK
, hr
);
2082 check( DPID_SERVERPLAYER
, dpid
);
2083 IDirectPlayX_DestroyPlayer( pDP
[0], dpid
);
2085 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2086 0, DPPLAYER_SPECTATOR
);
2087 checkHR( DP_OK
, hr
);
2089 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2090 0, ( DPPLAYER_SERVERPLAYER
|
2091 DPPLAYER_SPECTATOR
) );
2092 checkHR( DP_OK
, hr
);
2093 check( DPID_SERVERPLAYER
, dpid
);
2094 IDirectPlayX_DestroyPlayer( pDP
[0], dpid
);
2097 /* Session with DPSESSION_NEWPLAYERSDISABLED */
2098 IDirectPlayX_Close( pDP
[0] );
2099 dpsd
.dwFlags
= DPSESSION_NEWPLAYERSDISABLED
;
2100 hr
= IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
2101 checkHR( DP_OK
, hr
);
2104 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2106 checkHR( DPERR_CANTCREATEPLAYER
, hr
);
2108 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2109 0, DPPLAYER_SERVERPLAYER
);
2110 checkHR( DPERR_CANTCREATEPLAYER
, hr
);
2112 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2113 0, DPPLAYER_SPECTATOR
);
2114 checkHR( DPERR_CANTCREATEPLAYER
, hr
);
2117 /* Creating players in a Client/Server session */
2118 IDirectPlayX_Close( pDP
[0] );
2119 dpsd
.dwFlags
= DPSESSION_CLIENTSERVER
;
2120 hr
= IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
2121 checkHR( DP_OK
, hr
);
2122 hr
= IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
2124 checkHR( DP_OK
, hr
);
2127 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2129 checkHR( DPERR_ACCESSDENIED
, hr
);
2131 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2132 0, DPPLAYER_SERVERPLAYER
);
2133 checkHR( DP_OK
, hr
);
2134 check( DPID_SERVERPLAYER
, dpid
);
2136 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &dpid
, NULL
, NULL
, NULL
,
2137 0, DPPLAYER_SERVERPLAYER
);
2138 checkHR( DPERR_INVALIDFLAGS
, hr
);
2140 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &dpid
, NULL
, NULL
, NULL
,
2142 checkHR( DP_OK
, hr
);
2145 IDirectPlayX_Release( pDP
[0] );
2146 IDirectPlayX_Release( pDP
[1] );
2152 static void test_GetPlayerCaps(void)
2155 IDirectPlay4
*pDP
[2];
2156 DPSESSIONDESC2 dpsd
;
2167 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
2168 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
2169 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
2170 if (FAILED(hr
)) return;
2172 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
2173 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
2174 dpsd
.guidApplication
= appGuid
;
2175 dpsd
.dwMaxPlayers
= 10;
2177 ZeroMemory( &playerCaps
, sizeof(DPCAPS
) );
2180 /* Uninitialized service provider */
2181 playerCaps
.dwSize
= 0;
2182 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], 0, &playerCaps
, 0 );
2183 checkHR( DPERR_UNINITIALIZED
, hr
);
2185 playerCaps
.dwSize
= sizeof(DPCAPS
);
2186 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], 0, &playerCaps
, 0 );
2187 checkHR( DPERR_UNINITIALIZED
, hr
);
2190 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
2191 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
2195 playerCaps
.dwSize
= 0;
2197 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], 0, &playerCaps
, 0 );
2198 todo_wine
checkHR( DPERR_INVALIDPARAMS
, hr
);
2200 if ( hr
== DPERR_UNINITIALIZED
)
2202 todo_wine
win_skip( "GetPlayerCaps not implemented\n" );
2206 playerCaps
.dwSize
= sizeof(DPCAPS
);
2208 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], 0, &playerCaps
, 0 );
2209 checkHR( DPERR_INVALIDPLAYER
, hr
);
2211 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], 2, &playerCaps
, 0 );
2212 checkHR( DPERR_INVALIDPLAYER
, hr
);
2215 hr
= IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
2216 checkHR( DP_OK
, hr
);
2217 hr
= IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
2219 checkHR( DP_OK
, hr
);
2223 hr
= IDirectPlayX_CreatePlayer( pDP
[i
], &dpid
[i
],
2224 NULL
, NULL
, NULL
, 0, 0 );
2225 checkHR( DP_OK
, hr
);
2229 /* Uninitialized playerCaps */
2230 playerCaps
.dwSize
= 0;
2232 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], 0, &playerCaps
, 0 );
2233 checkHR( DPERR_INVALIDPARAMS
, hr
);
2235 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], 2, &playerCaps
, 0 );
2236 checkHR( DPERR_INVALIDPARAMS
, hr
);
2238 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], dpid
[0], &playerCaps
, 0 );
2239 checkHR( DPERR_INVALIDPARAMS
, hr
);
2241 /* Invalid player */
2242 playerCaps
.dwSize
= sizeof(DPCAPS
);
2244 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], 0, &playerCaps
, 0 );
2245 checkHR( DPERR_INVALIDPLAYER
, hr
);
2247 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], 2, &playerCaps
, 0 );
2248 checkHR( DPERR_INVALIDPLAYER
, hr
);
2250 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], dpid
[0], &playerCaps
, 0 );
2251 checkHR( DP_OK
, hr
);
2253 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], dpid
[0], NULL
, 0 );
2254 checkHR( DPERR_INVALIDPARAMS
, hr
);
2256 /* Regular parameters */
2260 dwFlags
<=DPGETCAPS_GUARANTEED
;
2261 dwFlags
+=DPGETCAPS_GUARANTEED
)
2264 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], dpid
[i
],
2265 &playerCaps
, dwFlags
);
2266 checkHR( DP_OK
, hr
);
2269 check( sizeof(DPCAPS
), playerCaps
.dwSize
);
2270 check( 40, playerCaps
.dwSize
);
2271 check( 0, playerCaps
.dwMaxQueueSize
);
2272 check( 0, playerCaps
.dwHundredBaud
);
2273 check( 0, playerCaps
.dwLatency
);
2274 check( 65536, playerCaps
.dwMaxLocalPlayers
);
2275 check( 20, playerCaps
.dwHeaderLength
);
2279 checkFlags( DPCAPS_ISHOST
|
2280 DPCAPS_GUARANTEEDOPTIMIZED
|
2281 DPCAPS_GUARANTEEDSUPPORTED
|
2282 DPCAPS_ASYNCSUPPORTED
|
2284 playerCaps
.dwFlags
, FLAGS_DPCAPS
);
2287 checkFlags( DPCAPS_ISHOST
|
2288 DPCAPS_GUARANTEEDOPTIMIZED
|
2289 DPCAPS_GUARANTEEDSUPPORTED
|
2290 DPCAPS_ASYNCSUPPORTED
,
2291 playerCaps
.dwFlags
, FLAGS_DPCAPS
);
2293 if ( dwFlags
== DPGETCAPS_GUARANTEED
)
2295 check( 1048547, playerCaps
.dwMaxBufferSize
);
2296 check( 64, playerCaps
.dwMaxPlayers
);
2300 check( 65479, playerCaps
.dwMaxBufferSize
);
2301 check( 65536, playerCaps
.dwMaxPlayers
);
2308 IDirectPlayX_Release( pDP
[0] );
2309 IDirectPlayX_Release( pDP
[1] );
2316 static void test_PlayerData(void)
2319 DPSESSIONDESC2 dpsd
;
2323 /* lpDataFake has to be bigger than the rest, limits lpDataGet size */
2324 LPCSTR lpDataFake
= "big_fake_data_chunk";
2325 DWORD dwDataSizeFake
= strlen(lpDataFake
)+1;
2327 LPCSTR lpData
= "remote_data";
2328 DWORD dwDataSize
= strlen(lpData
)+1;
2330 LPCSTR lpDataLocal
= "local_data";
2331 DWORD dwDataSizeLocal
= strlen(lpDataLocal
)+1;
2333 LPSTR lpDataGet
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
2335 DWORD dwDataSizeGet
= dwDataSizeFake
;
2338 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
2339 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
);
2340 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
2341 if (FAILED(hr
)) return;
2343 /* No service provider */
2344 hr
= IDirectPlayX_SetPlayerData( pDP
, 0, (LPVOID
) lpData
,
2346 checkHR( DPERR_UNINITIALIZED
, hr
);
2348 hr
= IDirectPlayX_GetPlayerData( pDP
, 0, lpDataGet
, &dwDataSizeGet
, 0 );
2349 checkHR( DPERR_UNINITIALIZED
, hr
);
2352 init_TCPIP_provider( pDP
, "127.0.0.1", 0 );
2354 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
2355 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
2356 dpsd
.guidApplication
= appGuid
;
2357 IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_CREATE
);
2360 /* Invalid player */
2361 hr
= IDirectPlayX_SetPlayerData( pDP
, 0, (LPVOID
) lpData
,
2363 todo_wine
checkHR( DPERR_INVALIDPLAYER
, hr
);
2365 hr
= IDirectPlayX_GetPlayerData( pDP
, 0, lpDataGet
, &dwDataSizeGet
, 0 );
2366 todo_wine
checkHR( DPERR_INVALIDPLAYER
, hr
);
2368 if ( hr
== DPERR_UNINITIALIZED
)
2370 todo_wine
win_skip( "Get/SetPlayerData not implemented\n" );
2374 /* Create the player */
2375 /* By default, the data is remote */
2376 hr
= IDirectPlayX_CreatePlayer( pDP
, &dpid
, NULL
, NULL
, (LPVOID
) lpData
,
2378 checkHR( DP_OK
, hr
);
2380 /* Invalid parameters */
2381 hr
= IDirectPlayX_SetPlayerData( pDP
, dpid
, NULL
, dwDataSize
, 0 );
2382 checkHR( DPERR_INVALIDPARAMS
, hr
);
2383 hr
= IDirectPlayX_SetPlayerData( pDP
, dpid
, lpDataGet
, -1, 0 );
2384 checkHR( DPERR_INVALIDPARAMS
, hr
);
2386 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, NULL
, 0 );
2387 checkHR( DPERR_INVALIDPARAMS
, hr
);
2391 * Remote data (default)
2395 /* Buffer redimension */
2396 dwDataSizeGet
= dwDataSizeFake
;
2397 strcpy(lpDataGet
, lpDataFake
);
2398 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, NULL
,
2399 &dwDataSizeGet
, 0 );
2400 check( DPERR_BUFFERTOOSMALL
, hr
);
2401 check( dwDataSize
, dwDataSizeGet
);
2402 checkStr( lpDataFake
, lpDataGet
);
2405 strcpy(lpDataGet
, lpDataFake
);
2406 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
, 0 );
2407 check( DPERR_BUFFERTOOSMALL
, hr
);
2408 check( dwDataSize
, dwDataSizeGet
);
2410 strcpy(lpDataGet
, lpDataFake
);
2411 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
, 0 );
2412 checkHR( DP_OK
, hr
);
2413 check( dwDataSize
, dwDataSizeGet
);
2414 checkStr( lpData
, lpDataGet
);
2416 /* Normal operation */
2417 dwDataSizeGet
= dwDataSizeFake
;
2418 strcpy(lpDataGet
, lpDataFake
);
2419 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
, 0 );
2420 checkHR( DP_OK
, hr
);
2421 check( dwDataSize
, dwDataSizeGet
);
2422 checkStr( lpData
, lpDataGet
);
2425 dwDataSizeGet
= dwDataSizeFake
;
2426 strcpy(lpDataGet
, lpDataFake
);
2427 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
, 0 );
2428 checkHR( DP_OK
, hr
);
2429 check( dwDataSize
, dwDataSizeGet
); /* Remote: works as expected */
2430 checkStr( lpData
, lpDataGet
);
2432 dwDataSizeGet
= dwDataSizeFake
;
2433 strcpy(lpDataGet
, lpDataFake
);
2434 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
,
2436 checkHR( DP_OK
, hr
);
2437 check( dwDataSize
, dwDataSizeGet
); /* Same behaviour as in previous test */
2438 checkStr( lpData
, lpDataGet
);
2440 dwDataSizeGet
= dwDataSizeFake
;
2441 strcpy(lpDataGet
, lpDataFake
);
2442 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
,
2444 checkHR( DP_OK
, hr
);
2445 check( 0, dwDataSizeGet
); /* Sets size to 0 (as local data doesn't exist) */
2446 checkStr( lpDataFake
, lpDataGet
);
2448 dwDataSizeGet
= dwDataSizeFake
;
2449 strcpy(lpDataGet
, lpDataFake
);
2450 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
,
2451 DPGET_LOCAL
| DPGET_REMOTE
);
2452 checkHR( DP_OK
, hr
);
2453 check( 0, dwDataSizeGet
); /* Same behaviour as in previous test */
2454 checkStr( lpDataFake
, lpDataGet
);
2456 /* Getting local data (which doesn't exist), buffer size is ignored */
2458 strcpy(lpDataGet
, lpDataFake
);
2459 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
,
2461 checkHR( DP_OK
, hr
);
2462 check( 0, dwDataSizeGet
); /* Sets size to 0 */
2463 checkStr( lpDataFake
, lpDataGet
);
2465 dwDataSizeGet
= dwDataSizeFake
;
2466 strcpy(lpDataGet
, lpDataFake
);
2467 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, NULL
, &dwDataSizeGet
,
2469 checkHR( DP_OK
, hr
);
2470 check( 0, dwDataSizeGet
); /* Sets size to 0 */
2471 checkStr( lpDataFake
, lpDataGet
);
2480 hr
= IDirectPlayX_SetPlayerData( pDP
, dpid
, (LPVOID
) lpDataLocal
,
2482 DPSET_LOCAL
| DPSET_GUARANTEED
);
2483 checkHR( DPERR_INVALIDPARAMS
, hr
);
2485 /* Correct parameters */
2486 hr
= IDirectPlayX_SetPlayerData( pDP
, dpid
, (LPVOID
) lpDataLocal
,
2487 dwDataSizeLocal
, DPSET_LOCAL
);
2488 checkHR( DP_OK
, hr
);
2490 /* Flag tests (again) */
2491 dwDataSizeGet
= dwDataSizeFake
;
2492 strcpy(lpDataGet
, lpDataFake
);
2493 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
, 0 );
2494 checkHR( DP_OK
, hr
);
2495 check( dwDataSize
, dwDataSizeGet
); /* Remote: works as expected */
2496 checkStr( lpData
, lpDataGet
);
2498 dwDataSizeGet
= dwDataSizeFake
;
2499 strcpy(lpDataGet
, lpDataFake
);
2500 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
,
2502 checkHR( DP_OK
, hr
);
2503 check( dwDataSize
, dwDataSizeGet
); /* Like in previous test */
2504 checkStr( lpData
, lpDataGet
);
2506 dwDataSizeGet
= dwDataSizeFake
;
2507 strcpy(lpDataGet
, lpDataFake
);
2508 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
,
2510 checkHR( DP_OK
, hr
);
2511 check( dwDataSizeLocal
, dwDataSizeGet
); /* Local: works as expected */
2512 checkStr( lpDataLocal
, lpDataGet
);
2514 dwDataSizeGet
= dwDataSizeFake
;
2515 strcpy(lpDataGet
, lpDataFake
);
2516 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
,
2517 DPGET_LOCAL
| DPGET_REMOTE
);
2518 checkHR( DP_OK
, hr
);
2519 check( dwDataSizeLocal
, dwDataSizeGet
); /* Like in previous test */
2520 checkStr( lpDataLocal
, lpDataGet
);
2522 /* Small buffer works as expected again */
2524 strcpy(lpDataGet
, lpDataFake
);
2525 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
,
2527 checkHR( DPERR_BUFFERTOOSMALL
, hr
);
2528 check( dwDataSizeLocal
, dwDataSizeGet
);
2529 checkStr( lpDataFake
, lpDataGet
);
2531 dwDataSizeGet
= dwDataSizeFake
;
2532 strcpy(lpDataGet
, lpDataFake
);
2533 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, NULL
,
2534 &dwDataSizeGet
, DPGET_LOCAL
);
2535 check( DPERR_BUFFERTOOSMALL
, hr
);
2536 check( dwDataSizeLocal
, dwDataSizeGet
);
2537 checkStr( lpDataFake
, lpDataGet
);
2541 * Changing remote data
2545 /* Remote data := local data */
2546 hr
= IDirectPlayX_SetPlayerData( pDP
, dpid
, (LPVOID
) lpDataLocal
,
2548 DPSET_GUARANTEED
| DPSET_REMOTE
);
2549 checkHR( DP_OK
, hr
);
2550 hr
= IDirectPlayX_SetPlayerData( pDP
, dpid
, (LPVOID
) lpDataLocal
,
2551 dwDataSizeLocal
, 0 );
2552 checkHR( DP_OK
, hr
);
2554 dwDataSizeGet
= dwDataSizeFake
;
2555 strcpy(lpDataGet
, lpDataFake
);
2556 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
, 0 );
2557 checkHR( DP_OK
, hr
);
2558 check( dwDataSizeLocal
, dwDataSizeGet
);
2559 checkStr( lpDataLocal
, lpDataGet
);
2561 /* Remote data := fake data */
2562 hr
= IDirectPlayX_SetPlayerData( pDP
, dpid
, (LPVOID
) lpDataFake
,
2563 dwDataSizeFake
, DPSET_REMOTE
);
2564 checkHR( DP_OK
, hr
);
2566 dwDataSizeGet
= dwDataSizeFake
+ 1;
2567 strcpy(lpDataGet
, lpData
);
2568 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
, 0 );
2569 checkHR( DP_OK
, hr
);
2570 check( dwDataSizeFake
, dwDataSizeGet
);
2571 checkStr( lpDataFake
, lpDataGet
);
2574 HeapFree( GetProcessHeap(), 0, lpDataGet
);
2575 IDirectPlayX_Release( pDP
);
2581 static void test_PlayerName(void)
2584 IDirectPlay4
*pDP
[2];
2585 DPSESSIONDESC2 dpsd
;
2591 DWORD dwDataSize
= 1024;
2592 LPVOID lpData
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, dwDataSize
);
2593 CallbackData callbackData
;
2598 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
2599 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
2600 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
2601 if (FAILED(hr
)) return;
2603 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
2604 ZeroMemory( &playerName
, sizeof(DPNAME
) );
2607 /* Service provider not initialized */
2608 hr
= IDirectPlayX_SetPlayerName( pDP
[0], 0, &playerName
, 0 );
2609 checkHR( DPERR_UNINITIALIZED
, hr
);
2612 hr
= IDirectPlayX_GetPlayerName( pDP
[0], 0, lpData
, &dwDataSize
);
2613 checkHR( DPERR_UNINITIALIZED
, hr
);
2614 check( 1024, dwDataSize
);
2617 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
2618 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
2621 /* Session not initialized */
2622 hr
= IDirectPlayX_SetPlayerName( pDP
[0], 0, &playerName
, 0 );
2623 todo_wine
checkHR( DPERR_INVALIDPLAYER
, hr
);
2625 if ( hr
== DPERR_UNINITIALIZED
)
2627 todo_wine
win_skip( "Get/SetPlayerName not implemented\n" );
2632 hr
= IDirectPlayX_GetPlayerName( pDP
[0], 0, lpData
, &dwDataSize
);
2633 checkHR( DPERR_INVALIDPLAYER
, hr
);
2634 check( 1024, dwDataSize
);
2637 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
2638 dpsd
.guidApplication
= appGuid
;
2639 dpsd
.dwMaxPlayers
= 10;
2640 IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
2641 IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
2644 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[0], NULL
, NULL
, NULL
, 0, 0 );
2645 IDirectPlayX_CreatePlayer( pDP
[1], &dpid
[1], NULL
, NULL
, NULL
, 0, 0 );
2648 /* Name not initialized */
2649 playerName
.dwSize
= -1;
2650 hr
= IDirectPlayX_SetPlayerName( pDP
[0], dpid
[0], &playerName
, 0 );
2651 checkHR( DP_OK
, hr
);
2654 hr
= IDirectPlayX_GetPlayerName( pDP
[0], 0, lpData
, &dwDataSize
);
2655 checkHR( DPERR_INVALIDPLAYER
, hr
);
2656 check( 1024, dwDataSize
);
2659 playerName
.dwSize
= sizeof(DPNAME
);
2660 playerName
.lpszShortNameA
= (LPSTR
) "player_name";
2661 playerName
.lpszLongNameA
= (LPSTR
) "player_long_name";
2664 /* Invalid parameters */
2665 hr
= IDirectPlayX_SetPlayerName( pDP
[0], -1, &playerName
, 0 );
2666 checkHR( DPERR_INVALIDPLAYER
, hr
);
2667 hr
= IDirectPlayX_SetPlayerName( pDP
[0], 0, &playerName
, 0 );
2668 checkHR( DPERR_INVALIDPLAYER
, hr
);
2669 hr
= IDirectPlayX_SetPlayerName( pDP
[0], dpid
[0], &playerName
, -1 );
2670 checkHR( DPERR_INVALIDPARAMS
, hr
);
2673 hr
= IDirectPlayX_GetPlayerName( pDP
[0], 0, lpData
, &dwDataSize
);
2674 checkHR( DPERR_INVALIDPLAYER
, hr
);
2675 check( 1024, dwDataSize
);
2679 /* Crashes under Win7 */
2681 hr
= IDirectPlayX_GetPlayerName( pDP
[0], dpid
[0], lpData
, &dwDataSize
);
2682 checkHR( DPERR_INVALIDPARAMS
, hr
);
2683 check( -1, dwDataSize
);
2686 hr
= IDirectPlayX_GetPlayerName( pDP
[0], dpid
[0], lpData
, NULL
);
2687 checkHR( DPERR_INVALIDPARAMS
, hr
);
2689 /* Trying to modify remote player */
2690 hr
= IDirectPlayX_SetPlayerName( pDP
[0], dpid
[1], &playerName
, 0 );
2691 checkHR( DPERR_ACCESSDENIED
, hr
);
2694 /* Regular operation */
2695 hr
= IDirectPlayX_SetPlayerName( pDP
[0], dpid
[0], &playerName
, 0 );
2696 checkHR( DP_OK
, hr
);
2698 hr
= IDirectPlayX_GetPlayerName( pDP
[0], dpid
[0], lpData
, &dwDataSize
);
2699 checkHR( DP_OK
, hr
);
2700 check( 45, dwDataSize
);
2701 checkStr( playerName
.lpszShortNameA
, ((LPDPNAME
)lpData
)->lpszShortNameA
);
2702 checkStr( playerName
.lpszLongNameA
, ((LPDPNAME
)lpData
)->lpszLongNameA
);
2703 check( 0, ((LPDPNAME
)lpData
)->dwFlags
);
2705 hr
= IDirectPlayX_SetPlayerName( pDP
[0], dpid
[0], NULL
, 0 );
2706 checkHR( DP_OK
, hr
);
2708 hr
= IDirectPlayX_GetPlayerName( pDP
[0], dpid
[0], lpData
, &dwDataSize
);
2709 checkHR( DP_OK
, hr
);
2710 check( 16, dwDataSize
);
2711 checkLP( NULL
, ((LPDPNAME
)lpData
)->lpszShortNameA
);
2712 checkLP( NULL
, ((LPDPNAME
)lpData
)->lpszLongNameA
);
2713 check( 0, ((LPDPNAME
)lpData
)->dwFlags
);
2716 /* Small buffer in get operation */
2718 hr
= IDirectPlayX_GetPlayerName( pDP
[0], dpid
[0], NULL
, &dwDataSize
);
2719 checkHR( DPERR_BUFFERTOOSMALL
, hr
);
2720 check( 16, dwDataSize
);
2723 hr
= IDirectPlayX_GetPlayerName( pDP
[0], dpid
[0], lpData
, &dwDataSize
);
2724 checkHR( DPERR_BUFFERTOOSMALL
, hr
);
2725 check( 16, dwDataSize
);
2727 hr
= IDirectPlayX_GetPlayerName( pDP
[0], dpid
[0], lpData
, &dwDataSize
);
2728 checkHR( DP_OK
, hr
);
2729 check( 16, dwDataSize
);
2730 checkLP( NULL
, ((LPDPNAME
)lpData
)->lpszShortNameA
);
2731 checkLP( NULL
, ((LPDPNAME
)lpData
)->lpszLongNameA
);
2732 check( 0, ((LPDPNAME
)lpData
)->dwFlags
);
2736 hr
= IDirectPlayX_SetPlayerName( pDP
[0], dpid
[0], &playerName
,
2738 checkHR( DP_OK
, hr
);
2740 hr
= IDirectPlayX_GetPlayerName( pDP
[0], dpid
[0], lpData
, &dwDataSize
);
2741 checkHR( DP_OK
, hr
);
2742 check( 45, dwDataSize
);
2743 checkStr( playerName
.lpszShortNameA
, ((LPDPNAME
)lpData
)->lpszShortNameA
);
2744 checkStr( playerName
.lpszLongNameA
, ((LPDPNAME
)lpData
)->lpszLongNameA
);
2745 check( 0, ((LPDPNAME
)lpData
)->dwFlags
);
2747 /* - Local (no propagation) */
2748 playerName
.lpszShortNameA
= (LPSTR
) "no_propagation";
2749 hr
= IDirectPlayX_SetPlayerName( pDP
[0], dpid
[0], &playerName
,
2751 checkHR( DP_OK
, hr
);
2754 hr
= IDirectPlayX_GetPlayerName( pDP
[0], dpid
[0],
2755 lpData
, &dwDataSize
); /* Local fetch */
2756 checkHR( DP_OK
, hr
);
2757 check( 48, dwDataSize
);
2758 checkStr( "no_propagation", ((LPDPNAME
)lpData
)->lpszShortNameA
);
2761 hr
= IDirectPlayX_GetPlayerName( pDP
[1], dpid
[0],
2762 lpData
, &dwDataSize
); /* Remote fetch */
2763 checkHR( DP_OK
, hr
);
2764 check( 45, dwDataSize
);
2765 checkStr( "player_name", ((LPDPNAME
)lpData
)->lpszShortNameA
);
2769 playerName
.lpszShortNameA
= (LPSTR
) "no_propagation_2";
2770 hr
= IDirectPlayX_SetPlayerName( pDP
[0], dpid
[0], &playerName
,
2771 DPSET_LOCAL
| DPSET_REMOTE
);
2772 checkHR( DP_OK
, hr
);
2775 hr
= IDirectPlayX_GetPlayerName( pDP
[0], dpid
[0],
2776 lpData
, &dwDataSize
); /* Local fetch */
2777 checkHR( DP_OK
, hr
);
2778 check( 50, dwDataSize
);
2779 checkStr( "no_propagation_2", ((LPDPNAME
)lpData
)->lpszShortNameA
);
2782 hr
= IDirectPlayX_GetPlayerName( pDP
[1], dpid
[0],
2783 lpData
, &dwDataSize
); /* Remote fetch */
2784 checkHR( DP_OK
, hr
);
2785 check( 45, dwDataSize
);
2786 checkStr( "player_name", ((LPDPNAME
)lpData
)->lpszShortNameA
);
2788 /* - Remote (propagation, default) */
2789 playerName
.lpszShortNameA
= (LPSTR
) "propagation";
2790 hr
= IDirectPlayX_SetPlayerName( pDP
[0], dpid
[0], &playerName
,
2792 checkHR( DP_OK
, hr
);
2795 hr
= IDirectPlayX_GetPlayerName( pDP
[1], dpid
[0],
2796 lpData
, &dwDataSize
); /* Remote fetch */
2797 checkHR( DP_OK
, hr
);
2798 check( 45, dwDataSize
);
2799 checkStr( "propagation", ((LPDPNAME
)lpData
)->lpszShortNameA
);
2802 playerName
.lpszShortNameA
= (LPSTR
) "propagation_2";
2803 hr
= IDirectPlayX_SetPlayerName( pDP
[0], dpid
[0], &playerName
,
2805 checkHR( DP_OK
, hr
);
2808 hr
= IDirectPlayX_GetPlayerName( pDP
[1], dpid
[0],
2809 lpData
, &dwDataSize
); /* Remote fetch */
2810 checkHR( DP_OK
, hr
);
2811 check( 47, dwDataSize
);
2812 checkStr( "propagation_2", ((LPDPNAME
)lpData
)->lpszShortNameA
);
2815 /* Checking system messages */
2816 check_messages( pDP
[0], dpid
, 2, &callbackData
);
2817 checkStr( "S0,S0,S0,S0,S0,S0,S0,", callbackData
.szTrace1
);
2818 checkStr( "48,28,57,28,57,57,59,", callbackData
.szTrace2
);
2819 check_messages( pDP
[1], dpid
, 2, &callbackData
);
2820 checkStr( "S1,S1,S1,S1,S1,S1,", callbackData
.szTrace1
);
2821 checkStr( "28,57,28,57,57,59,", callbackData
.szTrace2
);
2824 HeapFree( GetProcessHeap(), 0, lpData
);
2825 IDirectPlayX_Release( pDP
[0] );
2826 IDirectPlayX_Release( pDP
[1] );
2830 /* GetPlayerAccount */
2832 static BOOL CALLBACK
EnumSessions_cb_join_secure( LPCDPSESSIONDESC2 lpThisSD
,
2833 LPDWORD lpdwTimeOut
,
2837 IDirectPlay4
*pDP
= lpContext
;
2838 DPSESSIONDESC2 dpsd
;
2839 DPCREDENTIALS dpCredentials
;
2842 if (dwFlags
& DPESC_TIMEDOUT
)
2847 checkFlags( DPSESSION_SECURESERVER
, lpThisSD
->dwFlags
, FLAGS_DPSESSION
);
2849 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
2850 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
2851 dpsd
.guidApplication
= appGuid
;
2852 dpsd
.guidInstance
= lpThisSD
->guidInstance
;
2854 ZeroMemory( &dpCredentials
, sizeof(DPCREDENTIALS
) );
2855 dpCredentials
.dwSize
= sizeof(DPCREDENTIALS
);
2856 dpCredentials
.lpszUsernameA
= (LPSTR
) "user";
2857 dpCredentials
.lpszPasswordA
= (LPSTR
) "pass";
2858 hr
= IDirectPlayX_SecureOpen( pDP
, &dpsd
, DPOPEN_JOIN
,
2859 NULL
, &dpCredentials
);
2860 checkHR( DPERR_LOGONDENIED
, hr
); /* TODO: Make this work */
2865 static void test_GetPlayerAccount(void)
2868 IDirectPlay4
*pDP
[2];
2869 DPSESSIONDESC2 dpsd
;
2874 DWORD dwDataSize
= 1024;
2875 LPVOID lpData
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, dwDataSize
);
2880 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
2881 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
2882 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
2883 if (FAILED(hr
)) return;
2885 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
2886 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
2887 dpsd
.guidApplication
= appGuid
;
2888 dpsd
.dwMaxPlayers
= 10;
2890 /* Uninitialized service provider */
2891 hr
= IDirectPlayX_GetPlayerAccount( pDP
[0], 0, 0, lpData
, &dwDataSize
);
2892 todo_wine
checkHR( DPERR_UNINITIALIZED
, hr
);
2896 todo_wine
win_skip( "GetPlayerAccount not implemented\n" );
2901 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
2902 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
2906 hr
= IDirectPlayX_GetPlayerAccount( pDP
[0], 0, 0, lpData
, &dwDataSize
);
2907 checkHR( DPERR_NOSESSIONS
, hr
);
2910 IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
2911 IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
2916 hr
= IDirectPlayX_CreatePlayer( pDP
[i
], &dpid
[i
], NULL
, NULL
, NULL
,
2918 checkHR( DP_OK
, hr
);
2922 /* Session is not secure */
2924 hr
= IDirectPlayX_GetPlayerAccount( pDP
[0], dpid
[0], 0,
2925 lpData
, &dwDataSize
);
2926 checkHR( DPERR_UNSUPPORTED
, hr
);
2927 check( 1024, dwDataSize
);
2930 /* Open a secure session */
2933 hr
= IDirectPlayX_Close( pDP
[i
] );
2934 checkHR( DP_OK
, hr
);
2937 dpsd
.dwFlags
= DPSESSION_SECURESERVER
;
2938 hr
= IDirectPlayX_SecureOpen( pDP
[0], &dpsd
, DPOPEN_CREATE
, NULL
, NULL
);
2939 checkHR( DP_OK
, hr
);
2941 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[0],
2942 NULL
, NULL
, NULL
, 0, 0 );
2943 checkHR( DP_OK
, hr
);
2945 hr
= IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0,
2946 EnumSessions_cb_join_secure
, pDP
[1], 0 );
2947 checkHR( DP_OK
, hr
);
2949 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &dpid
[1],
2950 NULL
, NULL
, NULL
, 0, 0 );
2951 checkHR( DPERR_INVALIDPARAMS
, hr
);
2953 /* TODO: Player creation so that this works */
2955 /* Invalid player */
2957 hr
= IDirectPlayX_GetPlayerAccount( pDP
[0], 0, 0,
2958 lpData
, &dwDataSize
);
2959 checkHR( DPERR_INVALIDPLAYER
, hr
);
2960 check( 1024, dwDataSize
);
2964 hr
= IDirectPlayX_GetPlayerAccount( pDP
[0], dpid
[0], -1,
2965 lpData
, &dwDataSize
);
2966 checkHR( DPERR_INVALIDFLAGS
, hr
);
2967 check( 1024, dwDataSize
);
2970 hr
= IDirectPlayX_GetPlayerAccount( pDP
[0], dpid
[0], 1,
2971 lpData
, &dwDataSize
);
2972 checkHR( DPERR_INVALIDFLAGS
, hr
);
2973 check( 1024, dwDataSize
);
2977 hr
= IDirectPlayX_GetPlayerAccount( pDP
[0], dpid
[0], 0,
2978 NULL
, &dwDataSize
);
2979 checkHR( DPERR_INVALIDPLAYER
, hr
);
2980 check( 0, dwDataSize
);
2983 hr
= IDirectPlayX_GetPlayerAccount( pDP
[0], dpid
[0], 0,
2984 lpData
, &dwDataSize
);
2985 checkHR( DPERR_INVALIDPLAYER
, hr
);
2986 check( 0, dwDataSize
);
2988 hr
= IDirectPlayX_GetPlayerAccount( pDP
[0], dpid
[0], 0,
2989 lpData
, &dwDataSize
);
2990 checkHR( DPERR_INVALIDPLAYER
, hr
);
2991 check( 0, dwDataSize
);
2993 /* Normal operation */
2995 hr
= IDirectPlayX_GetPlayerAccount( pDP
[0], dpid
[0], 0,
2996 lpData
, &dwDataSize
);
2997 checkHR( DPERR_INVALIDPLAYER
, hr
);
2998 check( 1024, dwDataSize
);
3001 HeapFree( GetProcessHeap(), 0, lpData
);
3002 IDirectPlayX_Release( pDP
[0] );
3003 IDirectPlayX_Release( pDP
[1] );
3007 /* GetPlayerAddress */
3009 static BOOL CALLBACK
EnumAddress_cb( REFGUID guidDataType
,
3014 lpCallbackData callbackData
= lpContext
;
3015 static REFGUID types
[] = { &DPAID_TotalSize
,
3016 &DPAID_ServiceProvider
,
3019 static DWORD sizes
[] = { 4, 16, 12, 24, 4, 16, 10, 20 };
3022 checkGuid( types
[callbackData
->dwCounter1
%4], guidDataType
);
3023 check( sizes
[callbackData
->dwCounter1
], dwDataSize
);
3025 switch(callbackData
->dwCounter1
)
3028 check( 136, *(LPDWORD
) lpData
);
3031 check( 130, *(LPDWORD
) lpData
);
3035 checkGuid( &DPSPGUID_TCPIP
, lpData
);
3038 checkStr( "127.0.0.1", (LPSTR
) lpData
);
3044 callbackData
->dwCounter1
++;
3049 static void test_GetPlayerAddress(void)
3052 IDirectPlay4
*pDP
[2];
3053 IDirectPlayLobby3
*pDPL
;
3054 DPSESSIONDESC2 dpsd
;
3056 CallbackData callbackData
;
3060 DWORD dwDataSize
= 1024;
3061 LPVOID lpData
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, dwDataSize
);
3066 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
3067 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
3068 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
3069 if (FAILED(hr
)) return;
3071 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
3072 hr
= CoCreateInstance( &CLSID_DirectPlayLobby
, NULL
, CLSCTX_ALL
,
3073 &IID_IDirectPlayLobby3A
, (LPVOID
*) &pDPL
);
3074 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlayLobby / IID_IDirectPlayLobby3A failed\n" );
3075 if (FAILED(hr
)) return;
3077 /* Uninitialized service provider */
3078 hr
= IDirectPlayX_GetPlayerAddress( pDP
[0], 0, lpData
, &dwDataSize
);
3079 todo_wine
checkHR( DPERR_UNINITIALIZED
, hr
);
3083 todo_wine
win_skip( "GetPlayerAddress not implemented\n" );
3087 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
3088 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
3093 hr
= IDirectPlayX_GetPlayerAddress( pDP
[0], 0, lpData
, &dwDataSize
);
3094 checkHR( DPERR_UNSUPPORTED
, hr
);
3095 check( 1024, dwDataSize
);
3098 hr
= IDirectPlayX_GetPlayerAddress( pDP
[0], 1, lpData
, &dwDataSize
);
3099 checkHR( DPERR_INVALIDPLAYER
, hr
);
3100 check( 1024, dwDataSize
);
3103 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
3104 dpsd
.guidApplication
= appGuid
;
3105 dpsd
.dwMaxPlayers
= 10;
3106 IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
3107 IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
3112 hr
= IDirectPlayX_CreatePlayer( pDP
[i
], &dpid
[i
], NULL
, NULL
, NULL
,
3114 checkHR( DP_OK
, hr
);
3117 /* Invalid player */
3119 hr
= IDirectPlayX_GetPlayerAddress( pDP
[0], 0,
3120 lpData
, &dwDataSize
);
3121 checkHR( DPERR_UNSUPPORTED
, hr
);
3122 check( 1024, dwDataSize
);
3125 hr
= IDirectPlayX_GetPlayerAddress( pDP
[0], 1,
3126 lpData
, &dwDataSize
);
3127 checkHR( DPERR_INVALIDPLAYER
, hr
);
3128 check( 1024, dwDataSize
);
3132 hr
= IDirectPlayX_GetPlayerAddress( pDP
[0], dpid
[0],
3133 NULL
, &dwDataSize
);
3134 checkHR( DPERR_BUFFERTOOSMALL
, hr
);
3135 check( 136, dwDataSize
);
3138 hr
= IDirectPlayX_GetPlayerAddress( pDP
[0], dpid
[0],
3139 lpData
, &dwDataSize
);
3140 checkHR( DPERR_BUFFERTOOSMALL
, hr
);
3141 check( 136, dwDataSize
);
3143 hr
= IDirectPlayX_GetPlayerAddress( pDP
[0], dpid
[0],
3144 lpData
, &dwDataSize
);
3145 checkHR( DP_OK
, hr
);
3146 check( 136, dwDataSize
);
3149 /* Regular parameters */
3150 callbackData
.dwCounter1
= 0;
3154 hr
= IDirectPlayX_GetPlayerAddress( pDP
[0], dpid
[0],
3155 lpData
, &dwDataSize
);
3156 checkHR( DP_OK
, hr
);
3157 check( 136, dwDataSize
);
3159 hr
= IDirectPlayLobby_EnumAddress( pDPL
, EnumAddress_cb
, lpData
, dwDataSize
,
3161 checkHR( DP_OK
, hr
);
3163 check( 4, callbackData
.dwCounter1
);
3167 hr
= IDirectPlayX_GetPlayerAddress( pDP
[0], dpid
[1],
3168 lpData
, &dwDataSize
);
3169 checkHR( DP_OK
, hr
);
3170 check( 130, dwDataSize
);
3172 hr
= IDirectPlayLobby_EnumAddress( pDPL
, EnumAddress_cb
, lpData
, dwDataSize
,
3174 checkHR( DP_OK
, hr
);
3176 check( 8, callbackData
.dwCounter1
);
3179 HeapFree( GetProcessHeap(), 0, lpData
);
3182 IDirectPlayX_Release( pDP
[0] );
3183 IDirectPlayX_Release( pDP
[1] );
3184 IDirectPlayLobby_Release(pDPL
);
3187 /* GetPlayerFlags */
3189 static void test_GetPlayerFlags(void)
3192 IDirectPlay4
*pDP
[2];
3193 DPSESSIONDESC2 dpsd
;
3203 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
3204 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
3205 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
3206 if (FAILED(hr
)) return;
3208 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
3209 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
3210 dpsd
.guidApplication
= appGuid
;
3211 dpsd
.dwMaxPlayers
= 10;
3213 /* Uninitialized service provider */
3214 hr
= IDirectPlayX_GetPlayerFlags( pDP
[0], 0, &dwFlags
);
3215 todo_wine
checkHR( DPERR_UNINITIALIZED
, hr
);
3219 todo_wine
win_skip( "GetPlayerFlags not implemented\n" );
3223 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
3224 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
3228 hr
= IDirectPlayX_GetPlayerFlags( pDP
[0], 0, &dwFlags
);
3229 checkHR( DPERR_INVALIDPLAYER
, hr
);
3231 hr
= IDirectPlayX_GetPlayerFlags( pDP
[0], 1, &dwFlags
);
3232 checkHR( DPERR_INVALIDPLAYER
, hr
);
3235 IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
3236 IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
3241 hr
= IDirectPlayX_CreatePlayer( pDP
[i
], &dpid
[i
],
3242 NULL
, NULL
, NULL
, 0, 0 );
3243 checkHR( DP_OK
, hr
);
3245 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[2],
3247 0, DPPLAYER_SPECTATOR
);
3248 checkHR( DP_OK
, hr
);
3249 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[3],
3251 0, DPPLAYER_SERVERPLAYER
);
3252 checkHR( DP_OK
, hr
);
3255 /* Invalid player */
3256 hr
= IDirectPlayX_GetPlayerFlags( pDP
[0], 0, &dwFlags
);
3257 checkHR( DPERR_INVALIDPLAYER
, hr
);
3259 hr
= IDirectPlayX_GetPlayerFlags( pDP
[0], 2, &dwFlags
);
3260 checkHR( DPERR_INVALIDPLAYER
, hr
);
3262 /* Invalid parameters */
3263 hr
= IDirectPlayX_GetPlayerFlags( pDP
[0], dpid
[0], NULL
);
3264 checkHR( DPERR_INVALIDPARAMS
, hr
);
3267 /* Regular parameters */
3268 hr
= IDirectPlayX_GetPlayerFlags( pDP
[0], dpid
[0], &dwFlags
);
3269 checkHR( DP_OK
, hr
);
3270 checkFlags( dwFlags
, DPPLAYER_LOCAL
, FLAGS_DPPLAYER
);
3272 hr
= IDirectPlayX_GetPlayerFlags( pDP
[1], dpid
[1], &dwFlags
);
3273 checkHR( DP_OK
, hr
);
3274 checkFlags( dwFlags
, DPPLAYER_LOCAL
, FLAGS_DPPLAYER
);
3276 hr
= IDirectPlayX_GetPlayerFlags( pDP
[0], dpid
[1], &dwFlags
);
3277 checkHR( DP_OK
, hr
);
3278 checkFlags( dwFlags
, 0, FLAGS_DPPLAYER
);
3280 hr
= IDirectPlayX_GetPlayerFlags( pDP
[0], dpid
[2], &dwFlags
);
3281 checkHR( DP_OK
, hr
);
3282 checkFlags( dwFlags
, DPPLAYER_SPECTATOR
| DPPLAYER_LOCAL
, FLAGS_DPPLAYER
);
3284 hr
= IDirectPlayX_GetPlayerFlags( pDP
[1], dpid
[3], &dwFlags
);
3285 checkHR( DP_OK
, hr
);
3286 checkFlags( dwFlags
, DPPLAYER_SERVERPLAYER
, FLAGS_DPPLAYER
);
3289 IDirectPlayX_Release( pDP
[0] );
3290 IDirectPlayX_Release( pDP
[1] );
3295 CreateGroupInGroup */
3297 static void test_CreateGroup(void)
3301 DPSESSIONDESC2 dpsd
;
3302 DPID idFrom
, idTo
, dpid
, idGroup
, idGroupParent
;
3307 LPCSTR lpData
= "data";
3308 DWORD dwDataSize
= strlen(lpData
)+1;
3309 LPDPMSG_CREATEPLAYERORGROUP lpDataGet
= HeapAlloc( GetProcessHeap(),
3312 DWORD dwDataSizeGet
= 1024;
3313 CallbackData callbackData
;
3316 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
3317 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
);
3318 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
3319 if (FAILED(hr
)) return;
3320 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
3321 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
3322 dpsd
.guidApplication
= appGuid
;
3323 dpsd
.dwMaxPlayers
= 10;
3324 ZeroMemory( &groupName
, sizeof(DPNAME
) );
3327 /* No service provider */
3328 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
, NULL
, NULL
, 0, 0 );
3329 checkHR( DPERR_UNINITIALIZED
, hr
);
3331 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, 0, &idGroup
, NULL
, NULL
, 0, 0 );
3332 checkHR( DPERR_UNINITIALIZED
, hr
);
3336 init_TCPIP_provider( pDP
, "127.0.0.1", 0 );
3340 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3342 todo_wine
checkHR( DPERR_INVALIDPARAMS
, hr
);
3344 if ( hr
== DPERR_UNINITIALIZED
)
3346 todo_wine
win_skip( "CreateGroup not implemented\n" );
3350 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, 0, &idGroup
,
3352 checkHR( DPERR_INVALIDGROUP
, hr
);
3354 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, 2, &idGroup
,
3356 checkHR( DPERR_INVALIDGROUP
, hr
);
3359 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_CREATE
);
3360 checkHR( DP_OK
, hr
);
3361 IDirectPlayX_CreatePlayer( pDP
, &dpid
,
3362 NULL
, NULL
, NULL
, 0, 0 );
3367 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3369 checkHR( DP_OK
, hr
);
3371 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, idGroup
, &idGroup
,
3373 checkHR( DP_OK
, hr
);
3375 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3376 &groupName
, NULL
, 0, 0 );
3377 checkHR( DP_OK
, hr
);
3379 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, idGroup
, &idGroup
,
3380 &groupName
, NULL
, 0, 0 );
3381 checkHR( DP_OK
, hr
);
3384 groupName
.dwSize
= sizeof(DPNAME
);
3385 groupName
.lpszShortNameA
= (LPSTR
) lpData
;
3388 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3389 &groupName
, NULL
, 0, 0 );
3390 checkHR( DP_OK
, hr
);
3392 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, idGroup
, &idGroup
,
3393 &groupName
, NULL
, 0, 0 );
3394 checkHR( DP_OK
, hr
);
3397 /* Message checking */
3400 dwDataSizeGet
= 1024;
3401 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0, lpDataGet
,
3403 checkHR( DP_OK
, hr
);
3404 if ( NULL
== lpDataGet
->dpnName
.lpszShortNameA
)
3406 check( 48, dwDataSizeGet
);
3410 check( 48 + dwDataSize
, dwDataSizeGet
);
3411 checkStr( lpData
, lpDataGet
->dpnName
.lpszShortNameA
);
3413 check( DPID_SYSMSG
, idFrom
);
3414 checkConv( DPSYS_CREATEPLAYERORGROUP
, lpDataGet
->dwType
, dpMsgType2str
);
3415 check( DPPLAYERTYPE_GROUP
, lpDataGet
->dwPlayerType
);
3416 checkFlags( DPGROUP_LOCAL
, lpDataGet
->dwFlags
, FLAGS_DPGROUP
);
3418 check_messages( pDP
, &dpid
, 1, &callbackData
);
3419 checkStr( "", callbackData
.szTrace1
);
3423 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3424 NULL
, (LPVOID
) lpData
, -1, 0 );
3425 checkHR( DPERR_INVALIDPARAMS
, hr
);
3427 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3428 NULL
, (LPVOID
) lpData
, 0, 0 );
3429 checkHR( DP_OK
, hr
);
3431 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3432 NULL
, NULL
, dwDataSize
, 0 );
3433 checkHR( DPERR_INVALIDPARAMS
, hr
);
3435 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3436 NULL
, (LPVOID
) lpData
, dwDataSize
, 0 );
3437 checkHR( DP_OK
, hr
);
3440 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, idGroup
, &idGroup
,
3441 NULL
, (LPVOID
) lpData
, -1, 0 );
3442 checkHR( DPERR_INVALIDPARAMS
, hr
);
3444 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, idGroup
, &idGroup
,
3445 NULL
, (LPVOID
) lpData
, 0, 0 );
3446 checkHR( DP_OK
, hr
);
3448 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, idGroup
, &idGroup
,
3449 NULL
, NULL
, dwDataSize
, 0 );
3450 checkHR( DPERR_INVALIDPARAMS
, hr
);
3452 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, idGroup
, &idGroup
,
3453 NULL
, (LPVOID
)lpData
, dwDataSize
, 0 );
3454 checkHR( DP_OK
, hr
);
3457 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroupParent
,
3459 checkHR( DP_OK
, hr
);
3462 /* Message checking */
3465 dwDataSizeGet
= 1024;
3466 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0, lpDataGet
,
3468 checkHR( DP_OK
, hr
);
3469 check( 48 + lpDataGet
->dwDataSize
, dwDataSizeGet
);
3470 check( DPID_SYSMSG
, idFrom
);
3471 checkConv( DPSYS_CREATEPLAYERORGROUP
, lpDataGet
->dwType
, dpMsgType2str
);
3472 check( DPPLAYERTYPE_GROUP
, lpDataGet
->dwPlayerType
);
3473 checkFlags( DPGROUP_LOCAL
, lpDataGet
->dwFlags
, FLAGS_DPGROUP
);
3475 check_messages( pDP
, &dpid
, 1, &callbackData
);
3476 checkStr( "", callbackData
.szTrace1
);
3479 /* Flags and idGroupParent */
3480 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3482 checkHR( DP_OK
, hr
);
3484 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3485 NULL
, NULL
, 0, DPGROUP_HIDDEN
);
3486 checkHR( DP_OK
, hr
);
3488 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3489 NULL
, NULL
, 0, DPGROUP_STAGINGAREA
);
3490 checkHR( DP_OK
, hr
);
3492 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3494 DPGROUP_HIDDEN
| DPGROUP_STAGINGAREA
);
3495 checkHR( DP_OK
, hr
);
3498 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, idGroupParent
, &idGroup
,
3500 checkHR( DP_OK
, hr
);
3502 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, idGroupParent
, &idGroup
,
3503 NULL
, NULL
, 0, DPGROUP_HIDDEN
);
3504 checkHR( DP_OK
, hr
);
3506 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, idGroupParent
, &idGroup
,
3507 NULL
, NULL
, 0, DPGROUP_STAGINGAREA
);
3508 checkHR( DP_OK
, hr
);
3510 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, idGroupParent
, &idGroup
,
3513 DPGROUP_STAGINGAREA
);
3514 checkHR( DP_OK
, hr
);
3517 /* Message checking */
3520 dwDataSizeGet
= 1024;
3521 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0, lpDataGet
,
3523 checkHR( DP_OK
, hr
);
3524 check( 48, dwDataSizeGet
);
3525 check( DPID_SYSMSG
, idFrom
);
3526 checkConv( DPSYS_CREATEPLAYERORGROUP
, lpDataGet
->dwType
, dpMsgType2str
);
3527 check( DPPLAYERTYPE_GROUP
, lpDataGet
->dwPlayerType
);
3529 if ( lpDataGet
->dpIdParent
!= 0 )
3531 check( idGroupParent
, lpDataGet
->dpIdParent
);
3537 checkFlags( DPGROUP_LOCAL
,
3538 lpDataGet
->dwFlags
, FLAGS_DPGROUP
);
3541 checkFlags( DPGROUP_LOCAL
| DPGROUP_HIDDEN
,
3542 lpDataGet
->dwFlags
, FLAGS_DPGROUP
);
3545 checkFlags( DPGROUP_STAGINGAREA
| DPGROUP_LOCAL
,
3546 lpDataGet
->dwFlags
, FLAGS_DPGROUP
);
3549 checkFlags( DPGROUP_STAGINGAREA
| DPGROUP_LOCAL
| DPGROUP_HIDDEN
,
3550 lpDataGet
->dwFlags
, FLAGS_DPGROUP
);
3555 check_messages( pDP
, &dpid
, 1, &callbackData
);
3556 checkStr( "", callbackData
.szTrace1
);
3559 /* If a group is created in C/S mode, no messages are sent */
3562 IDirectPlayX_Close( pDP
);
3565 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_CREATE
);
3566 checkHR( DP_OK
, hr
);
3567 hr
= IDirectPlayX_CreatePlayer( pDP
, &dpid
, NULL
, NULL
, NULL
, 0, 0 );
3568 checkHR( DP_OK
, hr
);
3570 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
, NULL
, NULL
, 0, 0 );
3571 checkHR( DP_OK
, hr
);
3573 /* Messages are received */
3574 check_messages( pDP
, &dpid
, 1, &callbackData
);
3575 checkStr( "S0,", callbackData
.szTrace1
);
3578 /* - Client/Server */
3579 IDirectPlayX_Close( pDP
);
3581 dpsd
.dwFlags
= DPSESSION_CLIENTSERVER
;
3582 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_CREATE
);
3583 checkHR( DP_OK
, hr
);
3584 hr
= IDirectPlayX_CreatePlayer( pDP
, &dpid
,
3585 NULL
, NULL
, NULL
, 0,
3586 DPPLAYER_SERVERPLAYER
);
3587 checkHR( DP_OK
, hr
);
3589 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3591 checkHR( DP_OK
, hr
);
3594 check_messages( pDP
, &dpid
, 1, &callbackData
);
3595 checkStr( "S0,", callbackData
.szTrace1
); /* Or at least there
3596 shouldn't be messages... */
3599 HeapFree( GetProcessHeap(), 0, lpDataGet
);
3600 IDirectPlayX_Release( pDP
);
3606 static void test_GroupOwner(void)
3609 IDirectPlay4
*pDP
[2];
3610 DPSESSIONDESC2 dpsd
;
3611 DPID dpid
[2], idGroup
, idOwner
;
3618 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
3619 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
3620 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
3621 if (FAILED(hr
)) return;
3623 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
3624 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
3625 dpsd
.guidApplication
= appGuid
;
3626 dpsd
.dwMaxPlayers
= 10;
3630 /* Service provider not initialized */
3631 hr
= IDirectPlayX_GetGroupOwner( pDP
[0], idGroup
, &idOwner
);
3632 todo_wine
checkHR( DPERR_UNINITIALIZED
, hr
);
3633 check( 0, idOwner
);
3637 todo_wine
win_skip( "GetGroupOwner not implemented\n" );
3643 init_TCPIP_provider( pDP
[i
], "127.0.0.1", 0 );
3645 hr
= IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
3646 checkHR( DP_OK
, hr
);
3647 hr
= IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
3649 checkHR( DP_OK
, hr
);
3653 hr
= IDirectPlayX_CreatePlayer( pDP
[i
], &dpid
[i
],
3654 NULL
, NULL
, NULL
, 0, 0 );
3655 checkHR( DP_OK
, hr
);
3659 hr
= IDirectPlayX_GetGroupOwner( pDP
[0], idGroup
, &idOwner
);
3660 checkHR( DPERR_INVALIDGROUP
, hr
);
3662 hr
= IDirectPlayX_CreateGroup( pDP
[0], &idGroup
, NULL
, NULL
, 0, 0 );
3663 checkHR( DP_OK
, hr
);
3665 /* Fails, because we need a lobby session */
3666 hr
= IDirectPlayX_GetGroupOwner( pDP
[0], idGroup
, &idOwner
);
3667 checkHR( DPERR_UNSUPPORTED
, hr
);
3672 * - Check migration of the ownership of a group
3673 * when the owner leaves
3677 IDirectPlayX_Release( pDP
[0] );
3678 IDirectPlayX_Release( pDP
[1] );
3684 static BOOL CALLBACK
EnumPlayers_cb( DPID dpId
,
3690 lpCallbackData callbackData
= lpContext
;
3691 char playerIndex
= dpid2char( callbackData
->dpid
,
3692 callbackData
->dpidSize
,
3696 /* Trace to study player ids */
3697 callbackData
->szTrace1
[ callbackData
->dwCounter1
] = playerIndex
;
3698 callbackData
->dwCounter1
++;
3699 callbackData
->szTrace1
[ callbackData
->dwCounter1
] = '\0';
3701 /* Trace to study flags received */
3702 strcat( callbackData
->szTrace2
,
3703 ( dwFlags2str(dwFlags
, FLAGS_DPENUMPLAYERS
) +
3704 strlen("DPENUMPLAYERS_") ) );
3705 strcat( callbackData
->szTrace2
, ":" );
3708 if ( playerIndex
< '5' )
3710 check( DPPLAYERTYPE_PLAYER
, dwPlayerType
);
3714 check( DPPLAYERTYPE_GROUP
, dwPlayerType
);
3721 static BOOL CALLBACK
EnumSessions_cb_EnumPlayers( LPCDPSESSIONDESC2 lpThisSD
,
3722 LPDWORD lpdwTimeOut
,
3726 lpCallbackData callbackData
= lpContext
;
3729 if (dwFlags
& DPESC_TIMEDOUT
)
3735 callbackData
->dwCounter1
= 0;
3736 hr
= IDirectPlayX_EnumPlayers( callbackData
->pDP
, NULL
, EnumPlayers_cb
,
3738 checkHR( DPERR_NOSESSIONS
, hr
);
3739 check( 0, callbackData
->dwCounter1
);
3741 /* guid = appGuid */
3742 callbackData
->dwCounter1
= 0;
3743 hr
= IDirectPlayX_EnumPlayers( callbackData
->pDP
, (LPGUID
) &appGuid
,
3744 EnumPlayers_cb
, &callbackData
, 0 );
3745 checkHR( DPERR_NOSESSIONS
, hr
);
3746 check( 0, callbackData
->dwCounter1
);
3748 callbackData
->dwCounter1
= 0;
3749 hr
= IDirectPlayX_EnumPlayers( callbackData
->pDP
, (LPGUID
) &appGuid
,
3750 EnumPlayers_cb
, &callbackData
,
3751 DPENUMPLAYERS_SESSION
);
3752 checkHR( DPERR_NOSESSIONS
, hr
);
3753 check( 0, callbackData
->dwCounter1
);
3755 /* guid = guidInstance */
3756 callbackData
->dwCounter1
= 0;
3757 hr
= IDirectPlayX_EnumPlayers( callbackData
->pDP
,
3758 (LPGUID
) &lpThisSD
->guidInstance
,
3759 EnumPlayers_cb
, &callbackData
, 0 );
3760 checkHR( DPERR_NOSESSIONS
, hr
);
3761 check( 0, callbackData
->dwCounter1
);
3763 callbackData
->dwCounter1
= 0;
3764 hr
= IDirectPlayX_EnumPlayers( callbackData
->pDP
,
3765 (LPGUID
) &lpThisSD
->guidInstance
,
3766 EnumPlayers_cb
, &callbackData
,
3767 DPENUMPLAYERS_SESSION
);
3768 checkHR( DPERR_GENERIC
, hr
); /* Why? */
3769 check( 0, callbackData
->dwCounter1
);
3775 static void test_EnumPlayers(void)
3777 IDirectPlay4
*pDP
[3];
3778 DPSESSIONDESC2 dpsd
[3];
3779 DPID dpid
[5+2]; /* 5 players, 2 groups */
3780 CallbackData callbackData
;
3787 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
3788 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
3789 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
3790 if (FAILED(hr
)) return;
3792 ZeroMemory( &dpsd
[i
], sizeof(DPSESSIONDESC2
) );
3793 dpsd
[i
].dwSize
= sizeof(DPSESSIONDESC2
);
3796 dpsd
[0].guidApplication
= appGuid
;
3797 dpsd
[1].guidApplication
= appGuid2
;
3798 dpsd
[2].guidApplication
= GUID_NULL
;
3800 callbackData
.dpid
= dpid
;
3801 callbackData
.dpidSize
= 5+2;
3804 /* Uninitialized service provider */
3805 callbackData
.dwCounter1
= 0;
3806 hr
= IDirectPlayX_EnumPlayers( pDP
[0], (LPGUID
) &appGuid
, NULL
,
3808 checkHR( DPERR_UNINITIALIZED
, hr
);
3809 check( 0, callbackData
.dwCounter1
);
3812 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
3813 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
3814 init_TCPIP_provider( pDP
[2], "127.0.0.1", 0 );
3818 callbackData
.dwCounter1
= 0;
3819 hr
= IDirectPlayX_EnumPlayers( pDP
[0], NULL
, EnumPlayers_cb
,
3821 todo_wine
checkHR( DPERR_NOSESSIONS
, hr
);
3822 check( 0, callbackData
.dwCounter1
);
3824 if ( hr
== DPERR_UNINITIALIZED
)
3826 todo_wine
win_skip( "EnumPlayers not implemented\n" );
3830 callbackData
.dwCounter1
= 0;
3831 hr
= IDirectPlayX_EnumPlayers( pDP
[0], (LPGUID
) &appGuid
, EnumPlayers_cb
,
3833 checkHR( DPERR_NOSESSIONS
, hr
);
3834 check( 0, callbackData
.dwCounter1
);
3836 callbackData
.dwCounter1
= 0;
3837 hr
= IDirectPlayX_EnumPlayers( pDP
[0], (LPGUID
) &appGuid
, EnumPlayers_cb
,
3838 &callbackData
, DPENUMPLAYERS_SESSION
);
3839 checkHR( DPERR_NOSESSIONS
, hr
);
3840 check( 0, callbackData
.dwCounter1
);
3843 hr
= IDirectPlayX_Open( pDP
[0], &dpsd
[0], DPOPEN_CREATE
);
3844 checkHR( DP_OK
, hr
);
3845 hr
= IDirectPlayX_Open( pDP
[1], &dpsd
[1], DPOPEN_CREATE
);
3846 checkHR( DP_OK
, hr
);
3850 callbackData
.dwCounter1
= 0;
3851 hr
= IDirectPlayX_EnumPlayers( pDP
[0], NULL
, EnumPlayers_cb
,
3853 checkHR( DP_OK
, hr
);
3854 check( 0, callbackData
.dwCounter1
);
3857 /* Create players */
3858 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[0],
3859 NULL
, NULL
, NULL
, 0,
3860 DPPLAYER_SERVERPLAYER
);
3861 checkHR( DP_OK
, hr
);
3862 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &dpid
[1],
3863 NULL
, NULL
, NULL
, 0,
3865 checkHR( DP_OK
, hr
);
3867 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[2],
3868 NULL
, NULL
, NULL
, 0,
3870 checkHR( DP_OK
, hr
);
3871 hr
= IDirectPlayX_CreateGroup( pDP
[0], &dpid
[5],
3873 checkHR( DP_OK
, hr
);
3876 /* Invalid parameters */
3877 callbackData
.dwCounter1
= 0;
3878 hr
= IDirectPlayX_EnumPlayers( pDP
[0], (LPGUID
) &appGuid
, NULL
,
3880 checkHR( DPERR_INVALIDPARAMS
, hr
);
3881 check( 0, callbackData
.dwCounter1
);
3883 callbackData
.dwCounter1
= 0;
3884 hr
= IDirectPlayX_EnumPlayers( pDP
[0], NULL
, EnumPlayers_cb
,
3885 &callbackData
, DPENUMPLAYERS_SESSION
);
3886 checkHR( DPERR_INVALIDPARAMS
, hr
);
3887 check( 0, callbackData
.dwCounter1
);
3890 /* Regular operation */
3891 callbackData
.dwCounter1
= 0;
3892 callbackData
.szTrace2
[0] = 0;
3893 hr
= IDirectPlayX_EnumPlayers( pDP
[0], NULL
, EnumPlayers_cb
,
3895 checkHR( DP_OK
, hr
);
3896 check( 2, callbackData
.dwCounter1
);
3897 checkStr( "20", callbackData
.szTrace1
);
3898 checkStr( "ALL:SERVERPLAYER:", callbackData
.szTrace2
);
3900 callbackData
.dwCounter1
= 0;
3901 callbackData
.szTrace2
[0] = 0;
3902 hr
= IDirectPlayX_EnumPlayers( pDP
[1], NULL
, EnumPlayers_cb
,
3904 checkHR( DP_OK
, hr
);
3905 check( 1, callbackData
.dwCounter1
);
3906 checkStr( "1", callbackData
.szTrace1
);
3907 checkStr( "ALL:", callbackData
.szTrace2
);
3909 callbackData
.dwCounter1
= 0;
3910 callbackData
.szTrace2
[0] = 0;
3911 hr
= IDirectPlayX_EnumPlayers( pDP
[0], (LPGUID
) &appGuid
, EnumPlayers_cb
,
3913 checkHR( DP_OK
, hr
);
3914 check( 2, callbackData
.dwCounter1
); /* Guid is ignored */
3915 checkStr( "20", callbackData
.szTrace1
);
3916 checkStr( "ALL:SERVERPLAYER:", callbackData
.szTrace2
);
3919 /* Enumerating from a remote session */
3920 /* - Session not open */
3921 callbackData
.pDP
= pDP
[2];
3922 hr
= IDirectPlayX_EnumSessions( pDP
[2], &dpsd
[2], 0,
3923 EnumSessions_cb_EnumPlayers
,
3925 checkHR( DP_OK
, hr
);
3928 /* - Open session */
3929 callbackData
.pDP
= pDP
[2];
3930 hr
= IDirectPlayX_EnumSessions( pDP
[2], &dpsd
[0], 0, EnumSessions_cb_join
,
3932 checkHR( DP_OK
, hr
);
3933 hr
= IDirectPlayX_CreatePlayer( pDP
[2], &dpid
[3],
3934 NULL
, NULL
, NULL
, 0,
3935 DPPLAYER_SPECTATOR
);
3936 checkHR( DP_OK
, hr
);
3937 hr
= IDirectPlayX_CreatePlayer( pDP
[2], &dpid
[4],
3938 NULL
, NULL
, NULL
, 0,
3940 checkHR( DP_OK
, hr
);
3941 hr
= IDirectPlayX_CreateGroup( pDP
[2], &dpid
[6],
3943 checkHR( DP_OK
, hr
);
3945 callbackData
.dwCounter1
= 0;
3946 callbackData
.szTrace2
[0] = 0;
3947 hr
= IDirectPlayX_EnumPlayers( pDP
[2], NULL
, EnumPlayers_cb
,
3949 checkHR( DP_OK
, hr
);
3950 check( 4, callbackData
.dwCounter1
);
3951 checkStr( "4302", callbackData
.szTrace1
);
3952 checkStr( "ALL:SPECTATOR:SERVERPLAYER:ALL:", callbackData
.szTrace2
);
3957 callbackData
.dwCounter1
= 0;
3958 callbackData
.szTrace2
[0] = 0;
3959 hr
= IDirectPlayX_EnumPlayers( pDP
[2], NULL
, EnumPlayers_cb
,
3960 &callbackData
, DPENUMPLAYERS_ALL
);
3961 checkHR( DP_OK
, hr
);
3962 check( 4, callbackData
.dwCounter1
);
3963 checkStr( "4302", callbackData
.szTrace1
);
3964 checkStr( "ALL:SPECTATOR:SERVERPLAYER:ALL:", callbackData
.szTrace2
);
3966 callbackData
.dwCounter1
= 0;
3967 callbackData
.szTrace2
[0] = 0;
3968 hr
= IDirectPlayX_EnumPlayers( pDP
[2], NULL
, EnumPlayers_cb
,
3969 &callbackData
, DPENUMPLAYERS_GROUP
);
3970 checkHR( DP_OK
, hr
);
3971 check( 6, callbackData
.dwCounter1
);
3972 checkStr( "430256", callbackData
.szTrace1
);
3974 "GROUP,DPENUMPLAYERS_SPECTATOR:"
3975 "GROUP,DPENUMPLAYERS_SERVERPLAYER:"
3976 "GROUP:ALL:ALL:", callbackData
.szTrace2
);
3978 callbackData
.dwCounter1
= 0;
3979 callbackData
.szTrace2
[0] = 0;
3980 hr
= IDirectPlayX_EnumPlayers( pDP
[2], NULL
, EnumPlayers_cb
,
3981 &callbackData
, DPENUMPLAYERS_LOCAL
);
3982 checkHR( DP_OK
, hr
);
3983 check( 2, callbackData
.dwCounter1
);
3984 checkStr( "43", callbackData
.szTrace1
);
3986 "LOCAL,DPENUMPLAYERS_SPECTATOR:", callbackData
.szTrace2
);
3988 callbackData
.dwCounter1
= 0;
3989 callbackData
.szTrace2
[0] = 0;
3990 hr
= IDirectPlayX_EnumPlayers( pDP
[2], NULL
, EnumPlayers_cb
,
3991 &callbackData
, DPENUMPLAYERS_SERVERPLAYER
);
3992 checkHR( DP_OK
, hr
);
3993 check( 1, callbackData
.dwCounter1
);
3994 checkStr( "0", callbackData
.szTrace1
);
3995 checkStr( "SERVERPLAYER:", callbackData
.szTrace2
);
3997 callbackData
.dwCounter1
= 0;
3998 callbackData
.szTrace2
[0] = 0;
3999 hr
= IDirectPlayX_EnumPlayers( pDP
[2], NULL
, EnumPlayers_cb
,
4000 &callbackData
, DPENUMPLAYERS_SPECTATOR
);
4001 checkHR( DP_OK
, hr
);
4002 check( 1, callbackData
.dwCounter1
);
4003 checkStr( "3", callbackData
.szTrace1
);
4004 checkStr( "SPECTATOR:", callbackData
.szTrace2
);
4007 IDirectPlayX_Release( pDP
[0] );
4008 IDirectPlayX_Release( pDP
[1] );
4009 IDirectPlayX_Release( pDP
[2] );
4015 static BOOL CALLBACK
EnumGroups_cb( DPID dpId
,
4021 lpCallbackData callbackData
= lpContext
;
4022 char playerIndex
= dpid2char( callbackData
->dpid
,
4023 callbackData
->dpidSize
,
4027 /* Trace to study player ids */
4028 callbackData
->szTrace1
[ callbackData
->dwCounter1
] = playerIndex
;
4029 callbackData
->dwCounter1
++;
4030 callbackData
->szTrace1
[ callbackData
->dwCounter1
] = '\0';
4032 /* Trace to study flags received */
4033 strcat( callbackData
->szTrace2
,
4034 ( dwFlags2str(dwFlags
, FLAGS_DPENUMGROUPS
) +
4035 strlen("DPENUMGROUPS_") ) );
4036 strcat( callbackData
->szTrace2
, ":" );
4039 check( DPPLAYERTYPE_GROUP
, dwPlayerType
);
4044 static BOOL CALLBACK
EnumSessions_cb_EnumGroups( LPCDPSESSIONDESC2 lpThisSD
,
4045 LPDWORD lpdwTimeOut
,
4049 lpCallbackData callbackData
= lpContext
;
4052 if (dwFlags
& DPESC_TIMEDOUT
)
4058 callbackData
->dwCounter1
= 0;
4059 hr
= IDirectPlayX_EnumGroups( callbackData
->pDP
, NULL
,
4060 EnumGroups_cb
, &callbackData
, 0 );
4061 checkHR( DPERR_NOSESSIONS
, hr
);
4062 check( 0, callbackData
->dwCounter1
);
4064 /* guid = appGuid */
4065 callbackData
->dwCounter1
= 0;
4066 hr
= IDirectPlayX_EnumGroups( callbackData
->pDP
, (LPGUID
) &appGuid
,
4067 EnumGroups_cb
, &callbackData
, 0 );
4068 checkHR( DPERR_NOSESSIONS
, hr
);
4069 check( 0, callbackData
->dwCounter1
);
4071 callbackData
->dwCounter1
= 0;
4072 hr
= IDirectPlayX_EnumGroups( callbackData
->pDP
, (LPGUID
) &appGuid
,
4073 EnumGroups_cb
, &callbackData
,
4074 DPENUMGROUPS_SESSION
);
4075 checkHR( DPERR_NOSESSIONS
, hr
);
4076 check( 0, callbackData
->dwCounter1
);
4078 /* guid = guidInstance */
4079 callbackData
->dwCounter1
= 0;
4080 hr
= IDirectPlayX_EnumGroups( callbackData
->pDP
,
4081 (LPGUID
) &lpThisSD
->guidInstance
,
4082 EnumGroups_cb
, &callbackData
, 0 );
4083 checkHR( DPERR_NOSESSIONS
, hr
);
4084 check( 0, callbackData
->dwCounter1
);
4086 callbackData
->dwCounter1
= 0;
4087 hr
= IDirectPlayX_EnumGroups( callbackData
->pDP
,
4088 (LPGUID
) &lpThisSD
->guidInstance
,
4089 EnumGroups_cb
, &callbackData
,
4090 DPENUMGROUPS_SESSION
);
4091 checkHR( DPERR_GENERIC
, hr
); /* Why? */
4092 check( 0, callbackData
->dwCounter1
);
4098 static void test_EnumGroups(void)
4100 IDirectPlay4
*pDP
[3];
4101 DPSESSIONDESC2 dpsd
[3];
4103 CallbackData callbackData
;
4110 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
4111 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
4112 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
4113 if (FAILED(hr
)) return;
4115 ZeroMemory( &dpsd
[i
], sizeof(DPSESSIONDESC2
) );
4116 dpsd
[i
].dwSize
= sizeof(DPSESSIONDESC2
);
4119 dpsd
[0].guidApplication
= appGuid
;
4120 dpsd
[1].guidApplication
= appGuid2
;
4121 dpsd
[2].guidApplication
= GUID_NULL
;
4123 callbackData
.dpid
= dpid
;
4124 callbackData
.dpidSize
= 5;
4127 /* Uninitialized service provider */
4128 callbackData
.dwCounter1
= 0;
4129 hr
= IDirectPlayX_EnumGroups( pDP
[0], NULL
, EnumGroups_cb
,
4131 checkHR( DPERR_UNINITIALIZED
, hr
);
4132 check( 0, callbackData
.dwCounter1
);
4135 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
4136 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
4137 init_TCPIP_provider( pDP
[2], "127.0.0.1", 0 );
4141 callbackData
.dwCounter1
= 0;
4142 hr
= IDirectPlayX_EnumGroups( pDP
[0], NULL
, EnumGroups_cb
,
4144 todo_wine
checkHR( DPERR_NOSESSIONS
, hr
);
4145 check( 0, callbackData
.dwCounter1
);
4147 if ( hr
== DPERR_UNINITIALIZED
)
4149 todo_wine
win_skip( "EnumGroups not implemented\n" );
4153 callbackData
.dwCounter1
= 0;
4154 hr
= IDirectPlayX_EnumGroups( pDP
[0], (LPGUID
) &appGuid
, EnumGroups_cb
,
4156 checkHR( DPERR_NOSESSIONS
, hr
);
4157 check( 0, callbackData
.dwCounter1
);
4159 callbackData
.dwCounter1
= 0;
4160 hr
= IDirectPlayX_EnumGroups( pDP
[0], (LPGUID
) &appGuid
, EnumGroups_cb
,
4161 &callbackData
, DPENUMGROUPS_SESSION
);
4162 checkHR( DPERR_NOSESSIONS
, hr
);
4163 check( 0, callbackData
.dwCounter1
);
4166 hr
= IDirectPlayX_Open( pDP
[0], &dpsd
[0], DPOPEN_CREATE
);
4167 checkHR( DP_OK
, hr
);
4168 hr
= IDirectPlayX_Open( pDP
[1], &dpsd
[1], DPOPEN_CREATE
);
4169 checkHR( DP_OK
, hr
);
4173 callbackData
.dwCounter1
= 0;
4174 hr
= IDirectPlayX_EnumGroups( pDP
[0], NULL
, EnumGroups_cb
,
4176 checkHR( DP_OK
, hr
);
4177 check( 0, callbackData
.dwCounter1
);
4181 hr
= IDirectPlayX_CreateGroup( pDP
[0], &dpid
[0],
4183 checkHR( DP_OK
, hr
);
4184 hr
= IDirectPlayX_CreateGroupInGroup( pDP
[0], dpid
[0], &dpid
[3],
4186 checkHR( DP_OK
, hr
); /* Not a superior level group,
4187 won't appear in the enumerations */
4188 hr
= IDirectPlayX_CreateGroup( pDP
[1], &dpid
[1],
4190 checkHR( DP_OK
, hr
);
4191 hr
= IDirectPlayX_CreateGroup( pDP
[0], &dpid
[2],
4192 NULL
, NULL
, 0, DPGROUP_HIDDEN
);
4193 checkHR( DP_OK
, hr
);
4196 /* Invalid parameters */
4197 callbackData
.dwCounter1
= 0;
4198 hr
= IDirectPlayX_EnumGroups( pDP
[0], (LPGUID
) &appGuid
, NULL
,
4200 checkHR( DPERR_INVALIDPARAMS
, hr
);
4201 check( 0, callbackData
.dwCounter1
);
4203 callbackData
.dwCounter1
= 0;
4204 hr
= IDirectPlayX_EnumGroups( pDP
[0], NULL
, EnumGroups_cb
,
4205 &callbackData
, DPENUMGROUPS_SESSION
);
4206 checkHR( DPERR_INVALIDPARAMS
, hr
);
4207 check( 0, callbackData
.dwCounter1
);
4210 /* Regular operation */
4211 callbackData
.dwCounter1
= 0;
4212 callbackData
.szTrace2
[0] = 0;
4213 hr
= IDirectPlayX_EnumGroups( pDP
[0], NULL
, EnumGroups_cb
,
4215 checkHR( DP_OK
, hr
);
4216 check( 2, callbackData
.dwCounter1
);
4217 checkStr( "02", callbackData
.szTrace1
);
4218 checkStr( "ALL:HIDDEN:", callbackData
.szTrace2
);
4220 callbackData
.dwCounter1
= 0;
4221 callbackData
.szTrace2
[0] = 0;
4222 hr
= IDirectPlayX_EnumGroups( pDP
[1], NULL
, EnumGroups_cb
,
4224 checkHR( DP_OK
, hr
);
4225 check( 1, callbackData
.dwCounter1
);
4226 checkStr( "1", callbackData
.szTrace1
);
4227 checkStr( "ALL:", callbackData
.szTrace2
);
4229 callbackData
.dwCounter1
= 0;
4230 callbackData
.szTrace2
[0] = 0;
4231 hr
= IDirectPlayX_EnumGroups( pDP
[0], (LPGUID
) &appGuid
, EnumGroups_cb
,
4233 checkHR( DP_OK
, hr
);
4234 check( 2, callbackData
.dwCounter1
); /* Guid is ignored */
4235 checkStr( "02", callbackData
.szTrace1
);
4236 checkStr( "ALL:HIDDEN:", callbackData
.szTrace2
);
4239 /* Enumerating from a remote session */
4240 /* - Session not open */
4241 callbackData
.pDP
= pDP
[2];
4242 hr
= IDirectPlayX_EnumSessions( pDP
[2], &dpsd
[2], 0,
4243 EnumSessions_cb_EnumGroups
,
4245 checkHR( DP_OK
, hr
);
4247 /* - Open session */
4248 callbackData
.pDP
= pDP
[2];
4249 hr
= IDirectPlayX_EnumSessions( pDP
[2], &dpsd
[0], 0, EnumSessions_cb_join
,
4251 checkHR( DP_OK
, hr
);
4253 hr
= IDirectPlayX_CreateGroup( pDP
[2], &dpid
[3],
4255 checkHR( DP_OK
, hr
);
4256 hr
= IDirectPlayX_CreateGroup( pDP
[2], &dpid
[4],
4257 NULL
, NULL
, 0, DPGROUP_STAGINGAREA
);
4258 checkHR( DP_OK
, hr
);
4261 callbackData
.dwCounter1
= 0;
4262 callbackData
.szTrace2
[0] = 0;
4263 hr
= IDirectPlayX_EnumGroups( pDP
[2], NULL
, EnumGroups_cb
,
4265 checkHR( DP_OK
, hr
);
4266 check( 4, callbackData
.dwCounter1
);
4267 checkStr( "0234", callbackData
.szTrace1
);
4268 checkStr( "ALL:HIDDEN:ALL:STAGINGAREA:", callbackData
.szTrace2
);
4271 callbackData
.dwCounter1
= 0;
4272 callbackData
.szTrace2
[0] = 0;
4273 hr
= IDirectPlayX_EnumGroups( pDP
[2], NULL
, EnumGroups_cb
,
4274 &callbackData
, DPENUMGROUPS_ALL
);
4275 checkHR( DP_OK
, hr
);
4276 check( 4, callbackData
.dwCounter1
);
4277 checkStr( "0234", callbackData
.szTrace1
);
4278 checkStr( "ALL:HIDDEN:ALL:STAGINGAREA:", callbackData
.szTrace2
);
4280 callbackData
.dwCounter1
= 0;
4281 callbackData
.szTrace2
[0] = 0;
4282 hr
= IDirectPlayX_EnumGroups( pDP
[2], NULL
, EnumGroups_cb
,
4283 &callbackData
, DPENUMGROUPS_HIDDEN
);
4284 checkHR( DP_OK
, hr
);
4285 check( 1, callbackData
.dwCounter1
);
4286 checkStr( "2", callbackData
.szTrace1
);
4287 checkStr( "HIDDEN:", callbackData
.szTrace2
);
4289 callbackData
.dwCounter1
= 0;
4290 callbackData
.szTrace2
[0] = 0;
4291 hr
= IDirectPlayX_EnumGroups( pDP
[2], NULL
, EnumGroups_cb
,
4292 &callbackData
, DPENUMGROUPS_LOCAL
);
4293 checkHR( DP_OK
, hr
);
4294 check( 2, callbackData
.dwCounter1
);
4295 checkStr( "34", callbackData
.szTrace1
);
4297 "LOCAL,DPENUMGROUPS_STAGINGAREA:", callbackData
.szTrace2
);
4299 callbackData
.dwCounter1
= 0;
4300 callbackData
.szTrace2
[0] = 0;
4301 hr
= IDirectPlayX_EnumGroups( pDP
[2], NULL
, EnumGroups_cb
,
4302 &callbackData
, DPENUMGROUPS_REMOTE
);
4303 checkHR( DP_OK
, hr
);
4304 check( 2, callbackData
.dwCounter1
);
4305 checkStr( "02", callbackData
.szTrace1
);
4307 "REMOTE,DPENUMGROUPS_HIDDEN:", callbackData
.szTrace2
);
4309 callbackData
.dwCounter1
= 0;
4310 callbackData
.szTrace2
[0] = 0;
4311 hr
= IDirectPlayX_EnumGroups( pDP
[2], NULL
, EnumGroups_cb
,
4312 &callbackData
, DPENUMGROUPS_STAGINGAREA
);
4313 checkHR( DP_OK
, hr
);
4314 check( 1, callbackData
.dwCounter1
);
4315 checkStr( "4", callbackData
.szTrace1
);
4316 checkStr( "STAGINGAREA:", callbackData
.szTrace2
);
4319 IDirectPlayX_Release( pDP
[0] );
4320 IDirectPlayX_Release( pDP
[1] );
4321 IDirectPlayX_Release( pDP
[2] );
4325 static void test_EnumGroupsInGroup(void)
4327 IDirectPlay4
*pDP
[2];
4328 DPSESSIONDESC2 dpsd
[2];
4330 CallbackData callbackData
;
4337 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
4338 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
4339 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
4340 if (FAILED(hr
)) return;
4342 ZeroMemory( &dpsd
[i
], sizeof(DPSESSIONDESC2
) );
4343 dpsd
[i
].dwSize
= sizeof(DPSESSIONDESC2
);
4346 dpsd
[0].guidApplication
= appGuid
;
4347 dpsd
[1].guidApplication
= GUID_NULL
;
4349 callbackData
.dpid
= dpid
;
4350 callbackData
.dpidSize
= 6;
4353 /* Uninitialized service provider */
4354 callbackData
.dwCounter1
= 0;
4355 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], 0, NULL
, EnumGroups_cb
,
4357 checkHR( DPERR_UNINITIALIZED
, hr
);
4358 check( 0, callbackData
.dwCounter1
);
4361 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
4362 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
4364 hr
= IDirectPlayX_Open( pDP
[0], &dpsd
[0], DPOPEN_CREATE
);
4365 todo_wine
checkHR( DP_OK
, hr
);
4367 if ( hr
== DPERR_UNINITIALIZED
)
4369 todo_wine
win_skip( "EnumGroupsInGroup not implemented\n" );
4381 hr
= IDirectPlayX_CreateGroup( pDP
[0], &dpid
[0],
4383 checkHR( DP_OK
, hr
);
4384 hr
= IDirectPlayX_CreateGroup( pDP
[0], &dpid
[1],
4386 checkHR( DP_OK
, hr
);
4387 hr
= IDirectPlayX_CreateGroupInGroup( pDP
[0], dpid
[1], &dpid
[2],
4389 checkHR( DP_OK
, hr
);
4390 hr
= IDirectPlayX_CreateGroupInGroup( pDP
[0], dpid
[1], &dpid
[3],
4393 checkHR( DP_OK
, hr
);
4394 hr
= IDirectPlayX_CreateGroupInGroup( pDP
[0], dpid
[1], &dpid
[4],
4396 DPGROUP_STAGINGAREA
);
4397 checkHR( DP_OK
, hr
);
4398 hr
= IDirectPlayX_CreateGroup( pDP
[0], &dpid
[5],
4400 checkHR( DP_OK
, hr
);
4402 hr
= IDirectPlayX_AddGroupToGroup( pDP
[0], dpid
[1], dpid
[5] );
4403 checkHR( DP_OK
, hr
);
4406 /* Invalid parameters */
4407 callbackData
.dwCounter1
= 0;
4408 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], 0, NULL
, EnumGroups_cb
,
4410 checkHR( DPERR_INVALIDGROUP
, hr
);
4411 check( 0, callbackData
.dwCounter1
);
4413 callbackData
.dwCounter1
= 0;
4414 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], 10, NULL
, EnumGroups_cb
,
4416 checkHR( DPERR_INVALIDGROUP
, hr
);
4417 check( 0, callbackData
.dwCounter1
);
4419 callbackData
.dwCounter1
= 0;
4420 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], dpid
[1], (LPGUID
) &appGuid
,
4421 NULL
, &callbackData
, 0 );
4422 checkHR( DPERR_INVALIDPARAMS
, hr
);
4423 check( 0, callbackData
.dwCounter1
);
4425 callbackData
.dwCounter1
= 0;
4426 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], dpid
[1], NULL
, EnumGroups_cb
,
4427 &callbackData
, DPENUMGROUPS_SESSION
);
4428 checkHR( DPERR_INVALIDPARAMS
, hr
);
4429 check( 0, callbackData
.dwCounter1
);
4432 /* Regular operation */
4433 callbackData
.dwCounter1
= 0;
4434 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], dpid
[0], NULL
, EnumGroups_cb
,
4436 checkHR( DP_OK
, hr
);
4437 check( 0, callbackData
.dwCounter1
);
4439 callbackData
.dwCounter1
= 0;
4440 callbackData
.szTrace2
[0] = 0;
4441 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], dpid
[1], NULL
, EnumGroups_cb
,
4443 checkHR( DP_OK
, hr
);
4444 check( 4, callbackData
.dwCounter1
);
4445 checkStr( "5432", callbackData
.szTrace1
);
4446 checkStr( "SHORTCUT:STAGINGAREA:HIDDEN:ALL:", callbackData
.szTrace2
);
4448 callbackData
.dwCounter1
= 0;
4449 callbackData
.szTrace2
[0] = 0;
4450 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], dpid
[1], (LPGUID
) &appGuid
,
4451 EnumGroups_cb
, &callbackData
, 0 );
4452 checkHR( DP_OK
, hr
);
4453 check( 4, callbackData
.dwCounter1
); /* Guid is ignored */
4454 checkStr( "5432", callbackData
.szTrace1
);
4455 checkStr( "SHORTCUT:STAGINGAREA:HIDDEN:ALL:", callbackData
.szTrace2
);
4458 /* Enumerating from a remote session */
4459 /* - Session not open */
4460 callbackData
.pDP
= pDP
[1];
4461 hr
= IDirectPlayX_EnumSessions( pDP
[1], &dpsd
[1], 0,
4462 EnumSessions_cb_EnumGroups
,
4464 checkHR( DP_OK
, hr
);
4466 /* - Open session */
4467 hr
= IDirectPlayX_EnumSessions( pDP
[1], &dpsd
[0], 0, EnumSessions_cb_join
,
4469 checkHR( DP_OK
, hr
);
4472 callbackData
.dwCounter1
= 0;
4473 callbackData
.szTrace2
[0] = 0;
4474 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[1], dpid
[1], NULL
, EnumGroups_cb
,
4476 checkHR( DP_OK
, hr
);
4477 check( 4, callbackData
.dwCounter1
);
4478 checkStr( "5432", callbackData
.szTrace1
);
4479 checkStr( "SHORTCUT:STAGINGAREA:HIDDEN:ALL:", callbackData
.szTrace2
);
4482 callbackData
.dwCounter1
= 0;
4483 callbackData
.szTrace2
[0] = 0;
4484 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], dpid
[1], NULL
, EnumGroups_cb
,
4485 &callbackData
, DPENUMGROUPS_ALL
);
4486 checkHR( DP_OK
, hr
);
4487 check( 4, callbackData
.dwCounter1
);
4488 checkStr( "5432", callbackData
.szTrace1
);
4489 checkStr( "SHORTCUT:STAGINGAREA:HIDDEN:ALL:", callbackData
.szTrace2
);
4491 callbackData
.dwCounter1
= 0;
4492 callbackData
.szTrace2
[0] = 0;
4493 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], dpid
[1], NULL
, EnumGroups_cb
,
4494 &callbackData
, DPENUMGROUPS_HIDDEN
);
4495 checkHR( DP_OK
, hr
);
4496 check( 1, callbackData
.dwCounter1
);
4497 checkStr( "3", callbackData
.szTrace1
);
4498 checkStr( "HIDDEN:", callbackData
.szTrace2
);
4500 callbackData
.dwCounter1
= 0;
4501 callbackData
.szTrace2
[0] = 0;
4502 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], dpid
[1], NULL
, EnumGroups_cb
,
4503 &callbackData
, DPENUMGROUPS_LOCAL
);
4504 checkHR( DP_OK
, hr
);
4505 check( 4, callbackData
.dwCounter1
);
4506 checkStr( "5432", callbackData
.szTrace1
);
4507 checkStr( "LOCAL,DPENUMGROUPS_SHORTCUT:"
4508 "LOCAL,DPENUMGROUPS_STAGINGAREA:"
4509 "LOCAL,DPENUMGROUPS_HIDDEN:LOCAL:", callbackData
.szTrace2
);
4511 callbackData
.dwCounter1
= 0;
4512 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], dpid
[1], NULL
, EnumGroups_cb
,
4513 &callbackData
, DPENUMGROUPS_REMOTE
);
4514 checkHR( DP_OK
, hr
);
4515 check( 0, callbackData
.dwCounter1
);
4517 callbackData
.dwCounter1
= 0;
4518 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[1], dpid
[1], NULL
, EnumGroups_cb
,
4519 &callbackData
, DPENUMGROUPS_LOCAL
);
4520 checkHR( DP_OK
, hr
);
4521 check( 0, callbackData
.dwCounter1
);
4523 callbackData
.dwCounter1
= 0;
4524 callbackData
.szTrace2
[0] = 0;
4525 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[1], dpid
[1], NULL
, EnumGroups_cb
,
4526 &callbackData
, DPENUMGROUPS_REMOTE
);
4527 checkHR( DP_OK
, hr
);
4528 check( 4, callbackData
.dwCounter1
);
4529 checkStr( "5432", callbackData
.szTrace1
);
4530 checkStr( "REMOTE,DPENUMGROUPS_SHORTCUT:"
4531 "REMOTE,DPENUMGROUPS_STAGINGAREA:"
4532 "REMOTE,DPENUMGROUPS_HIDDEN:REMOTE:", callbackData
.szTrace2
);
4534 callbackData
.dwCounter1
= 0;
4535 callbackData
.szTrace2
[0] = 0;
4536 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], dpid
[1], NULL
, EnumGroups_cb
,
4537 &callbackData
, DPENUMGROUPS_SHORTCUT
);
4538 checkHR( DP_OK
, hr
);
4539 check( 1, callbackData
.dwCounter1
);
4540 checkStr( "5", callbackData
.szTrace1
);
4541 checkStr( "SHORTCUT:", callbackData
.szTrace2
);
4543 callbackData
.dwCounter1
= 0;
4544 callbackData
.szTrace2
[0] = 0;
4545 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], dpid
[1], NULL
, EnumGroups_cb
,
4547 DPENUMGROUPS_STAGINGAREA
);
4548 checkHR( DP_OK
, hr
);
4549 check( 1, callbackData
.dwCounter1
);
4550 checkStr( "4", callbackData
.szTrace1
);
4551 checkStr( "STAGINGAREA:", callbackData
.szTrace2
);
4554 IDirectPlayX_Release( pDP
[0] );
4555 IDirectPlayX_Release( pDP
[1] );
4559 static void test_groups_p2p(void)
4562 IDirectPlay4
*pDP
[2];
4563 DPSESSIONDESC2 dpsd
;
4564 DPID idPlayer
[6], idGroup
[3];
4568 DWORD dwDataSize
= 1024;
4569 LPVOID lpData
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, 1024 );
4570 CallbackData callbackData
;
4575 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
4576 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
4577 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
4578 if (FAILED(hr
)) return;
4580 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
4581 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
4582 dpsd
.guidApplication
= appGuid
;
4583 dpsd
.dwMaxPlayers
= 10;
4586 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
4587 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
4589 hr
= IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
4590 todo_wine
checkHR( DP_OK
, hr
);
4591 hr
= IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
4593 todo_wine
checkHR( DP_OK
, hr
);
4595 if ( hr
== DPERR_UNINITIALIZED
)
4597 todo_wine
win_skip( "dplay not implemented enough for this test yet\n" );
4602 /* Create players */
4603 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &idPlayer
[0],
4604 NULL
, NULL
, NULL
, 0, 0 );
4605 checkHR( DP_OK
, hr
);
4606 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &idPlayer
[1],
4607 NULL
, NULL
, NULL
, 0, 0 );
4608 checkHR( DP_OK
, hr
);
4609 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &idPlayer
[2],
4610 NULL
, NULL
, NULL
, 0, 0 );
4611 checkHR( DP_OK
, hr
);
4612 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &idPlayer
[3],
4613 NULL
, NULL
, NULL
, 0, 0 );
4614 checkHR( DP_OK
, hr
);
4615 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &idPlayer
[4],
4616 NULL
, NULL
, NULL
, 0, 0 );
4617 checkHR( DP_OK
, hr
);
4618 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &idPlayer
[5],
4619 NULL
, NULL
, NULL
, 0, 0 );
4620 checkHR( DP_OK
, hr
);
4622 hr
= IDirectPlayX_CreateGroup( pDP
[0], &idGroup
[0],
4624 checkHR( DP_OK
, hr
);
4625 hr
= IDirectPlayX_CreateGroup( pDP
[1], &idGroup
[2],
4627 checkHR( DP_OK
, hr
);
4628 hr
= IDirectPlayX_CreateGroupInGroup( pDP
[1], idGroup
[2], &idGroup
[1],
4630 checkHR( DP_OK
, hr
);
4634 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4635 checkStr( "S0," "S1,S0,"
4636 "S2,S1,S0," "S2,S1,S0,"
4637 "S2,S1,S0," "S2,S1,S0,"
4638 "S2,S1,S0," "S2,S1,S0,", callbackData
.szTrace1
);
4639 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4640 checkStr( "S3," "S4,S3,"
4641 "S5,S4,S3," "S5,S4,S3,"
4642 "S5,S4,S3,", callbackData
.szTrace1
);
4647 * Player 1 | Group 0 | pDP 0
4649 * Player 3 | Group 1 ) |
4650 * Player 4 | | Group 2 | pDP 1
4655 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[0], idGroup
[0], idPlayer
[0] );
4656 checkHR( DP_OK
, hr
);
4657 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[0], idGroup
[0], idPlayer
[1] );
4658 checkHR( DP_OK
, hr
);
4659 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[0], idGroup
[0], idPlayer
[2] );
4660 checkHR( DP_OK
, hr
);
4661 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[1], idGroup
[1], idPlayer
[3] );
4662 checkHR( DP_OK
, hr
);
4663 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[1], idGroup
[1], idPlayer
[4] );
4664 checkHR( DP_OK
, hr
);
4665 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[1], idGroup
[2], idPlayer
[4] );
4666 checkHR( DP_OK
, hr
);
4667 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[1], idGroup
[2], idPlayer
[5] );
4668 checkHR( DP_OK
, hr
);
4670 hr
= IDirectPlayX_AddGroupToGroup( pDP
[1], idGroup
[2], idGroup
[1] );
4671 checkHR( DP_OK
, hr
);
4674 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4675 checkStr( "S2,S1,S0," "S2,S1,S0," "S2,S1,S0,"
4676 "S2,S1,S0," "S2,S1,S0," "S2,S1,S0,"
4677 "S2,S1,S0,", callbackData
.szTrace1
);
4678 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4679 checkStr( "S5,S4,S3," "S5,S4,S3," "S5,S4,S3,"
4680 "S5,S4,S3," "S5,S4,S3," "S5,S4,S3,"
4681 "S5,S4,S3,", callbackData
.szTrace1
);
4684 /* Sending broadcast messages, and checking who receives them */
4688 hr
= IDirectPlayX_Send( pDP
[0], idPlayer
[0], DPID_ALLPLAYERS
, 0,
4689 lpData
, dwDataSize
);
4690 checkHR( DP_OK
, hr
);
4691 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4692 checkStr( "02,01,", callbackData
.szTrace1
);
4693 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4694 checkStr( "05,04,03,", callbackData
.szTrace1
);
4697 hr
= IDirectPlayX_Send( pDP
[0], idPlayer
[0], idGroup
[0], 0,
4698 lpData
, dwDataSize
);
4699 checkHR( DP_OK
, hr
);
4700 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4701 checkStr( "02,01,", callbackData
.szTrace1
);
4702 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4703 checkStr( "", callbackData
.szTrace1
);
4705 hr
= IDirectPlayX_Send( pDP
[0], idPlayer
[0], idGroup
[1], 0,
4706 lpData
, dwDataSize
);
4707 checkHR( DP_OK
, hr
);
4708 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4709 checkStr( "", callbackData
.szTrace1
);
4710 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4711 checkStr( "04,03,", callbackData
.szTrace1
);
4713 hr
= IDirectPlayX_Send( pDP
[0], idPlayer
[0], idGroup
[2], 0,
4714 lpData
, dwDataSize
);
4715 checkHR( DP_OK
, hr
);
4716 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4717 checkStr( "", callbackData
.szTrace1
);
4718 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4719 checkStr( "05,04,", callbackData
.szTrace1
);
4722 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[3], DPID_ALLPLAYERS
, 0,
4723 lpData
, dwDataSize
);
4724 checkHR( DP_OK
, hr
);
4725 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4726 checkStr( "32,31,30,", callbackData
.szTrace1
);
4727 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4728 checkStr( "35,34,", callbackData
.szTrace1
);
4730 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[3], idGroup
[0], 0,
4731 lpData
, dwDataSize
);
4732 checkHR( DP_OK
, hr
);
4733 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4734 checkStr( "32,31,30,", callbackData
.szTrace1
);
4735 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4736 checkStr( "", callbackData
.szTrace1
);
4738 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[3], idGroup
[1], 0,
4739 lpData
, dwDataSize
);
4740 checkHR( DP_OK
, hr
);
4741 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4742 checkStr( "", callbackData
.szTrace1
);
4743 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4744 checkStr( "34,", callbackData
.szTrace1
);
4746 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[3], idGroup
[2], 0,
4747 lpData
, dwDataSize
);
4748 checkHR( DP_OK
, hr
);
4749 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4750 checkStr( "", callbackData
.szTrace1
);
4751 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4752 checkStr( "35,34,", callbackData
.szTrace1
);
4755 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[5], DPID_ALLPLAYERS
, 0,
4756 lpData
, dwDataSize
);
4757 checkHR( DP_OK
, hr
);
4758 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4759 checkStr( "52,51,50,", callbackData
.szTrace1
);
4760 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4761 checkStr( "54,53,", callbackData
.szTrace1
);
4763 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[5], idGroup
[0], 0,
4764 lpData
, dwDataSize
);
4765 checkHR( DP_OK
, hr
);
4766 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4767 checkStr( "52,51,50,", callbackData
.szTrace1
);
4768 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4769 checkStr( "", callbackData
.szTrace1
);
4771 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[5], idGroup
[1], 0,
4772 lpData
, dwDataSize
);
4773 checkHR( DP_OK
, hr
);
4774 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4775 checkStr( "", callbackData
.szTrace1
);
4776 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4777 checkStr( "54,53,", callbackData
.szTrace1
);
4779 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[5], idGroup
[2], 0,
4780 lpData
, dwDataSize
);
4781 checkHR( DP_OK
, hr
);
4782 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4783 checkStr( "", callbackData
.szTrace1
);
4784 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4785 checkStr( "54,", callbackData
.szTrace1
);
4788 HeapFree( GetProcessHeap(), 0, lpData
);
4789 IDirectPlayX_Release( pDP
[0] );
4790 IDirectPlayX_Release( pDP
[1] );
4794 static void test_groups_cs(void)
4797 IDirectPlay4
*pDP
[2];
4798 DPSESSIONDESC2 dpsd
;
4799 DPID idPlayer
[6], idGroup
[3];
4800 CallbackData callbackData
;
4804 DWORD dwDataSize
= 1024;
4805 LPVOID lpData
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, 1024 );
4810 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
4811 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
4812 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
4813 if (FAILED(hr
)) return;
4815 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
4816 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
4817 dpsd
.guidApplication
= appGuid
;
4818 dpsd
.dwMaxPlayers
= 10;
4821 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
4822 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
4824 dpsd
.dwFlags
= DPSESSION_CLIENTSERVER
;
4825 hr
= IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
4826 todo_wine
checkHR( DP_OK
, hr
);
4828 hr
= IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
4830 todo_wine
checkHR( DP_OK
, hr
);
4832 if ( hr
== DPERR_UNINITIALIZED
)
4834 todo_wine
win_skip( "dplay not implemented enough for this test yet\n" );
4839 /* Create players */
4840 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &idPlayer
[0],
4841 NULL
, NULL
, NULL
, 0, 0 );
4842 checkHR( DPERR_ACCESSDENIED
, hr
);
4843 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &idPlayer
[0],
4844 NULL
, NULL
, NULL
, 0,
4845 DPPLAYER_SERVERPLAYER
);
4846 checkHR( DP_OK
, hr
);
4847 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &idPlayer
[1],
4848 NULL
, NULL
, NULL
, 0, 0 );
4849 checkHR( DPERR_ACCESSDENIED
, hr
);
4850 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &idPlayer
[1],
4851 NULL
, NULL
, NULL
, 0, 0 );
4852 checkHR( DP_OK
, hr
);
4853 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &idPlayer
[2],
4854 NULL
, NULL
, NULL
, 0, 0 );
4855 checkHR( DP_OK
, hr
);
4856 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &idPlayer
[3],
4857 NULL
, NULL
, NULL
, 0, 0 );
4858 checkHR( DP_OK
, hr
);
4859 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &idPlayer
[4],
4860 NULL
, NULL
, NULL
, 0, 0 );
4861 checkHR( DP_OK
, hr
);
4862 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &idPlayer
[5],
4863 NULL
, NULL
, NULL
, 0, 0 );
4864 checkHR( DP_OK
, hr
);
4866 hr
= IDirectPlayX_CreateGroup( pDP
[0], &idGroup
[0],
4868 checkHR( DP_OK
, hr
);
4869 hr
= IDirectPlayX_CreateGroup( pDP
[1], &idGroup
[2],
4871 checkHR( DP_OK
, hr
);
4872 hr
= IDirectPlayX_CreateGroupInGroup( pDP
[1], idGroup
[2], &idGroup
[1],
4874 checkHR( DP_OK
, hr
);
4878 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4879 checkStr( "S0,S0,S0,S0,S0,S0,", callbackData
.szTrace1
);
4880 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4881 checkStr( "S1," "S2,S1," "S3,S2,S1," "S4,S3,S2,S1,"
4882 "S5,S4,S3,S2,S1," "S5,S4,S3,S2,S1,", callbackData
.szTrace1
);
4885 * Player 0 | | pDP 0
4886 * Player 1 | Group 0 |
4888 * Player 3 | Group 1 ) |
4889 * Player 4 | | Group 2 | pDP 1
4894 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[0], idGroup
[0], idPlayer
[0] );
4895 checkHR( DP_OK
, hr
);
4896 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[0], idGroup
[0], idPlayer
[1] );
4897 checkHR( DP_OK
, hr
);
4898 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[0], idGroup
[0], idPlayer
[2] );
4899 checkHR( DP_OK
, hr
);
4900 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[1], idGroup
[1], idPlayer
[3] );
4901 checkHR( DP_OK
, hr
);
4902 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[1], idGroup
[1], idPlayer
[4] );
4903 checkHR( DP_OK
, hr
);
4904 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[1], idGroup
[2], idPlayer
[4] );
4905 checkHR( DP_OK
, hr
);
4906 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[1], idGroup
[2], idPlayer
[5] );
4907 checkHR( DP_OK
, hr
);
4909 hr
= IDirectPlayX_AddGroupToGroup( pDP
[1], idGroup
[2], idGroup
[1] );
4910 checkHR( DP_OK
, hr
);
4913 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4914 checkStr( "S0,S0,S0,S0,", callbackData
.szTrace1
);
4915 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4916 checkStr( "S5," "S4,S3,S2,S1," "S5,S4,S3,S2,S1,"
4917 "S5,S4,S3,S2,S1," "S5,S4,S3,S2,S1,", callbackData
.szTrace1
);
4920 /* Sending broadcast messages, and checking who receives them */
4923 hr
= IDirectPlayX_Send( pDP
[0], idPlayer
[0], DPID_ALLPLAYERS
, 0,
4924 lpData
, dwDataSize
);
4925 checkHR( DP_OK
, hr
);
4926 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4927 checkStr( "", callbackData
.szTrace1
);
4928 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4929 checkStr( "05,04,03,02,01,", callbackData
.szTrace1
);
4932 hr
= IDirectPlayX_Send( pDP
[0], idPlayer
[0], idGroup
[0], 0,
4933 lpData
, dwDataSize
);
4934 checkHR( DP_OK
, hr
);
4935 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4936 checkStr( "", callbackData
.szTrace1
);
4937 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4938 checkStr( "02,01,", callbackData
.szTrace1
);
4940 hr
= IDirectPlayX_Send( pDP
[0], idPlayer
[0], idGroup
[1], 0,
4941 lpData
, dwDataSize
);
4942 checkHR( DPERR_INVALIDPARAMS
, hr
);
4943 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4944 checkStr( "", callbackData
.szTrace1
);
4945 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4946 checkStr( "", callbackData
.szTrace1
);
4948 hr
= IDirectPlayX_Send( pDP
[0], idPlayer
[0], idGroup
[2], 0,
4949 lpData
, dwDataSize
);
4950 checkHR( DPERR_INVALIDPARAMS
, hr
);
4951 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4952 checkStr( "", callbackData
.szTrace1
);
4953 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4954 checkStr( "", callbackData
.szTrace1
);
4957 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[3], DPID_ALLPLAYERS
, 0,
4958 lpData
, dwDataSize
);
4959 checkHR( DP_OK
, hr
);
4960 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4961 checkStr( "30,", callbackData
.szTrace1
);
4962 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4963 checkStr( "35,34,32,31,", callbackData
.szTrace1
);
4965 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[3], idGroup
[0], 0,
4966 lpData
, dwDataSize
);
4967 checkHR( DPERR_INVALIDPARAMS
, hr
);
4968 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4969 checkStr( "", callbackData
.szTrace1
);
4970 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4971 checkStr( "", callbackData
.szTrace1
);
4973 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[3], idGroup
[1], 0,
4974 lpData
, dwDataSize
);
4975 checkHR( DP_OK
, hr
);
4976 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4977 checkStr( "", callbackData
.szTrace1
);
4978 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4979 checkStr( "34,", callbackData
.szTrace1
);
4981 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[3], idGroup
[2], 0,
4982 lpData
, dwDataSize
);
4983 checkHR( DP_OK
, hr
);
4984 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4985 checkStr( "", callbackData
.szTrace1
);
4986 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4987 checkStr( "35,34,", callbackData
.szTrace1
);
4990 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[5], DPID_ALLPLAYERS
, 0,
4991 lpData
, dwDataSize
);
4992 checkHR( DP_OK
, hr
);
4993 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4994 checkStr( "50,", callbackData
.szTrace1
);
4995 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4996 checkStr( "54,53,52,51,", callbackData
.szTrace1
);
4998 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[5], idGroup
[0], 0,
4999 lpData
, dwDataSize
);
5000 checkHR( DPERR_INVALIDPARAMS
, hr
);
5001 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
5002 checkStr( "", callbackData
.szTrace1
);
5003 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
5004 checkStr( "", callbackData
.szTrace1
);
5006 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[5], idGroup
[1], 0,
5007 lpData
, dwDataSize
);
5008 checkHR( DP_OK
, hr
);
5009 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
5010 checkStr( "", callbackData
.szTrace1
);
5011 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
5012 checkStr( "54,53,", callbackData
.szTrace1
);
5014 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[5], idGroup
[2], 0,
5015 lpData
, dwDataSize
);
5016 checkHR( DP_OK
, hr
);
5017 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
5018 checkStr( "", callbackData
.szTrace1
);
5019 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
5020 checkStr( "54,", callbackData
.szTrace1
);
5023 HeapFree( GetProcessHeap(), 0, lpData
);
5024 IDirectPlayX_Release( pDP
[0] );
5025 IDirectPlayX_Release( pDP
[1] );
5031 static void test_Send(void)
5034 IDirectPlay4
*pDP
[2];
5035 DPSESSIONDESC2 dpsd
;
5036 DPID dpid
[4], idFrom
, idTo
;
5037 CallbackData callbackData
;
5039 LPCSTR message
= "message";
5040 DWORD messageSize
= strlen(message
) + 1;
5041 DWORD dwDataSize
= 1024;
5042 LPDPMSG_GENERIC lpData
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, dwDataSize
);
5043 LPDPMSG_SECUREMESSAGE lpDataSecure
;
5049 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
5050 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
5051 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
5052 if (FAILED(hr
)) return;
5054 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
5057 /* Uninitialized service provider */
5058 hr
= IDirectPlayX_Send( pDP
[0], 0, 0, 0,
5059 (LPVOID
) message
, messageSize
);
5060 checkHR( DPERR_UNINITIALIZED
, hr
);
5063 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
5064 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
5066 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
5067 dpsd
.guidApplication
= appGuid
;
5068 dpsd
.dwMaxPlayers
= 10;
5069 IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
5070 IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
5072 IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
5075 /* Incorrect players */
5076 hr
= IDirectPlayX_Send( pDP
[0], 0, 1, 2,
5077 (LPVOID
) message
, messageSize
);
5078 todo_wine
checkHR( DPERR_INVALIDPLAYER
, hr
);
5080 if ( hr
== DPERR_UNINITIALIZED
)
5082 todo_wine
win_skip( "Send not implemented\n" );
5087 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[0], NULL
, NULL
, NULL
, 0, 0 );
5088 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[1], NULL
, NULL
, NULL
, 0, 0 );
5089 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[2], NULL
, NULL
, NULL
, 0, 0 );
5090 IDirectPlayX_CreatePlayer( pDP
[1], &dpid
[3], NULL
, NULL
, NULL
, 0, 0 );
5092 /* Purge player creation messages */
5093 check_messages( pDP
[0], dpid
, 4, &callbackData
);
5094 checkStr( "S0," "S1,S0," "S2,S1,S0,", callbackData
.szTrace1
);
5095 check_messages( pDP
[1], dpid
, 4, &callbackData
);
5096 checkStr( "", callbackData
.szTrace1
);
5099 /* Message to self: no error, but no message is sent */
5100 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[0], 0,
5101 (LPVOID
) message
, messageSize
);
5102 checkHR( DP_OK
, hr
);
5104 /* Send a message from a remote player */
5105 hr
= IDirectPlayX_Send( pDP
[1], dpid
[0], dpid
[1], 0,
5106 (LPVOID
) message
, messageSize
);
5107 checkHR( DPERR_ACCESSDENIED
, hr
);
5108 hr
= IDirectPlayX_Send( pDP
[1], dpid
[0], dpid
[3], 0,
5109 (LPVOID
) message
, messageSize
);
5110 checkHR( DPERR_ACCESSDENIED
, hr
);
5113 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1], 0,
5114 NULL
, messageSize
);
5115 checkHR( DPERR_INVALIDPARAMS
, hr
);
5116 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1], 0,
5117 (LPVOID
) message
, 0 );
5118 checkHR( DPERR_INVALIDPARAMS
, hr
);
5121 /* Checking no message was sent */
5122 check_messages( pDP
[0], dpid
, 4, &callbackData
);
5123 checkStr( "", callbackData
.szTrace1
);
5124 check_messages( pDP
[1], dpid
, 4, &callbackData
);
5125 checkStr( "", callbackData
.szTrace1
);
5128 /* Regular parameters */
5129 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5131 (LPVOID
) message
, messageSize
);
5132 checkHR( DP_OK
, hr
);
5134 hr
= IDirectPlayX_Receive( pDP
[0], &dpid
[0], &dpid
[1],
5135 DPRECEIVE_FROMPLAYER
| DPRECEIVE_TOPLAYER
,
5136 lpData
, &dwDataSize
);
5137 checkHR( DP_OK
, hr
);
5138 checkStr( message
, (LPSTR
) lpData
);
5139 check( strlen(message
)+1, dwDataSize
);
5141 check_messages( pDP
[0], dpid
, 4, &callbackData
);
5142 checkStr( "", callbackData
.szTrace1
);
5143 check_messages( pDP
[1], dpid
, 4, &callbackData
);
5144 checkStr( "", callbackData
.szTrace1
);
5147 /* Message to a remote player */
5148 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[3], 0,
5149 (LPVOID
) message
, messageSize
);
5150 checkHR( DP_OK
, hr
);
5152 hr
= IDirectPlayX_Receive( pDP
[0], &dpid
[0], &dpid
[3],
5153 DPRECEIVE_FROMPLAYER
| DPRECEIVE_TOPLAYER
,
5154 lpData
, &dwDataSize
);
5155 checkHR( DPERR_NOMESSAGES
, hr
);
5156 hr
= IDirectPlayX_Receive( pDP
[1], &dpid
[0], &dpid
[3],
5157 DPRECEIVE_FROMPLAYER
| DPRECEIVE_TOPLAYER
,
5158 lpData
, &dwDataSize
);
5159 checkHR( DP_OK
, hr
);
5160 checkStr( message
, (LPSTR
) lpData
);
5161 check( strlen(message
)+1, dwDataSize
);
5163 check_messages( pDP
[0], dpid
, 4, &callbackData
);
5164 checkStr( "", callbackData
.szTrace1
);
5165 check_messages( pDP
[1], dpid
, 4, &callbackData
);
5166 checkStr( "", callbackData
.szTrace1
);
5171 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], DPID_ALLPLAYERS
, 0,
5172 (LPVOID
) message
, messageSize
);
5173 checkHR( DP_OK
, hr
);
5177 hr
= IDirectPlayX_Receive( pDP
[0], &dpid
[0], &dpid
[i
],
5178 DPRECEIVE_FROMPLAYER
| DPRECEIVE_TOPLAYER
,
5179 lpData
, &dwDataSize
);
5180 checkHR( DP_OK
, hr
);
5181 checkStr( message
, (LPSTR
) lpData
);
5183 hr
= IDirectPlayX_Receive( pDP
[1], &dpid
[0], &dpid
[3],
5184 DPRECEIVE_FROMPLAYER
| DPRECEIVE_TOPLAYER
,
5185 lpData
, &dwDataSize
);
5186 checkHR( DP_OK
, hr
);
5187 checkStr( message
, (LPSTR
) lpData
);
5189 check_messages( pDP
[0], dpid
, 4, &callbackData
);
5190 checkStr( "", callbackData
.szTrace1
);
5191 check_messages( pDP
[1], dpid
, 4, &callbackData
);
5192 checkStr( "", callbackData
.szTrace1
);
5195 hr
= IDirectPlayX_Send( pDP
[0], DPID_ALLPLAYERS
, dpid
[1],
5197 (LPVOID
) message
, messageSize
);
5198 checkHR( DPERR_INVALIDPLAYER
, hr
);
5199 hr
= IDirectPlayX_Send( pDP
[0], DPID_ALLPLAYERS
, DPID_ALLPLAYERS
,
5201 (LPVOID
) message
, messageSize
);
5202 checkHR( DPERR_INVALIDPLAYER
, hr
);
5206 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5208 (LPVOID
) message
, messageSize
);
5209 checkHR( DP_OK
, hr
);
5211 hr
= IDirectPlayX_Receive( pDP
[0], &dpid
[0], &dpid
[1],
5212 DPRECEIVE_FROMPLAYER
| DPRECEIVE_TOPLAYER
,
5213 lpData
, &dwDataSize
);
5214 checkHR( DP_OK
, hr
);
5215 checkStr( message
, (LPSTR
)lpData
);
5217 /* - Inorrect flags */
5218 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5220 (LPVOID
) message
, messageSize
);
5221 checkHR( DPERR_INVALIDPARAMS
, hr
);
5222 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5224 (LPVOID
) message
, messageSize
);
5225 checkHR( DPERR_INVALIDPARAMS
, hr
);
5226 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5227 DPSEND_ENCRYPTED
| DPSEND_SIGNED
,
5228 (LPVOID
) message
, messageSize
);
5229 checkHR( DPERR_INVALIDPARAMS
, hr
);
5231 /* - Correct flags, but session is not secure */
5232 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5233 DPSEND_ENCRYPTED
| DPSEND_GUARANTEED
,
5234 (LPVOID
) message
, messageSize
);
5235 checkHR( DPERR_INVALIDPARAMS
, hr
);
5236 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5237 DPSEND_SIGNED
| DPSEND_GUARANTEED
,
5238 (LPVOID
) message
, messageSize
);
5239 checkHR( DPERR_INVALIDPARAMS
, hr
);
5240 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5241 ( DPSEND_ENCRYPTED
|
5243 DPSEND_GUARANTEED
),
5244 (LPVOID
) message
, messageSize
);
5245 checkHR( DPERR_INVALIDPARAMS
, hr
);
5247 /* - Correct flags, secure session incorrectly opened (without flags) */
5248 hr
= IDirectPlayX_Close( pDP
[0] );
5249 checkHR( DP_OK
, hr
);
5252 hr
= IDirectPlayX_SecureOpen( pDP
[0], &dpsd
, DPOPEN_CREATE
, NULL
, NULL
);
5253 checkHR( DP_OK
, hr
);
5255 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[i
], NULL
, NULL
, NULL
, 0, 0 );
5257 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5258 DPSEND_ENCRYPTED
| DPSEND_GUARANTEED
,
5259 (LPVOID
) message
, messageSize
);
5260 checkHR( DPERR_INVALIDPARAMS
, hr
);
5261 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5262 DPSEND_SIGNED
| DPSEND_GUARANTEED
,
5263 (LPVOID
) message
, messageSize
);
5264 checkHR( DPERR_INVALIDPARAMS
, hr
);
5265 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5266 ( DPSEND_ENCRYPTED
|
5268 DPSEND_GUARANTEED
),
5269 (LPVOID
) message
, messageSize
);
5270 checkHR( DPERR_INVALIDPARAMS
, hr
);
5272 /* - Correct flags, secure session */
5273 hr
= IDirectPlayX_Close( pDP
[0] );
5274 checkHR( DP_OK
, hr
);
5276 dpsd
.dwFlags
= DPSESSION_SECURESERVER
;
5277 hr
= IDirectPlayX_SecureOpen( pDP
[0], &dpsd
, DPOPEN_CREATE
, NULL
, NULL
);
5278 checkHR( DP_OK
, hr
);
5279 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[0], NULL
, NULL
, NULL
, 0, 0 );
5280 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[1], NULL
, NULL
, NULL
, 0, 0 );
5283 check_messages( pDP
[0], dpid
, 6, &callbackData
);
5284 checkStr( "S0,", callbackData
.szTrace1
);
5287 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5288 DPSEND_ENCRYPTED
| DPSEND_GUARANTEED
,
5289 (LPVOID
) message
, messageSize
);
5290 checkHR( DP_OK
, hr
);
5291 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5292 DPSEND_SIGNED
| DPSEND_GUARANTEED
,
5293 (LPVOID
) message
, messageSize
);
5294 checkHR( DP_OK
, hr
);
5295 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5296 ( DPSEND_ENCRYPTED
|
5298 DPSEND_GUARANTEED
),
5299 (LPVOID
) message
, messageSize
);
5300 checkHR( DP_OK
, hr
);
5306 hr
= IDirectPlayX_Receive( pDP
[0], &idFrom
, &idTo
, 0, lpData
,
5309 lpDataSecure
= (LPDPMSG_SECUREMESSAGE
) lpData
;
5311 checkHR( DP_OK
, hr
);
5312 checkConv( DPSYS_SECUREMESSAGE
, lpData
->dwType
, dpMsgType2str
);
5313 check( DPID_SYSMSG
, idFrom
);
5314 check( dpid
[1], idTo
);
5315 check( dpid
[0], lpDataSecure
->dpIdFrom
);
5316 checkStr( message
, (LPSTR
) lpDataSecure
->lpData
);
5317 check( strlen(message
)+1, lpDataSecure
->dwDataSize
);
5322 checkFlags( DPSEND_ENCRYPTED
,
5323 lpDataSecure
->dwFlags
,
5327 checkFlags( DPSEND_SIGNED
,
5328 lpDataSecure
->dwFlags
,
5332 checkFlags( DPSEND_SIGNED
| DPSEND_ENCRYPTED
,
5333 lpDataSecure
->dwFlags
,
5339 check_messages( pDP
[0], dpid
, 4, &callbackData
);
5340 checkStr( "", callbackData
.szTrace1
);
5343 /* - Even in a secure session, incorrect flags still not working */
5344 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5346 (LPVOID
) message
, messageSize
);
5347 checkHR( DPERR_INVALIDPARAMS
, hr
);
5348 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5350 (LPVOID
) message
, messageSize
);
5351 checkHR( DPERR_INVALIDPARAMS
, hr
);
5352 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5353 DPSEND_ENCRYPTED
| DPSEND_SIGNED
,
5354 (LPVOID
) message
, messageSize
);
5355 checkHR( DPERR_INVALIDPARAMS
, hr
);
5358 HeapFree( GetProcessHeap(), 0, lpData
);
5359 IDirectPlayX_Release( pDP
[0] );
5360 IDirectPlayX_Release( pDP
[1] );
5366 static void test_Receive(void)
5370 DPSESSIONDESC2 dpsd
;
5371 DPID dpid
[4], idFrom
, idTo
;
5373 LPCSTR message
= "message";
5374 DWORD messageSize
= strlen(message
) + 1;
5375 DWORD dwDataSize
= 1024;
5376 LPDPMSG_GENERIC lpData
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
5378 LPDPMSG_CREATEPLAYERORGROUP lpDataCreate
;
5379 LPDPMSG_DESTROYPLAYERORGROUP lpDataDestroy
;
5385 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
5386 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
);
5387 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
5388 if (FAILED(hr
)) return;
5390 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
5391 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
5392 dpsd
.guidApplication
= appGuid
;
5394 init_TCPIP_provider( pDP
, "127.0.0.1", 0 );
5396 IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_CREATE
);
5399 /* Invalid parameters */
5400 hr
= IDirectPlayX_Receive( pDP
, NULL
, &idTo
, 0,
5401 lpData
, &dwDataSize
);
5402 todo_wine
checkHR( DPERR_INVALIDPARAMS
, hr
);
5404 if ( hr
== DPERR_UNINITIALIZED
)
5406 todo_wine
win_skip( "Receive not implemented\n" );
5410 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, NULL
, 0,
5411 lpData
, &dwDataSize
);
5412 checkHR( DPERR_INVALIDPARAMS
, hr
);
5413 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0,
5415 checkHR( DPERR_INVALIDPARAMS
, hr
);
5417 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0,
5418 lpData
, &dwDataSize
);
5419 checkHR( DPERR_INVALIDPARAMS
, hr
);
5421 /* No messages yet */
5422 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0,
5423 NULL
, &dwDataSize
);
5424 checkHR( DPERR_NOMESSAGES
, hr
);
5426 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0,
5427 lpData
, &dwDataSize
);
5428 checkHR( DPERR_NOMESSAGES
, hr
);
5431 IDirectPlayX_CreatePlayer( pDP
, &dpid
[0], NULL
, 0, NULL
, 0, 0 );
5432 IDirectPlayX_CreatePlayer( pDP
, &dpid
[1], NULL
, 0, NULL
, 0,
5433 DPPLAYER_SPECTATOR
);
5434 IDirectPlayX_CreatePlayer( pDP
, &dpid
[2], NULL
, 0, NULL
, 0, 0 );
5435 IDirectPlayX_CreatePlayer( pDP
, &dpid
[3], NULL
, 0, NULL
, 0, 0 );
5442 IDirectPlayX_GetMessageCount( pDP
, dpid
[i
], &dwCount
);
5443 check( 3-i
, dwCount
);
5447 IDirectPlayX_DestroyPlayer( pDP
, dpid
[3] );
5448 IDirectPlayX_DestroyPlayer( pDP
, dpid
[1] );
5453 IDirectPlayX_GetMessageCount( pDP
, dpid
[0], &dwCount
);
5454 check( 5, dwCount
);
5455 IDirectPlayX_GetMessageCount( pDP
, dpid
[1], &dwCount
);
5456 check( 5, dwCount
);
5457 IDirectPlayX_GetMessageCount( pDP
, dpid
[2], &dwCount
);
5458 check( 3, dwCount
);
5459 IDirectPlayX_GetMessageCount( pDP
, dpid
[3], &dwCount
);
5460 check( 3, dwCount
);
5463 /* Buffer too small */
5464 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idFrom
, 0,
5465 NULL
, &dwDataSize
);
5466 checkHR( DPERR_BUFFERTOOSMALL
, hr
);
5467 check( 48, dwDataSize
);
5469 hr
= IDirectPlayX_Receive( pDP
, &idTo
, &idFrom
, 0,
5470 lpData
, &dwDataSize
);
5471 checkHR( DPERR_BUFFERTOOSMALL
, hr
);
5472 check( 48, dwDataSize
);
5475 /* Checking the order or reception */
5476 for (i
=0; i
<11; i
++)
5479 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0,
5480 lpData
, &dwDataSize
);
5482 checkHR( DP_OK
, hr
);
5483 check( DPID_SYSMSG
, idFrom
);
5485 if (i
<6) /* Player creation */
5487 checkConv( DPSYS_CREATEPLAYERORGROUP
, lpData
->dwType
, dpMsgType2str
);
5488 check( 48, dwDataSize
);
5489 lpDataCreate
= (LPDPMSG_CREATEPLAYERORGROUP
) lpData
;
5490 check( DPPLAYERTYPE_PLAYER
, lpDataCreate
->dwPlayerType
);
5491 checkLP( NULL
, lpDataCreate
->lpData
);
5492 check( 0, lpDataCreate
->dwDataSize
);
5493 checkLP( NULL
, lpDataCreate
->dpnName
.lpszShortNameA
);
5494 check( 0, lpDataCreate
->dpIdParent
);
5496 else /* Player destruction */
5498 checkConv( DPSYS_DESTROYPLAYERORGROUP
, lpData
->dwType
,
5500 check( 52, dwDataSize
);
5501 lpDataDestroy
= (LPDPMSG_DESTROYPLAYERORGROUP
) lpData
;
5502 check( DPPLAYERTYPE_PLAYER
, lpDataDestroy
->dwPlayerType
);
5503 checkLP( NULL
, lpDataDestroy
->lpLocalData
);
5504 check( 0, lpDataDestroy
->dwLocalDataSize
);
5505 checkLP( NULL
, lpDataDestroy
->lpRemoteData
);
5506 check( 0, lpDataDestroy
->dwRemoteDataSize
);
5507 checkLP( NULL
, lpDataDestroy
->dpnName
.lpszShortNameA
);
5508 check( 0, lpDataDestroy
->dpIdParent
);
5515 lpDataCreate
= (LPDPMSG_CREATEPLAYERORGROUP
) lpData
;
5516 check( dpid
[0], idTo
);
5517 check( dpid
[1], lpDataCreate
->dpId
);
5518 check( 1, lpDataCreate
->dwCurrentPlayers
);
5519 checkFlags( DPPLAYER_LOCAL
|DPPLAYER_SPECTATOR
, lpDataCreate
->dwFlags
,
5520 FLAGS_DPPLAYER
|FLAGS_DPGROUP
);
5525 check( dpid
[1], idTo
);
5526 lpDataCreate
= (LPDPMSG_CREATEPLAYERORGROUP
) lpData
;
5527 check( dpid
[2], lpDataCreate
->dpId
);
5528 check( 2, lpDataCreate
->dwCurrentPlayers
);
5529 checkFlags( DPPLAYER_LOCAL
, lpDataCreate
->dwFlags
,
5530 FLAGS_DPPLAYER
| FLAGS_DPGROUP
);
5533 check( dpid
[0], idTo
);
5534 lpDataCreate
= (LPDPMSG_CREATEPLAYERORGROUP
) lpData
;
5535 check( dpid
[2], lpDataCreate
->dpId
);
5536 check( 2, lpDataCreate
->dwCurrentPlayers
);
5537 checkFlags( DPPLAYER_LOCAL
, lpDataCreate
->dwFlags
,
5538 FLAGS_DPPLAYER
| FLAGS_DPGROUP
);
5543 check( dpid
[2], idTo
);
5544 lpDataCreate
= (LPDPMSG_CREATEPLAYERORGROUP
) lpData
;
5545 check( dpid
[3], lpDataCreate
->dpId
);
5546 check( 3, lpDataCreate
->dwCurrentPlayers
);
5547 checkFlags( DPPLAYER_LOCAL
, lpDataCreate
->dwFlags
,
5548 FLAGS_DPPLAYER
| FLAGS_DPGROUP
);
5551 check( dpid
[1], idTo
);
5552 lpDataCreate
= (LPDPMSG_CREATEPLAYERORGROUP
) lpData
;
5553 check( dpid
[3], lpDataCreate
->dpId
);
5554 check( 3, lpDataCreate
->dwCurrentPlayers
);
5555 checkFlags( DPPLAYER_LOCAL
, lpDataCreate
->dwFlags
,
5556 FLAGS_DPPLAYER
| FLAGS_DPGROUP
);
5559 check( dpid
[0], idTo
);
5560 lpDataCreate
= (LPDPMSG_CREATEPLAYERORGROUP
) lpData
;
5561 check( dpid
[3], lpDataCreate
->dpId
);
5562 check( 3, lpDataCreate
->dwCurrentPlayers
);
5563 checkFlags( DPPLAYER_LOCAL
, lpDataCreate
->dwFlags
,
5564 FLAGS_DPPLAYER
| FLAGS_DPGROUP
);
5569 check( dpid
[2], idTo
);
5570 lpDataDestroy
= (LPDPMSG_DESTROYPLAYERORGROUP
) lpData
;
5571 check( dpid
[3], lpDataDestroy
->dpId
);
5572 checkFlags( DPPLAYER_LOCAL
, lpDataDestroy
->dwFlags
,
5573 FLAGS_DPPLAYER
| FLAGS_DPGROUP
);
5576 check( dpid
[1], idTo
);
5577 lpDataDestroy
= (LPDPMSG_DESTROYPLAYERORGROUP
) lpData
;
5578 check( dpid
[3], lpDataDestroy
->dpId
);
5579 checkFlags( DPPLAYER_LOCAL
, lpDataDestroy
->dwFlags
,
5580 FLAGS_DPPLAYER
| FLAGS_DPGROUP
);
5583 check( dpid
[0], idTo
);
5584 lpDataDestroy
= (LPDPMSG_DESTROYPLAYERORGROUP
) lpData
;
5585 check( dpid
[3], lpDataDestroy
->dpId
);
5586 checkFlags( DPPLAYER_LOCAL
, lpDataDestroy
->dwFlags
,
5587 FLAGS_DPPLAYER
| FLAGS_DPGROUP
);
5592 check( dpid
[2], idTo
);
5593 lpDataDestroy
= (LPDPMSG_DESTROYPLAYERORGROUP
) lpData
;
5594 check( dpid
[1], lpDataDestroy
->dpId
);
5595 checkFlags( DPPLAYER_LOCAL
|
5596 DPPLAYER_SPECTATOR
, lpDataDestroy
->dwFlags
,
5597 FLAGS_DPPLAYER
| FLAGS_DPGROUP
);
5600 check( dpid
[0], idTo
);
5601 lpDataDestroy
= (LPDPMSG_DESTROYPLAYERORGROUP
) lpData
;
5602 check( dpid
[1], lpDataDestroy
->dpId
);
5603 checkFlags( DPPLAYER_LOCAL
|
5604 DPPLAYER_SPECTATOR
, lpDataDestroy
->dwFlags
,
5605 FLAGS_DPPLAYER
| FLAGS_DPGROUP
);
5609 trace( "%s\n", dpMsgType2str(lpData
->dwType
) );
5614 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0, lpData
, &dwDataSize
);
5615 checkHR( DPERR_NOMESSAGES
, hr
);
5618 /* New data message */
5619 hr
= IDirectPlayX_Send( pDP
, dpid
[0], dpid
[2], 0,
5620 (LPVOID
) message
, messageSize
);
5621 checkHR( DP_OK
, hr
);
5624 /* Ensuring DPRECEIVE_PEEK doesn't remove the messages from the queue */
5625 for (i
=0; i
<10; i
++)
5627 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, DPRECEIVE_PEEK
,
5628 lpData
, &dwDataSize
);
5629 checkHR( DP_OK
, hr
);
5630 checkStr( message
, (LPSTR
) lpData
);
5633 /* Removing the message from the queue */
5634 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0, lpData
, &dwDataSize
);
5635 checkHR( DP_OK
, hr
);
5636 check( idFrom
, dpid
[0] );
5637 check( idTo
, dpid
[2] );
5638 checkStr( message
, (LPSTR
) lpData
);
5640 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0, lpData
, &dwDataSize
);
5641 checkHR( DPERR_NOMESSAGES
, hr
);
5644 HeapFree( GetProcessHeap(), 0, lpData
);
5645 IDirectPlayX_Release( pDP
);
5649 /* GetMessageCount */
5651 static void test_GetMessageCount(void)
5654 IDirectPlay4
*pDP
[2];
5655 DPSESSIONDESC2 dpsd
;
5661 DWORD dwDataSize
= 1024;
5662 LPVOID lpData
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, dwDataSize
);
5663 CallbackData callbackData
;
5668 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
5669 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
5670 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
5671 if (FAILED(hr
)) return;
5673 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
5676 hr
= IDirectPlayX_GetMessageCount( pDP
[0], 0, &dwCount
);
5677 todo_wine
checkHR( DPERR_UNINITIALIZED
, hr
);
5678 check( -1, dwCount
);
5682 todo_wine
win_skip( "GetMessageCount not implemented\n" );
5687 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
5688 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
5692 hr
= IDirectPlayX_GetMessageCount( pDP
[0], 0, &dwCount
);
5693 checkHR( DP_OK
, hr
);
5694 check( 0, dwCount
);
5697 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
5698 dpsd
.guidApplication
= appGuid
;
5699 dpsd
.dwMaxPlayers
= 10;
5700 IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
5701 IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
5704 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[0], NULL
, NULL
, NULL
, 0, 0 );
5705 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[1], NULL
, NULL
, NULL
, 0, 0 );
5706 IDirectPlayX_CreatePlayer( pDP
[1], &dpid
[3], NULL
, NULL
, NULL
, 0, 0 );
5707 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[2], NULL
, NULL
, NULL
, 0, 0 );
5710 /* Incorrect parameters */
5712 hr
= IDirectPlayX_GetMessageCount( pDP
[0], dpid
[0], NULL
);
5713 checkHR( DPERR_INVALIDPARAMS
, hr
);
5714 check( -1, dwCount
);
5717 hr
= IDirectPlayX_GetMessageCount( pDP
[0], 0, NULL
);
5718 checkHR( DPERR_INVALIDPARAMS
, hr
);
5719 check( -1, dwCount
);
5722 hr
= IDirectPlayX_GetMessageCount( pDP
[0], -1, &dwCount
);
5723 checkHR( DPERR_INVALIDPLAYER
, hr
);
5724 check( -1, dwCount
);
5727 /* Correct parameters */
5728 /* Player creation messages */
5730 hr
= IDirectPlayX_GetMessageCount( pDP
[0], 0, &dwCount
);
5731 checkHR( DP_OK
, hr
);
5732 check( 5, dwCount
);
5735 hr
= IDirectPlayX_GetMessageCount( pDP
[1], 0, &dwCount
);
5736 checkHR( DP_OK
, hr
);
5737 check( 1, dwCount
);
5740 hr
= IDirectPlayX_GetMessageCount( pDP
[0], dpid
[0], &dwCount
);
5741 checkHR( DP_OK
, hr
);
5742 check( 3, dwCount
);
5745 hr
= IDirectPlayX_GetMessageCount( pDP
[0], dpid
[1], &dwCount
);
5746 checkHR( DP_OK
, hr
);
5747 check( 2, dwCount
);
5750 hr
= IDirectPlayX_GetMessageCount( pDP
[0], dpid
[3], &dwCount
);
5751 checkHR( DP_OK
, hr
);
5752 /* Remote player: doesn't throw error but result is 0 and not 1 */
5753 check( 0, dwCount
);
5756 hr
= IDirectPlayX_GetMessageCount( pDP
[1], dpid
[3], &dwCount
);
5757 checkHR( DP_OK
, hr
);
5758 check( 1, dwCount
);
5761 hr
= IDirectPlayX_GetMessageCount( pDP
[0], dpid
[1], &dwCount
);
5762 checkHR( DP_OK
, hr
);
5763 check( 2, dwCount
);
5767 check_messages( pDP
[0], dpid
, 6, &callbackData
);
5768 checkStr( "S0,S1,S0,S1,S0,", callbackData
.szTrace1
);
5769 check_messages( pDP
[1], dpid
, 6, &callbackData
);
5770 checkStr( "S3,", callbackData
.szTrace1
);
5773 /* Ensure queues is purged */
5775 hr
= IDirectPlayX_GetMessageCount( pDP
[0], 0, &dwCount
);
5776 checkHR( DP_OK
, hr
);
5777 check( 0, dwCount
);
5780 hr
= IDirectPlayX_GetMessageCount( pDP
[1], 0, &dwCount
);
5781 checkHR( DP_OK
, hr
);
5782 check( 0, dwCount
);
5785 /* Send data messages */
5787 IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1], 0, lpData
, dwDataSize
);
5789 IDirectPlayX_Send( pDP
[0], dpid
[1], dpid
[2], 0, lpData
, dwDataSize
);
5791 IDirectPlayX_Send( pDP
[0], dpid
[2], dpid
[3], 0, lpData
, dwDataSize
);
5794 /* Check all messages are in the queues */
5796 hr
= IDirectPlayX_GetMessageCount( pDP
[0], 0, &dwCount
);
5797 checkHR( DP_OK
, hr
);
5798 check( 11, dwCount
);
5801 hr
= IDirectPlayX_GetMessageCount( pDP
[1], 0, &dwCount
);
5802 checkHR( DP_OK
, hr
);
5803 check( 7, dwCount
);
5806 hr
= IDirectPlayX_GetMessageCount( pDP
[0], dpid
[0], &dwCount
);
5807 checkHR( DP_OK
, hr
);
5808 check( 0, dwCount
);
5811 hr
= IDirectPlayX_GetMessageCount( pDP
[0], dpid
[1], &dwCount
);
5812 checkHR( DP_OK
, hr
);
5813 check( 5, dwCount
);
5816 hr
= IDirectPlayX_GetMessageCount( pDP
[0], dpid
[2], &dwCount
);
5817 checkHR( DP_OK
, hr
);
5818 check( 6, dwCount
);
5821 hr
= IDirectPlayX_GetMessageCount( pDP
[1], dpid
[3], &dwCount
);
5822 checkHR( DP_OK
, hr
);
5823 check( 7, dwCount
);
5826 /* Purge queues again */
5827 check_messages( pDP
[0], dpid
, 6, &callbackData
);
5828 checkStr( "01,01,01,01,01,"
5829 "12,12,12,12,12,12,", callbackData
.szTrace1
);
5830 check_messages( pDP
[1], dpid
, 6, &callbackData
);
5831 checkStr( "23,23,23,23,23,23,23,", callbackData
.szTrace1
);
5834 /* Check queues are purged */
5836 hr
= IDirectPlayX_GetMessageCount( pDP
[0], 0, &dwCount
);
5837 checkHR( DP_OK
, hr
);
5838 check( 0, dwCount
);
5841 hr
= IDirectPlayX_GetMessageCount( pDP
[1], 0, &dwCount
);
5842 checkHR( DP_OK
, hr
);
5843 check( 0, dwCount
);
5846 hr
= IDirectPlayX_GetMessageCount( pDP
[0], dpid
[0], &dwCount
);
5847 checkHR( DP_OK
, hr
);
5848 check( 0, dwCount
);
5851 hr
= IDirectPlayX_GetMessageCount( pDP
[0], dpid
[1], &dwCount
);
5852 checkHR( DP_OK
, hr
);
5853 check( 0, dwCount
);
5856 hr
= IDirectPlayX_GetMessageCount( pDP
[0], dpid
[2], &dwCount
);
5857 checkHR( DP_OK
, hr
);
5858 check( 0, dwCount
);
5861 hr
= IDirectPlayX_GetMessageCount( pDP
[1], dpid
[3], &dwCount
);
5862 checkHR( DP_OK
, hr
);
5863 check( 0, dwCount
);
5866 HeapFree( GetProcessHeap(), 0, lpData
);
5867 IDirectPlayX_Release( pDP
[0] );
5868 IDirectPlayX_Release( pDP
[1] );
5872 /* GetMessageQueue */
5874 static void test_GetMessageQueue(void)
5877 IDirectPlay4
*pDP
[2];
5878 DPSESSIONDESC2 dpsd
;
5880 CallbackData callbackData
;
5883 DWORD dwNumMsgs
, dwNumBytes
;
5885 DWORD dwDataSize
= 1024;
5886 LPVOID lpData
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, dwDataSize
);
5891 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
5892 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
5893 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
5894 if (FAILED(hr
)) return;
5896 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
5899 dwNumMsgs
= dwNumBytes
= -1;
5900 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], 0, 0, 0,
5901 &dwNumMsgs
, &dwNumBytes
);
5902 todo_wine
checkHR( DPERR_UNINITIALIZED
, hr
);
5903 check( -1, dwNumMsgs
);
5904 check( -1, dwNumBytes
);
5908 todo_wine
win_skip( "GetMessageQueue not implemented\n" );
5913 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
5914 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
5917 dwNumMsgs
= dwNumBytes
= -1;
5918 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], 0, 0, 0,
5919 &dwNumMsgs
, &dwNumBytes
);
5920 checkHR( DP_OK
, hr
);
5921 check( 0, dwNumMsgs
);
5922 check( 0, dwNumBytes
);
5925 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
5926 dpsd
.guidApplication
= appGuid
;
5927 dpsd
.dwMaxPlayers
= 10;
5928 IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
5929 IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
5932 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[0], NULL
, NULL
, NULL
, 0, 0 );
5933 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[1], NULL
, NULL
, NULL
, 0, 0 );
5934 IDirectPlayX_CreatePlayer( pDP
[1], &dpid
[3], NULL
, NULL
, NULL
, 0, 0 );
5935 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[2], NULL
, NULL
, NULL
, 0, 0 );
5939 /* Incorrect parameters */
5940 dwNumMsgs
= dwNumBytes
= -1;
5941 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], -1, dpid
[1],
5943 &dwNumMsgs
, &dwNumBytes
);
5944 checkHR( DPERR_INVALIDPLAYER
, hr
);
5945 check( -1, dwNumMsgs
);
5946 check( -1, dwNumBytes
);
5948 dwNumMsgs
= dwNumBytes
= -1;
5949 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], -1,
5951 &dwNumMsgs
, &dwNumBytes
);
5952 checkHR( DPERR_INVALIDPLAYER
, hr
);
5953 check( -1, dwNumMsgs
);
5954 check( -1, dwNumBytes
);
5956 dwNumMsgs
= dwNumBytes
= -1;
5957 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], dpid
[0],
5959 &dwNumMsgs
, &dwNumBytes
);
5960 checkHR( DPERR_INVALIDFLAGS
, hr
);
5961 check( -1, dwNumMsgs
);
5962 check( -1, dwNumBytes
);
5964 dwNumMsgs
= dwNumBytes
= -1;
5965 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], dpid
[1],
5966 ( DPMESSAGEQUEUE_SEND
|
5967 DPMESSAGEQUEUE_RECEIVE
),
5968 &dwNumMsgs
, &dwNumBytes
);
5969 checkHR( DPERR_INVALIDFLAGS
, hr
);
5970 check( -1, dwNumMsgs
);
5971 check( -1, dwNumBytes
);
5973 /* - Remote players */
5976 /* Crash under Win7 */
5977 dwNumMsgs
= dwNumBytes
= -1;
5978 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], 0, dpid
[3],
5979 DPMESSAGEQUEUE_RECEIVE
,
5980 &dwNumMsgs
, &dwNumBytes
);
5981 checkHR( DPERR_INVALIDPLAYER
, hr
); /* Player 3 is remote */
5982 check( -1, dwNumMsgs
);
5983 check( -1, dwNumBytes
);
5986 dwNumMsgs
= dwNumBytes
= -1;
5987 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[3], 0,
5988 DPMESSAGEQUEUE_SEND
,
5989 &dwNumMsgs
, &dwNumBytes
);
5990 checkHR( DPERR_INVALIDPLAYER
, hr
); /* Player 3 is remote */
5991 check( -1, dwNumMsgs
);
5992 check( -1, dwNumBytes
);
5994 /* - Remote players, this time in the right place */
5995 dwNumMsgs
= dwNumBytes
= -1;
5996 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], 0, dpid
[3],
5997 DPMESSAGEQUEUE_SEND
,
5998 &dwNumMsgs
, &dwNumBytes
);
5999 checkHR( DP_OK
, hr
);
6000 check( 0, dwNumMsgs
);
6001 check( 0, dwNumBytes
);
6003 dwNumMsgs
= dwNumBytes
= -1;
6004 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[3], 0,
6005 DPMESSAGEQUEUE_RECEIVE
,
6006 &dwNumMsgs
, &dwNumBytes
);
6007 checkHR( DP_OK
, hr
);
6008 check( 0, dwNumMsgs
);
6009 check( 0, dwNumBytes
);
6012 /* Correct parameters */
6013 dwNumMsgs
= dwNumBytes
= -1;
6014 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], 0, dpid
[1],
6015 DPMESSAGEQUEUE_RECEIVE
,
6016 &dwNumMsgs
, &dwNumBytes
);
6017 checkHR( DP_OK
, hr
);
6018 check( 2, dwNumMsgs
);
6019 check( 96, dwNumBytes
);
6021 dwNumMsgs
= dwNumBytes
= -1;
6022 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], 0,
6023 DPMESSAGEQUEUE_RECEIVE
,
6024 &dwNumMsgs
, &dwNumBytes
);
6025 checkHR( DP_OK
, hr
);
6026 check( 0, dwNumMsgs
);
6027 check( 0, dwNumBytes
);
6029 dwNumMsgs
= dwNumBytes
= -1;
6030 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], 0, 0,
6031 DPMESSAGEQUEUE_RECEIVE
,
6032 &dwNumMsgs
, &dwNumBytes
);
6033 checkHR( DP_OK
, hr
);
6034 check( 5, dwNumMsgs
);
6035 check( 240, dwNumBytes
);
6037 dwNumMsgs
= dwNumBytes
= -1;
6038 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], dpid
[1],
6039 DPMESSAGEQUEUE_RECEIVE
,
6040 NULL
, &dwNumBytes
);
6041 checkHR( DP_OK
, hr
);
6042 check( -1, dwNumMsgs
);
6043 check( 0, dwNumBytes
);
6045 dwNumMsgs
= dwNumBytes
= -1;
6046 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], dpid
[1],
6047 DPMESSAGEQUEUE_RECEIVE
,
6049 checkHR( DP_OK
, hr
);
6050 check( 0, dwNumMsgs
);
6051 check( -1, dwNumBytes
);
6053 dwNumMsgs
= dwNumBytes
= -1;
6054 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], dpid
[1],
6055 DPMESSAGEQUEUE_RECEIVE
,
6057 checkHR( DP_OK
, hr
);
6058 check( -1, dwNumMsgs
);
6059 check( -1, dwNumBytes
);
6061 dwNumMsgs
= dwNumBytes
= -1;
6062 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], dpid
[1],
6063 DPMESSAGEQUEUE_RECEIVE
,
6064 &dwNumMsgs
, &dwNumBytes
);
6065 checkHR( DP_OK
, hr
);
6066 check( 0, dwNumMsgs
);
6067 check( 0, dwNumBytes
);
6070 /* Purge messages */
6071 check_messages( pDP
[0], dpid
, 6, &callbackData
);
6072 checkStr( "S0,S1,S0,S1,S0,", callbackData
.szTrace1
);
6073 check_messages( pDP
[1], dpid
, 6, &callbackData
);
6074 checkStr( "S3,", callbackData
.szTrace1
);
6076 /* Check queues are empty */
6077 dwNumMsgs
= dwNumBytes
= -1;
6078 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], 0, 0,
6079 DPMESSAGEQUEUE_RECEIVE
,
6080 &dwNumMsgs
, &dwNumBytes
);
6081 checkHR( DP_OK
, hr
);
6082 check( 0, dwNumMsgs
);
6083 check( 0, dwNumBytes
);
6086 /* Sending 4 data messages from 0 to 1 */
6090 IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1], 0, lpData
, dwDataSize
);
6092 IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[3], 0, lpData
, dwDataSize
);
6094 IDirectPlayX_Send( pDP
[0], dpid
[1], dpid
[3], 0, lpData
, dwDataSize
);
6097 dwNumMsgs
= dwNumBytes
= -1;
6098 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], dpid
[1],
6099 DPMESSAGEQUEUE_RECEIVE
,
6100 &dwNumMsgs
, &dwNumBytes
);
6101 checkHR( DP_OK
, hr
);
6102 check( 4, dwNumMsgs
);
6103 check( 4*dwDataSize
, dwNumBytes
);
6105 dwNumMsgs
= dwNumBytes
= -1;
6106 hr
= IDirectPlayX_GetMessageQueue( pDP
[1], dpid
[0], dpid
[3],
6107 DPMESSAGEQUEUE_RECEIVE
,
6108 &dwNumMsgs
, &dwNumBytes
);
6109 checkHR( DP_OK
, hr
);
6110 check( 3, dwNumMsgs
);
6111 check( 3*dwDataSize
, dwNumBytes
);
6113 dwNumMsgs
= dwNumBytes
= -1;
6114 hr
= IDirectPlayX_GetMessageQueue( pDP
[1], dpid
[1], dpid
[3],
6115 DPMESSAGEQUEUE_RECEIVE
,
6116 &dwNumMsgs
, &dwNumBytes
);
6117 checkHR( DP_OK
, hr
);
6118 check( 2, dwNumMsgs
);
6119 check( 2*dwDataSize
, dwNumBytes
);
6121 dwNumMsgs
= dwNumBytes
= -1;
6122 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], 0,
6123 DPMESSAGEQUEUE_RECEIVE
,
6124 &dwNumMsgs
, &dwNumBytes
);
6125 checkHR( DP_OK
, hr
);
6126 check( 4, dwNumMsgs
);
6127 check( 4*dwDataSize
, dwNumBytes
);
6129 dwNumMsgs
= dwNumBytes
= -1;
6130 hr
= IDirectPlayX_GetMessageQueue( pDP
[1], dpid
[0], 0,
6131 DPMESSAGEQUEUE_RECEIVE
,
6132 &dwNumMsgs
, &dwNumBytes
);
6133 checkHR( DP_OK
, hr
);
6134 check( 3, dwNumMsgs
);
6135 check( 3*dwDataSize
, dwNumBytes
);
6137 dwNumMsgs
= dwNumBytes
= -1;
6138 hr
= IDirectPlayX_GetMessageQueue( pDP
[1], 0, dpid
[3],
6139 DPMESSAGEQUEUE_RECEIVE
,
6140 &dwNumMsgs
, &dwNumBytes
);
6141 checkHR( DP_OK
, hr
);
6142 check( 5, dwNumMsgs
);
6143 check( 5*dwDataSize
, dwNumBytes
);
6145 dwNumMsgs
= dwNumBytes
= -1;
6146 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], 0, 0,
6147 DPMESSAGEQUEUE_RECEIVE
,
6148 &dwNumMsgs
, &dwNumBytes
);
6149 checkHR( DP_OK
, hr
);
6150 check( 4, dwNumMsgs
);
6151 check( 4*dwDataSize
, dwNumBytes
);
6153 dwNumMsgs
= dwNumBytes
= -1;
6154 hr
= IDirectPlayX_GetMessageQueue( pDP
[1], 0, 0,
6155 DPMESSAGEQUEUE_RECEIVE
,
6156 &dwNumMsgs
, &dwNumBytes
);
6157 checkHR( DP_OK
, hr
);
6158 check( 5, dwNumMsgs
);
6159 check( 5*dwDataSize
, dwNumBytes
);
6162 dwNumMsgs
= dwNumBytes
= -1;
6163 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], dpid
[1],
6164 DPMESSAGEQUEUE_SEND
,
6165 &dwNumMsgs
, &dwNumBytes
);
6166 checkHR( DP_OK
, hr
);
6167 check( 0, dwNumMsgs
);
6168 check( 0, dwNumBytes
);
6170 dwNumMsgs
= dwNumBytes
= -1;
6171 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], dpid
[1],
6173 &dwNumMsgs
, &dwNumBytes
);
6174 checkHR( DP_OK
, hr
);
6175 check( 0, dwNumMsgs
);
6176 check( 0, dwNumBytes
);
6179 HeapFree( GetProcessHeap(), 0, lpData
);
6180 IDirectPlayX_Release( pDP
[0] );
6181 IDirectPlayX_Release( pDP
[1] );
6185 /* Remote data replication */
6187 static void test_remote_data_replication(void)
6190 IDirectPlay4
*pDP
[2];
6191 DPSESSIONDESC2 dpsd
;
6192 DPID dpid
[2], idFrom
, idTo
;
6193 CallbackData callbackData
;
6196 DWORD dwFlags
, dwDataSize
= 1024;
6199 LPDPMSG_SETPLAYERORGROUPDATA lpData
= HeapAlloc( GetProcessHeap(),
6203 LPCSTR lpDataLocal
[] = { "local_0", "local_1" };
6204 LPCSTR lpDataRemote
[] = { "remote_0", "remote_1" };
6205 LPCSTR lpDataFake
= "ugly_fake_data";
6206 LPSTR lpDataGet
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, 32 );
6207 DWORD dwDataSizeLocal
= strlen(lpDataLocal
[0])+1,
6208 dwDataSizeRemote
= strlen(lpDataRemote
[0])+1,
6209 dwDataSizeFake
= strlen(lpDataFake
)+1,
6215 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
6216 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
6217 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
6218 if (FAILED(hr
)) return;
6219 init_TCPIP_provider( pDP
[i
], "127.0.0.1", 0 );
6221 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
6222 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
6223 dpsd
.guidApplication
= appGuid
;
6226 hr
= IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
6227 todo_wine
checkHR( DP_OK
, hr
);
6229 if ( hr
== DPERR_UNINITIALIZED
)
6231 todo_wine
win_skip( "dplay not implemented enough for this test yet\n" );
6235 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[0],
6236 NULL
, NULL
, NULL
, 0, 0 );
6237 checkHR( DP_OK
, hr
);
6240 hr
= IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
6242 checkHR( DP_OK
, hr
);
6244 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &dpid
[1],
6245 NULL
, NULL
, NULL
, 0, 0 );
6246 checkHR( DP_OK
, hr
);
6251 /* Local (0,0) (1,1) */
6252 IDirectPlayX_GetPlayerFlags( pDP
[i
], dpid
[i
], &dwFlags
);
6253 checkFlags( DPPLAYER_LOCAL
, dwFlags
, FLAGS_DPPLAYER
);
6254 /* Remote (0,1) (1,0) */
6255 IDirectPlayX_GetPlayerFlags( pDP
[i
], dpid
[!i
], &dwFlags
);
6256 checkFlags( 0, dwFlags
, FLAGS_DPPLAYER
);
6259 /* Set data for a local player */
6262 hr
= IDirectPlayX_SetPlayerData( pDP
[i
], dpid
[i
],
6263 (LPVOID
) lpDataLocal
[i
],
6266 checkHR( DP_OK
, hr
);
6267 hr
= IDirectPlayX_SetPlayerData( pDP
[i
], dpid
[i
],
6268 (LPVOID
) lpDataRemote
[i
],
6271 checkHR( DP_OK
, hr
);
6274 /* Retrieve data locally (0->0, 1->1) */
6277 dwDataSizeGet
= dwDataSizeFake
;
6278 strcpy( lpDataGet
, lpDataFake
);
6279 hr
= IDirectPlayX_GetPlayerData( pDP
[i
], dpid
[i
],
6280 lpDataGet
, &dwDataSizeGet
,
6282 checkHR( DP_OK
, hr
);
6283 check( dwDataSizeLocal
, dwDataSizeGet
);
6284 checkStr( lpDataLocal
[i
], lpDataGet
);
6286 dwDataSizeGet
= dwDataSizeFake
;
6287 strcpy( lpDataGet
, lpDataFake
);
6288 hr
= IDirectPlayX_GetPlayerData( pDP
[i
], dpid
[i
],
6289 lpDataGet
, &dwDataSizeGet
,
6291 checkHR( DP_OK
, hr
);
6292 check( dwDataSizeRemote
, dwDataSizeGet
);
6293 checkStr( lpDataRemote
[i
], lpDataGet
);
6297 /* Set data for a remote player */
6298 /* This should fail with DPERR_ACCESSDENIED,
6299 but for some reason it doesn't */
6302 IDirectPlayX_SetPlayerData( pDP
[i
], dpid
[!i
],
6303 (LPVOID
) lpDataLocal
[!i
],
6306 checkHR( DP_OK
, hr
);
6307 IDirectPlayX_SetPlayerData( pDP
[i
], dpid
[!i
],
6308 (LPVOID
) lpDataRemote
[!i
],
6311 checkHR( DP_OK
, hr
);
6314 /* Retrieve crossed data (0->1, 1->0) */
6317 dwDataSizeGet
= dwDataSizeFake
;
6318 strcpy( lpDataGet
, lpDataFake
);
6319 hr
= IDirectPlayX_GetPlayerData( pDP
[i
], dpid
[!i
],
6320 lpDataGet
, &dwDataSizeGet
,
6322 checkHR( DP_OK
, hr
);
6323 check( dwDataSizeLocal
, dwDataSizeGet
);
6324 checkStr( lpDataLocal
[!i
], lpDataGet
);
6326 dwDataSizeGet
= dwDataSizeFake
;
6327 strcpy( lpDataGet
, lpDataFake
);
6328 hr
= IDirectPlayX_GetPlayerData( pDP
[i
], dpid
[!i
],
6329 lpDataGet
, &dwDataSizeGet
,
6331 checkHR( DP_OK
, hr
);
6332 check( dwDataSizeRemote
, dwDataSizeGet
);
6333 checkStr( lpDataRemote
[!i
], lpDataGet
);
6337 /* Purge "new player" messages from queue */
6338 hr
= IDirectPlayX_Receive( pDP
[0], &idFrom
, &idTo
, 0, lpData
, &dwDataSize
);
6339 checkHR( DP_OK
, hr
);
6340 checkConv( DPSYS_CREATEPLAYERORGROUP
, lpData
->dwType
, dpMsgType2str
);
6342 /* Check number of messages in queue */
6345 IDirectPlayX_GetMessageCount( pDP
[i
], dpid
[i
], &dwCount
);
6346 check( 2, dwCount
);
6347 IDirectPlayX_GetMessageCount( pDP
[i
], dpid
[!i
], &dwCount
);
6348 check( 0, dwCount
);
6351 /* Checking system messages */
6356 hr
= IDirectPlayX_Receive( pDP
[i
], &idFrom
, &idTo
, 0, lpData
,
6358 checkHR( DP_OK
, hr
);
6359 check( 29, dwDataSize
);
6360 check( DPID_SYSMSG
, idFrom
);
6361 check( dpid
[i
], idTo
);
6362 checkConv( DPSYS_SETPLAYERORGROUPDATA
, lpData
->dwType
,
6364 check( DPPLAYERTYPE_PLAYER
, lpData
->dwPlayerType
);
6365 check( dpid
[j
], lpData
->dpId
);
6366 checkStr( lpDataRemote
[j
], (LPSTR
) lpData
->lpData
);
6367 check( dwDataSizeRemote
, lpData
->dwDataSize
);
6370 hr
= IDirectPlayX_Receive( pDP
[i
], &idFrom
, &idTo
, 0,
6371 lpData
, &dwDataSize
);
6372 checkHR( DPERR_NOMESSAGES
, hr
);
6376 /* Changing remote data */
6377 hr
= IDirectPlayX_SetPlayerData( pDP
[0], dpid
[0],
6378 (LPVOID
) lpDataRemote
[0], dwDataSizeRemote
,
6380 checkHR( DP_OK
, hr
);
6382 /* Checking system messages (j=0) */
6385 hr
= IDirectPlayX_Receive( pDP
[i
], &idFrom
, &idTo
, 0,
6386 lpData
, &dwDataSize
);
6387 checkHR( DP_OK
, hr
);
6388 check( 29, dwDataSize
);
6389 check( DPID_SYSMSG
, idFrom
);
6390 check( dpid
[i
], idTo
);
6391 checkConv( DPSYS_SETPLAYERORGROUPDATA
, lpData
->dwType
, dpMsgType2str
);
6392 check( DPPLAYERTYPE_PLAYER
, lpData
->dwPlayerType
);
6393 check( dpid
[0], lpData
->dpId
);
6394 checkStr( lpDataRemote
[0], (LPSTR
) lpData
->lpData
);
6395 check( dwDataSizeRemote
, lpData
->dwDataSize
);
6399 /* Queue is empty */
6400 check_messages( pDP
[0], dpid
, 2, &callbackData
);
6401 checkStr( "", callbackData
.szTrace1
);
6402 check_messages( pDP
[1], dpid
, 2, &callbackData
);
6403 checkStr( "", callbackData
.szTrace1
);
6406 HeapFree( GetProcessHeap(), 0, lpDataGet
);
6407 HeapFree( GetProcessHeap(), 0, lpData
);
6408 IDirectPlayX_Release( pDP
[0] );
6409 IDirectPlayX_Release( pDP
[1] );
6413 /* Host migration */
6415 static void test_host_migration(void)
6418 IDirectPlay4
*pDP
[2];
6419 DPSESSIONDESC2 dpsd
;
6420 DPID dpid
[2], idFrom
, idTo
;
6425 DWORD dwDataSize
= 1024;
6426 LPDPMSG_DESTROYPLAYERORGROUP lpData
= HeapAlloc( GetProcessHeap(),
6433 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
6434 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
6435 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
6436 if (FAILED(hr
)) return;
6437 init_TCPIP_provider( pDP
[i
], "127.0.0.1", 0 );
6439 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
6440 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
6441 dpsd
.guidApplication
= appGuid
;
6442 dpsd
.dwMaxPlayers
= 10;
6443 dpsd
.dwFlags
= DPSESSION_MIGRATEHOST
;
6446 hr
= IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
6447 todo_wine
checkHR( DP_OK
, hr
);
6451 todo_wine
win_skip( "dplay not implemented enough for this test yet\n" );
6455 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[0], NULL
, NULL
, NULL
, 0, 0 );
6456 checkHR( DP_OK
, hr
);
6459 hr
= IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
6461 checkHR( DP_OK
, hr
);
6463 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &dpid
[1], NULL
, NULL
, NULL
, 0, 0 );
6464 checkHR( DP_OK
, hr
);
6467 /* Host: One message in queue */
6468 IDirectPlayX_GetMessageCount( pDP
[0], dpid
[0], &dwCount
);
6469 check( 1, dwCount
);
6471 hr
= IDirectPlayX_Receive( pDP
[0], &idFrom
, &idTo
, DPRECEIVE_PEEK
,
6472 lpData
, &dwDataSize
);
6473 checkHR( DP_OK
, hr
);
6474 checkConv( DPSYS_CREATEPLAYERORGROUP
, lpData
->dwType
, dpMsgType2str
);
6476 /* Peer: No messages */
6477 IDirectPlayX_GetMessageCount( pDP
[1], dpid
[1], &dwCount
);
6478 check( 0, dwCount
);
6479 hr
= IDirectPlayX_Receive( pDP
[1], &idFrom
, &idTo
, DPRECEIVE_PEEK
,
6480 lpData
, &dwDataSize
);
6481 checkHR( DPERR_NOMESSAGES
, hr
);
6485 IDirectPlayX_Close( pDP
[0] );
6488 /* Host: Queue is cleaned */
6489 IDirectPlayX_GetMessageCount( pDP
[0], dpid
[0], &dwCount
);
6490 check( 0, dwCount
);
6491 hr
= IDirectPlayX_Receive( pDP
[0], &idFrom
, &idTo
, DPRECEIVE_PEEK
,
6492 lpData
, &dwDataSize
);
6493 checkHR( DPERR_NOMESSAGES
, hr
);
6495 /* Peer: gets message of player destruction */
6496 IDirectPlayX_GetMessageCount( pDP
[1], dpid
[1], &dwCount
);
6497 check( 2, dwCount
);
6499 hr
= IDirectPlayX_Receive( pDP
[1], &idFrom
, &idTo
, DPRECEIVE_PEEK
,
6500 lpData
, &dwDataSize
);
6501 checkHR( DP_OK
, hr
);
6502 checkConv( DPSYS_DESTROYPLAYERORGROUP
, lpData
->dwType
, dpMsgType2str
);
6505 /* Message analysis */
6508 hr
= IDirectPlayX_Receive( pDP
[1], &idFrom
, &idTo
, 0,
6509 lpData
, &dwDataSize
);
6510 checkHR( DP_OK
, hr
);
6511 check( DPID_SYSMSG
, idFrom
);
6512 check( dpid
[1], idTo
); /* Peer player id */
6516 checkConv( DPSYS_DESTROYPLAYERORGROUP
, lpData
->dwType
,
6518 check( DPPLAYERTYPE_PLAYER
, lpData
->dwPlayerType
);
6519 check( dpid
[0], lpData
->dpId
); /* Host player id */
6520 checkLP( NULL
, lpData
->lpLocalData
);
6521 check( 0, lpData
->dwLocalDataSize
);
6522 checkLP( NULL
, lpData
->lpRemoteData
);
6523 check( 0, lpData
->dwRemoteDataSize
);
6524 checkLP( NULL
, lpData
->dpnName
.lpszShortNameA
);
6525 check( 0, lpData
->dpIdParent
);
6526 checkFlags( 0, lpData
->dwFlags
,
6527 FLAGS_DPPLAYER
| FLAGS_DPGROUP
);
6530 checkConv( DPSYS_HOST
, lpData
->dwType
, dpMsgType2str
);
6537 hr
= IDirectPlayX_Receive( pDP
[1], &idFrom
, &idTo
, 0, lpData
, &dwDataSize
);
6538 checkHR( DPERR_NOMESSAGES
, hr
);
6541 HeapFree( GetProcessHeap(), 0, lpData
);
6542 IDirectPlayX_Release( pDP
[0] );
6543 IDirectPlayX_Release( pDP
[1] );
6547 static void test_COM(void)
6550 IDirectPlay2A
*dp2A
;
6552 IDirectPlay3A
*dp3A
;
6554 IDirectPlay4A
*dp4A
;
6555 IDirectPlay4
*dp4
= (IDirectPlay4
*)0xdeadbeef;
6560 /* COM aggregation */
6561 hr
= CoCreateInstance(&CLSID_DirectPlay
, (IUnknown
*)0xdeadbeef, CLSCTX_INPROC_SERVER
,
6562 &IID_IUnknown
, (void**)&dp4
);
6563 ok(hr
== CLASS_E_NOAGGREGATION
|| broken(hr
== E_INVALIDARG
),
6564 "DirectPlay create failed: %08lx, expected CLASS_E_NOAGGREGATION\n", hr
);
6565 ok(!dp4
|| dp4
== (IDirectPlay4
*)0xdeadbeef, "dp4 = %p\n", dp4
);
6568 hr
= CoCreateInstance(&CLSID_DirectPlay
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectPlayLobby
,
6570 ok(hr
== E_NOINTERFACE
, "DirectPlay create failed: %08lx, expected E_NOINTERFACE\n", hr
);
6572 /* Different refcount for all DirectPlay Interfaces */
6573 hr
= CoCreateInstance(&CLSID_DirectPlay
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectPlay4
,
6575 ok(hr
== S_OK
, "DirectPlay create failed: %08lx, expected S_OK\n", hr
);
6576 refcount
= IDirectPlayX_AddRef(dp4
);
6577 ok(refcount
== 2, "refcount == %lu, expected 2\n", refcount
);
6579 hr
= IDirectPlayX_QueryInterface(dp4
, &IID_IDirectPlay2A
, (void**)&dp2A
);
6580 ok(hr
== S_OK
, "QueryInterface for IID_IDirectPlay2A failed: %08lx\n", hr
);
6581 refcount
= IDirectPlay2_AddRef(dp2A
);
6582 ok(refcount
== 2, "refcount == %lu, expected 2\n", refcount
);
6583 IDirectPlay2_Release(dp2A
);
6585 hr
= IDirectPlayX_QueryInterface(dp4
, &IID_IDirectPlay2
, (void**)&dp2
);
6586 ok(hr
== S_OK
, "QueryInterface for IID_IDirectPlay2 failed: %08lx\n", hr
);
6587 refcount
= IDirectPlay2_AddRef(dp2
);
6588 ok(refcount
== 2, "refcount == %lu, expected 2\n", refcount
);
6589 IDirectPlay2_Release(dp2
);
6591 hr
= IDirectPlayX_QueryInterface(dp4
, &IID_IDirectPlay3A
, (void**)&dp3A
);
6592 ok(hr
== S_OK
, "QueryInterface for IID_IDirectPlay3A failed: %08lx\n", hr
);
6593 refcount
= IDirectPlay3_AddRef(dp3A
);
6594 ok(refcount
== 2, "refcount == %lu, expected 2\n", refcount
);
6595 IDirectPlay3_Release(dp3A
);
6597 hr
= IDirectPlayX_QueryInterface(dp4
, &IID_IDirectPlay3
, (void**)&dp3
);
6598 ok(hr
== S_OK
, "QueryInterface for IID_IDirectPlay3 failed: %08lx\n", hr
);
6599 refcount
= IDirectPlay3_AddRef(dp3
);
6600 ok(refcount
== 2, "refcount == %lu, expected 2\n", refcount
);
6601 IDirectPlay3_Release(dp3
);
6603 hr
= IDirectPlayX_QueryInterface(dp4
, &IID_IDirectPlay4A
, (void**)&dp4A
);
6604 ok(hr
== S_OK
, "QueryInterface for IID_IDirectPlay4A failed: %08lx\n", hr
);
6605 refcount
= IDirectPlayX_AddRef(dp4A
);
6606 ok(refcount
== 2, "refcount == %lu, expected 2\n", refcount
);
6607 IDirectPlayX_Release(dp4A
);
6609 /* IDirectPlay and IUnknown share a refcount */
6610 hr
= IDirectPlayX_QueryInterface(dp4
, &IID_IDirectPlay
, (void**)&dp
);
6611 ok(hr
== S_OK
, "QueryInterface for IID_IDirectPlay failed: %08lx\n", hr
);
6612 refcount
= IDirectPlayX_AddRef(dp
);
6613 ok(refcount
== 2, "refcount == %lu, expected 2\n", refcount
);
6614 IDirectPlay_Release(dp
);
6616 hr
= IDirectPlayX_QueryInterface(dp4
, &IID_IUnknown
, (void**)&unk
);
6617 ok(hr
== S_OK
, "QueryInterface for IID_IUnknown failed: %08lx\n", hr
);
6618 refcount
= IUnknown_AddRef(unk
);
6619 ok(refcount
== 3, "refcount == %lu, expected 3\n", refcount
);
6620 refcount
= IUnknown_Release(unk
);
6621 ok(refcount
== 2, "refcount == %lu, expected 2\n", refcount
);
6623 IUnknown_Release(unk
);
6624 IDirectPlay_Release(dp
);
6625 IDirectPlayX_Release(dp4A
);
6626 IDirectPlay3_Release(dp3
);
6627 IDirectPlay3_Release(dp3A
);
6628 IDirectPlay2_Release(dp2
);
6629 IDirectPlay2_Release(dp2A
);
6630 IDirectPlayX_Release(dp4
);
6631 refcount
= IDirectPlayX_Release(dp4
);
6632 ok(refcount
== 0, "refcount == %lu, expected 0\n", refcount
);
6635 static void test_COM_dplobby(void)
6637 IDirectPlayLobby
*dpl
= (IDirectPlayLobby
*)0xdeadbeef;
6638 IDirectPlayLobbyA
*dplA
;
6639 IDirectPlayLobby2A
*dpl2A
;
6640 IDirectPlayLobby2
*dpl2
;
6641 IDirectPlayLobby3A
*dpl3A
;
6642 IDirectPlayLobby3
*dpl3
;
6647 /* COM aggregation */
6648 hr
= CoCreateInstance(&CLSID_DirectPlayLobby
, (IUnknown
*)0xdeadbeef, CLSCTX_INPROC_SERVER
,
6649 &IID_IUnknown
, (void**)&dpl
);
6650 ok(hr
== CLASS_E_NOAGGREGATION
|| broken(hr
== E_INVALIDARG
),
6651 "DirectPlayLobby create failed: %08lx, expected CLASS_E_NOAGGREGATION\n", hr
);
6652 ok(!dpl
|| dpl
== (IDirectPlayLobby
*)0xdeadbeef, "dpl = %p\n", dpl
);
6655 hr
= CoCreateInstance(&CLSID_DirectPlayLobby
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectPlay
,
6657 ok(hr
== E_NOINTERFACE
, "DirectPlayLobby create failed: %08lx, expected E_NOINTERFACE\n", hr
);
6659 /* Different refcount for all DirectPlayLobby Interfaces */
6660 hr
= CoCreateInstance(&CLSID_DirectPlayLobby
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectPlayLobby
,
6662 ok(hr
== S_OK
, "DirectPlayLobby create failed: %08lx, expected S_OK\n", hr
);
6663 refcount
= IDirectPlayLobby_AddRef(dpl
);
6664 ok(refcount
== 2, "refcount == %lu, expected 2\n", refcount
);
6666 hr
= IDirectPlayLobby_QueryInterface(dpl
, &IID_IDirectPlayLobbyA
, (void**)&dplA
);
6667 ok(hr
== S_OK
, "QueryInterface for IID_IDirectPlayLobbyA failed: %08lx\n", hr
);
6668 refcount
= IDirectPlayLobby_AddRef(dplA
);
6669 ok(refcount
== 2, "refcount == %lu, expected 2\n", refcount
);
6670 IDirectPlayLobby_Release(dplA
);
6672 hr
= IDirectPlayLobby_QueryInterface(dpl
, &IID_IDirectPlayLobby2
, (void**)&dpl2
);
6673 ok(hr
== S_OK
, "QueryInterface for IID_IDirectPlayLobby2 failed: %08lx\n", hr
);
6674 refcount
= IDirectPlayLobby_AddRef(dpl2
);
6675 ok(refcount
== 2, "refcount == %lu, expected 2\n", refcount
);
6676 IDirectPlayLobby_Release(dpl2
);
6678 hr
= IDirectPlayLobby_QueryInterface(dpl
, &IID_IDirectPlayLobby2A
, (void**)&dpl2A
);
6679 ok(hr
== S_OK
, "QueryInterface for IID_IDirectPlayLobby2A failed: %08lx\n", hr
);
6680 refcount
= IDirectPlayLobby_AddRef(dpl2A
);
6681 ok(refcount
== 2, "refcount == %lu, expected 2\n", refcount
);
6682 IDirectPlayLobby_Release(dpl2A
);
6684 hr
= IDirectPlayLobby_QueryInterface(dpl
, &IID_IDirectPlayLobby3
, (void**)&dpl3
);
6685 ok(hr
== S_OK
, "QueryInterface for IID_IDirectPlayLobby3 failed: %08lx\n", hr
);
6686 refcount
= IDirectPlayLobby_AddRef(dpl3
);
6687 ok(refcount
== 2, "refcount == %lu, expected 2\n", refcount
);
6688 IDirectPlayLobby_Release(dpl3
);
6690 hr
= IDirectPlayLobby_QueryInterface(dpl
, &IID_IDirectPlayLobby3A
, (void**)&dpl3A
);
6691 ok(hr
== S_OK
, "QueryInterface for IID_IDirectPlayLobby3A failed: %08lx\n", hr
);
6692 refcount
= IDirectPlayLobby_AddRef(dpl3A
);
6693 ok(refcount
== 2, "refcount == %lu, expected 2\n", refcount
);
6694 IDirectPlayLobby_Release(dpl3A
);
6696 /* IDirectPlayLobby and IUnknown share a refcount */
6697 hr
= IDirectPlayX_QueryInterface(dpl
, &IID_IUnknown
, (void**)&unk
);
6698 ok(hr
== S_OK
, "QueryInterface for IID_IUnknown failed: %08lx\n", hr
);
6699 refcount
= IUnknown_AddRef(unk
);
6700 ok(refcount
== 4, "refcount == %lu, expected 4\n", refcount
);
6701 IDirectPlayLobby_Release(unk
);
6703 IUnknown_Release(unk
);
6704 IDirectPlayLobby_Release(dpl3
);
6705 IDirectPlayLobby_Release(dpl3A
);
6706 IDirectPlayLobby_Release(dpl2
);
6707 IDirectPlayLobby_Release(dpl2A
);
6708 IDirectPlayLobby_Release(dplA
);
6709 IDirectPlayLobby_Release(dpl
);
6710 refcount
= IDirectPlayLobby_Release(dpl
);
6711 ok(refcount
== 0, "refcount == %lu, expected 0\n", refcount
);
6720 static BOOL
is_process_elevated(void)
6723 if (OpenProcessToken( GetCurrentProcess(), TOKEN_QUERY
, &token
))
6725 TOKEN_ELEVATION_TYPE type
;
6729 ret
= GetTokenInformation( token
, TokenElevationType
, &type
, sizeof(type
), &size
);
6730 CloseHandle( token
);
6731 return (ret
&& type
== TokenElevationTypeFull
);
6736 static BOOL
is_firewall_enabled(void)
6739 INetFwMgr
*mgr
= NULL
;
6740 INetFwPolicy
*policy
= NULL
;
6741 INetFwProfile
*profile
= NULL
;
6742 VARIANT_BOOL enabled
= VARIANT_FALSE
;
6744 init
= CoInitializeEx( 0, COINIT_APARTMENTTHREADED
);
6746 hr
= CoCreateInstance( &CLSID_NetFwMgr
, NULL
, CLSCTX_INPROC_SERVER
, &IID_INetFwMgr
,
6748 ok( hr
== S_OK
, "got %08lx\n", hr
);
6749 if (hr
!= S_OK
) goto done
;
6751 hr
= INetFwMgr_get_LocalPolicy( mgr
, &policy
);
6752 ok( hr
== S_OK
, "got %08lx\n", hr
);
6753 if (hr
!= S_OK
) goto done
;
6755 hr
= INetFwPolicy_get_CurrentProfile( policy
, &profile
);
6756 if (hr
!= S_OK
) goto done
;
6758 hr
= INetFwProfile_get_FirewallEnabled( profile
, &enabled
);
6759 ok( hr
== S_OK
, "got %08lx\n", hr
);
6762 if (policy
) INetFwPolicy_Release( policy
);
6763 if (profile
) INetFwProfile_Release( profile
);
6764 if (mgr
) INetFwMgr_Release( mgr
);
6765 if (SUCCEEDED( init
)) CoUninitialize();
6766 return (enabled
== VARIANT_TRUE
);
6769 static HRESULT
set_firewall( enum firewall_op op
)
6772 INetFwMgr
*mgr
= NULL
;
6773 INetFwPolicy
*policy
= NULL
;
6774 INetFwProfile
*profile
= NULL
;
6775 INetFwAuthorizedApplication
*app
= NULL
;
6776 INetFwAuthorizedApplications
*apps
= NULL
;
6777 BSTR name
, image
= SysAllocStringLen( NULL
, MAX_PATH
);
6778 WCHAR path
[MAX_PATH
];
6780 if (!GetModuleFileNameW( NULL
, image
, MAX_PATH
))
6782 SysFreeString( image
);
6786 if(!GetSystemDirectoryW(path
, MAX_PATH
))
6788 SysFreeString( image
);
6791 lstrcatW( path
, L
"\\dplaysvr.exe" );
6793 init
= CoInitializeEx( 0, COINIT_APARTMENTTHREADED
);
6795 hr
= CoCreateInstance( &CLSID_NetFwMgr
, NULL
, CLSCTX_INPROC_SERVER
, &IID_INetFwMgr
,
6797 ok( hr
== S_OK
, "got %08lx\n", hr
);
6798 if (hr
!= S_OK
) goto done
;
6800 hr
= INetFwMgr_get_LocalPolicy( mgr
, &policy
);
6801 ok( hr
== S_OK
, "got %08lx\n", hr
);
6802 if (hr
!= S_OK
) goto done
;
6804 hr
= INetFwPolicy_get_CurrentProfile( policy
, &profile
);
6805 if (hr
!= S_OK
) goto done
;
6807 hr
= INetFwProfile_get_AuthorizedApplications( profile
, &apps
);
6808 ok( hr
== S_OK
, "got %08lx\n", hr
);
6809 if (hr
!= S_OK
) goto done
;
6811 hr
= CoCreateInstance( &CLSID_NetFwAuthorizedApplication
, NULL
, CLSCTX_INPROC_SERVER
,
6812 &IID_INetFwAuthorizedApplication
, (void **)&app
);
6813 ok( hr
== S_OK
, "got %08lx\n", hr
);
6814 if (hr
!= S_OK
) goto done
;
6816 hr
= INetFwAuthorizedApplication_put_ProcessImageFileName( app
, image
);
6817 if (hr
!= S_OK
) goto done
;
6819 name
= SysAllocString( L
"dplay_client" );
6820 hr
= INetFwAuthorizedApplication_put_Name( app
, name
);
6821 SysFreeString( name
);
6822 ok( hr
== S_OK
, "got %08lx\n", hr
);
6823 if (hr
!= S_OK
) goto done
;
6826 hr
= INetFwAuthorizedApplications_Add( apps
, app
);
6827 else if (op
== APP_REMOVE
)
6828 hr
= INetFwAuthorizedApplications_Remove( apps
, image
);
6831 if (hr
!= S_OK
) goto done
;
6833 INetFwAuthorizedApplication_Release( app
);
6834 hr
= CoCreateInstance( &CLSID_NetFwAuthorizedApplication
, NULL
, CLSCTX_INPROC_SERVER
,
6835 &IID_INetFwAuthorizedApplication
, (void **)&app
);
6836 ok( hr
== S_OK
, "got %08lx\n", hr
);
6837 if (hr
!= S_OK
) goto done
;
6839 SysFreeString( image
);
6840 image
= SysAllocString( path
);
6841 hr
= INetFwAuthorizedApplication_put_ProcessImageFileName( app
, image
);
6842 if (hr
!= S_OK
) goto done
;
6844 name
= SysAllocString( L
"dplay_server" );
6845 hr
= INetFwAuthorizedApplication_put_Name( app
, name
);
6846 SysFreeString( name
);
6847 ok( hr
== S_OK
, "got %08lx\n", hr
);
6848 if (hr
!= S_OK
) goto done
;
6851 hr
= INetFwAuthorizedApplications_Add( apps
, app
);
6852 else if (op
== APP_REMOVE
)
6853 hr
= INetFwAuthorizedApplications_Remove( apps
, image
);
6858 if (app
) INetFwAuthorizedApplication_Release( app
);
6859 if (apps
) INetFwAuthorizedApplications_Release( apps
);
6860 if (policy
) INetFwPolicy_Release( policy
);
6861 if (profile
) INetFwProfile_Release( profile
);
6862 if (mgr
) INetFwMgr_Release( mgr
);
6863 if (SUCCEEDED( init
)) CoUninitialize();
6864 SysFreeString( image
);
6868 /* taken from programs/winetest/main.c */
6869 static BOOL
is_stub_dll(const char *filename
)
6873 BOOL isstub
= FALSE
;
6876 size
= GetFileVersionInfoSizeA(filename
, &ver
);
6877 if (!size
) return FALSE
;
6879 data
= HeapAlloc(GetProcessHeap(), 0, size
);
6880 if (!data
) return FALSE
;
6882 if (GetFileVersionInfoA(filename
, ver
, size
, data
))
6886 sprintf(buf
, "\\StringFileInfo\\%04x%04x\\OriginalFilename", MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), 1200);
6887 if (VerQueryValueA(data
, buf
, (void**)&p
, &size
))
6888 isstub
= !lstrcmpiA("wcodstub.dll", p
);
6890 HeapFree(GetProcessHeap(), 0, data
);
6897 BOOL firewall_enabled
;
6899 char path
[MAX_PATH
];
6902 if(!GetSystemDirectoryA(path
, MAX_PATH
))
6904 skip("Failed to get systems directory\n");
6907 strcat(path
, "\\dplayx.dll");
6909 if (!winetest_interactive
&& (GetFileAttributesA(path
) == INVALID_FILE_ATTRIBUTES
|| is_stub_dll(path
)))
6911 win_skip("dplayx is missing or a stub dll, skipping tests\n");
6915 if ((firewall_enabled
= is_firewall_enabled()) && !is_process_elevated())
6917 skip("no privileges, skipping tests to avoid firewall dialog\n");
6921 if (firewall_enabled
)
6923 hr
= set_firewall(APP_ADD
);
6926 skip("can't authorize app in firewall %08lx\n", hr
);
6931 CoInitialize( NULL
);
6933 module
= LoadLibraryA("dplayx.dll");
6935 pDirectPlayEnumerateA
= (void *)GetProcAddress(module
, "DirectPlayEnumerateA");
6936 pDirectPlayEnumerateW
= (void *)GetProcAddress(module
, "DirectPlayEnumerateW");
6937 pDirectPlayCreate
= (void *)GetProcAddress(module
, "DirectPlayCreate");
6941 test_EnumerateProviders();
6942 test_DirectPlayCreate();
6943 test_EnumConnections();
6944 test_InitializeConnection();
6946 test_EnumAddressTypes();
6948 if (!winetest_interactive
)
6950 skip("Run in interactive mode to run all dplayx tests.\n");
6954 trace("Running in interactive mode, tests will take a while\n");
6956 /* test_Open() takes almost a minute, */
6958 /* test_EnumSession takes three minutes */
6959 test_EnumSessions();
6962 /* test_CreatePlayer() takes over a minute */
6963 test_CreatePlayer();
6964 test_GetPlayerCaps();
6968 /* test_GetPlayerAccount() takes over 30s */
6969 test_GetPlayerAccount();
6970 test_GetPlayerAddress();
6971 test_GetPlayerFlags();
6978 test_EnumGroupsInGroup();
6985 test_GetMessageCount();
6986 test_GetMessageQueue();
6988 test_remote_data_replication();
6989 test_host_migration();
6992 FreeLibrary(module
);
6994 if (firewall_enabled
) set_firewall(APP_REMOVE
);