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 #define checkFlags(expected, result, flags) \
49 ok( (expected) == (result), \
50 "expected=0x%08x(%s) got=0x%08x(%s)\n", \
51 expected, dwFlags2str(expected, flags), \
52 result, dwFlags2str(result, flags) );
53 #define checkGuid(expected, result) \
54 ok( IsEqualGUID(expected, result), \
55 "expected=%s got=%s\n", \
56 Guid2str(expected), Guid2str(result) );
57 #define checkConv(expected, result, function) \
58 ok( (expected) == (result), \
59 "expected=0x%08x(%s) got=0x%08x(%s)\n", \
60 expected, function(expected), \
61 result, function(result) );
64 DEFINE_GUID(appGuid
, 0xbdcfe03e, 0xf0ec, 0x415b, 0x82, 0x11, 0x6f, 0x86, 0xd8, 0x19, 0x7f, 0xe1);
65 DEFINE_GUID(appGuid2
, 0x93417d3f, 0x7d26, 0x46ba, 0xb5, 0x76, 0xfe, 0x4b, 0x20, 0xbb, 0xad, 0x70);
66 DEFINE_GUID(GUID_NULL
,0,0,0,0,0,0,0,0,0,0,0);
67 DEFINE_GUID(invalid_guid
, 0x7b48b707, 0x0034, 0xc000, 0x02, 0x00, 0x00, 0x00, 0xec, 0xf6, 0x32, 0x00);
70 typedef struct tagCallbackData
73 UINT dwCounter1
, dwCounter2
;
75 char szTrace1
[1024], szTrace2
[1024];
78 } CallbackData
, *lpCallbackData
;
88 static LPSTR
get_temp_buffer(void)
90 static UINT index
= 0;
91 static char buff
[10][256];
93 index
= (index
+ 1) % 10;
100 static LPCSTR
Guid2str(const GUID
*guid
)
102 if (!guid
) return "(null)";
104 /* Service providers */
105 if (IsEqualGUID(guid
, &DPSPGUID_IPX
))
106 return "DPSPGUID_IPX";
107 if (IsEqualGUID(guid
, &DPSPGUID_TCPIP
))
108 return "DPSPGUID_TCPIP";
109 if (IsEqualGUID(guid
, &DPSPGUID_SERIAL
))
110 return "DPSPGUID_SERIAL";
111 if (IsEqualGUID(guid
, &DPSPGUID_MODEM
))
112 return "DPSPGUID_MODEM";
113 /* DirectPlay Address IDs */
114 if (IsEqualGUID(guid
, &DPAID_TotalSize
))
115 return "DPAID_TotalSize";
116 if (IsEqualGUID(guid
, &DPAID_ServiceProvider
))
117 return "DPAID_ServiceProvider";
118 if (IsEqualGUID(guid
, &DPAID_LobbyProvider
))
119 return "DPAID_LobbyProvider";
120 if (IsEqualGUID(guid
, &DPAID_Phone
))
121 return "DPAID_Phone";
122 if (IsEqualGUID(guid
, &DPAID_PhoneW
))
123 return "DPAID_PhoneW";
124 if (IsEqualGUID(guid
, &DPAID_Modem
))
125 return "DPAID_Modem";
126 if (IsEqualGUID(guid
, &DPAID_ModemW
))
127 return "DPAID_ModemW";
128 if (IsEqualGUID(guid
, &DPAID_INet
))
130 if (IsEqualGUID(guid
, &DPAID_INetW
))
131 return "DPAID_INetW";
132 if (IsEqualGUID(guid
, &DPAID_INetPort
))
133 return "DPAID_INetPort";
134 if (IsEqualGUID(guid
, &DPAID_ComPort
))
135 return "DPAID_ComPort";
137 return wine_dbgstr_guid(guid
);
141 static LPCSTR
dpResult2str(HRESULT hr
)
145 case DP_OK
: return "DP_OK";
146 case DPERR_ALREADYINITIALIZED
: return "DPERR_ALREADYINITIALIZED";
147 case DPERR_ACCESSDENIED
: return "DPERR_ACCESSDENIED";
148 case DPERR_ACTIVEPLAYERS
: return "DPERR_ACTIVEPLAYERS";
149 case DPERR_BUFFERTOOSMALL
: return "DPERR_BUFFERTOOSMALL";
150 case DPERR_CANTADDPLAYER
: return "DPERR_CANTADDPLAYER";
151 case DPERR_CANTCREATEGROUP
: return "DPERR_CANTCREATEGROUP";
152 case DPERR_CANTCREATEPLAYER
: return "DPERR_CANTCREATEPLAYER";
153 case DPERR_CANTCREATESESSION
: return "DPERR_CANTCREATESESSION";
154 case DPERR_CAPSNOTAVAILABLEYET
: return "DPERR_CAPSNOTAVAILABLEYET";
155 case DPERR_EXCEPTION
: return "DPERR_EXCEPTION";
156 case DPERR_GENERIC
: return "DPERR_GENERIC";
157 case DPERR_INVALIDFLAGS
: return "DPERR_INVALIDFLAGS";
158 case DPERR_INVALIDOBJECT
: return "DPERR_INVALIDOBJECT";
159 case DPERR_INVALIDPARAMS
: return "DPERR_INVALIDPARAMS";
160 /* symbol with the same value: DPERR_INVALIDPARAM */
161 case DPERR_INVALIDPLAYER
: return "DPERR_INVALIDPLAYER";
162 case DPERR_INVALIDGROUP
: return "DPERR_INVALIDGROUP";
163 case DPERR_NOCAPS
: return "DPERR_NOCAPS";
164 case DPERR_NOCONNECTION
: return "DPERR_NOCONNECTION";
165 case DPERR_NOMEMORY
: return "DPERR_NOMEMORY";
166 /* symbol with the same value: DPERR_OUTOFMEMORY */
167 case DPERR_NOMESSAGES
: return "DPERR_NOMESSAGES";
168 case DPERR_NONAMESERVERFOUND
: return "DPERR_NONAMESERVERFOUND";
169 case DPERR_NOPLAYERS
: return "DPERR_NOPLAYERS";
170 case DPERR_NOSESSIONS
: return "DPERR_NOSESSIONS";
171 case DPERR_PENDING
: return "DPERR_PENDING";
172 case DPERR_SENDTOOBIG
: return "DPERR_SENDTOOBIG";
173 case DPERR_TIMEOUT
: return "DPERR_TIMEOUT";
174 case DPERR_UNAVAILABLE
: return "DPERR_UNAVAILABLE";
175 case DPERR_UNSUPPORTED
: return "DPERR_UNSUPPORTED";
176 case DPERR_BUSY
: return "DPERR_BUSY";
177 case DPERR_USERCANCEL
: return "DPERR_USERCANCEL";
178 case DPERR_NOINTERFACE
: return "DPERR_NOINTERFACE";
179 case DPERR_CANNOTCREATESERVER
: return "DPERR_CANNOTCREATESERVER";
180 case DPERR_PLAYERLOST
: return "DPERR_PLAYERLOST";
181 case DPERR_SESSIONLOST
: return "DPERR_SESSIONLOST";
182 case DPERR_UNINITIALIZED
: return "DPERR_UNINITIALIZED";
183 case DPERR_NONEWPLAYERS
: return "DPERR_NONEWPLAYERS";
184 case DPERR_INVALIDPASSWORD
: return "DPERR_INVALIDPASSWORD";
185 case DPERR_CONNECTING
: return "DPERR_CONNECTING";
186 case DPERR_CONNECTIONLOST
: return "DPERR_CONNECTIONLOST";
187 case DPERR_UNKNOWNMESSAGE
: return "DPERR_UNKNOWNMESSAGE";
188 case DPERR_CANCELFAILED
: return "DPERR_CANCELFAILED";
189 case DPERR_INVALIDPRIORITY
: return "DPERR_INVALIDPRIORITY";
190 case DPERR_NOTHANDLED
: return "DPERR_NOTHANDLED";
191 case DPERR_CANCELLED
: return "DPERR_CANCELLED";
192 case DPERR_ABORTED
: return "DPERR_ABORTED";
193 case DPERR_BUFFERTOOLARGE
: return "DPERR_BUFFERTOOLARGE";
194 case DPERR_CANTCREATEPROCESS
: return "DPERR_CANTCREATEPROCESS";
195 case DPERR_APPNOTSTARTED
: return "DPERR_APPNOTSTARTED";
196 case DPERR_INVALIDINTERFACE
: return "DPERR_INVALIDINTERFACE";
197 case DPERR_NOSERVICEPROVIDER
: return "DPERR_NOSERVICEPROVIDER";
198 case DPERR_UNKNOWNAPPLICATION
: return "DPERR_UNKNOWNAPPLICATION";
199 case DPERR_NOTLOBBIED
: return "DPERR_NOTLOBBIED";
200 case DPERR_SERVICEPROVIDERLOADED
: return "DPERR_SERVICEPROVIDERLOADED";
201 case DPERR_ALREADYREGISTERED
: return "DPERR_ALREADYREGISTERED";
202 case DPERR_NOTREGISTERED
: return "DPERR_NOTREGISTERED";
203 case DPERR_AUTHENTICATIONFAILED
: return "DPERR_AUTHENTICATIONFAILED";
204 case DPERR_CANTLOADSSPI
: return "DPERR_CANTLOADSSPI";
205 case DPERR_ENCRYPTIONFAILED
: return "DPERR_ENCRYPTIONFAILED";
206 case DPERR_SIGNFAILED
: return "DPERR_SIGNFAILED";
207 case DPERR_CANTLOADSECURITYPACKAGE
: return "DPERR_CANTLOADSECURITYPACKAGE";
208 case DPERR_ENCRYPTIONNOTSUPPORTED
: return "DPERR_ENCRYPTIONNOTSUPPORTED";
209 case DPERR_CANTLOADCAPI
: return "DPERR_CANTLOADCAPI";
210 case DPERR_NOTLOGGEDIN
: return "DPERR_NOTLOGGEDIN";
211 case DPERR_LOGONDENIED
: return "DPERR_LOGONDENIED";
212 case CLASS_E_NOAGGREGATION
: return "CLASS_E_NOAGGREGATION";
216 LPSTR buffer
= get_temp_buffer();
217 sprintf( buffer
, "%d", HRESULT_CODE(hr
) );
223 static LPCSTR
dpMsgType2str(DWORD dwType
)
227 case DPSYS_CREATEPLAYERORGROUP
: return "DPSYS_CREATEPLAYERORGROUP";
228 case DPSYS_DESTROYPLAYERORGROUP
: return "DPSYS_DESTROYPLAYERORGROUP";
229 case DPSYS_ADDPLAYERTOGROUP
: return "DPSYS_ADDPLAYERTOGROUP";
230 case DPSYS_DELETEPLAYERFROMGROUP
: return "DPSYS_DELETEPLAYERFROMGROUP";
231 case DPSYS_SESSIONLOST
: return "DPSYS_SESSIONLOST";
232 case DPSYS_HOST
: return "DPSYS_HOST";
233 case DPSYS_SETPLAYERORGROUPDATA
: return "DPSYS_SETPLAYERORGROUPDATA";
234 case DPSYS_SETPLAYERORGROUPNAME
: return "DPSYS_SETPLAYERORGROUPNAME";
235 case DPSYS_SETSESSIONDESC
: return "DPSYS_SETSESSIONDESC";
236 case DPSYS_ADDGROUPTOGROUP
: return "DPSYS_ADDGROUPTOGROUP";
237 case DPSYS_DELETEGROUPFROMGROUP
: return "DPSYS_DELETEGROUPFROMGROUP";
238 case DPSYS_SECUREMESSAGE
: return "DPSYS_SECUREMESSAGE";
239 case DPSYS_STARTSESSION
: return "DPSYS_STARTSESSION";
240 case DPSYS_CHAT
: return "DPSYS_DPSYS_CHAT";
241 case DPSYS_SETGROUPOWNER
: return "DPSYS_SETGROUPOWNER";
242 case DPSYS_SENDCOMPLETE
: return "DPSYS_SENDCOMPLETE";
244 default: return "UNKNOWN";
248 static LPCSTR
dwFlags2str(DWORD dwFlags
, DWORD flagType
)
251 #define FLAGS_DPCONNECTION (1<<0)
252 #define FLAGS_DPENUMPLAYERS (1<<1)
253 #define FLAGS_DPENUMGROUPS (1<<2)
254 #define FLAGS_DPPLAYER (1<<3)
255 #define FLAGS_DPGROUP (1<<4)
256 #define FLAGS_DPENUMSESSIONS (1<<5)
257 #define FLAGS_DPGETCAPS (1<<6)
258 #define FLAGS_DPGET (1<<7)
259 #define FLAGS_DPRECEIVE (1<<8)
260 #define FLAGS_DPSEND (1<<9)
261 #define FLAGS_DPSET (1<<10)
262 #define FLAGS_DPMESSAGEQUEUE (1<<11)
263 #define FLAGS_DPCONNECT (1<<12)
264 #define FLAGS_DPOPEN (1<<13)
265 #define FLAGS_DPSESSION (1<<14)
266 #define FLAGS_DPLCONNECTION (1<<15)
267 #define FLAGS_DPESC (1<<16)
268 #define FLAGS_DPCAPS (1<<17)
270 LPSTR flags
= get_temp_buffer();
272 /* EnumConnections */
274 if (flagType
& FLAGS_DPCONNECTION
)
276 if (dwFlags
& DPCONNECTION_DIRECTPLAY
)
277 strcat(flags
, "DPCONNECTION_DIRECTPLAY,");
278 if (dwFlags
& DPCONNECTION_DIRECTPLAYLOBBY
)
279 strcat(flags
, "DPCONNECTION_DIRECTPLAYLOBBY,");
285 if (flagType
& FLAGS_DPENUMPLAYERS
)
287 if (dwFlags
== DPENUMPLAYERS_ALL
)
288 strcat(flags
, "DPENUMPLAYERS_ALL,");
289 if (dwFlags
& DPENUMPLAYERS_LOCAL
)
290 strcat(flags
, "DPENUMPLAYERS_LOCAL,");
291 if (dwFlags
& DPENUMPLAYERS_REMOTE
)
292 strcat(flags
, "DPENUMPLAYERS_REMOTE,");
293 if (dwFlags
& DPENUMPLAYERS_GROUP
)
294 strcat(flags
, "DPENUMPLAYERS_GROUP,");
295 if (dwFlags
& DPENUMPLAYERS_SESSION
)
296 strcat(flags
, "DPENUMPLAYERS_SESSION,");
297 if (dwFlags
& DPENUMPLAYERS_SERVERPLAYER
)
298 strcat(flags
, "DPENUMPLAYERS_SERVERPLAYER,");
299 if (dwFlags
& DPENUMPLAYERS_SPECTATOR
)
300 strcat(flags
, "DPENUMPLAYERS_SPECTATOR,");
301 if (dwFlags
& DPENUMPLAYERS_OWNER
)
302 strcat(flags
, "DPENUMPLAYERS_OWNER,");
304 if (flagType
& FLAGS_DPENUMGROUPS
)
306 if (dwFlags
== DPENUMGROUPS_ALL
)
307 strcat(flags
, "DPENUMGROUPS_ALL,");
308 if (dwFlags
& DPENUMPLAYERS_LOCAL
)
309 strcat(flags
, "DPENUMGROUPS_LOCAL,");
310 if (dwFlags
& DPENUMPLAYERS_REMOTE
)
311 strcat(flags
, "DPENUMGROUPS_REMOTE,");
312 if (dwFlags
& DPENUMPLAYERS_GROUP
)
313 strcat(flags
, "DPENUMGROUPS_GROUP,");
314 if (dwFlags
& DPENUMPLAYERS_SESSION
)
315 strcat(flags
, "DPENUMGROUPS_SESSION,");
316 if (dwFlags
& DPENUMGROUPS_SHORTCUT
)
317 strcat(flags
, "DPENUMGROUPS_SHORTCUT,");
318 if (dwFlags
& DPENUMGROUPS_STAGINGAREA
)
319 strcat(flags
, "DPENUMGROUPS_STAGINGAREA,");
320 if (dwFlags
& DPENUMGROUPS_HIDDEN
)
321 strcat(flags
, "DPENUMGROUPS_HIDDEN,");
326 if (flagType
& FLAGS_DPPLAYER
)
328 if (dwFlags
& DPPLAYER_SERVERPLAYER
)
329 strcat(flags
, "DPPLAYER_SERVERPLAYER,");
330 if (dwFlags
& DPPLAYER_SPECTATOR
)
331 strcat(flags
, "DPPLAYER_SPECTATOR,");
332 if (dwFlags
& DPPLAYER_LOCAL
)
333 strcat(flags
, "DPPLAYER_LOCAL,");
334 if (dwFlags
& DPPLAYER_OWNER
)
335 strcat(flags
, "DPPLAYER_OWNER,");
340 if (flagType
& FLAGS_DPGROUP
)
342 if (dwFlags
& DPGROUP_STAGINGAREA
)
343 strcat(flags
, "DPGROUP_STAGINGAREA,");
344 if (dwFlags
& DPGROUP_LOCAL
)
345 strcat(flags
, "DPGROUP_LOCAL,");
346 if (dwFlags
& DPGROUP_HIDDEN
)
347 strcat(flags
, "DPGROUP_HIDDEN,");
352 if (flagType
& FLAGS_DPENUMSESSIONS
)
354 if (dwFlags
& DPENUMSESSIONS_AVAILABLE
)
355 strcat(flags
, "DPENUMSESSIONS_AVAILABLE,");
356 if (dwFlags
& DPENUMSESSIONS_ALL
)
357 strcat(flags
, "DPENUMSESSIONS_ALL,");
358 if (dwFlags
& DPENUMSESSIONS_ASYNC
)
359 strcat(flags
, "DPENUMSESSIONS_ASYNC,");
360 if (dwFlags
& DPENUMSESSIONS_STOPASYNC
)
361 strcat(flags
, "DPENUMSESSIONS_STOPASYNC,");
362 if (dwFlags
& DPENUMSESSIONS_PASSWORDREQUIRED
)
363 strcat(flags
, "DPENUMSESSIONS_PASSWORDREQUIRED,");
364 if (dwFlags
& DPENUMSESSIONS_RETURNSTATUS
)
365 strcat(flags
, "DPENUMSESSIONS_RETURNSTATUS,");
371 if (flagType
& FLAGS_DPGETCAPS
)
373 if (dwFlags
& DPGETCAPS_GUARANTEED
)
374 strcat(flags
, "DPGETCAPS_GUARANTEED,");
380 if (flagType
& FLAGS_DPGET
)
382 if (dwFlags
== DPGET_REMOTE
)
383 strcat(flags
, "DPGET_REMOTE,");
384 if (dwFlags
& DPGET_LOCAL
)
385 strcat(flags
, "DPGET_LOCAL,");
390 if (flagType
& FLAGS_DPRECEIVE
)
392 if (dwFlags
& DPRECEIVE_ALL
)
393 strcat(flags
, "DPRECEIVE_ALL,");
394 if (dwFlags
& DPRECEIVE_TOPLAYER
)
395 strcat(flags
, "DPRECEIVE_TOPLAYER,");
396 if (dwFlags
& DPRECEIVE_FROMPLAYER
)
397 strcat(flags
, "DPRECEIVE_FROMPLAYER,");
398 if (dwFlags
& DPRECEIVE_PEEK
)
399 strcat(flags
, "DPRECEIVE_PEEK,");
404 if (flagType
& FLAGS_DPSEND
)
406 /*if (dwFlags == DPSEND_NONGUARANTEED)
407 strcat(flags, "DPSEND_NONGUARANTEED,");*/
408 if (dwFlags
== DPSEND_MAX_PRIORITY
) /* = DPSEND_MAX_PRI */
410 strcat(flags
, "DPSEND_MAX_PRIORITY,");
414 if (dwFlags
& DPSEND_GUARANTEED
)
415 strcat(flags
, "DPSEND_GUARANTEED,");
416 if (dwFlags
& DPSEND_HIGHPRIORITY
)
417 strcat(flags
, "DPSEND_HIGHPRIORITY,");
418 if (dwFlags
& DPSEND_OPENSTREAM
)
419 strcat(flags
, "DPSEND_OPENSTREAM,");
420 if (dwFlags
& DPSEND_CLOSESTREAM
)
421 strcat(flags
, "DPSEND_CLOSESTREAM,");
422 if (dwFlags
& DPSEND_SIGNED
)
423 strcat(flags
, "DPSEND_SIGNED,");
424 if (dwFlags
& DPSEND_ENCRYPTED
)
425 strcat(flags
, "DPSEND_ENCRYPTED,");
426 if (dwFlags
& DPSEND_LOBBYSYSTEMMESSAGE
)
427 strcat(flags
, "DPSEND_LOBBYSYSTEMMESSAGE,");
428 if (dwFlags
& DPSEND_ASYNC
)
429 strcat(flags
, "DPSEND_ASYNC,");
430 if (dwFlags
& DPSEND_NOSENDCOMPLETEMSG
)
431 strcat(flags
, "DPSEND_NOSENDCOMPLETEMSG,");
441 if (flagType
& FLAGS_DPSET
)
443 if (dwFlags
== DPSET_REMOTE
)
444 strcat(flags
, "DPSET_REMOTE,");
445 if (dwFlags
& DPSET_LOCAL
)
446 strcat(flags
, "DPSET_LOCAL,");
447 if (dwFlags
& DPSET_GUARANTEED
)
448 strcat(flags
, "DPSET_GUARANTEED,");
451 /* GetMessageQueue */
453 if (flagType
& FLAGS_DPMESSAGEQUEUE
)
455 if (dwFlags
& DPMESSAGEQUEUE_SEND
)
456 strcat(flags
, "DPMESSAGEQUEUE_SEND,");
457 if (dwFlags
& DPMESSAGEQUEUE_RECEIVE
)
458 strcat(flags
, "DPMESSAGEQUEUE_RECEIVE,");
463 if (flagType
& FLAGS_DPCONNECT
)
465 if (dwFlags
& DPCONNECT_RETURNSTATUS
)
466 strcat(flags
, "DPCONNECT_RETURNSTATUS,");
471 if (flagType
& FLAGS_DPOPEN
)
473 if (dwFlags
& DPOPEN_JOIN
)
474 strcat(flags
, "DPOPEN_JOIN,");
475 if (dwFlags
& DPOPEN_CREATE
)
476 strcat(flags
, "DPOPEN_CREATE,");
477 if (dwFlags
& DPOPEN_RETURNSTATUS
)
478 strcat(flags
, "DPOPEN_RETURNSTATUS,");
483 if (flagType
& FLAGS_DPSESSION
)
485 if (dwFlags
& DPSESSION_NEWPLAYERSDISABLED
)
486 strcat(flags
, "DPSESSION_NEWPLAYERSDISABLED,");
487 if (dwFlags
& DPSESSION_MIGRATEHOST
)
488 strcat(flags
, "DPSESSION_MIGRATEHOST,");
489 if (dwFlags
& DPSESSION_NOMESSAGEID
)
490 strcat(flags
, "DPSESSION_NOMESSAGEID,");
491 if (dwFlags
& DPSESSION_JOINDISABLED
)
492 strcat(flags
, "DPSESSION_JOINDISABLED,");
493 if (dwFlags
& DPSESSION_KEEPALIVE
)
494 strcat(flags
, "DPSESSION_KEEPALIVE,");
495 if (dwFlags
& DPSESSION_NODATAMESSAGES
)
496 strcat(flags
, "DPSESSION_NODATAMESSAGES,");
497 if (dwFlags
& DPSESSION_SECURESERVER
)
498 strcat(flags
, "DPSESSION_SECURESERVER,");
499 if (dwFlags
& DPSESSION_PRIVATE
)
500 strcat(flags
, "DPSESSION_PRIVATE,");
501 if (dwFlags
& DPSESSION_PASSWORDREQUIRED
)
502 strcat(flags
, "DPSESSION_PASSWORDREQUIRED,");
503 if (dwFlags
& DPSESSION_MULTICASTSERVER
)
504 strcat(flags
, "DPSESSION_MULTICASTSERVER,");
505 if (dwFlags
& DPSESSION_CLIENTSERVER
)
506 strcat(flags
, "DPSESSION_CLIENTSERVER,");
508 if (dwFlags
& DPSESSION_DIRECTPLAYPROTOCOL
)
509 strcat(flags
, "DPSESSION_DIRECTPLAYPROTOCOL,");
510 if (dwFlags
& DPSESSION_NOPRESERVEORDER
)
511 strcat(flags
, "DPSESSION_NOPRESERVEORDER,");
512 if (dwFlags
& DPSESSION_OPTIMIZELATENCY
)
513 strcat(flags
, "DPSESSION_OPTIMIZELATENCY,");
519 if (flagType
& FLAGS_DPLCONNECTION
)
521 if (dwFlags
& DPLCONNECTION_CREATESESSION
)
522 strcat(flags
, "DPLCONNECTION_CREATESESSION,");
523 if (dwFlags
& DPLCONNECTION_JOINSESSION
)
524 strcat(flags
, "DPLCONNECTION_JOINSESSION,");
527 /* EnumSessionsCallback2 */
529 if (flagType
& FLAGS_DPESC
)
531 if (dwFlags
& DPESC_TIMEDOUT
)
532 strcat(flags
, "DPESC_TIMEDOUT,");
538 if (flagType
& FLAGS_DPCAPS
)
540 if (dwFlags
& DPCAPS_ISHOST
)
541 strcat(flags
, "DPCAPS_ISHOST,");
542 if (dwFlags
& DPCAPS_GROUPOPTIMIZED
)
543 strcat(flags
, "DPCAPS_GROUPOPTIMIZED,");
544 if (dwFlags
& DPCAPS_KEEPALIVEOPTIMIZED
)
545 strcat(flags
, "DPCAPS_KEEPALIVEOPTIMIZED,");
546 if (dwFlags
& DPCAPS_GUARANTEEDOPTIMIZED
)
547 strcat(flags
, "DPCAPS_GUARANTEEDOPTIMIZED,");
548 if (dwFlags
& DPCAPS_GUARANTEEDSUPPORTED
)
549 strcat(flags
, "DPCAPS_GUARANTEEDSUPPORTED,");
550 if (dwFlags
& DPCAPS_SIGNINGSUPPORTED
)
551 strcat(flags
, "DPCAPS_SIGNINGSUPPORTED,");
552 if (dwFlags
& DPCAPS_ENCRYPTIONSUPPORTED
)
553 strcat(flags
, "DPCAPS_ENCRYPTIONSUPPORTED,");
554 if (dwFlags
& DPCAPS_ASYNCCANCELSUPPORTED
)
555 strcat(flags
, "DPCAPS_ASYNCCANCELSUPPORTED,");
556 if (dwFlags
& DPCAPS_ASYNCCANCELALLSUPPORTED
)
557 strcat(flags
, "DPCAPS_ASYNCCANCELALLSUPPORTED,");
558 if (dwFlags
& DPCAPS_SENDTIMEOUTSUPPORTED
)
559 strcat(flags
, "DPCAPS_SENDTIMEOUTSUPPORTED,");
560 if (dwFlags
& DPCAPS_SENDPRIORITYSUPPORTED
)
561 strcat(flags
, "DPCAPS_SENDPRIORITYSUPPORTED,");
562 if (dwFlags
& DPCAPS_ASYNCSUPPORTED
)
563 strcat(flags
, "DPCAPS_ASYNCSUPPORTED,");
565 if (dwFlags
& DPPLAYERCAPS_LOCAL
)
566 strcat(flags
, "DPPLAYERCAPS_LOCAL,");
569 if ((strlen(flags
) == 0) && (dwFlags
!= 0))
570 strcpy(flags
, "UNKNOWN");
572 flags
[strlen(flags
)-1] = '\0';
577 static char dpid2char(DPID
* dpid
, DWORD dpidSize
, DPID idPlayer
)
580 if ( idPlayer
== DPID_SYSMSG
)
582 for (i
=0; i
<dpidSize
; i
++)
584 if ( idPlayer
== dpid
[i
] )
590 static void check_messages( IDirectPlay4
*pDP
, DPID
*dpid
, DWORD dpidSize
,
591 lpCallbackData callbackData
)
593 /* Retrieves all messages from the queue of pDP, performing tests
594 * to check if we are receiving what we expect.
596 * Information about the messages is stores in callbackData:
598 * callbackData->dwCounter1: Number of messages received.
599 * callbackData->szTrace1: Traces for sender and receiver.
600 * We store the position a dpid holds in the dpid array.
603 * trace string: "01,02,03,14"
604 * expanded: [ '01', '02', '03', '14' ]
606 * \ \ \ ) message 3: from 1 to 4
607 * \ \ ) message 2: from 0 to 3
608 * \ ) message 1: from 0 to 2
609 * ) message 0: from 0 to 1
612 * sender of message i = character in place 3*i of the array
613 * receiver of message i = character in place 3*i+1 of the array
615 * A sender value of 'S' means DPID_SYSMSG, this is, a system message.
617 * callbackData->szTrace2: Traces for message sizes.
622 DWORD dwDataSize
= 1024;
623 LPVOID lpData
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, dwDataSize
);
627 callbackData
->szTrace2
[0] = '\0';
630 while ( DP_OK
== (hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0,
631 lpData
, &dwDataSize
)) )
634 callbackData
->szTrace1
[ 3*i
] = dpid2char( dpid
, dpidSize
, idFrom
);
635 callbackData
->szTrace1
[ 3*i
+1 ] = dpid2char( dpid
, dpidSize
, idTo
);
636 callbackData
->szTrace1
[ 3*i
+2 ] = ',';
638 sprintf( temp
, "%d,", dwDataSize
);
639 strcat( callbackData
->szTrace2
, temp
);
645 checkHR( DPERR_NOMESSAGES
, hr
);
647 callbackData
->szTrace1
[ 3*i
] = '\0';
648 callbackData
->dwCounter1
= i
;
651 HeapFree( GetProcessHeap(), 0, lpData
);
654 static void init_TCPIP_provider( IDirectPlay4
*pDP
, LPCSTR strIPAddressString
, WORD port
)
657 DPCOMPOUNDADDRESSELEMENT addressElements
[3];
658 LPVOID pAddress
= NULL
;
659 DWORD dwAddressSize
= 0;
660 IDirectPlayLobby3
*pDPL
;
663 hr
= CoCreateInstance( &CLSID_DirectPlayLobby
, NULL
, CLSCTX_ALL
,
664 &IID_IDirectPlayLobby3A
, (LPVOID
*) &pDPL
);
665 ok (SUCCEEDED (hr
), "CCI of CLSID_DirectPlayLobby / IID_IDirectPlayLobby3A failed\n");
666 if (FAILED (hr
)) return;
668 /* Service provider */
669 addressElements
[0].guidDataType
= DPAID_ServiceProvider
;
670 addressElements
[0].dwDataSize
= sizeof(GUID
);
671 addressElements
[0].lpData
= (LPVOID
) &DPSPGUID_TCPIP
;
673 /* IP address string */
674 addressElements
[1].guidDataType
= DPAID_INet
;
675 addressElements
[1].dwDataSize
= lstrlenA(strIPAddressString
) + 1;
676 addressElements
[1].lpData
= (LPVOID
) strIPAddressString
;
678 /* Optional Port number */
681 addressElements
[2].guidDataType
= DPAID_INetPort
;
682 addressElements
[2].dwDataSize
= sizeof(WORD
);
683 addressElements
[2].lpData
= &port
;
687 hr
= IDirectPlayLobby_CreateCompoundAddress( pDPL
, addressElements
, 2,
688 NULL
, &dwAddressSize
);
689 checkHR( DPERR_BUFFERTOOSMALL
, hr
);
691 if( hr
== DPERR_BUFFERTOOSMALL
)
693 pAddress
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, dwAddressSize
);
694 hr
= IDirectPlayLobby_CreateCompoundAddress( pDPL
, addressElements
, 2,
695 pAddress
, &dwAddressSize
);
696 checkHR( DP_OK
, hr
);
699 hr
= IDirectPlayX_InitializeConnection( pDP
, pAddress
, 0 );
700 checkHR( DP_OK
, hr
);
702 HeapFree( GetProcessHeap(), 0, pAddress
);
703 IDirectPlayLobby_Release(pDPL
);
706 static BOOL CALLBACK
EnumSessions_cb_join( LPCDPSESSIONDESC2 lpThisSD
,
711 IDirectPlay4
*pDP
= lpContext
;
715 if (dwFlags
& DPESC_TIMEDOUT
)
720 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
721 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
722 dpsd
.guidApplication
= appGuid
;
723 dpsd
.guidInstance
= lpThisSD
->guidInstance
;
725 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_JOIN
);
726 checkHR( DP_OK
, hr
);
732 /* DirectPlayCreate */
734 static void test_DirectPlayCreate(void)
740 /* TODO: Check how it behaves with pUnk!=NULL */
743 hr
= pDirectPlayCreate( NULL
, NULL
, NULL
);
744 checkHR( DPERR_INVALIDPARAMS
, hr
);
745 hr
= pDirectPlayCreate( (LPGUID
) &GUID_NULL
, NULL
, NULL
);
746 checkHR( DPERR_INVALIDPARAMS
, hr
);
747 hr
= pDirectPlayCreate( (LPGUID
) &DPSPGUID_TCPIP
, NULL
, NULL
);
748 checkHR( DPERR_INVALIDPARAMS
, hr
);
750 /* pUnk==NULL, pDP!=NULL */
751 hr
= pDirectPlayCreate( NULL
, &pDP
, NULL
);
752 checkHR( DPERR_INVALIDPARAMS
, hr
);
753 hr
= pDirectPlayCreate( (LPGUID
) &GUID_NULL
, &pDP
, NULL
);
754 checkHR( DP_OK
, hr
);
756 IDirectPlayX_Release( pDP
);
757 hr
= pDirectPlayCreate( (LPGUID
) &DPSPGUID_TCPIP
, &pDP
, NULL
);
758 checkHR( DP_OK
, hr
);
760 IDirectPlayX_Release( pDP
);
764 static BOOL CALLBACK
callback_providersA(GUID
* guid
, char *name
, DWORD major
, DWORD minor
, void *arg
)
766 struct provider_data
*prov
= arg
;
768 if (!prov
) return TRUE
;
770 if (prov
->call_count
< ARRAY_SIZE(prov
->guid_data
))
772 prov
->guid_ptr
[prov
->call_count
] = guid
;
773 prov
->guid_data
[prov
->call_count
] = *guid
;
778 if (prov
->ret_value
) /* Only trace when looping all providers */
779 trace("Provider #%d '%s' (%d.%d)\n", prov
->call_count
, name
, major
, minor
);
780 return prov
->ret_value
;
783 static BOOL CALLBACK
callback_providersW(GUID
* guid
, WCHAR
*name
, DWORD major
, DWORD minor
, void *arg
)
785 struct provider_data
*prov
= arg
;
787 if (!prov
) return TRUE
;
789 if (prov
->call_count
< ARRAY_SIZE(prov
->guid_data
))
791 prov
->guid_ptr
[prov
->call_count
] = guid
;
792 prov
->guid_data
[prov
->call_count
] = *guid
;
797 return prov
->ret_value
;
800 static void test_EnumerateProviders(void)
804 struct provider_data arg
;
806 memset(&arg
, 0, sizeof(arg
));
807 arg
.ret_value
= TRUE
;
809 hr
= pDirectPlayEnumerateA(callback_providersA
, NULL
);
810 ok(SUCCEEDED(hr
), "DirectPlayEnumerateA failed\n");
812 SetLastError(0xdeadbeef);
813 hr
= pDirectPlayEnumerateA(NULL
, &arg
);
814 ok(FAILED(hr
), "DirectPlayEnumerateA expected to fail\n");
815 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got 0x%x\n", GetLastError());
817 SetLastError(0xdeadbeef);
818 hr
= pDirectPlayEnumerateA(NULL
, NULL
);
819 ok(FAILED(hr
), "DirectPlayEnumerateA expected to fail\n");
820 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got 0x%x\n", GetLastError());
822 hr
= pDirectPlayEnumerateA(callback_providersA
, &arg
);
823 ok(SUCCEEDED(hr
), "DirectPlayEnumerateA failed\n");
824 ok(arg
.call_count
> 0, "Expected at least one valid provider\n");
825 trace("Found %d providers\n", arg
.call_count
);
827 /* The returned GUID values must have persisted after enumeration (bug 37185) */
828 for(i
= 0; i
< arg
.call_count
; i
++)
830 ok(IsEqualGUID(arg
.guid_ptr
[i
], &arg
.guid_data
[i
]), "#%d Expected equal GUID values\n", i
);
833 memset(&arg
, 0, sizeof(arg
));
834 arg
.ret_value
= FALSE
;
835 hr
= pDirectPlayEnumerateA(callback_providersA
, &arg
);
836 ok(SUCCEEDED(hr
), "DirectPlayEnumerateA failed\n");
837 ok(arg
.call_count
== 1, "Expected 1, got %d\n", arg
.call_count
);
839 hr
= pDirectPlayEnumerateW(callback_providersW
, NULL
);
840 ok(SUCCEEDED(hr
), "DirectPlayEnumerateW failed\n");
842 SetLastError(0xdeadbeef);
843 hr
= pDirectPlayEnumerateW(NULL
, &arg
);
844 ok(FAILED(hr
), "DirectPlayEnumerateW expected to fail\n");
845 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got 0x%x\n", GetLastError());
847 SetLastError(0xdeadbeef);
848 hr
= pDirectPlayEnumerateW(NULL
, NULL
);
849 ok(FAILED(hr
), "DirectPlayEnumerateW expected to fail\n");
850 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got 0x%x\n", GetLastError());
852 memset(&arg
, 0, sizeof(arg
));
853 arg
.ret_value
= TRUE
;
854 hr
= pDirectPlayEnumerateW(callback_providersW
, &arg
);
855 ok(SUCCEEDED(hr
), "DirectPlayEnumerateW failed\n");
856 ok(arg
.call_count
> 0, "Expected at least one valid provider\n");
858 /* The returned GUID values must have persisted after enumeration (bug 37185) */
859 for(i
= 0; i
< arg
.call_count
; i
++)
861 ok(IsEqualGUID(arg
.guid_ptr
[i
], &arg
.guid_data
[i
]), "#%d Expected equal GUID values\n", i
);
864 memset(&arg
, 0, sizeof(arg
));
865 arg
.ret_value
= FALSE
;
866 hr
= pDirectPlayEnumerateW(callback_providersW
, &arg
);
867 ok(SUCCEEDED(hr
), "DirectPlayEnumerateW failed\n");
868 ok(arg
.call_count
== 1, "Expected 1, got %d\n", arg
.call_count
);
871 /* EnumConnections */
873 static BOOL CALLBACK
EnumAddress_cb2( REFGUID guidDataType
,
878 lpCallbackData callbackData
= lpContext
;
880 static REFGUID types
[] = { &DPAID_TotalSize
,
881 &DPAID_ServiceProvider
,
883 static DWORD sizes
[] = { 4, 16, 0 };
884 static REFGUID sps
[] = { &DPSPGUID_SERIAL
, &DPSPGUID_MODEM
,
885 &DPSPGUID_IPX
, &DPSPGUID_TCPIP
};
888 checkGuid( types
[ callbackData
->dwCounter2
], guidDataType
);
889 check( sizes
[ callbackData
->dwCounter2
], dwDataSize
);
891 if ( IsEqualGUID( types
[0], guidDataType
) )
893 todo_wine
check( 80, *((LPDWORD
) lpData
) );
895 else if ( IsEqualGUID( types
[1], guidDataType
) )
899 for( i
=0; i
< ARRAY_SIZE(sps
) && !found
; i
++ )
900 found
= IsEqualGUID( sps
[i
], lpData
);
901 ok( found
, "Unknown Address type found %s\n", wine_dbgstr_guid(lpData
) );
904 callbackData
->dwCounter2
++;
909 static BOOL CALLBACK
EnumConnections_cb( LPCGUID lpguidSP
,
911 DWORD dwConnectionSize
,
917 lpCallbackData callbackData
= lpContext
;
918 IDirectPlayLobby
*pDPL
;
922 if (!callbackData
->dwFlags
)
924 callbackData
->dwFlags
= DPCONNECTION_DIRECTPLAY
;
927 checkFlags( callbackData
->dwFlags
, dwFlags
, FLAGS_DPCONNECTION
);
929 /* Get info from lpConnection */
930 hr
= CoCreateInstance( &CLSID_DirectPlayLobby
, NULL
, CLSCTX_ALL
,
931 &IID_IDirectPlayLobby3A
, (LPVOID
*) &pDPL
);
932 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlayLobby / IID_IDirectPlayLobby3A failed\n");
936 callbackData
->dwCounter2
= 0;
937 IDirectPlayLobby_EnumAddress( pDPL
, EnumAddress_cb2
, lpConnection
,
938 dwConnectionSize
, callbackData
);
939 todo_wine
check( 3, callbackData
->dwCounter2
);
941 callbackData
->dwCounter1
++;
943 IDirectPlayLobby_Release(pDPL
);
948 static void test_EnumConnections(void)
952 CallbackData callbackData
;
956 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
957 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
);
959 ok (SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n");
960 if (FAILED(hr
)) return;
962 callbackData
.dwCounter1
= 0;
963 callbackData
.dwFlags
= 0;
964 hr
= IDirectPlayX_EnumConnections( pDP
, &appGuid
, EnumConnections_cb
,
965 &callbackData
, callbackData
.dwFlags
);
966 checkHR( DP_OK
, hr
);
967 ok( callbackData
.dwCounter1
== 4 || callbackData
.dwCounter1
== 3, "got=%d\n", callbackData
.dwCounter1
);
969 callbackData
.dwCounter1
= 0;
970 callbackData
.dwFlags
= 0;
971 hr
= IDirectPlayX_EnumConnections( pDP
, NULL
, EnumConnections_cb
,
972 &callbackData
, callbackData
.dwFlags
);
973 checkHR( DP_OK
, hr
);
974 ok( callbackData
.dwCounter1
== 4 || callbackData
.dwCounter1
== 3, "got=%d\n", callbackData
.dwCounter1
);
976 callbackData
.dwCounter1
= 0;
977 callbackData
.dwFlags
= 0;
978 hr
= IDirectPlayX_EnumConnections( pDP
, &appGuid
, NULL
,
979 &callbackData
, callbackData
.dwFlags
);
980 checkHR( DPERR_INVALIDPARAMS
, hr
);
981 check( 0, callbackData
.dwCounter1
);
985 callbackData
.dwCounter1
= 0;
986 callbackData
.dwFlags
= DPCONNECTION_DIRECTPLAY
;
987 hr
= IDirectPlayX_EnumConnections( pDP
, &appGuid
, EnumConnections_cb
,
988 &callbackData
, callbackData
.dwFlags
);
989 checkHR( DP_OK
, hr
);
990 ok( callbackData
.dwCounter1
== 4 || callbackData
.dwCounter1
== 3, "got=%d\n", callbackData
.dwCounter1
);
992 callbackData
.dwCounter1
= 0;
993 callbackData
.dwFlags
= DPCONNECTION_DIRECTPLAYLOBBY
;
994 hr
= IDirectPlayX_EnumConnections( pDP
, &appGuid
, EnumConnections_cb
,
995 &callbackData
, callbackData
.dwFlags
);
996 checkHR( DP_OK
, hr
);
997 check( 0, callbackData
.dwCounter1
);
999 callbackData
.dwCounter1
= 0;
1000 callbackData
.dwFlags
= ( DPCONNECTION_DIRECTPLAY
|
1001 DPCONNECTION_DIRECTPLAYLOBBY
);
1002 hr
= IDirectPlayX_EnumConnections( pDP
, &appGuid
, EnumConnections_cb
,
1003 &callbackData
, callbackData
.dwFlags
);
1004 checkHR( DP_OK
, hr
);
1005 ok( callbackData
.dwCounter1
== 4 || callbackData
.dwCounter1
== 3, "got=%d\n", callbackData
.dwCounter1
);
1007 callbackData
.dwCounter1
= 0;
1008 callbackData
.dwFlags
= ~( DPCONNECTION_DIRECTPLAY
|
1009 DPCONNECTION_DIRECTPLAYLOBBY
);
1010 hr
= IDirectPlayX_EnumConnections( pDP
, &appGuid
, EnumConnections_cb
,
1011 &callbackData
, callbackData
.dwFlags
);
1012 checkHR( DPERR_INVALIDFLAGS
, hr
);
1013 check( 0, callbackData
.dwCounter1
);
1016 IDirectPlayX_Release( pDP
);
1019 /* InitializeConnection */
1021 static BOOL CALLBACK
EnumConnections_cb2( LPCGUID lpguidSP
,
1022 LPVOID lpConnection
,
1023 DWORD dwConnectionSize
,
1028 IDirectPlay4
*pDP
= lpContext
;
1031 /* Incorrect parameters */
1032 hr
= IDirectPlayX_InitializeConnection( pDP
, NULL
, 1 );
1033 checkHR( DPERR_INVALIDPARAMS
, hr
);
1034 hr
= IDirectPlayX_InitializeConnection( pDP
, lpConnection
, 1 );
1035 checkHR( DPERR_INVALIDFLAGS
, hr
);
1037 /* Normal operation.
1038 We're only interested in ensuring that the TCP/IP provider works */
1040 if( IsEqualGUID(lpguidSP
, &DPSPGUID_TCPIP
) )
1042 hr
= IDirectPlayX_InitializeConnection( pDP
, lpConnection
, 0 );
1043 checkHR( DP_OK
, hr
);
1044 hr
= IDirectPlayX_InitializeConnection( pDP
, lpConnection
, 0 );
1045 checkHR( DPERR_ALREADYINITIALIZED
, hr
);
1051 static void test_InitializeConnection(void)
1057 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
1058 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
);
1060 ok (SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n");
1061 if (FAILED(hr
)) return;
1063 IDirectPlayX_EnumConnections( pDP
, &appGuid
, EnumConnections_cb2
, pDP
, 0 );
1065 IDirectPlayX_Release( pDP
);
1070 static void test_GetCaps(void)
1079 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
1080 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
);
1081 ok (SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n");
1082 if (FAILED(hr
)) return;
1084 ZeroMemory( &dpcaps
, sizeof(DPCAPS
) );
1086 /* Service provider not ininitialized */
1087 hr
= IDirectPlayX_GetCaps( pDP
, &dpcaps
, 0 );
1088 checkHR( DPERR_UNINITIALIZED
, hr
);
1090 init_TCPIP_provider( pDP
, "127.0.0.1", 0 );
1092 /* dpcaps not ininitialized */
1093 hr
= IDirectPlayX_GetCaps( pDP
, &dpcaps
, 0 );
1094 checkHR( DPERR_INVALIDPARAMS
, hr
);
1096 dpcaps
.dwSize
= sizeof(DPCAPS
);
1099 dwFlags
<=DPGETCAPS_GUARANTEED
;
1100 dwFlags
+=DPGETCAPS_GUARANTEED
)
1103 hr
= IDirectPlayX_GetCaps( pDP
, &dpcaps
, dwFlags
);
1104 checkHR( DP_OK
, hr
);
1105 check( sizeof(DPCAPS
), dpcaps
.dwSize
);
1106 check( DPCAPS_ASYNCSUPPORTED
|
1107 DPCAPS_GUARANTEEDOPTIMIZED
|
1108 DPCAPS_GUARANTEEDSUPPORTED
,
1110 check( 0, dpcaps
.dwMaxQueueSize
);
1111 check( 0, dpcaps
.dwHundredBaud
);
1112 check( 500, dpcaps
.dwLatency
);
1113 check( 65536, dpcaps
.dwMaxLocalPlayers
);
1114 check( 20, dpcaps
.dwHeaderLength
);
1115 check( 5000, dpcaps
.dwTimeout
);
1120 check( 65479, dpcaps
.dwMaxBufferSize
);
1121 check( 65536, dpcaps
.dwMaxPlayers
);
1123 case DPGETCAPS_GUARANTEED
:
1124 check( 1048547, dpcaps
.dwMaxBufferSize
);
1125 check( 64, dpcaps
.dwMaxPlayers
);
1131 IDirectPlayX_Release( pDP
);
1134 static void test_EnumAddressTypes(void)
1138 DPCOMPOUNDADDRESSELEMENT addressElements
[2];
1139 LPVOID pAddress
= NULL
;
1140 DWORD dwAddressSize
= 0;
1141 IDirectPlayLobby3
*pDPL
;
1144 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
1145 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
);
1146 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
1150 hr
= CoCreateInstance( &CLSID_DirectPlayLobby
, NULL
, CLSCTX_ALL
,
1151 &IID_IDirectPlayLobby3A
, (LPVOID
*) &pDPL
);
1152 ok (SUCCEEDED (hr
), "CCI of CLSID_DirectPlayLobby / IID_IDirectPlayLobby3A failed\n");
1153 if (FAILED (hr
)) return;
1155 addressElements
[0].guidDataType
= DPAID_ServiceProvider
;
1156 addressElements
[0].dwDataSize
= sizeof(GUID
);
1157 addressElements
[0].lpData
= (void*) &DPSPGUID_TCPIP
;
1159 addressElements
[1].guidDataType
= invalid_guid
;
1160 addressElements
[1].dwDataSize
= sizeof(WORD
);
1161 addressElements
[1].lpData
= &port
;
1163 hr
= IDirectPlayLobby_CreateCompoundAddress( pDPL
, addressElements
, 2, NULL
, &dwAddressSize
);
1164 checkHR( DPERR_BUFFERTOOSMALL
, hr
);
1166 if( hr
== DPERR_BUFFERTOOSMALL
)
1168 pAddress
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, dwAddressSize
);
1169 hr
= IDirectPlayLobby_CreateCompoundAddress( pDPL
, addressElements
, 2,
1170 pAddress
, &dwAddressSize
);
1171 checkHR( DP_OK
, hr
);
1174 IDirectPlayX_Close(pDP
);
1175 IDirectPlayX_Release(pDP
);
1176 IDirectPlayLobby_Release(pDPL
);
1178 HeapFree( GetProcessHeap(), 0, pAddress
);
1183 static BOOL CALLBACK
EnumSessions_cb2( LPCDPSESSIONDESC2 lpThisSD
,
1184 LPDWORD lpdwTimeOut
,
1188 IDirectPlay4
*pDP
= lpContext
;
1189 DPSESSIONDESC2 dpsd
;
1192 if (dwFlags
& DPESC_TIMEDOUT
)
1196 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
1197 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
1198 dpsd
.guidApplication
= appGuid
;
1199 dpsd
.guidInstance
= lpThisSD
->guidInstance
;
1201 if ( lpThisSD
->dwFlags
& DPSESSION_PASSWORDREQUIRED
)
1203 /* Incorrect password */
1204 U2(dpsd
).lpszPasswordA
= (LPSTR
) "sonic boom";
1205 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_JOIN
);
1206 checkHR( DPERR_INVALIDPASSWORD
, hr
);
1208 /* Correct password */
1209 U2(dpsd
).lpszPasswordA
= (LPSTR
) "hadouken";
1210 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_JOIN
);
1211 checkHR( DP_OK
, hr
);
1215 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_JOIN
);
1216 checkHR( DP_OK
, hr
);
1219 hr
= IDirectPlayX_Close( pDP
);
1220 checkHR( DP_OK
, hr
);
1225 static void test_Open(void)
1228 IDirectPlay4
*pDP
, *pDP_server
;
1229 DPSESSIONDESC2 dpsd
, dpsd_server
;
1233 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
1234 &IID_IDirectPlay4A
, (LPVOID
*) &pDP_server
);
1235 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
1236 if (FAILED(hr
)) return;
1238 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
1239 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
);
1240 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
1241 if (FAILED(hr
)) return;
1243 ZeroMemory( &dpsd_server
, sizeof(DPSESSIONDESC2
) );
1244 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
1246 /* Service provider not initialized */
1247 hr
= IDirectPlayX_Open( pDP_server
, &dpsd_server
, DPOPEN_CREATE
);
1248 todo_wine
checkHR( DPERR_INVALIDPARAMS
, hr
);
1250 init_TCPIP_provider( pDP_server
, "127.0.0.1", 0 );
1251 init_TCPIP_provider( pDP
, "127.0.0.1", 0 );
1253 /* Uninitialized dpsd */
1254 hr
= IDirectPlayX_Open( pDP_server
, &dpsd_server
, DPOPEN_CREATE
);
1255 checkHR( DPERR_INVALIDPARAMS
, hr
);
1258 dpsd_server
.dwSize
= sizeof(DPSESSIONDESC2
);
1259 dpsd_server
.guidApplication
= appGuid
;
1260 dpsd_server
.dwMaxPlayers
= 10;
1263 /* Regular operation */
1264 hr
= IDirectPlayX_Open( pDP_server
, &dpsd_server
, DPOPEN_CREATE
);
1265 todo_wine
checkHR( DP_OK
, hr
);
1268 hr
= IDirectPlayX_Open( pDP_server
, &dpsd_server
, DPOPEN_CREATE
);
1269 todo_wine
checkHR( DPERR_ALREADYINITIALIZED
, hr
);
1272 IDirectPlayX_Close( pDP_server
);
1274 dpsd_server
.dwFlags
= DPSESSION_CLIENTSERVER
| DPSESSION_MIGRATEHOST
;
1275 hr
= IDirectPlayX_Open( pDP_server
, &dpsd_server
, DPOPEN_CREATE
);
1276 todo_wine
checkHR( DPERR_INVALIDFLAGS
, hr
);
1278 dpsd_server
.dwFlags
= DPSESSION_MULTICASTSERVER
| DPSESSION_MIGRATEHOST
;
1279 hr
= IDirectPlayX_Open( pDP_server
, &dpsd_server
, DPOPEN_CREATE
);
1280 todo_wine
checkHR( DPERR_INVALIDFLAGS
, hr
);
1282 dpsd_server
.dwFlags
= DPSESSION_SECURESERVER
| DPSESSION_MIGRATEHOST
;
1283 hr
= IDirectPlayX_Open( pDP_server
, &dpsd_server
, DPOPEN_CREATE
);
1284 todo_wine
checkHR( DPERR_INVALIDFLAGS
, hr
);
1287 /* Joining sessions */
1288 /* - Checking how strict dplay is with sizes */
1290 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_JOIN
);
1291 checkHR( DPERR_INVALIDPARAMS
, hr
);
1293 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
)-1;
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
);
1302 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_JOIN
);
1303 todo_wine
checkHR( DPERR_NOSESSIONS
, hr
); /* Only checks for size, not guids */
1306 dpsd
.guidApplication
= appGuid
;
1307 dpsd
.guidInstance
= appGuid
;
1310 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_JOIN
);
1311 todo_wine
checkHR( DPERR_NOSESSIONS
, hr
);
1312 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_JOIN
| DPOPEN_CREATE
);
1313 todo_wine
checkHR( DPERR_NOSESSIONS
, hr
); /* Second flag is ignored */
1315 dpsd_server
.dwFlags
= 0;
1318 /* Join to normal session */
1319 hr
= IDirectPlayX_Open( pDP_server
, &dpsd_server
, DPOPEN_CREATE
);
1320 todo_wine
checkHR( DP_OK
, hr
);
1322 IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb2
, pDP
, 0 );
1325 /* Already initialized session */
1326 hr
= IDirectPlayX_Open( pDP_server
, &dpsd_server
, DPOPEN_CREATE
);
1327 todo_wine
checkHR( DPERR_ALREADYINITIALIZED
, hr
);
1330 /* Checking which is the error checking order */
1331 dpsd_server
.dwSize
= 0;
1333 hr
= IDirectPlayX_Open( pDP_server
, &dpsd_server
, DPOPEN_CREATE
);
1334 checkHR( DPERR_INVALIDPARAMS
, hr
);
1336 dpsd_server
.dwSize
= sizeof(DPSESSIONDESC2
);
1339 /* Join to protected session */
1340 IDirectPlayX_Close( pDP_server
);
1341 U2(dpsd_server
).lpszPasswordA
= (LPSTR
) "hadouken";
1342 hr
= IDirectPlayX_Open( pDP_server
, &dpsd_server
, DPOPEN_CREATE
);
1343 todo_wine
checkHR( DP_OK
, hr
);
1345 IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb2
,
1346 pDP
, DPENUMSESSIONS_PASSWORDREQUIRED
);
1349 IDirectPlayX_Release( pDP
);
1350 IDirectPlayX_Release( pDP_server
);
1356 static BOOL CALLBACK
EnumSessions_cb( LPCDPSESSIONDESC2 lpThisSD
,
1357 LPDWORD lpdwTimeOut
,
1361 lpCallbackData callbackData
= lpContext
;
1362 callbackData
->dwCounter1
++;
1364 if ( dwFlags
& DPESC_TIMEDOUT
)
1366 check( TRUE
, lpThisSD
== NULL
);
1369 check( FALSE
, lpThisSD
== NULL
);
1372 if ( U2(*lpThisSD
).lpszPasswordA
!= NULL
)
1374 check( TRUE
, (lpThisSD
->dwFlags
& DPSESSION_PASSWORDREQUIRED
) != 0 );
1377 if ( lpThisSD
->dwFlags
& DPSESSION_NEWPLAYERSDISABLED
)
1379 check( 0, lpThisSD
->dwCurrentPlayers
);
1382 check( sizeof(*lpThisSD
), lpThisSD
->dwSize
);
1383 checkLP( NULL
, U2(*lpThisSD
).lpszPasswordA
);
1388 static IDirectPlay4
*create_session(DPSESSIONDESC2
*lpdpsd
)
1396 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
1397 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
);
1398 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
1399 if (FAILED(hr
)) return NULL
;
1401 init_TCPIP_provider( pDP
, "127.0.0.1", 0 );
1403 hr
= IDirectPlayX_Open( pDP
, lpdpsd
, DPOPEN_CREATE
);
1404 todo_wine
checkHR( DP_OK
, hr
);
1406 if ( ! (lpdpsd
->dwFlags
& DPSESSION_NEWPLAYERSDISABLED
) )
1408 ZeroMemory( &name
, sizeof(DPNAME
) );
1409 name
.dwSize
= sizeof(DPNAME
);
1410 U1(name
).lpszShortNameA
= (LPSTR
) "bofh";
1412 hr
= IDirectPlayX_CreatePlayer( pDP
, &dpid
, &name
, NULL
, NULL
,
1413 0, DPPLAYER_SERVERPLAYER
);
1414 todo_wine
checkHR( DP_OK
, hr
);
1421 static void test_EnumSessions(void)
1424 #define N_SESSIONS 6
1426 IDirectPlay4
*pDP
, *pDPserver
[N_SESSIONS
];
1427 DPSESSIONDESC2 dpsd
, dpsd_server
[N_SESSIONS
];
1428 CallbackData callbackData
;
1433 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
1434 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
);
1435 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
1436 if (FAILED(hr
)) return;
1438 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
1439 callbackData
.dwCounter1
= -1; /* So that after a call to EnumSessions
1440 we get the exact number of sessions */
1441 callbackData
.dwFlags
= 0;
1444 /* Service provider not initialized */
1445 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1447 checkHR( DPERR_UNINITIALIZED
, hr
);
1450 init_TCPIP_provider( pDP
, "127.0.0.1", 0 );
1453 /* Session with no size */
1454 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1456 todo_wine
checkHR( DPERR_INVALIDPARAMS
, hr
);
1458 if ( hr
== DPERR_UNINITIALIZED
)
1460 todo_wine
win_skip( "EnumSessions not implemented\n" );
1464 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
1468 callbackData
.dwCounter1
= -1;
1469 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1471 checkHR( DP_OK
, hr
);
1472 check( 0, callbackData
.dwCounter1
);
1475 dpsd
.guidApplication
= appGuid
;
1477 /* Set up sessions */
1478 for (i
=0; i
<N_SESSIONS
; i
++)
1480 memcpy( &dpsd_server
[i
], &dpsd
, sizeof(DPSESSIONDESC2
) );
1483 U1(dpsd_server
[0]).lpszSessionNameA
= (LPSTR
) "normal";
1484 dpsd_server
[0].dwFlags
= ( DPSESSION_CLIENTSERVER
|
1485 DPSESSION_DIRECTPLAYPROTOCOL
);
1486 dpsd_server
[0].dwMaxPlayers
= 10;
1488 U1(dpsd_server
[1]).lpszSessionNameA
= (LPSTR
) "full";
1489 dpsd_server
[1].dwFlags
= ( DPSESSION_CLIENTSERVER
|
1490 DPSESSION_DIRECTPLAYPROTOCOL
);
1491 dpsd_server
[1].dwMaxPlayers
= 1;
1493 U1(dpsd_server
[2]).lpszSessionNameA
= (LPSTR
) "no new";
1494 dpsd_server
[2].dwFlags
= ( DPSESSION_CLIENTSERVER
|
1495 DPSESSION_DIRECTPLAYPROTOCOL
|
1496 DPSESSION_NEWPLAYERSDISABLED
);
1497 dpsd_server
[2].dwMaxPlayers
= 10;
1499 U1(dpsd_server
[3]).lpszSessionNameA
= (LPSTR
) "no join";
1500 dpsd_server
[3].dwFlags
= ( DPSESSION_CLIENTSERVER
|
1501 DPSESSION_DIRECTPLAYPROTOCOL
|
1502 DPSESSION_JOINDISABLED
);
1503 dpsd_server
[3].dwMaxPlayers
= 10;
1505 U1(dpsd_server
[4]).lpszSessionNameA
= (LPSTR
) "private";
1506 dpsd_server
[4].dwFlags
= ( DPSESSION_CLIENTSERVER
|
1507 DPSESSION_DIRECTPLAYPROTOCOL
|
1508 DPSESSION_PRIVATE
);
1509 dpsd_server
[4].dwMaxPlayers
= 10;
1510 U2(dpsd_server
[4]).lpszPasswordA
= (LPSTR
) "password";
1512 U1(dpsd_server
[5]).lpszSessionNameA
= (LPSTR
) "protected";
1513 dpsd_server
[5].dwFlags
= ( DPSESSION_CLIENTSERVER
|
1514 DPSESSION_DIRECTPLAYPROTOCOL
|
1515 DPSESSION_PASSWORDREQUIRED
);
1516 dpsd_server
[5].dwMaxPlayers
= 10;
1517 U2(dpsd_server
[5]).lpszPasswordA
= (LPSTR
) "password";
1520 for (i
=0; i
<N_SESSIONS
; i
++)
1522 pDPserver
[i
] = create_session( &dpsd_server
[i
] );
1523 if (!pDPserver
[i
]) return;
1527 /* Invalid params */
1528 callbackData
.dwCounter1
= -1;
1529 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1530 &callbackData
, -1 );
1531 checkHR( DPERR_INVALIDPARAMS
, hr
);
1533 hr
= IDirectPlayX_EnumSessions( pDP
, NULL
, 0, EnumSessions_cb
,
1535 checkHR( DPERR_INVALIDPARAMS
, hr
);
1537 check( -1, callbackData
.dwCounter1
);
1541 callbackData
.dwFlags
= DPENUMSESSIONS_ALL
; /* Doesn't list private,
1543 callbackData
.dwCounter1
= -1;
1544 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1545 &callbackData
, callbackData
.dwFlags
);
1546 checkHR( DP_OK
, hr
);
1547 check( N_SESSIONS
-2, callbackData
.dwCounter1
);
1549 /* Doesn't list private */
1550 callbackData
.dwFlags
= ( DPENUMSESSIONS_ALL
|
1551 DPENUMSESSIONS_PASSWORDREQUIRED
);
1552 callbackData
.dwCounter1
= -1;
1553 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1554 &callbackData
, callbackData
.dwFlags
);
1555 checkHR( DP_OK
, hr
);
1556 check( N_SESSIONS
-1, callbackData
.dwCounter1
);
1558 /* Doesn't list full, no new, no join, private, protected */
1559 callbackData
.dwFlags
= DPENUMSESSIONS_AVAILABLE
;
1560 callbackData
.dwCounter1
= -1;
1561 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1562 &callbackData
, callbackData
.dwFlags
);
1563 checkHR( DP_OK
, hr
);
1564 check( N_SESSIONS
-5, callbackData
.dwCounter1
);
1566 /* Like with DPENUMSESSIONS_AVAILABLE */
1567 callbackData
.dwFlags
= 0;
1568 callbackData
.dwCounter1
= -1;
1569 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1570 &callbackData
, callbackData
.dwFlags
);
1571 checkHR( DP_OK
, hr
);
1572 check( N_SESSIONS
-5, callbackData
.dwCounter1
);
1574 /* Doesn't list full, no new, no join, private */
1575 callbackData
.dwFlags
= DPENUMSESSIONS_PASSWORDREQUIRED
;
1576 callbackData
.dwCounter1
= -1;
1577 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1578 &callbackData
, callbackData
.dwFlags
);
1579 checkHR( DP_OK
, hr
);
1580 check( N_SESSIONS
-4, callbackData
.dwCounter1
);
1583 /* Async enumeration */
1584 callbackData
.dwFlags
= DPENUMSESSIONS_ASYNC
;
1585 callbackData
.dwCounter1
= -1;
1586 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1587 &callbackData
, callbackData
.dwFlags
);
1588 checkHR( DP_OK
, hr
);
1589 check( N_SESSIONS
-4, callbackData
.dwCounter1
); /* Read cache of last
1592 callbackData
.dwFlags
= DPENUMSESSIONS_STOPASYNC
;
1593 callbackData
.dwCounter1
= -1;
1594 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1595 &callbackData
, callbackData
.dwFlags
);
1596 checkHR( DP_OK
, hr
);
1597 check( 0, callbackData
.dwCounter1
); /* Stop enumeration */
1599 callbackData
.dwFlags
= DPENUMSESSIONS_ASYNC
;
1600 callbackData
.dwCounter1
= -1;
1601 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1602 &callbackData
, callbackData
.dwFlags
);
1603 checkHR( DP_OK
, hr
);
1604 check( 0, callbackData
.dwCounter1
); /* Start enumeration */
1606 Sleep(500); /* Give time to fill the cache */
1608 callbackData
.dwFlags
= DPENUMSESSIONS_ASYNC
;
1609 callbackData
.dwCounter1
= -1;
1610 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1611 &callbackData
, callbackData
.dwFlags
);
1612 checkHR( DP_OK
, hr
);
1613 check( N_SESSIONS
-5, callbackData
.dwCounter1
); /* Retrieve results */
1615 callbackData
.dwFlags
= DPENUMSESSIONS_STOPASYNC
;
1616 callbackData
.dwCounter1
= -1;
1617 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1618 &callbackData
, callbackData
.dwFlags
);
1619 checkHR( DP_OK
, hr
);
1620 check( 0, callbackData
.dwCounter1
); /* Stop enumeration */
1623 /* Specific tests for passworded sessions */
1625 for (i
=0; i
<N_SESSIONS
; i
++)
1627 IDirectPlayX_Release( pDPserver
[i
] );
1630 /* - Only session password set */
1633 U2(dpsd_server
[i
]).lpszPasswordA
= (LPSTR
) "password";
1634 dpsd_server
[i
].dwFlags
= 0;
1635 pDPserver
[i
] = create_session( &dpsd_server
[i
] );
1638 callbackData
.dwFlags
= 0;
1639 callbackData
.dwCounter1
= -1;
1640 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1641 &callbackData
, callbackData
.dwFlags
);
1642 checkHR( DP_OK
, hr
);
1643 check( 0, callbackData
.dwCounter1
);
1645 callbackData
.dwFlags
= DPENUMSESSIONS_PASSWORDREQUIRED
;
1646 callbackData
.dwCounter1
= -1;
1647 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1648 &callbackData
, callbackData
.dwFlags
);
1649 checkHR( DP_OK
, hr
);
1650 check( 2, callbackData
.dwCounter1
); /* Both sessions automatically
1651 set DPSESSION_PASSWORDREQUIRED */
1653 /* - Only session flag set */
1654 for (i
=4; i
<=5; i
++)
1656 IDirectPlayX_Release( pDPserver
[i
] );
1657 U2(dpsd_server
[i
]).lpszPasswordA
= NULL
;
1659 dpsd_server
[4].dwFlags
= DPSESSION_PRIVATE
;
1660 dpsd_server
[5].dwFlags
= DPSESSION_PASSWORDREQUIRED
;
1661 for (i
=4; i
<=5; i
++)
1663 pDPserver
[i
] = create_session( &dpsd_server
[i
] );
1666 callbackData
.dwFlags
= 0;
1667 callbackData
.dwCounter1
= -1;
1668 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1669 &callbackData
, callbackData
.dwFlags
);
1670 checkHR( DP_OK
, hr
);
1671 check( 2, callbackData
.dwCounter1
); /* Without password,
1672 the flag is ignored */
1674 /* - Both session flag and password set */
1675 for (i
=4; i
<=5; i
++)
1677 IDirectPlayX_Release( pDPserver
[i
] );
1678 U2(dpsd_server
[i
]).lpszPasswordA
= (LPSTR
) "password";
1680 dpsd_server
[4].dwFlags
= DPSESSION_PRIVATE
;
1681 dpsd_server
[5].dwFlags
= DPSESSION_PASSWORDREQUIRED
;
1682 for (i
=4; i
<=5; i
++)
1684 pDPserver
[i
] = create_session( &dpsd_server
[i
] );
1687 /* - Listing without password */
1688 callbackData
.dwCounter1
= -1;
1689 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1690 &callbackData
, callbackData
.dwFlags
);
1691 checkHR( DP_OK
, hr
);
1692 check( 0, callbackData
.dwCounter1
);
1694 callbackData
.dwFlags
= DPENUMSESSIONS_PASSWORDREQUIRED
;
1695 callbackData
.dwCounter1
= -1;
1696 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1697 &callbackData
, callbackData
.dwFlags
);
1698 checkHR( DP_OK
, hr
);
1699 check( 1, callbackData
.dwCounter1
);
1701 /* - Listing with incorrect password */
1702 U2(dpsd
).lpszPasswordA
= (LPSTR
) "bad_password";
1703 callbackData
.dwFlags
= 0;
1704 callbackData
.dwCounter1
= -1;
1705 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1706 &callbackData
, callbackData
.dwFlags
);
1707 checkHR( DP_OK
, hr
);
1708 check( 0, callbackData
.dwCounter1
);
1710 callbackData
.dwFlags
= DPENUMSESSIONS_PASSWORDREQUIRED
;
1711 callbackData
.dwCounter1
= -1;
1712 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1713 &callbackData
, callbackData
.dwFlags
);
1714 checkHR( DP_OK
, hr
);
1715 check( 1, callbackData
.dwCounter1
);
1717 /* - Listing with correct password */
1718 U2(dpsd
).lpszPasswordA
= (LPSTR
) "password";
1719 callbackData
.dwCounter1
= -1;
1720 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1721 &callbackData
, callbackData
.dwFlags
);
1722 checkHR( DP_OK
, hr
);
1723 check( 2, callbackData
.dwCounter1
);
1726 U2(dpsd
).lpszPasswordA
= NULL
;
1727 callbackData
.dwFlags
= DPENUMSESSIONS_ASYNC
;
1728 callbackData
.dwCounter1
= -1;
1729 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1730 &callbackData
, callbackData
.dwFlags
);
1731 checkHR( DP_OK
, hr
);
1732 check( 2, callbackData
.dwCounter1
); /* Read cache of last sync enumeration,
1733 even private sessions */
1738 /* - Creating two servers with different application GUIDs */
1739 for (i
=4; i
<=5; i
++)
1741 IDirectPlayX_Release( pDPserver
[i
] );
1742 dpsd_server
[i
].dwFlags
= ( DPSESSION_CLIENTSERVER
|
1743 DPSESSION_DIRECTPLAYPROTOCOL
);
1744 U2(dpsd_server
[i
]).lpszPasswordA
= NULL
;
1745 dpsd_server
[i
].dwMaxPlayers
= 10;
1747 U1(dpsd_server
[4]).lpszSessionNameA
= (LPSTR
) "normal1";
1748 dpsd_server
[4].guidApplication
= appGuid
;
1749 U1(dpsd_server
[5]).lpszSessionNameA
= (LPSTR
) "normal2";
1750 dpsd_server
[5].guidApplication
= appGuid2
;
1751 for (i
=4; i
<=5; i
++)
1753 pDPserver
[i
] = create_session( &dpsd_server
[i
] );
1756 callbackData
.dwFlags
= 0;
1758 dpsd
.guidApplication
= appGuid2
;
1759 callbackData
.dwCounter1
= -1;
1760 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1761 &callbackData
, callbackData
.dwFlags
);
1762 checkHR( DP_OK
, hr
);
1763 check( 1, callbackData
.dwCounter1
); /* Only one of the sessions */
1765 dpsd
.guidApplication
= appGuid
;
1766 callbackData
.dwCounter1
= -1;
1767 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1768 &callbackData
, callbackData
.dwFlags
);
1769 checkHR( DP_OK
, hr
);
1770 check( 1, callbackData
.dwCounter1
); /* The other session */
1772 For some reason, if we enum 1st with appGuid and 2nd with appGuid2,
1773 in the second enum we get the 2 sessions. Dplay fault? Elves? */
1775 dpsd
.guidApplication
= GUID_NULL
;
1776 callbackData
.dwCounter1
= -1;
1777 hr
= IDirectPlayX_EnumSessions( pDP
, &dpsd
, 0, EnumSessions_cb
,
1778 &callbackData
, callbackData
.dwFlags
);
1779 checkHR( DP_OK
, hr
);
1780 check( 2, callbackData
.dwCounter1
); /* Both sessions */
1782 for (i
=4; i
<=5; i
++)
1784 IDirectPlayX_Release( pDPserver
[i
] );
1786 IDirectPlayX_Release( pDP
);
1793 static void test_SessionDesc(void)
1796 IDirectPlay4
*pDP
[2];
1797 DPSESSIONDESC2 dpsd
;
1798 LPDPSESSIONDESC2 lpData
[2];
1804 CallbackData callbackData
;
1809 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
1810 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
1811 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
1812 if (FAILED(hr
)) return;
1814 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
1816 /* Service provider not initialized */
1817 hr
= IDirectPlayX_SetSessionDesc( pDP
[0], NULL
, 0 );
1818 checkHR( DPERR_UNINITIALIZED
, hr
);
1820 hr
= IDirectPlayX_GetSessionDesc( pDP
[0], NULL
, NULL
);
1821 checkHR( DPERR_UNINITIALIZED
, hr
);
1824 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
1825 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
1828 /* No sessions open */
1829 hr
= IDirectPlayX_SetSessionDesc( pDP
[0], NULL
, 0 );
1830 todo_wine
checkHR( DPERR_NOSESSIONS
, hr
);
1832 if ( hr
== DPERR_UNINITIALIZED
)
1834 todo_wine
win_skip("Get/SetSessionDesc not implemented\n");
1838 hr
= IDirectPlayX_GetSessionDesc( pDP
[0], NULL
, NULL
);
1839 checkHR( DPERR_NOSESSIONS
, hr
);
1842 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
1843 dpsd
.guidApplication
= appGuid
;
1844 dpsd
.dwMaxPlayers
= 10;
1848 IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
1850 IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
1855 /* Players, only to receive messages */
1856 IDirectPlayX_CreatePlayer( pDP
[i
], &dpid
[i
], NULL
, NULL
, NULL
, 0, 0 );
1858 lpData
[i
] = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, 1024 );
1860 lpDataMsg
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, 1024 );
1863 /* Incorrect parameters */
1864 hr
= IDirectPlayX_SetSessionDesc( pDP
[0], NULL
, 0 );
1865 checkHR( DPERR_INVALIDPARAMS
, hr
);
1866 hr
= IDirectPlayX_GetSessionDesc( pDP
[0], NULL
, NULL
);
1867 checkHR( DPERR_INVALIDPARAM
, hr
);
1870 /* Crashes under Win7 */
1871 hr
= IDirectPlayX_GetSessionDesc( pDP
[0], lpData
[0], NULL
);
1872 checkHR( DPERR_INVALIDPARAM
, hr
);
1874 hr
= IDirectPlayX_GetSessionDesc( pDP
[0], lpData
[0], &dwDataSize
);
1875 checkHR( DPERR_INVALIDPARAMS
, hr
);
1876 check( -1, dwDataSize
);
1879 /* Get: Insufficient buffer size */
1881 hr
= IDirectPlayX_GetSessionDesc( pDP
[0], lpData
[0], &dwDataSize
);
1882 checkHR( DPERR_BUFFERTOOSMALL
, hr
);
1883 check( dpsd
.dwSize
, dwDataSize
);
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], NULL
, &dwDataSize
);
1890 checkHR( DPERR_BUFFERTOOSMALL
, hr
);
1891 check( dpsd
.dwSize
, dwDataSize
);
1893 /* Get: Regular operation
1894 * i=0: Local session
1895 * i=1: Remote session */
1898 hr
= IDirectPlayX_GetSessionDesc( pDP
[i
], lpData
[i
], &dwDataSize
);
1899 checkHR( DP_OK
, hr
);
1900 check( sizeof(DPSESSIONDESC2
), dwDataSize
);
1901 check( sizeof(DPSESSIONDESC2
), lpData
[i
]->dwSize
);
1902 checkGuid( &appGuid
, &lpData
[i
]->guidApplication
);
1903 check( dpsd
.dwMaxPlayers
, lpData
[i
]->dwMaxPlayers
);
1906 checkGuid( &lpData
[0]->guidInstance
, &lpData
[1]->guidInstance
);
1908 /* Set: Regular operation */
1909 U1(dpsd
).lpszSessionNameA
= (LPSTR
) "Wahaa";
1910 hr
= IDirectPlayX_SetSessionDesc( pDP
[0], &dpsd
, 0 );
1911 checkHR( DP_OK
, hr
);
1914 hr
= IDirectPlayX_GetSessionDesc( pDP
[1], lpData
[1], &dwDataSize
);
1915 checkHR( DP_OK
, hr
);
1916 checkStr( U1(dpsd
).lpszSessionNameA
, U1(*lpData
[1]).lpszSessionNameA
);
1919 /* Set: Failing to modify a remote session */
1920 hr
= IDirectPlayX_SetSessionDesc( pDP
[1], &dpsd
, 0 );
1921 checkHR( DPERR_ACCESSDENIED
, hr
);
1923 /* Trying to change immutable properties */
1925 hr
= IDirectPlayX_SetSessionDesc( pDP
[0], &dpsd
, 0 );
1926 checkHR( DP_OK
, hr
);
1927 dpsd
.dwFlags
= DPSESSION_SECURESERVER
;
1928 hr
= IDirectPlayX_SetSessionDesc( pDP
[0], &dpsd
, 0 );
1929 checkHR( DPERR_INVALIDPARAMS
, hr
);
1931 hr
= IDirectPlayX_SetSessionDesc( pDP
[0], &dpsd
, 0 );
1932 checkHR( DP_OK
, hr
);
1935 hr
= IDirectPlayX_SetSessionDesc( pDP
[0], &dpsd
, 0 );
1936 checkHR( DPERR_INVALIDPARAMS
, hr
);
1937 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
1938 hr
= IDirectPlayX_SetSessionDesc( pDP
[0], &dpsd
, 0 );
1939 checkHR( DP_OK
, hr
);
1941 /* Changing the GUIDs and size is ignored */
1942 dpsd
.guidApplication
= appGuid2
;
1943 hr
= IDirectPlayX_SetSessionDesc( pDP
[0], &dpsd
, 0 );
1944 checkHR( DP_OK
, hr
);
1945 dpsd
.guidInstance
= appGuid2
;
1946 hr
= IDirectPlayX_SetSessionDesc( pDP
[0], &dpsd
, 0 );
1947 checkHR( DP_OK
, hr
);
1949 hr
= IDirectPlayX_GetSessionDesc( pDP
[0], lpData
[0], &dwDataSize
);
1950 checkHR( DP_OK
, hr
);
1951 checkGuid( &appGuid
, &lpData
[0]->guidApplication
);
1952 checkGuid( &lpData
[1]->guidInstance
, &lpData
[0]->guidInstance
);
1953 check( sizeof(DPSESSIONDESC2
), lpData
[0]->dwSize
);
1956 /* Checking system messages */
1957 check_messages( pDP
[0], dpid
, 2, &callbackData
);
1958 checkStr( "S0,S0,S0,S0,S0,S0,S0,", callbackData
.szTrace1
);
1959 checkStr( "48,90,90,90,90,90,90,", callbackData
.szTrace2
);
1960 check_messages( pDP
[1], dpid
, 2, &callbackData
);
1961 checkStr( "S1,S1,S1,S1,S1,S1,", callbackData
.szTrace1
);
1962 checkStr( "90,90,90,90,90,90,", callbackData
.szTrace2
);
1964 HeapFree( GetProcessHeap(), 0, lpDataMsg
);
1967 HeapFree( GetProcessHeap(), 0, lpData
[i
] );
1968 IDirectPlayX_Release( pDP
[i
] );
1975 static void test_CreatePlayer(void)
1978 IDirectPlay4
*pDP
[2];
1979 DPSESSIONDESC2 dpsd
;
1985 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
1986 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[0] );
1987 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
1988 if (FAILED(hr
)) return;
1990 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
1991 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[1] );
1992 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
1993 if (FAILED(hr
)) return;
1995 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
1996 ZeroMemory( &name
, sizeof(DPNAME
) );
1999 /* Connection not initialized */
2000 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
, 0, 0 );
2001 checkHR( DPERR_UNINITIALIZED
, hr
);
2004 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
2005 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
2008 /* Session not open */
2009 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
, 0, 0 );
2010 todo_wine
checkHR( DPERR_INVALIDPARAMS
, hr
);
2012 if ( hr
== DPERR_UNINITIALIZED
)
2014 todo_wine
win_skip( "CreatePlayer not implemented\n" );
2018 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
2019 dpsd
.guidApplication
= appGuid
;
2020 IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
2024 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
, 0, 0 );
2025 checkHR( DP_OK
, hr
);
2031 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, &name
, NULL
, NULL
, 0, 0 );
2032 checkHR( DP_OK
, hr
);
2035 name
.dwSize
= sizeof(DPNAME
);
2036 U1(name
).lpszShortNameA
= (LPSTR
) "test";
2037 U2(name
).lpszLongNameA
= NULL
;
2040 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, &name
, NULL
, NULL
,
2042 checkHR( DP_OK
, hr
);
2046 hr
= IDirectPlayX_CreatePlayer( pDP
[0], NULL
, NULL
, NULL
, NULL
,
2048 checkHR( DPERR_INVALIDPARAMS
, hr
);
2051 /* There can only be one server player */
2052 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2053 0, DPPLAYER_SERVERPLAYER
);
2054 checkHR( DP_OK
, hr
);
2055 check( DPID_SERVERPLAYER
, dpid
);
2057 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2058 0, DPPLAYER_SERVERPLAYER
);
2059 checkHR( DPERR_CANTCREATEPLAYER
, hr
);
2061 IDirectPlayX_DestroyPlayer( pDP
[0], dpid
);
2063 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2064 0, DPPLAYER_SERVERPLAYER
);
2065 checkHR( DP_OK
, hr
);
2066 check( DPID_SERVERPLAYER
, dpid
);
2067 IDirectPlayX_DestroyPlayer( pDP
[0], dpid
);
2071 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2073 checkHR( DP_OK
, hr
);
2075 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2076 0, DPPLAYER_SERVERPLAYER
);
2077 checkHR( DP_OK
, hr
);
2078 check( DPID_SERVERPLAYER
, dpid
);
2079 IDirectPlayX_DestroyPlayer( pDP
[0], dpid
);
2081 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2082 0, DPPLAYER_SPECTATOR
);
2083 checkHR( DP_OK
, hr
);
2085 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2086 0, ( DPPLAYER_SERVERPLAYER
|
2087 DPPLAYER_SPECTATOR
) );
2088 checkHR( DP_OK
, hr
);
2089 check( DPID_SERVERPLAYER
, dpid
);
2090 IDirectPlayX_DestroyPlayer( pDP
[0], dpid
);
2093 /* Session with DPSESSION_NEWPLAYERSDISABLED */
2094 IDirectPlayX_Close( pDP
[0] );
2095 dpsd
.dwFlags
= DPSESSION_NEWPLAYERSDISABLED
;
2096 hr
= IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
2097 checkHR( DP_OK
, hr
);
2100 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2102 checkHR( DPERR_CANTCREATEPLAYER
, hr
);
2104 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2105 0, DPPLAYER_SERVERPLAYER
);
2106 checkHR( DPERR_CANTCREATEPLAYER
, hr
);
2108 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2109 0, DPPLAYER_SPECTATOR
);
2110 checkHR( DPERR_CANTCREATEPLAYER
, hr
);
2113 /* Creating players in a Client/Server session */
2114 IDirectPlayX_Close( pDP
[0] );
2115 dpsd
.dwFlags
= DPSESSION_CLIENTSERVER
;
2116 hr
= IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
2117 checkHR( DP_OK
, hr
);
2118 hr
= IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
2120 checkHR( DP_OK
, hr
);
2123 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2125 checkHR( DPERR_ACCESSDENIED
, hr
);
2127 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
, NULL
, NULL
, NULL
,
2128 0, DPPLAYER_SERVERPLAYER
);
2129 checkHR( DP_OK
, hr
);
2130 check( DPID_SERVERPLAYER
, dpid
);
2132 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &dpid
, NULL
, NULL
, NULL
,
2133 0, DPPLAYER_SERVERPLAYER
);
2134 checkHR( DPERR_INVALIDFLAGS
, hr
);
2136 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &dpid
, NULL
, NULL
, NULL
,
2138 checkHR( DP_OK
, hr
);
2141 IDirectPlayX_Release( pDP
[0] );
2142 IDirectPlayX_Release( pDP
[1] );
2148 static void test_GetPlayerCaps(void)
2151 IDirectPlay4
*pDP
[2];
2152 DPSESSIONDESC2 dpsd
;
2163 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
2164 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
2165 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
2166 if (FAILED(hr
)) return;
2168 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
2169 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
2170 dpsd
.guidApplication
= appGuid
;
2171 dpsd
.dwMaxPlayers
= 10;
2173 ZeroMemory( &playerCaps
, sizeof(DPCAPS
) );
2176 /* Uninitialized service provider */
2177 playerCaps
.dwSize
= 0;
2178 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], 0, &playerCaps
, 0 );
2179 checkHR( DPERR_UNINITIALIZED
, hr
);
2181 playerCaps
.dwSize
= sizeof(DPCAPS
);
2182 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], 0, &playerCaps
, 0 );
2183 checkHR( DPERR_UNINITIALIZED
, hr
);
2186 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
2187 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
2191 playerCaps
.dwSize
= 0;
2193 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], 0, &playerCaps
, 0 );
2194 todo_wine
checkHR( DPERR_INVALIDPARAMS
, hr
);
2196 if ( hr
== DPERR_UNINITIALIZED
)
2198 todo_wine
win_skip( "GetPlayerCaps not implemented\n" );
2202 playerCaps
.dwSize
= sizeof(DPCAPS
);
2204 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], 0, &playerCaps
, 0 );
2205 checkHR( DPERR_INVALIDPLAYER
, hr
);
2207 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], 2, &playerCaps
, 0 );
2208 checkHR( DPERR_INVALIDPLAYER
, hr
);
2211 hr
= IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
2212 checkHR( DP_OK
, hr
);
2213 hr
= IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
2215 checkHR( DP_OK
, hr
);
2219 hr
= IDirectPlayX_CreatePlayer( pDP
[i
], &dpid
[i
],
2220 NULL
, NULL
, NULL
, 0, 0 );
2221 checkHR( DP_OK
, hr
);
2225 /* Uninitialized playerCaps */
2226 playerCaps
.dwSize
= 0;
2228 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], 0, &playerCaps
, 0 );
2229 checkHR( DPERR_INVALIDPARAMS
, hr
);
2231 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], 2, &playerCaps
, 0 );
2232 checkHR( DPERR_INVALIDPARAMS
, hr
);
2234 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], dpid
[0], &playerCaps
, 0 );
2235 checkHR( DPERR_INVALIDPARAMS
, hr
);
2237 /* Invalid player */
2238 playerCaps
.dwSize
= sizeof(DPCAPS
);
2240 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], 0, &playerCaps
, 0 );
2241 checkHR( DPERR_INVALIDPLAYER
, hr
);
2243 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], 2, &playerCaps
, 0 );
2244 checkHR( DPERR_INVALIDPLAYER
, hr
);
2246 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], dpid
[0], &playerCaps
, 0 );
2247 checkHR( DP_OK
, hr
);
2249 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], dpid
[0], NULL
, 0 );
2250 checkHR( DPERR_INVALIDPARAMS
, hr
);
2252 /* Regular parameters */
2256 dwFlags
<=DPGETCAPS_GUARANTEED
;
2257 dwFlags
+=DPGETCAPS_GUARANTEED
)
2260 hr
= IDirectPlayX_GetPlayerCaps( pDP
[0], dpid
[i
],
2261 &playerCaps
, dwFlags
);
2262 checkHR( DP_OK
, hr
);
2265 check( sizeof(DPCAPS
), playerCaps
.dwSize
);
2266 check( 40, playerCaps
.dwSize
);
2267 check( 0, playerCaps
.dwMaxQueueSize
);
2268 check( 0, playerCaps
.dwHundredBaud
);
2269 check( 0, playerCaps
.dwLatency
);
2270 check( 65536, playerCaps
.dwMaxLocalPlayers
);
2271 check( 20, playerCaps
.dwHeaderLength
);
2275 checkFlags( DPCAPS_ISHOST
|
2276 DPCAPS_GUARANTEEDOPTIMIZED
|
2277 DPCAPS_GUARANTEEDSUPPORTED
|
2278 DPCAPS_ASYNCSUPPORTED
|
2280 playerCaps
.dwFlags
, FLAGS_DPCAPS
);
2283 checkFlags( DPCAPS_ISHOST
|
2284 DPCAPS_GUARANTEEDOPTIMIZED
|
2285 DPCAPS_GUARANTEEDSUPPORTED
|
2286 DPCAPS_ASYNCSUPPORTED
,
2287 playerCaps
.dwFlags
, FLAGS_DPCAPS
);
2289 if ( dwFlags
== DPGETCAPS_GUARANTEED
)
2291 check( 1048547, playerCaps
.dwMaxBufferSize
);
2292 check( 64, playerCaps
.dwMaxPlayers
);
2296 check( 65479, playerCaps
.dwMaxBufferSize
);
2297 check( 65536, playerCaps
.dwMaxPlayers
);
2304 IDirectPlayX_Release( pDP
[0] );
2305 IDirectPlayX_Release( pDP
[1] );
2312 static void test_PlayerData(void)
2315 DPSESSIONDESC2 dpsd
;
2319 /* lpDataFake has to be bigger than the rest, limits lpDataGet size */
2320 LPCSTR lpDataFake
= "big_fake_data_chunk";
2321 DWORD dwDataSizeFake
= strlen(lpDataFake
)+1;
2323 LPCSTR lpData
= "remote_data";
2324 DWORD dwDataSize
= strlen(lpData
)+1;
2326 LPCSTR lpDataLocal
= "local_data";
2327 DWORD dwDataSizeLocal
= strlen(lpDataLocal
)+1;
2329 LPSTR lpDataGet
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
2331 DWORD dwDataSizeGet
= dwDataSizeFake
;
2334 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
2335 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
);
2336 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
2337 if (FAILED(hr
)) return;
2339 /* No service provider */
2340 hr
= IDirectPlayX_SetPlayerData( pDP
, 0, (LPVOID
) lpData
,
2342 checkHR( DPERR_UNINITIALIZED
, hr
);
2344 hr
= IDirectPlayX_GetPlayerData( pDP
, 0, lpDataGet
, &dwDataSizeGet
, 0 );
2345 checkHR( DPERR_UNINITIALIZED
, hr
);
2348 init_TCPIP_provider( pDP
, "127.0.0.1", 0 );
2350 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
2351 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
2352 dpsd
.guidApplication
= appGuid
;
2353 IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_CREATE
);
2356 /* Invalid player */
2357 hr
= IDirectPlayX_SetPlayerData( pDP
, 0, (LPVOID
) lpData
,
2359 todo_wine
checkHR( DPERR_INVALIDPLAYER
, hr
);
2361 hr
= IDirectPlayX_GetPlayerData( pDP
, 0, lpDataGet
, &dwDataSizeGet
, 0 );
2362 todo_wine
checkHR( DPERR_INVALIDPLAYER
, hr
);
2364 if ( hr
== DPERR_UNINITIALIZED
)
2366 todo_wine
win_skip( "Get/SetPlayerData not implemented\n" );
2370 /* Create the player */
2371 /* By default, the data is remote */
2372 hr
= IDirectPlayX_CreatePlayer( pDP
, &dpid
, NULL
, NULL
, (LPVOID
) lpData
,
2374 checkHR( DP_OK
, hr
);
2376 /* Invalid parameters */
2377 hr
= IDirectPlayX_SetPlayerData( pDP
, dpid
, NULL
, dwDataSize
, 0 );
2378 checkHR( DPERR_INVALIDPARAMS
, hr
);
2379 hr
= IDirectPlayX_SetPlayerData( pDP
, dpid
, lpDataGet
, -1, 0 );
2380 checkHR( DPERR_INVALIDPARAMS
, hr
);
2382 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, NULL
, 0 );
2383 checkHR( DPERR_INVALIDPARAMS
, hr
);
2387 * Remote data (default)
2391 /* Buffer redimension */
2392 dwDataSizeGet
= dwDataSizeFake
;
2393 strcpy(lpDataGet
, lpDataFake
);
2394 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, NULL
,
2395 &dwDataSizeGet
, 0 );
2396 check( DPERR_BUFFERTOOSMALL
, hr
);
2397 check( dwDataSize
, dwDataSizeGet
);
2398 checkStr( lpDataFake
, lpDataGet
);
2401 strcpy(lpDataGet
, lpDataFake
);
2402 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
, 0 );
2403 check( DPERR_BUFFERTOOSMALL
, hr
);
2404 check( dwDataSize
, dwDataSizeGet
);
2406 strcpy(lpDataGet
, lpDataFake
);
2407 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
, 0 );
2408 checkHR( DP_OK
, hr
);
2409 check( dwDataSize
, dwDataSizeGet
);
2410 checkStr( lpData
, lpDataGet
);
2412 /* Normal operation */
2413 dwDataSizeGet
= dwDataSizeFake
;
2414 strcpy(lpDataGet
, lpDataFake
);
2415 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
, 0 );
2416 checkHR( DP_OK
, hr
);
2417 check( dwDataSize
, dwDataSizeGet
);
2418 checkStr( lpData
, lpDataGet
);
2421 dwDataSizeGet
= dwDataSizeFake
;
2422 strcpy(lpDataGet
, lpDataFake
);
2423 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
, 0 );
2424 checkHR( DP_OK
, hr
);
2425 check( dwDataSize
, dwDataSizeGet
); /* Remote: works as expected */
2426 checkStr( lpData
, lpDataGet
);
2428 dwDataSizeGet
= dwDataSizeFake
;
2429 strcpy(lpDataGet
, lpDataFake
);
2430 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
,
2432 checkHR( DP_OK
, hr
);
2433 check( dwDataSize
, dwDataSizeGet
); /* Same behaviour as in previous test */
2434 checkStr( lpData
, lpDataGet
);
2436 dwDataSizeGet
= dwDataSizeFake
;
2437 strcpy(lpDataGet
, lpDataFake
);
2438 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
,
2440 checkHR( DP_OK
, hr
);
2441 check( 0, dwDataSizeGet
); /* Sets size to 0 (as local data doesn't exist) */
2442 checkStr( lpDataFake
, lpDataGet
);
2444 dwDataSizeGet
= dwDataSizeFake
;
2445 strcpy(lpDataGet
, lpDataFake
);
2446 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
,
2447 DPGET_LOCAL
| DPGET_REMOTE
);
2448 checkHR( DP_OK
, hr
);
2449 check( 0, dwDataSizeGet
); /* Same behaviour as in previous test */
2450 checkStr( lpDataFake
, lpDataGet
);
2452 /* Getting local data (which doesn't exist), buffer size is ignored */
2454 strcpy(lpDataGet
, lpDataFake
);
2455 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
,
2457 checkHR( DP_OK
, hr
);
2458 check( 0, dwDataSizeGet
); /* Sets size to 0 */
2459 checkStr( lpDataFake
, lpDataGet
);
2461 dwDataSizeGet
= dwDataSizeFake
;
2462 strcpy(lpDataGet
, lpDataFake
);
2463 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, NULL
, &dwDataSizeGet
,
2465 checkHR( DP_OK
, hr
);
2466 check( 0, dwDataSizeGet
); /* Sets size to 0 */
2467 checkStr( lpDataFake
, lpDataGet
);
2476 hr
= IDirectPlayX_SetPlayerData( pDP
, dpid
, (LPVOID
) lpDataLocal
,
2478 DPSET_LOCAL
| DPSET_GUARANTEED
);
2479 checkHR( DPERR_INVALIDPARAMS
, hr
);
2481 /* Correct parameters */
2482 hr
= IDirectPlayX_SetPlayerData( pDP
, dpid
, (LPVOID
) lpDataLocal
,
2483 dwDataSizeLocal
, DPSET_LOCAL
);
2484 checkHR( DP_OK
, hr
);
2486 /* Flag tests (again) */
2487 dwDataSizeGet
= dwDataSizeFake
;
2488 strcpy(lpDataGet
, lpDataFake
);
2489 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
, 0 );
2490 checkHR( DP_OK
, hr
);
2491 check( dwDataSize
, dwDataSizeGet
); /* Remote: works as expected */
2492 checkStr( lpData
, lpDataGet
);
2494 dwDataSizeGet
= dwDataSizeFake
;
2495 strcpy(lpDataGet
, lpDataFake
);
2496 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
,
2498 checkHR( DP_OK
, hr
);
2499 check( dwDataSize
, dwDataSizeGet
); /* Like in previous test */
2500 checkStr( lpData
, lpDataGet
);
2502 dwDataSizeGet
= dwDataSizeFake
;
2503 strcpy(lpDataGet
, lpDataFake
);
2504 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
,
2506 checkHR( DP_OK
, hr
);
2507 check( dwDataSizeLocal
, dwDataSizeGet
); /* Local: works as expected */
2508 checkStr( lpDataLocal
, lpDataGet
);
2510 dwDataSizeGet
= dwDataSizeFake
;
2511 strcpy(lpDataGet
, lpDataFake
);
2512 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
,
2513 DPGET_LOCAL
| DPGET_REMOTE
);
2514 checkHR( DP_OK
, hr
);
2515 check( dwDataSizeLocal
, dwDataSizeGet
); /* Like in previous test */
2516 checkStr( lpDataLocal
, lpDataGet
);
2518 /* Small buffer works as expected again */
2520 strcpy(lpDataGet
, lpDataFake
);
2521 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
,
2523 checkHR( DPERR_BUFFERTOOSMALL
, hr
);
2524 check( dwDataSizeLocal
, dwDataSizeGet
);
2525 checkStr( lpDataFake
, lpDataGet
);
2527 dwDataSizeGet
= dwDataSizeFake
;
2528 strcpy(lpDataGet
, lpDataFake
);
2529 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, NULL
,
2530 &dwDataSizeGet
, DPGET_LOCAL
);
2531 check( DPERR_BUFFERTOOSMALL
, hr
);
2532 check( dwDataSizeLocal
, dwDataSizeGet
);
2533 checkStr( lpDataFake
, lpDataGet
);
2537 * Changing remote data
2541 /* Remote data := local data */
2542 hr
= IDirectPlayX_SetPlayerData( pDP
, dpid
, (LPVOID
) lpDataLocal
,
2544 DPSET_GUARANTEED
| DPSET_REMOTE
);
2545 checkHR( DP_OK
, hr
);
2546 hr
= IDirectPlayX_SetPlayerData( pDP
, dpid
, (LPVOID
) lpDataLocal
,
2547 dwDataSizeLocal
, 0 );
2548 checkHR( DP_OK
, hr
);
2550 dwDataSizeGet
= dwDataSizeFake
;
2551 strcpy(lpDataGet
, lpDataFake
);
2552 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
, 0 );
2553 checkHR( DP_OK
, hr
);
2554 check( dwDataSizeLocal
, dwDataSizeGet
);
2555 checkStr( lpDataLocal
, lpDataGet
);
2557 /* Remote data := fake data */
2558 hr
= IDirectPlayX_SetPlayerData( pDP
, dpid
, (LPVOID
) lpDataFake
,
2559 dwDataSizeFake
, DPSET_REMOTE
);
2560 checkHR( DP_OK
, hr
);
2562 dwDataSizeGet
= dwDataSizeFake
+ 1;
2563 strcpy(lpDataGet
, lpData
);
2564 hr
= IDirectPlayX_GetPlayerData( pDP
, dpid
, lpDataGet
, &dwDataSizeGet
, 0 );
2565 checkHR( DP_OK
, hr
);
2566 check( dwDataSizeFake
, dwDataSizeGet
);
2567 checkStr( lpDataFake
, lpDataGet
);
2570 HeapFree( GetProcessHeap(), 0, lpDataGet
);
2571 IDirectPlayX_Release( pDP
);
2577 static void test_PlayerName(void)
2580 IDirectPlay4
*pDP
[2];
2581 DPSESSIONDESC2 dpsd
;
2587 DWORD dwDataSize
= 1024;
2588 LPVOID lpData
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, dwDataSize
);
2589 CallbackData callbackData
;
2594 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
2595 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
2596 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
2597 if (FAILED(hr
)) return;
2599 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
2600 ZeroMemory( &playerName
, sizeof(DPNAME
) );
2603 /* Service provider not initialized */
2604 hr
= IDirectPlayX_SetPlayerName( pDP
[0], 0, &playerName
, 0 );
2605 checkHR( DPERR_UNINITIALIZED
, hr
);
2608 hr
= IDirectPlayX_GetPlayerName( pDP
[0], 0, lpData
, &dwDataSize
);
2609 checkHR( DPERR_UNINITIALIZED
, hr
);
2610 check( 1024, dwDataSize
);
2613 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
2614 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
2617 /* Session not initialized */
2618 hr
= IDirectPlayX_SetPlayerName( pDP
[0], 0, &playerName
, 0 );
2619 todo_wine
checkHR( DPERR_INVALIDPLAYER
, hr
);
2621 if ( hr
== DPERR_UNINITIALIZED
)
2623 todo_wine
win_skip( "Get/SetPlayerName not implemented\n" );
2628 hr
= IDirectPlayX_GetPlayerName( pDP
[0], 0, lpData
, &dwDataSize
);
2629 checkHR( DPERR_INVALIDPLAYER
, hr
);
2630 check( 1024, dwDataSize
);
2633 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
2634 dpsd
.guidApplication
= appGuid
;
2635 dpsd
.dwMaxPlayers
= 10;
2636 IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
2637 IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
2640 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[0], NULL
, NULL
, NULL
, 0, 0 );
2641 IDirectPlayX_CreatePlayer( pDP
[1], &dpid
[1], NULL
, NULL
, NULL
, 0, 0 );
2644 /* Name not initialized */
2645 playerName
.dwSize
= -1;
2646 hr
= IDirectPlayX_SetPlayerName( pDP
[0], dpid
[0], &playerName
, 0 );
2647 checkHR( DP_OK
, hr
);
2650 hr
= IDirectPlayX_GetPlayerName( pDP
[0], 0, lpData
, &dwDataSize
);
2651 checkHR( DPERR_INVALIDPLAYER
, hr
);
2652 check( 1024, dwDataSize
);
2655 playerName
.dwSize
= sizeof(DPNAME
);
2656 U1(playerName
).lpszShortNameA
= (LPSTR
) "player_name";
2657 U2(playerName
).lpszLongNameA
= (LPSTR
) "player_long_name";
2660 /* Invalid parameters */
2661 hr
= IDirectPlayX_SetPlayerName( pDP
[0], -1, &playerName
, 0 );
2662 checkHR( DPERR_INVALIDPLAYER
, hr
);
2663 hr
= IDirectPlayX_SetPlayerName( pDP
[0], 0, &playerName
, 0 );
2664 checkHR( DPERR_INVALIDPLAYER
, hr
);
2665 hr
= IDirectPlayX_SetPlayerName( pDP
[0], dpid
[0], &playerName
, -1 );
2666 checkHR( DPERR_INVALIDPARAMS
, hr
);
2669 hr
= IDirectPlayX_GetPlayerName( pDP
[0], 0, lpData
, &dwDataSize
);
2670 checkHR( DPERR_INVALIDPLAYER
, hr
);
2671 check( 1024, dwDataSize
);
2675 /* Crashes under Win7 */
2677 hr
= IDirectPlayX_GetPlayerName( pDP
[0], dpid
[0], lpData
, &dwDataSize
);
2678 checkHR( DPERR_INVALIDPARAMS
, hr
);
2679 check( -1, dwDataSize
);
2682 hr
= IDirectPlayX_GetPlayerName( pDP
[0], dpid
[0], lpData
, NULL
);
2683 checkHR( DPERR_INVALIDPARAMS
, hr
);
2685 /* Trying to modify remote player */
2686 hr
= IDirectPlayX_SetPlayerName( pDP
[0], dpid
[1], &playerName
, 0 );
2687 checkHR( DPERR_ACCESSDENIED
, hr
);
2690 /* Regular operation */
2691 hr
= IDirectPlayX_SetPlayerName( pDP
[0], dpid
[0], &playerName
, 0 );
2692 checkHR( DP_OK
, hr
);
2694 hr
= IDirectPlayX_GetPlayerName( pDP
[0], dpid
[0], lpData
, &dwDataSize
);
2695 checkHR( DP_OK
, hr
);
2696 check( 45, dwDataSize
);
2697 checkStr( U1(playerName
).lpszShortNameA
, U1(*(LPDPNAME
)lpData
).lpszShortNameA
);
2698 checkStr( U2(playerName
).lpszLongNameA
, U2(*(LPDPNAME
)lpData
).lpszLongNameA
);
2699 check( 0, ((LPDPNAME
)lpData
)->dwFlags
);
2701 hr
= IDirectPlayX_SetPlayerName( pDP
[0], dpid
[0], NULL
, 0 );
2702 checkHR( DP_OK
, hr
);
2704 hr
= IDirectPlayX_GetPlayerName( pDP
[0], dpid
[0], lpData
, &dwDataSize
);
2705 checkHR( DP_OK
, hr
);
2706 check( 16, dwDataSize
);
2707 checkLP( NULL
, U1(*(LPDPNAME
)lpData
).lpszShortNameA
);
2708 checkLP( NULL
, U2(*(LPDPNAME
)lpData
).lpszLongNameA
);
2709 check( 0, ((LPDPNAME
)lpData
)->dwFlags
);
2712 /* Small buffer in get operation */
2714 hr
= IDirectPlayX_GetPlayerName( pDP
[0], dpid
[0], NULL
, &dwDataSize
);
2715 checkHR( DPERR_BUFFERTOOSMALL
, hr
);
2716 check( 16, dwDataSize
);
2719 hr
= IDirectPlayX_GetPlayerName( pDP
[0], dpid
[0], lpData
, &dwDataSize
);
2720 checkHR( DPERR_BUFFERTOOSMALL
, hr
);
2721 check( 16, dwDataSize
);
2723 hr
= IDirectPlayX_GetPlayerName( pDP
[0], dpid
[0], lpData
, &dwDataSize
);
2724 checkHR( DP_OK
, hr
);
2725 check( 16, dwDataSize
);
2726 checkLP( NULL
, U1(*(LPDPNAME
)lpData
).lpszShortNameA
);
2727 checkLP( NULL
, U2(*(LPDPNAME
)lpData
).lpszLongNameA
);
2728 check( 0, ((LPDPNAME
)lpData
)->dwFlags
);
2732 hr
= IDirectPlayX_SetPlayerName( pDP
[0], dpid
[0], &playerName
,
2734 checkHR( DP_OK
, hr
);
2736 hr
= IDirectPlayX_GetPlayerName( pDP
[0], dpid
[0], lpData
, &dwDataSize
);
2737 checkHR( DP_OK
, hr
);
2738 check( 45, dwDataSize
);
2739 checkStr( U1(playerName
).lpszShortNameA
, U1(*(LPDPNAME
)lpData
).lpszShortNameA
);
2740 checkStr( U2(playerName
).lpszLongNameA
, U2(*(LPDPNAME
)lpData
).lpszLongNameA
);
2741 check( 0, ((LPDPNAME
)lpData
)->dwFlags
);
2743 /* - Local (no propagation) */
2744 U1(playerName
).lpszShortNameA
= (LPSTR
) "no_propagation";
2745 hr
= IDirectPlayX_SetPlayerName( pDP
[0], dpid
[0], &playerName
,
2747 checkHR( DP_OK
, hr
);
2750 hr
= IDirectPlayX_GetPlayerName( pDP
[0], dpid
[0],
2751 lpData
, &dwDataSize
); /* Local fetch */
2752 checkHR( DP_OK
, hr
);
2753 check( 48, dwDataSize
);
2754 checkStr( "no_propagation", U1(*(LPDPNAME
)lpData
).lpszShortNameA
);
2757 hr
= IDirectPlayX_GetPlayerName( pDP
[1], dpid
[0],
2758 lpData
, &dwDataSize
); /* Remote fetch */
2759 checkHR( DP_OK
, hr
);
2760 check( 45, dwDataSize
);
2761 checkStr( "player_name", U1(*(LPDPNAME
)lpData
).lpszShortNameA
);
2765 U1(playerName
).lpszShortNameA
= (LPSTR
) "no_propagation_2";
2766 hr
= IDirectPlayX_SetPlayerName( pDP
[0], dpid
[0], &playerName
,
2767 DPSET_LOCAL
| DPSET_REMOTE
);
2768 checkHR( DP_OK
, hr
);
2771 hr
= IDirectPlayX_GetPlayerName( pDP
[0], dpid
[0],
2772 lpData
, &dwDataSize
); /* Local fetch */
2773 checkHR( DP_OK
, hr
);
2774 check( 50, dwDataSize
);
2775 checkStr( "no_propagation_2", U1(*(LPDPNAME
)lpData
).lpszShortNameA
);
2778 hr
= IDirectPlayX_GetPlayerName( pDP
[1], dpid
[0],
2779 lpData
, &dwDataSize
); /* Remote fetch */
2780 checkHR( DP_OK
, hr
);
2781 check( 45, dwDataSize
);
2782 checkStr( "player_name", U1(*(LPDPNAME
)lpData
).lpszShortNameA
);
2784 /* - Remote (propagation, default) */
2785 U1(playerName
).lpszShortNameA
= (LPSTR
) "propagation";
2786 hr
= IDirectPlayX_SetPlayerName( pDP
[0], dpid
[0], &playerName
,
2788 checkHR( DP_OK
, hr
);
2791 hr
= IDirectPlayX_GetPlayerName( pDP
[1], dpid
[0],
2792 lpData
, &dwDataSize
); /* Remote fetch */
2793 checkHR( DP_OK
, hr
);
2794 check( 45, dwDataSize
);
2795 checkStr( "propagation", U1(*(LPDPNAME
)lpData
).lpszShortNameA
);
2798 U1(playerName
).lpszShortNameA
= (LPSTR
) "propagation_2";
2799 hr
= IDirectPlayX_SetPlayerName( pDP
[0], dpid
[0], &playerName
,
2801 checkHR( DP_OK
, hr
);
2804 hr
= IDirectPlayX_GetPlayerName( pDP
[1], dpid
[0],
2805 lpData
, &dwDataSize
); /* Remote fetch */
2806 checkHR( DP_OK
, hr
);
2807 check( 47, dwDataSize
);
2808 checkStr( "propagation_2", U1(*(LPDPNAME
)lpData
).lpszShortNameA
);
2811 /* Checking system messages */
2812 check_messages( pDP
[0], dpid
, 2, &callbackData
);
2813 checkStr( "S0,S0,S0,S0,S0,S0,S0,", callbackData
.szTrace1
);
2814 checkStr( "48,28,57,28,57,57,59,", callbackData
.szTrace2
);
2815 check_messages( pDP
[1], dpid
, 2, &callbackData
);
2816 checkStr( "S1,S1,S1,S1,S1,S1,", callbackData
.szTrace1
);
2817 checkStr( "28,57,28,57,57,59,", callbackData
.szTrace2
);
2820 HeapFree( GetProcessHeap(), 0, lpData
);
2821 IDirectPlayX_Release( pDP
[0] );
2822 IDirectPlayX_Release( pDP
[1] );
2826 /* GetPlayerAccount */
2828 static BOOL CALLBACK
EnumSessions_cb_join_secure( LPCDPSESSIONDESC2 lpThisSD
,
2829 LPDWORD lpdwTimeOut
,
2833 IDirectPlay4
*pDP
= lpContext
;
2834 DPSESSIONDESC2 dpsd
;
2835 DPCREDENTIALS dpCredentials
;
2838 if (dwFlags
& DPESC_TIMEDOUT
)
2843 checkFlags( DPSESSION_SECURESERVER
, lpThisSD
->dwFlags
, FLAGS_DPSESSION
);
2845 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
2846 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
2847 dpsd
.guidApplication
= appGuid
;
2848 dpsd
.guidInstance
= lpThisSD
->guidInstance
;
2850 ZeroMemory( &dpCredentials
, sizeof(DPCREDENTIALS
) );
2851 dpCredentials
.dwSize
= sizeof(DPCREDENTIALS
);
2852 U1(dpCredentials
).lpszUsernameA
= (LPSTR
) "user";
2853 U2(dpCredentials
).lpszPasswordA
= (LPSTR
) "pass";
2854 hr
= IDirectPlayX_SecureOpen( pDP
, &dpsd
, DPOPEN_JOIN
,
2855 NULL
, &dpCredentials
);
2856 checkHR( DPERR_LOGONDENIED
, hr
); /* TODO: Make this work */
2861 static void test_GetPlayerAccount(void)
2864 IDirectPlay4
*pDP
[2];
2865 DPSESSIONDESC2 dpsd
;
2870 DWORD dwDataSize
= 1024;
2871 LPVOID lpData
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, dwDataSize
);
2876 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
2877 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
2878 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
2879 if (FAILED(hr
)) return;
2881 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
2882 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
2883 dpsd
.guidApplication
= appGuid
;
2884 dpsd
.dwMaxPlayers
= 10;
2886 /* Uninitialized service provider */
2887 hr
= IDirectPlayX_GetPlayerAccount( pDP
[0], 0, 0, lpData
, &dwDataSize
);
2888 todo_wine
checkHR( DPERR_UNINITIALIZED
, hr
);
2892 todo_wine
win_skip( "GetPlayerAccount not implemented\n" );
2897 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
2898 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
2902 hr
= IDirectPlayX_GetPlayerAccount( pDP
[0], 0, 0, lpData
, &dwDataSize
);
2903 checkHR( DPERR_NOSESSIONS
, hr
);
2906 IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
2907 IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
2912 hr
= IDirectPlayX_CreatePlayer( pDP
[i
], &dpid
[i
], NULL
, NULL
, NULL
,
2914 checkHR( DP_OK
, hr
);
2918 /* Session is not secure */
2920 hr
= IDirectPlayX_GetPlayerAccount( pDP
[0], dpid
[0], 0,
2921 lpData
, &dwDataSize
);
2922 checkHR( DPERR_UNSUPPORTED
, hr
);
2923 check( 1024, dwDataSize
);
2926 /* Open a secure session */
2929 hr
= IDirectPlayX_Close( pDP
[i
] );
2930 checkHR( DP_OK
, hr
);
2933 dpsd
.dwFlags
= DPSESSION_SECURESERVER
;
2934 hr
= IDirectPlayX_SecureOpen( pDP
[0], &dpsd
, DPOPEN_CREATE
, NULL
, NULL
);
2935 checkHR( DP_OK
, hr
);
2937 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[0],
2938 NULL
, NULL
, NULL
, 0, 0 );
2939 checkHR( DP_OK
, hr
);
2941 hr
= IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0,
2942 EnumSessions_cb_join_secure
, pDP
[1], 0 );
2943 checkHR( DP_OK
, hr
);
2945 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &dpid
[1],
2946 NULL
, NULL
, NULL
, 0, 0 );
2947 checkHR( DPERR_INVALIDPARAMS
, hr
);
2949 /* TODO: Player creation so that this works */
2951 /* Invalid player */
2953 hr
= IDirectPlayX_GetPlayerAccount( pDP
[0], 0, 0,
2954 lpData
, &dwDataSize
);
2955 checkHR( DPERR_INVALIDPLAYER
, hr
);
2956 check( 1024, dwDataSize
);
2960 hr
= IDirectPlayX_GetPlayerAccount( pDP
[0], dpid
[0], -1,
2961 lpData
, &dwDataSize
);
2962 checkHR( DPERR_INVALIDFLAGS
, hr
);
2963 check( 1024, dwDataSize
);
2966 hr
= IDirectPlayX_GetPlayerAccount( pDP
[0], dpid
[0], 1,
2967 lpData
, &dwDataSize
);
2968 checkHR( DPERR_INVALIDFLAGS
, hr
);
2969 check( 1024, dwDataSize
);
2973 hr
= IDirectPlayX_GetPlayerAccount( pDP
[0], dpid
[0], 0,
2974 NULL
, &dwDataSize
);
2975 checkHR( DPERR_INVALIDPLAYER
, hr
);
2976 check( 0, dwDataSize
);
2979 hr
= IDirectPlayX_GetPlayerAccount( pDP
[0], dpid
[0], 0,
2980 lpData
, &dwDataSize
);
2981 checkHR( DPERR_INVALIDPLAYER
, hr
);
2982 check( 0, dwDataSize
);
2984 hr
= IDirectPlayX_GetPlayerAccount( pDP
[0], dpid
[0], 0,
2985 lpData
, &dwDataSize
);
2986 checkHR( DPERR_INVALIDPLAYER
, hr
);
2987 check( 0, dwDataSize
);
2989 /* Normal operation */
2991 hr
= IDirectPlayX_GetPlayerAccount( pDP
[0], dpid
[0], 0,
2992 lpData
, &dwDataSize
);
2993 checkHR( DPERR_INVALIDPLAYER
, hr
);
2994 check( 1024, dwDataSize
);
2997 HeapFree( GetProcessHeap(), 0, lpData
);
2998 IDirectPlayX_Release( pDP
[0] );
2999 IDirectPlayX_Release( pDP
[1] );
3003 /* GetPlayerAddress */
3005 static BOOL CALLBACK
EnumAddress_cb( REFGUID guidDataType
,
3010 lpCallbackData callbackData
= lpContext
;
3011 static REFGUID types
[] = { &DPAID_TotalSize
,
3012 &DPAID_ServiceProvider
,
3015 static DWORD sizes
[] = { 4, 16, 12, 24, 4, 16, 10, 20 };
3018 checkGuid( types
[callbackData
->dwCounter1
%4], guidDataType
);
3019 check( sizes
[callbackData
->dwCounter1
], dwDataSize
);
3021 switch(callbackData
->dwCounter1
)
3024 check( 136, *(LPDWORD
) lpData
);
3027 check( 130, *(LPDWORD
) lpData
);
3031 checkGuid( &DPSPGUID_TCPIP
, lpData
);
3034 checkStr( "127.0.0.1", (LPSTR
) lpData
);
3040 callbackData
->dwCounter1
++;
3045 static void test_GetPlayerAddress(void)
3048 IDirectPlay4
*pDP
[2];
3049 IDirectPlayLobby3
*pDPL
;
3050 DPSESSIONDESC2 dpsd
;
3052 CallbackData callbackData
;
3056 DWORD dwDataSize
= 1024;
3057 LPVOID lpData
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, dwDataSize
);
3062 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
3063 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
3064 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
3065 if (FAILED(hr
)) return;
3067 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
3068 hr
= CoCreateInstance( &CLSID_DirectPlayLobby
, NULL
, CLSCTX_ALL
,
3069 &IID_IDirectPlayLobby3A
, (LPVOID
*) &pDPL
);
3070 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlayLobby / IID_IDirectPlayLobby3A failed\n" );
3071 if (FAILED(hr
)) return;
3073 /* Uninitialized service provider */
3074 hr
= IDirectPlayX_GetPlayerAddress( pDP
[0], 0, lpData
, &dwDataSize
);
3075 todo_wine
checkHR( DPERR_UNINITIALIZED
, hr
);
3079 todo_wine
win_skip( "GetPlayerAddress not implemented\n" );
3083 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
3084 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
3089 hr
= IDirectPlayX_GetPlayerAddress( pDP
[0], 0, lpData
, &dwDataSize
);
3090 checkHR( DPERR_UNSUPPORTED
, hr
);
3091 check( 1024, dwDataSize
);
3094 hr
= IDirectPlayX_GetPlayerAddress( pDP
[0], 1, lpData
, &dwDataSize
);
3095 checkHR( DPERR_INVALIDPLAYER
, hr
);
3096 check( 1024, dwDataSize
);
3099 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
3100 dpsd
.guidApplication
= appGuid
;
3101 dpsd
.dwMaxPlayers
= 10;
3102 IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
3103 IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
3108 hr
= IDirectPlayX_CreatePlayer( pDP
[i
], &dpid
[i
], NULL
, NULL
, NULL
,
3110 checkHR( DP_OK
, hr
);
3113 /* Invalid player */
3115 hr
= IDirectPlayX_GetPlayerAddress( pDP
[0], 0,
3116 lpData
, &dwDataSize
);
3117 checkHR( DPERR_UNSUPPORTED
, hr
);
3118 check( 1024, dwDataSize
);
3121 hr
= IDirectPlayX_GetPlayerAddress( pDP
[0], 1,
3122 lpData
, &dwDataSize
);
3123 checkHR( DPERR_INVALIDPLAYER
, hr
);
3124 check( 1024, dwDataSize
);
3128 hr
= IDirectPlayX_GetPlayerAddress( pDP
[0], dpid
[0],
3129 NULL
, &dwDataSize
);
3130 checkHR( DPERR_BUFFERTOOSMALL
, hr
);
3131 check( 136, dwDataSize
);
3134 hr
= IDirectPlayX_GetPlayerAddress( pDP
[0], dpid
[0],
3135 lpData
, &dwDataSize
);
3136 checkHR( DPERR_BUFFERTOOSMALL
, hr
);
3137 check( 136, dwDataSize
);
3139 hr
= IDirectPlayX_GetPlayerAddress( pDP
[0], dpid
[0],
3140 lpData
, &dwDataSize
);
3141 checkHR( DP_OK
, hr
);
3142 check( 136, dwDataSize
);
3145 /* Regular parameters */
3146 callbackData
.dwCounter1
= 0;
3150 hr
= IDirectPlayX_GetPlayerAddress( pDP
[0], dpid
[0],
3151 lpData
, &dwDataSize
);
3152 checkHR( DP_OK
, hr
);
3153 check( 136, dwDataSize
);
3155 hr
= IDirectPlayLobby_EnumAddress( pDPL
, EnumAddress_cb
, lpData
, dwDataSize
,
3157 checkHR( DP_OK
, hr
);
3159 check( 4, callbackData
.dwCounter1
);
3163 hr
= IDirectPlayX_GetPlayerAddress( pDP
[0], dpid
[1],
3164 lpData
, &dwDataSize
);
3165 checkHR( DP_OK
, hr
);
3166 check( 130, dwDataSize
);
3168 hr
= IDirectPlayLobby_EnumAddress( pDPL
, EnumAddress_cb
, lpData
, dwDataSize
,
3170 checkHR( DP_OK
, hr
);
3172 check( 8, callbackData
.dwCounter1
);
3175 HeapFree( GetProcessHeap(), 0, lpData
);
3178 IDirectPlayX_Release( pDP
[0] );
3179 IDirectPlayX_Release( pDP
[1] );
3180 IDirectPlayLobby_Release(pDPL
);
3183 /* GetPlayerFlags */
3185 static void test_GetPlayerFlags(void)
3188 IDirectPlay4
*pDP
[2];
3189 DPSESSIONDESC2 dpsd
;
3199 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
3200 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
3201 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
3202 if (FAILED(hr
)) return;
3204 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
3205 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
3206 dpsd
.guidApplication
= appGuid
;
3207 dpsd
.dwMaxPlayers
= 10;
3209 /* Uninitialized service provider */
3210 hr
= IDirectPlayX_GetPlayerFlags( pDP
[0], 0, &dwFlags
);
3211 todo_wine
checkHR( DPERR_UNINITIALIZED
, hr
);
3215 todo_wine
win_skip( "GetPlayerFlags not implemented\n" );
3219 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
3220 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
3224 hr
= IDirectPlayX_GetPlayerFlags( pDP
[0], 0, &dwFlags
);
3225 checkHR( DPERR_INVALIDPLAYER
, hr
);
3227 hr
= IDirectPlayX_GetPlayerFlags( pDP
[0], 1, &dwFlags
);
3228 checkHR( DPERR_INVALIDPLAYER
, hr
);
3231 IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
3232 IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
3237 hr
= IDirectPlayX_CreatePlayer( pDP
[i
], &dpid
[i
],
3238 NULL
, NULL
, NULL
, 0, 0 );
3239 checkHR( DP_OK
, hr
);
3241 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[2],
3243 0, DPPLAYER_SPECTATOR
);
3244 checkHR( DP_OK
, hr
);
3245 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[3],
3247 0, DPPLAYER_SERVERPLAYER
);
3248 checkHR( DP_OK
, hr
);
3251 /* Invalid player */
3252 hr
= IDirectPlayX_GetPlayerFlags( pDP
[0], 0, &dwFlags
);
3253 checkHR( DPERR_INVALIDPLAYER
, hr
);
3255 hr
= IDirectPlayX_GetPlayerFlags( pDP
[0], 2, &dwFlags
);
3256 checkHR( DPERR_INVALIDPLAYER
, hr
);
3258 /* Invalid parameters */
3259 hr
= IDirectPlayX_GetPlayerFlags( pDP
[0], dpid
[0], NULL
);
3260 checkHR( DPERR_INVALIDPARAMS
, hr
);
3263 /* Regular parameters */
3264 hr
= IDirectPlayX_GetPlayerFlags( pDP
[0], dpid
[0], &dwFlags
);
3265 checkHR( DP_OK
, hr
);
3266 checkFlags( dwFlags
, DPPLAYER_LOCAL
, FLAGS_DPPLAYER
);
3268 hr
= IDirectPlayX_GetPlayerFlags( pDP
[1], dpid
[1], &dwFlags
);
3269 checkHR( DP_OK
, hr
);
3270 checkFlags( dwFlags
, DPPLAYER_LOCAL
, FLAGS_DPPLAYER
);
3272 hr
= IDirectPlayX_GetPlayerFlags( pDP
[0], dpid
[1], &dwFlags
);
3273 checkHR( DP_OK
, hr
);
3274 checkFlags( dwFlags
, 0, FLAGS_DPPLAYER
);
3276 hr
= IDirectPlayX_GetPlayerFlags( pDP
[0], dpid
[2], &dwFlags
);
3277 checkHR( DP_OK
, hr
);
3278 checkFlags( dwFlags
, DPPLAYER_SPECTATOR
| DPPLAYER_LOCAL
, FLAGS_DPPLAYER
);
3280 hr
= IDirectPlayX_GetPlayerFlags( pDP
[1], dpid
[3], &dwFlags
);
3281 checkHR( DP_OK
, hr
);
3282 checkFlags( dwFlags
, DPPLAYER_SERVERPLAYER
, FLAGS_DPPLAYER
);
3285 IDirectPlayX_Release( pDP
[0] );
3286 IDirectPlayX_Release( pDP
[1] );
3291 CreateGroupInGroup */
3293 static void test_CreateGroup(void)
3297 DPSESSIONDESC2 dpsd
;
3298 DPID idFrom
, idTo
, dpid
, idGroup
, idGroupParent
;
3303 LPCSTR lpData
= "data";
3304 DWORD dwDataSize
= strlen(lpData
)+1;
3305 LPDPMSG_CREATEPLAYERORGROUP lpDataGet
= HeapAlloc( GetProcessHeap(),
3308 DWORD dwDataSizeGet
= 1024;
3309 CallbackData callbackData
;
3312 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
3313 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
);
3314 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
3315 if (FAILED(hr
)) return;
3316 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
3317 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
3318 dpsd
.guidApplication
= appGuid
;
3319 dpsd
.dwMaxPlayers
= 10;
3320 ZeroMemory( &groupName
, sizeof(DPNAME
) );
3323 /* No service provider */
3324 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
, NULL
, NULL
, 0, 0 );
3325 checkHR( DPERR_UNINITIALIZED
, hr
);
3327 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, 0, &idGroup
, NULL
, NULL
, 0, 0 );
3328 checkHR( DPERR_UNINITIALIZED
, hr
);
3332 init_TCPIP_provider( pDP
, "127.0.0.1", 0 );
3336 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3338 todo_wine
checkHR( DPERR_INVALIDPARAMS
, hr
);
3340 if ( hr
== DPERR_UNINITIALIZED
)
3342 todo_wine
win_skip( "CreateGroup not implemented\n" );
3346 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, 0, &idGroup
,
3348 checkHR( DPERR_INVALIDGROUP
, hr
);
3350 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, 2, &idGroup
,
3352 checkHR( DPERR_INVALIDGROUP
, hr
);
3355 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_CREATE
);
3356 checkHR( DP_OK
, hr
);
3357 IDirectPlayX_CreatePlayer( pDP
, &dpid
,
3358 NULL
, NULL
, NULL
, 0, 0 );
3363 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3365 checkHR( DP_OK
, hr
);
3367 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, idGroup
, &idGroup
,
3369 checkHR( DP_OK
, hr
);
3371 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3372 &groupName
, NULL
, 0, 0 );
3373 checkHR( DP_OK
, hr
);
3375 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, idGroup
, &idGroup
,
3376 &groupName
, NULL
, 0, 0 );
3377 checkHR( DP_OK
, hr
);
3380 groupName
.dwSize
= sizeof(DPNAME
);
3381 U1(groupName
).lpszShortNameA
= (LPSTR
) lpData
;
3384 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3385 &groupName
, NULL
, 0, 0 );
3386 checkHR( DP_OK
, hr
);
3388 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, idGroup
, &idGroup
,
3389 &groupName
, NULL
, 0, 0 );
3390 checkHR( DP_OK
, hr
);
3393 /* Message checking */
3396 dwDataSizeGet
= 1024;
3397 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0, lpDataGet
,
3399 checkHR( DP_OK
, hr
);
3400 if ( NULL
== U1(lpDataGet
->dpnName
).lpszShortNameA
)
3402 check( 48, dwDataSizeGet
);
3406 check( 48 + dwDataSize
, dwDataSizeGet
);
3407 checkStr( lpData
, U1(lpDataGet
->dpnName
).lpszShortNameA
);
3409 check( DPID_SYSMSG
, idFrom
);
3410 checkConv( DPSYS_CREATEPLAYERORGROUP
, lpDataGet
->dwType
, dpMsgType2str
);
3411 check( DPPLAYERTYPE_GROUP
, lpDataGet
->dwPlayerType
);
3412 checkFlags( DPGROUP_LOCAL
, lpDataGet
->dwFlags
, FLAGS_DPGROUP
);
3414 check_messages( pDP
, &dpid
, 1, &callbackData
);
3415 checkStr( "", callbackData
.szTrace1
);
3419 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3420 NULL
, (LPVOID
) lpData
, -1, 0 );
3421 checkHR( DPERR_INVALIDPARAMS
, hr
);
3423 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3424 NULL
, (LPVOID
) lpData
, 0, 0 );
3425 checkHR( DP_OK
, hr
);
3427 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3428 NULL
, NULL
, dwDataSize
, 0 );
3429 checkHR( DPERR_INVALIDPARAMS
, hr
);
3431 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3432 NULL
, (LPVOID
) lpData
, dwDataSize
, 0 );
3433 checkHR( DP_OK
, hr
);
3436 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, idGroup
, &idGroup
,
3437 NULL
, (LPVOID
) lpData
, -1, 0 );
3438 checkHR( DPERR_INVALIDPARAMS
, hr
);
3440 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, idGroup
, &idGroup
,
3441 NULL
, (LPVOID
) lpData
, 0, 0 );
3442 checkHR( DP_OK
, hr
);
3444 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, idGroup
, &idGroup
,
3445 NULL
, NULL
, dwDataSize
, 0 );
3446 checkHR( DPERR_INVALIDPARAMS
, hr
);
3448 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, idGroup
, &idGroup
,
3449 NULL
, (LPVOID
)lpData
, dwDataSize
, 0 );
3450 checkHR( DP_OK
, hr
);
3453 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroupParent
,
3455 checkHR( DP_OK
, hr
);
3458 /* Message checking */
3461 dwDataSizeGet
= 1024;
3462 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0, lpDataGet
,
3464 checkHR( DP_OK
, hr
);
3465 check( 48 + lpDataGet
->dwDataSize
, dwDataSizeGet
);
3466 check( DPID_SYSMSG
, idFrom
);
3467 checkConv( DPSYS_CREATEPLAYERORGROUP
, lpDataGet
->dwType
, dpMsgType2str
);
3468 check( DPPLAYERTYPE_GROUP
, lpDataGet
->dwPlayerType
);
3469 checkFlags( DPGROUP_LOCAL
, lpDataGet
->dwFlags
, FLAGS_DPGROUP
);
3471 check_messages( pDP
, &dpid
, 1, &callbackData
);
3472 checkStr( "", callbackData
.szTrace1
);
3475 /* Flags and idGroupParent */
3476 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3478 checkHR( DP_OK
, hr
);
3480 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3481 NULL
, NULL
, 0, DPGROUP_HIDDEN
);
3482 checkHR( DP_OK
, hr
);
3484 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3485 NULL
, NULL
, 0, DPGROUP_STAGINGAREA
);
3486 checkHR( DP_OK
, hr
);
3488 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3490 DPGROUP_HIDDEN
| DPGROUP_STAGINGAREA
);
3491 checkHR( DP_OK
, hr
);
3494 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, idGroupParent
, &idGroup
,
3496 checkHR( DP_OK
, hr
);
3498 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, idGroupParent
, &idGroup
,
3499 NULL
, NULL
, 0, DPGROUP_HIDDEN
);
3500 checkHR( DP_OK
, hr
);
3502 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, idGroupParent
, &idGroup
,
3503 NULL
, NULL
, 0, DPGROUP_STAGINGAREA
);
3504 checkHR( DP_OK
, hr
);
3506 hr
= IDirectPlayX_CreateGroupInGroup( pDP
, idGroupParent
, &idGroup
,
3509 DPGROUP_STAGINGAREA
);
3510 checkHR( DP_OK
, hr
);
3513 /* Message checking */
3516 dwDataSizeGet
= 1024;
3517 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0, lpDataGet
,
3519 checkHR( DP_OK
, hr
);
3520 check( 48, dwDataSizeGet
);
3521 check( DPID_SYSMSG
, idFrom
);
3522 checkConv( DPSYS_CREATEPLAYERORGROUP
, lpDataGet
->dwType
, dpMsgType2str
);
3523 check( DPPLAYERTYPE_GROUP
, lpDataGet
->dwPlayerType
);
3525 if ( lpDataGet
->dpIdParent
!= 0 )
3527 check( idGroupParent
, lpDataGet
->dpIdParent
);
3533 checkFlags( DPGROUP_LOCAL
,
3534 lpDataGet
->dwFlags
, FLAGS_DPGROUP
);
3537 checkFlags( DPGROUP_LOCAL
| DPGROUP_HIDDEN
,
3538 lpDataGet
->dwFlags
, FLAGS_DPGROUP
);
3541 checkFlags( DPGROUP_STAGINGAREA
| DPGROUP_LOCAL
,
3542 lpDataGet
->dwFlags
, FLAGS_DPGROUP
);
3545 checkFlags( DPGROUP_STAGINGAREA
| DPGROUP_LOCAL
| DPGROUP_HIDDEN
,
3546 lpDataGet
->dwFlags
, FLAGS_DPGROUP
);
3551 check_messages( pDP
, &dpid
, 1, &callbackData
);
3552 checkStr( "", callbackData
.szTrace1
);
3555 /* If a group is created in C/S mode, no messages are sent */
3558 IDirectPlayX_Close( pDP
);
3561 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_CREATE
);
3562 checkHR( DP_OK
, hr
);
3563 hr
= IDirectPlayX_CreatePlayer( pDP
, &dpid
, NULL
, NULL
, NULL
, 0, 0 );
3564 checkHR( DP_OK
, hr
);
3566 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
, NULL
, NULL
, 0, 0 );
3567 checkHR( DP_OK
, hr
);
3569 /* Messages are received */
3570 check_messages( pDP
, &dpid
, 1, &callbackData
);
3571 checkStr( "S0,", callbackData
.szTrace1
);
3574 /* - Client/Server */
3575 IDirectPlayX_Close( pDP
);
3577 dpsd
.dwFlags
= DPSESSION_CLIENTSERVER
;
3578 hr
= IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_CREATE
);
3579 checkHR( DP_OK
, hr
);
3580 hr
= IDirectPlayX_CreatePlayer( pDP
, &dpid
,
3581 NULL
, NULL
, NULL
, 0,
3582 DPPLAYER_SERVERPLAYER
);
3583 checkHR( DP_OK
, hr
);
3585 hr
= IDirectPlayX_CreateGroup( pDP
, &idGroup
,
3587 checkHR( DP_OK
, hr
);
3590 check_messages( pDP
, &dpid
, 1, &callbackData
);
3591 checkStr( "S0,", callbackData
.szTrace1
); /* Or at least there
3592 shouldn't be messages... */
3595 HeapFree( GetProcessHeap(), 0, lpDataGet
);
3596 IDirectPlayX_Release( pDP
);
3602 static void test_GroupOwner(void)
3605 IDirectPlay4
*pDP
[2];
3606 DPSESSIONDESC2 dpsd
;
3607 DPID dpid
[2], idGroup
, idOwner
;
3614 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
3615 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
3616 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
3617 if (FAILED(hr
)) return;
3619 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
3620 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
3621 dpsd
.guidApplication
= appGuid
;
3622 dpsd
.dwMaxPlayers
= 10;
3626 /* Service provider not initialized */
3627 hr
= IDirectPlayX_GetGroupOwner( pDP
[0], idGroup
, &idOwner
);
3628 todo_wine
checkHR( DPERR_UNINITIALIZED
, hr
);
3629 check( 0, idOwner
);
3633 todo_wine
win_skip( "GetGroupOwner not implemented\n" );
3639 init_TCPIP_provider( pDP
[i
], "127.0.0.1", 0 );
3641 hr
= IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
3642 checkHR( DP_OK
, hr
);
3643 hr
= IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
3645 checkHR( DP_OK
, hr
);
3649 hr
= IDirectPlayX_CreatePlayer( pDP
[i
], &dpid
[i
],
3650 NULL
, NULL
, NULL
, 0, 0 );
3651 checkHR( DP_OK
, hr
);
3655 hr
= IDirectPlayX_GetGroupOwner( pDP
[0], idGroup
, &idOwner
);
3656 checkHR( DPERR_INVALIDGROUP
, hr
);
3658 hr
= IDirectPlayX_CreateGroup( pDP
[0], &idGroup
, NULL
, NULL
, 0, 0 );
3659 checkHR( DP_OK
, hr
);
3661 /* Fails, because we need a lobby session */
3662 hr
= IDirectPlayX_GetGroupOwner( pDP
[0], idGroup
, &idOwner
);
3663 checkHR( DPERR_UNSUPPORTED
, hr
);
3668 * - Check migration of the ownership of a group
3669 * when the owner leaves
3673 IDirectPlayX_Release( pDP
[0] );
3674 IDirectPlayX_Release( pDP
[1] );
3680 static BOOL CALLBACK
EnumPlayers_cb( DPID dpId
,
3686 lpCallbackData callbackData
= lpContext
;
3687 char playerIndex
= dpid2char( callbackData
->dpid
,
3688 callbackData
->dpidSize
,
3692 /* Trace to study player ids */
3693 callbackData
->szTrace1
[ callbackData
->dwCounter1
] = playerIndex
;
3694 callbackData
->dwCounter1
++;
3695 callbackData
->szTrace1
[ callbackData
->dwCounter1
] = '\0';
3697 /* Trace to study flags received */
3698 strcat( callbackData
->szTrace2
,
3699 ( dwFlags2str(dwFlags
, FLAGS_DPENUMPLAYERS
) +
3700 strlen("DPENUMPLAYERS_") ) );
3701 strcat( callbackData
->szTrace2
, ":" );
3704 if ( playerIndex
< '5' )
3706 check( DPPLAYERTYPE_PLAYER
, dwPlayerType
);
3710 check( DPPLAYERTYPE_GROUP
, dwPlayerType
);
3717 static BOOL CALLBACK
EnumSessions_cb_EnumPlayers( LPCDPSESSIONDESC2 lpThisSD
,
3718 LPDWORD lpdwTimeOut
,
3722 lpCallbackData callbackData
= lpContext
;
3725 if (dwFlags
& DPESC_TIMEDOUT
)
3731 callbackData
->dwCounter1
= 0;
3732 hr
= IDirectPlayX_EnumPlayers( callbackData
->pDP
, NULL
, EnumPlayers_cb
,
3734 checkHR( DPERR_NOSESSIONS
, hr
);
3735 check( 0, callbackData
->dwCounter1
);
3737 /* guid = appGuid */
3738 callbackData
->dwCounter1
= 0;
3739 hr
= IDirectPlayX_EnumPlayers( callbackData
->pDP
, (LPGUID
) &appGuid
,
3740 EnumPlayers_cb
, &callbackData
, 0 );
3741 checkHR( DPERR_NOSESSIONS
, hr
);
3742 check( 0, callbackData
->dwCounter1
);
3744 callbackData
->dwCounter1
= 0;
3745 hr
= IDirectPlayX_EnumPlayers( callbackData
->pDP
, (LPGUID
) &appGuid
,
3746 EnumPlayers_cb
, &callbackData
,
3747 DPENUMPLAYERS_SESSION
);
3748 checkHR( DPERR_NOSESSIONS
, hr
);
3749 check( 0, callbackData
->dwCounter1
);
3751 /* guid = guidInstance */
3752 callbackData
->dwCounter1
= 0;
3753 hr
= IDirectPlayX_EnumPlayers( callbackData
->pDP
,
3754 (LPGUID
) &lpThisSD
->guidInstance
,
3755 EnumPlayers_cb
, &callbackData
, 0 );
3756 checkHR( DPERR_NOSESSIONS
, hr
);
3757 check( 0, callbackData
->dwCounter1
);
3759 callbackData
->dwCounter1
= 0;
3760 hr
= IDirectPlayX_EnumPlayers( callbackData
->pDP
,
3761 (LPGUID
) &lpThisSD
->guidInstance
,
3762 EnumPlayers_cb
, &callbackData
,
3763 DPENUMPLAYERS_SESSION
);
3764 checkHR( DPERR_GENERIC
, hr
); /* Why? */
3765 check( 0, callbackData
->dwCounter1
);
3771 static void test_EnumPlayers(void)
3773 IDirectPlay4
*pDP
[3];
3774 DPSESSIONDESC2 dpsd
[3];
3775 DPID dpid
[5+2]; /* 5 players, 2 groups */
3776 CallbackData callbackData
;
3783 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
3784 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
3785 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
3786 if (FAILED(hr
)) return;
3788 ZeroMemory( &dpsd
[i
], sizeof(DPSESSIONDESC2
) );
3789 dpsd
[i
].dwSize
= sizeof(DPSESSIONDESC2
);
3792 dpsd
[0].guidApplication
= appGuid
;
3793 dpsd
[1].guidApplication
= appGuid2
;
3794 dpsd
[2].guidApplication
= GUID_NULL
;
3796 callbackData
.dpid
= dpid
;
3797 callbackData
.dpidSize
= 5+2;
3800 /* Uninitialized service provider */
3801 callbackData
.dwCounter1
= 0;
3802 hr
= IDirectPlayX_EnumPlayers( pDP
[0], (LPGUID
) &appGuid
, NULL
,
3804 checkHR( DPERR_UNINITIALIZED
, hr
);
3805 check( 0, callbackData
.dwCounter1
);
3808 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
3809 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
3810 init_TCPIP_provider( pDP
[2], "127.0.0.1", 0 );
3814 callbackData
.dwCounter1
= 0;
3815 hr
= IDirectPlayX_EnumPlayers( pDP
[0], NULL
, EnumPlayers_cb
,
3817 todo_wine
checkHR( DPERR_NOSESSIONS
, hr
);
3818 check( 0, callbackData
.dwCounter1
);
3820 if ( hr
== DPERR_UNINITIALIZED
)
3822 todo_wine
win_skip( "EnumPlayers not implemented\n" );
3826 callbackData
.dwCounter1
= 0;
3827 hr
= IDirectPlayX_EnumPlayers( pDP
[0], (LPGUID
) &appGuid
, EnumPlayers_cb
,
3829 checkHR( DPERR_NOSESSIONS
, hr
);
3830 check( 0, callbackData
.dwCounter1
);
3832 callbackData
.dwCounter1
= 0;
3833 hr
= IDirectPlayX_EnumPlayers( pDP
[0], (LPGUID
) &appGuid
, EnumPlayers_cb
,
3834 &callbackData
, DPENUMPLAYERS_SESSION
);
3835 checkHR( DPERR_NOSESSIONS
, hr
);
3836 check( 0, callbackData
.dwCounter1
);
3839 hr
= IDirectPlayX_Open( pDP
[0], &dpsd
[0], DPOPEN_CREATE
);
3840 checkHR( DP_OK
, hr
);
3841 hr
= IDirectPlayX_Open( pDP
[1], &dpsd
[1], DPOPEN_CREATE
);
3842 checkHR( DP_OK
, hr
);
3846 callbackData
.dwCounter1
= 0;
3847 hr
= IDirectPlayX_EnumPlayers( pDP
[0], NULL
, EnumPlayers_cb
,
3849 checkHR( DP_OK
, hr
);
3850 check( 0, callbackData
.dwCounter1
);
3853 /* Create players */
3854 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[0],
3855 NULL
, NULL
, NULL
, 0,
3856 DPPLAYER_SERVERPLAYER
);
3857 checkHR( DP_OK
, hr
);
3858 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &dpid
[1],
3859 NULL
, NULL
, NULL
, 0,
3861 checkHR( DP_OK
, hr
);
3863 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[2],
3864 NULL
, NULL
, NULL
, 0,
3866 checkHR( DP_OK
, hr
);
3867 hr
= IDirectPlayX_CreateGroup( pDP
[0], &dpid
[5],
3869 checkHR( DP_OK
, hr
);
3872 /* Invalid parameters */
3873 callbackData
.dwCounter1
= 0;
3874 hr
= IDirectPlayX_EnumPlayers( pDP
[0], (LPGUID
) &appGuid
, NULL
,
3876 checkHR( DPERR_INVALIDPARAMS
, hr
);
3877 check( 0, callbackData
.dwCounter1
);
3879 callbackData
.dwCounter1
= 0;
3880 hr
= IDirectPlayX_EnumPlayers( pDP
[0], NULL
, EnumPlayers_cb
,
3881 &callbackData
, DPENUMPLAYERS_SESSION
);
3882 checkHR( DPERR_INVALIDPARAMS
, hr
);
3883 check( 0, callbackData
.dwCounter1
);
3886 /* Regular operation */
3887 callbackData
.dwCounter1
= 0;
3888 callbackData
.szTrace2
[0] = 0;
3889 hr
= IDirectPlayX_EnumPlayers( pDP
[0], NULL
, EnumPlayers_cb
,
3891 checkHR( DP_OK
, hr
);
3892 check( 2, callbackData
.dwCounter1
);
3893 checkStr( "20", callbackData
.szTrace1
);
3894 checkStr( "ALL:SERVERPLAYER:", callbackData
.szTrace2
);
3896 callbackData
.dwCounter1
= 0;
3897 callbackData
.szTrace2
[0] = 0;
3898 hr
= IDirectPlayX_EnumPlayers( pDP
[1], NULL
, EnumPlayers_cb
,
3900 checkHR( DP_OK
, hr
);
3901 check( 1, callbackData
.dwCounter1
);
3902 checkStr( "1", callbackData
.szTrace1
);
3903 checkStr( "ALL:", callbackData
.szTrace2
);
3905 callbackData
.dwCounter1
= 0;
3906 callbackData
.szTrace2
[0] = 0;
3907 hr
= IDirectPlayX_EnumPlayers( pDP
[0], (LPGUID
) &appGuid
, EnumPlayers_cb
,
3909 checkHR( DP_OK
, hr
);
3910 check( 2, callbackData
.dwCounter1
); /* Guid is ignored */
3911 checkStr( "20", callbackData
.szTrace1
);
3912 checkStr( "ALL:SERVERPLAYER:", callbackData
.szTrace2
);
3915 /* Enumerating from a remote session */
3916 /* - Session not open */
3917 callbackData
.pDP
= pDP
[2];
3918 hr
= IDirectPlayX_EnumSessions( pDP
[2], &dpsd
[2], 0,
3919 EnumSessions_cb_EnumPlayers
,
3921 checkHR( DP_OK
, hr
);
3924 /* - Open session */
3925 callbackData
.pDP
= pDP
[2];
3926 hr
= IDirectPlayX_EnumSessions( pDP
[2], &dpsd
[0], 0, EnumSessions_cb_join
,
3928 checkHR( DP_OK
, hr
);
3929 hr
= IDirectPlayX_CreatePlayer( pDP
[2], &dpid
[3],
3930 NULL
, NULL
, NULL
, 0,
3931 DPPLAYER_SPECTATOR
);
3932 checkHR( DP_OK
, hr
);
3933 hr
= IDirectPlayX_CreatePlayer( pDP
[2], &dpid
[4],
3934 NULL
, NULL
, NULL
, 0,
3936 checkHR( DP_OK
, hr
);
3937 hr
= IDirectPlayX_CreateGroup( pDP
[2], &dpid
[6],
3939 checkHR( DP_OK
, hr
);
3941 callbackData
.dwCounter1
= 0;
3942 callbackData
.szTrace2
[0] = 0;
3943 hr
= IDirectPlayX_EnumPlayers( pDP
[2], NULL
, EnumPlayers_cb
,
3945 checkHR( DP_OK
, hr
);
3946 check( 4, callbackData
.dwCounter1
);
3947 checkStr( "4302", callbackData
.szTrace1
);
3948 checkStr( "ALL:SPECTATOR:SERVERPLAYER:ALL:", callbackData
.szTrace2
);
3953 callbackData
.dwCounter1
= 0;
3954 callbackData
.szTrace2
[0] = 0;
3955 hr
= IDirectPlayX_EnumPlayers( pDP
[2], NULL
, EnumPlayers_cb
,
3956 &callbackData
, DPENUMPLAYERS_ALL
);
3957 checkHR( DP_OK
, hr
);
3958 check( 4, callbackData
.dwCounter1
);
3959 checkStr( "4302", callbackData
.szTrace1
);
3960 checkStr( "ALL:SPECTATOR:SERVERPLAYER:ALL:", callbackData
.szTrace2
);
3962 callbackData
.dwCounter1
= 0;
3963 callbackData
.szTrace2
[0] = 0;
3964 hr
= IDirectPlayX_EnumPlayers( pDP
[2], NULL
, EnumPlayers_cb
,
3965 &callbackData
, DPENUMPLAYERS_GROUP
);
3966 checkHR( DP_OK
, hr
);
3967 check( 6, callbackData
.dwCounter1
);
3968 checkStr( "430256", callbackData
.szTrace1
);
3970 "GROUP,DPENUMPLAYERS_SPECTATOR:"
3971 "GROUP,DPENUMPLAYERS_SERVERPLAYER:"
3972 "GROUP:ALL:ALL:", callbackData
.szTrace2
);
3974 callbackData
.dwCounter1
= 0;
3975 callbackData
.szTrace2
[0] = 0;
3976 hr
= IDirectPlayX_EnumPlayers( pDP
[2], NULL
, EnumPlayers_cb
,
3977 &callbackData
, DPENUMPLAYERS_LOCAL
);
3978 checkHR( DP_OK
, hr
);
3979 check( 2, callbackData
.dwCounter1
);
3980 checkStr( "43", callbackData
.szTrace1
);
3982 "LOCAL,DPENUMPLAYERS_SPECTATOR:", callbackData
.szTrace2
);
3984 callbackData
.dwCounter1
= 0;
3985 callbackData
.szTrace2
[0] = 0;
3986 hr
= IDirectPlayX_EnumPlayers( pDP
[2], NULL
, EnumPlayers_cb
,
3987 &callbackData
, DPENUMPLAYERS_SERVERPLAYER
);
3988 checkHR( DP_OK
, hr
);
3989 check( 1, callbackData
.dwCounter1
);
3990 checkStr( "0", callbackData
.szTrace1
);
3991 checkStr( "SERVERPLAYER:", callbackData
.szTrace2
);
3993 callbackData
.dwCounter1
= 0;
3994 callbackData
.szTrace2
[0] = 0;
3995 hr
= IDirectPlayX_EnumPlayers( pDP
[2], NULL
, EnumPlayers_cb
,
3996 &callbackData
, DPENUMPLAYERS_SPECTATOR
);
3997 checkHR( DP_OK
, hr
);
3998 check( 1, callbackData
.dwCounter1
);
3999 checkStr( "3", callbackData
.szTrace1
);
4000 checkStr( "SPECTATOR:", callbackData
.szTrace2
);
4003 IDirectPlayX_Release( pDP
[0] );
4004 IDirectPlayX_Release( pDP
[1] );
4005 IDirectPlayX_Release( pDP
[2] );
4011 static BOOL CALLBACK
EnumGroups_cb( DPID dpId
,
4017 lpCallbackData callbackData
= lpContext
;
4018 char playerIndex
= dpid2char( callbackData
->dpid
,
4019 callbackData
->dpidSize
,
4023 /* Trace to study player ids */
4024 callbackData
->szTrace1
[ callbackData
->dwCounter1
] = playerIndex
;
4025 callbackData
->dwCounter1
++;
4026 callbackData
->szTrace1
[ callbackData
->dwCounter1
] = '\0';
4028 /* Trace to study flags received */
4029 strcat( callbackData
->szTrace2
,
4030 ( dwFlags2str(dwFlags
, FLAGS_DPENUMGROUPS
) +
4031 strlen("DPENUMGROUPS_") ) );
4032 strcat( callbackData
->szTrace2
, ":" );
4035 check( DPPLAYERTYPE_GROUP
, dwPlayerType
);
4040 static BOOL CALLBACK
EnumSessions_cb_EnumGroups( LPCDPSESSIONDESC2 lpThisSD
,
4041 LPDWORD lpdwTimeOut
,
4045 lpCallbackData callbackData
= lpContext
;
4048 if (dwFlags
& DPESC_TIMEDOUT
)
4054 callbackData
->dwCounter1
= 0;
4055 hr
= IDirectPlayX_EnumGroups( callbackData
->pDP
, NULL
,
4056 EnumGroups_cb
, &callbackData
, 0 );
4057 checkHR( DPERR_NOSESSIONS
, hr
);
4058 check( 0, callbackData
->dwCounter1
);
4060 /* guid = appGuid */
4061 callbackData
->dwCounter1
= 0;
4062 hr
= IDirectPlayX_EnumGroups( callbackData
->pDP
, (LPGUID
) &appGuid
,
4063 EnumGroups_cb
, &callbackData
, 0 );
4064 checkHR( DPERR_NOSESSIONS
, hr
);
4065 check( 0, callbackData
->dwCounter1
);
4067 callbackData
->dwCounter1
= 0;
4068 hr
= IDirectPlayX_EnumGroups( callbackData
->pDP
, (LPGUID
) &appGuid
,
4069 EnumGroups_cb
, &callbackData
,
4070 DPENUMGROUPS_SESSION
);
4071 checkHR( DPERR_NOSESSIONS
, hr
);
4072 check( 0, callbackData
->dwCounter1
);
4074 /* guid = guidInstance */
4075 callbackData
->dwCounter1
= 0;
4076 hr
= IDirectPlayX_EnumGroups( callbackData
->pDP
,
4077 (LPGUID
) &lpThisSD
->guidInstance
,
4078 EnumGroups_cb
, &callbackData
, 0 );
4079 checkHR( DPERR_NOSESSIONS
, hr
);
4080 check( 0, callbackData
->dwCounter1
);
4082 callbackData
->dwCounter1
= 0;
4083 hr
= IDirectPlayX_EnumGroups( callbackData
->pDP
,
4084 (LPGUID
) &lpThisSD
->guidInstance
,
4085 EnumGroups_cb
, &callbackData
,
4086 DPENUMGROUPS_SESSION
);
4087 checkHR( DPERR_GENERIC
, hr
); /* Why? */
4088 check( 0, callbackData
->dwCounter1
);
4094 static void test_EnumGroups(void)
4096 IDirectPlay4
*pDP
[3];
4097 DPSESSIONDESC2 dpsd
[3];
4099 CallbackData callbackData
;
4106 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
4107 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
4108 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
4109 if (FAILED(hr
)) return;
4111 ZeroMemory( &dpsd
[i
], sizeof(DPSESSIONDESC2
) );
4112 dpsd
[i
].dwSize
= sizeof(DPSESSIONDESC2
);
4115 dpsd
[0].guidApplication
= appGuid
;
4116 dpsd
[1].guidApplication
= appGuid2
;
4117 dpsd
[2].guidApplication
= GUID_NULL
;
4119 callbackData
.dpid
= dpid
;
4120 callbackData
.dpidSize
= 5;
4123 /* Uninitialized service provider */
4124 callbackData
.dwCounter1
= 0;
4125 hr
= IDirectPlayX_EnumGroups( pDP
[0], NULL
, EnumGroups_cb
,
4127 checkHR( DPERR_UNINITIALIZED
, hr
);
4128 check( 0, callbackData
.dwCounter1
);
4131 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
4132 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
4133 init_TCPIP_provider( pDP
[2], "127.0.0.1", 0 );
4137 callbackData
.dwCounter1
= 0;
4138 hr
= IDirectPlayX_EnumGroups( pDP
[0], NULL
, EnumGroups_cb
,
4140 todo_wine
checkHR( DPERR_NOSESSIONS
, hr
);
4141 check( 0, callbackData
.dwCounter1
);
4143 if ( hr
== DPERR_UNINITIALIZED
)
4145 todo_wine
win_skip( "EnumGroups not implemented\n" );
4149 callbackData
.dwCounter1
= 0;
4150 hr
= IDirectPlayX_EnumGroups( pDP
[0], (LPGUID
) &appGuid
, EnumGroups_cb
,
4152 checkHR( DPERR_NOSESSIONS
, hr
);
4153 check( 0, callbackData
.dwCounter1
);
4155 callbackData
.dwCounter1
= 0;
4156 hr
= IDirectPlayX_EnumGroups( pDP
[0], (LPGUID
) &appGuid
, EnumGroups_cb
,
4157 &callbackData
, DPENUMGROUPS_SESSION
);
4158 checkHR( DPERR_NOSESSIONS
, hr
);
4159 check( 0, callbackData
.dwCounter1
);
4162 hr
= IDirectPlayX_Open( pDP
[0], &dpsd
[0], DPOPEN_CREATE
);
4163 checkHR( DP_OK
, hr
);
4164 hr
= IDirectPlayX_Open( pDP
[1], &dpsd
[1], DPOPEN_CREATE
);
4165 checkHR( DP_OK
, hr
);
4169 callbackData
.dwCounter1
= 0;
4170 hr
= IDirectPlayX_EnumGroups( pDP
[0], NULL
, EnumGroups_cb
,
4172 checkHR( DP_OK
, hr
);
4173 check( 0, callbackData
.dwCounter1
);
4177 hr
= IDirectPlayX_CreateGroup( pDP
[0], &dpid
[0],
4179 checkHR( DP_OK
, hr
);
4180 hr
= IDirectPlayX_CreateGroupInGroup( pDP
[0], dpid
[0], &dpid
[3],
4182 checkHR( DP_OK
, hr
); /* Not a superior level group,
4183 won't appear in the enumerations */
4184 hr
= IDirectPlayX_CreateGroup( pDP
[1], &dpid
[1],
4186 checkHR( DP_OK
, hr
);
4187 hr
= IDirectPlayX_CreateGroup( pDP
[0], &dpid
[2],
4188 NULL
, NULL
, 0, DPGROUP_HIDDEN
);
4189 checkHR( DP_OK
, hr
);
4192 /* Invalid parameters */
4193 callbackData
.dwCounter1
= 0;
4194 hr
= IDirectPlayX_EnumGroups( pDP
[0], (LPGUID
) &appGuid
, NULL
,
4196 checkHR( DPERR_INVALIDPARAMS
, hr
);
4197 check( 0, callbackData
.dwCounter1
);
4199 callbackData
.dwCounter1
= 0;
4200 hr
= IDirectPlayX_EnumGroups( pDP
[0], NULL
, EnumGroups_cb
,
4201 &callbackData
, DPENUMGROUPS_SESSION
);
4202 checkHR( DPERR_INVALIDPARAMS
, hr
);
4203 check( 0, callbackData
.dwCounter1
);
4206 /* Regular operation */
4207 callbackData
.dwCounter1
= 0;
4208 callbackData
.szTrace2
[0] = 0;
4209 hr
= IDirectPlayX_EnumGroups( pDP
[0], NULL
, EnumGroups_cb
,
4211 checkHR( DP_OK
, hr
);
4212 check( 2, callbackData
.dwCounter1
);
4213 checkStr( "02", callbackData
.szTrace1
);
4214 checkStr( "ALL:HIDDEN:", callbackData
.szTrace2
);
4216 callbackData
.dwCounter1
= 0;
4217 callbackData
.szTrace2
[0] = 0;
4218 hr
= IDirectPlayX_EnumGroups( pDP
[1], NULL
, EnumGroups_cb
,
4220 checkHR( DP_OK
, hr
);
4221 check( 1, callbackData
.dwCounter1
);
4222 checkStr( "1", callbackData
.szTrace1
);
4223 checkStr( "ALL:", callbackData
.szTrace2
);
4225 callbackData
.dwCounter1
= 0;
4226 callbackData
.szTrace2
[0] = 0;
4227 hr
= IDirectPlayX_EnumGroups( pDP
[0], (LPGUID
) &appGuid
, EnumGroups_cb
,
4229 checkHR( DP_OK
, hr
);
4230 check( 2, callbackData
.dwCounter1
); /* Guid is ignored */
4231 checkStr( "02", callbackData
.szTrace1
);
4232 checkStr( "ALL:HIDDEN:", callbackData
.szTrace2
);
4235 /* Enumerating from a remote session */
4236 /* - Session not open */
4237 callbackData
.pDP
= pDP
[2];
4238 hr
= IDirectPlayX_EnumSessions( pDP
[2], &dpsd
[2], 0,
4239 EnumSessions_cb_EnumGroups
,
4241 checkHR( DP_OK
, hr
);
4243 /* - Open session */
4244 callbackData
.pDP
= pDP
[2];
4245 hr
= IDirectPlayX_EnumSessions( pDP
[2], &dpsd
[0], 0, EnumSessions_cb_join
,
4247 checkHR( DP_OK
, hr
);
4249 hr
= IDirectPlayX_CreateGroup( pDP
[2], &dpid
[3],
4251 checkHR( DP_OK
, hr
);
4252 hr
= IDirectPlayX_CreateGroup( pDP
[2], &dpid
[4],
4253 NULL
, NULL
, 0, DPGROUP_STAGINGAREA
);
4254 checkHR( DP_OK
, hr
);
4257 callbackData
.dwCounter1
= 0;
4258 callbackData
.szTrace2
[0] = 0;
4259 hr
= IDirectPlayX_EnumGroups( pDP
[2], NULL
, EnumGroups_cb
,
4261 checkHR( DP_OK
, hr
);
4262 check( 4, callbackData
.dwCounter1
);
4263 checkStr( "0234", callbackData
.szTrace1
);
4264 checkStr( "ALL:HIDDEN:ALL:STAGINGAREA:", callbackData
.szTrace2
);
4267 callbackData
.dwCounter1
= 0;
4268 callbackData
.szTrace2
[0] = 0;
4269 hr
= IDirectPlayX_EnumGroups( pDP
[2], NULL
, EnumGroups_cb
,
4270 &callbackData
, DPENUMGROUPS_ALL
);
4271 checkHR( DP_OK
, hr
);
4272 check( 4, callbackData
.dwCounter1
);
4273 checkStr( "0234", callbackData
.szTrace1
);
4274 checkStr( "ALL:HIDDEN:ALL:STAGINGAREA:", callbackData
.szTrace2
);
4276 callbackData
.dwCounter1
= 0;
4277 callbackData
.szTrace2
[0] = 0;
4278 hr
= IDirectPlayX_EnumGroups( pDP
[2], NULL
, EnumGroups_cb
,
4279 &callbackData
, DPENUMGROUPS_HIDDEN
);
4280 checkHR( DP_OK
, hr
);
4281 check( 1, callbackData
.dwCounter1
);
4282 checkStr( "2", callbackData
.szTrace1
);
4283 checkStr( "HIDDEN:", callbackData
.szTrace2
);
4285 callbackData
.dwCounter1
= 0;
4286 callbackData
.szTrace2
[0] = 0;
4287 hr
= IDirectPlayX_EnumGroups( pDP
[2], NULL
, EnumGroups_cb
,
4288 &callbackData
, DPENUMGROUPS_LOCAL
);
4289 checkHR( DP_OK
, hr
);
4290 check( 2, callbackData
.dwCounter1
);
4291 checkStr( "34", callbackData
.szTrace1
);
4293 "LOCAL,DPENUMGROUPS_STAGINGAREA:", callbackData
.szTrace2
);
4295 callbackData
.dwCounter1
= 0;
4296 callbackData
.szTrace2
[0] = 0;
4297 hr
= IDirectPlayX_EnumGroups( pDP
[2], NULL
, EnumGroups_cb
,
4298 &callbackData
, DPENUMGROUPS_REMOTE
);
4299 checkHR( DP_OK
, hr
);
4300 check( 2, callbackData
.dwCounter1
);
4301 checkStr( "02", callbackData
.szTrace1
);
4303 "REMOTE,DPENUMGROUPS_HIDDEN:", callbackData
.szTrace2
);
4305 callbackData
.dwCounter1
= 0;
4306 callbackData
.szTrace2
[0] = 0;
4307 hr
= IDirectPlayX_EnumGroups( pDP
[2], NULL
, EnumGroups_cb
,
4308 &callbackData
, DPENUMGROUPS_STAGINGAREA
);
4309 checkHR( DP_OK
, hr
);
4310 check( 1, callbackData
.dwCounter1
);
4311 checkStr( "4", callbackData
.szTrace1
);
4312 checkStr( "STAGINGAREA:", callbackData
.szTrace2
);
4315 IDirectPlayX_Release( pDP
[0] );
4316 IDirectPlayX_Release( pDP
[1] );
4317 IDirectPlayX_Release( pDP
[2] );
4321 static void test_EnumGroupsInGroup(void)
4323 IDirectPlay4
*pDP
[2];
4324 DPSESSIONDESC2 dpsd
[2];
4326 CallbackData callbackData
;
4333 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
4334 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
4335 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
4336 if (FAILED(hr
)) return;
4338 ZeroMemory( &dpsd
[i
], sizeof(DPSESSIONDESC2
) );
4339 dpsd
[i
].dwSize
= sizeof(DPSESSIONDESC2
);
4342 dpsd
[0].guidApplication
= appGuid
;
4343 dpsd
[1].guidApplication
= GUID_NULL
;
4345 callbackData
.dpid
= dpid
;
4346 callbackData
.dpidSize
= 6;
4349 /* Uninitialized service provider */
4350 callbackData
.dwCounter1
= 0;
4351 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], 0, NULL
, EnumGroups_cb
,
4353 checkHR( DPERR_UNINITIALIZED
, hr
);
4354 check( 0, callbackData
.dwCounter1
);
4357 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
4358 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
4360 hr
= IDirectPlayX_Open( pDP
[0], &dpsd
[0], DPOPEN_CREATE
);
4361 todo_wine
checkHR( DP_OK
, hr
);
4363 if ( hr
== DPERR_UNINITIALIZED
)
4365 todo_wine
win_skip( "EnumGroupsInGroup not implemented\n" );
4377 hr
= IDirectPlayX_CreateGroup( pDP
[0], &dpid
[0],
4379 checkHR( DP_OK
, hr
);
4380 hr
= IDirectPlayX_CreateGroup( pDP
[0], &dpid
[1],
4382 checkHR( DP_OK
, hr
);
4383 hr
= IDirectPlayX_CreateGroupInGroup( pDP
[0], dpid
[1], &dpid
[2],
4385 checkHR( DP_OK
, hr
);
4386 hr
= IDirectPlayX_CreateGroupInGroup( pDP
[0], dpid
[1], &dpid
[3],
4389 checkHR( DP_OK
, hr
);
4390 hr
= IDirectPlayX_CreateGroupInGroup( pDP
[0], dpid
[1], &dpid
[4],
4392 DPGROUP_STAGINGAREA
);
4393 checkHR( DP_OK
, hr
);
4394 hr
= IDirectPlayX_CreateGroup( pDP
[0], &dpid
[5],
4396 checkHR( DP_OK
, hr
);
4398 hr
= IDirectPlayX_AddGroupToGroup( pDP
[0], dpid
[1], dpid
[5] );
4399 checkHR( DP_OK
, hr
);
4402 /* Invalid parameters */
4403 callbackData
.dwCounter1
= 0;
4404 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], 0, NULL
, EnumGroups_cb
,
4406 checkHR( DPERR_INVALIDGROUP
, hr
);
4407 check( 0, callbackData
.dwCounter1
);
4409 callbackData
.dwCounter1
= 0;
4410 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], 10, NULL
, EnumGroups_cb
,
4412 checkHR( DPERR_INVALIDGROUP
, hr
);
4413 check( 0, callbackData
.dwCounter1
);
4415 callbackData
.dwCounter1
= 0;
4416 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], dpid
[1], (LPGUID
) &appGuid
,
4417 NULL
, &callbackData
, 0 );
4418 checkHR( DPERR_INVALIDPARAMS
, hr
);
4419 check( 0, callbackData
.dwCounter1
);
4421 callbackData
.dwCounter1
= 0;
4422 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], dpid
[1], NULL
, EnumGroups_cb
,
4423 &callbackData
, DPENUMGROUPS_SESSION
);
4424 checkHR( DPERR_INVALIDPARAMS
, hr
);
4425 check( 0, callbackData
.dwCounter1
);
4428 /* Regular operation */
4429 callbackData
.dwCounter1
= 0;
4430 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], dpid
[0], NULL
, EnumGroups_cb
,
4432 checkHR( DP_OK
, hr
);
4433 check( 0, callbackData
.dwCounter1
);
4435 callbackData
.dwCounter1
= 0;
4436 callbackData
.szTrace2
[0] = 0;
4437 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], dpid
[1], NULL
, EnumGroups_cb
,
4439 checkHR( DP_OK
, hr
);
4440 check( 4, callbackData
.dwCounter1
);
4441 checkStr( "5432", callbackData
.szTrace1
);
4442 checkStr( "SHORTCUT:STAGINGAREA:HIDDEN:ALL:", callbackData
.szTrace2
);
4444 callbackData
.dwCounter1
= 0;
4445 callbackData
.szTrace2
[0] = 0;
4446 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], dpid
[1], (LPGUID
) &appGuid
,
4447 EnumGroups_cb
, &callbackData
, 0 );
4448 checkHR( DP_OK
, hr
);
4449 check( 4, callbackData
.dwCounter1
); /* Guid is ignored */
4450 checkStr( "5432", callbackData
.szTrace1
);
4451 checkStr( "SHORTCUT:STAGINGAREA:HIDDEN:ALL:", callbackData
.szTrace2
);
4454 /* Enumerating from a remote session */
4455 /* - Session not open */
4456 callbackData
.pDP
= pDP
[1];
4457 hr
= IDirectPlayX_EnumSessions( pDP
[1], &dpsd
[1], 0,
4458 EnumSessions_cb_EnumGroups
,
4460 checkHR( DP_OK
, hr
);
4462 /* - Open session */
4463 hr
= IDirectPlayX_EnumSessions( pDP
[1], &dpsd
[0], 0, EnumSessions_cb_join
,
4465 checkHR( DP_OK
, hr
);
4468 callbackData
.dwCounter1
= 0;
4469 callbackData
.szTrace2
[0] = 0;
4470 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[1], dpid
[1], NULL
, EnumGroups_cb
,
4472 checkHR( DP_OK
, hr
);
4473 check( 4, callbackData
.dwCounter1
);
4474 checkStr( "5432", callbackData
.szTrace1
);
4475 checkStr( "SHORTCUT:STAGINGAREA:HIDDEN:ALL:", callbackData
.szTrace2
);
4478 callbackData
.dwCounter1
= 0;
4479 callbackData
.szTrace2
[0] = 0;
4480 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], dpid
[1], NULL
, EnumGroups_cb
,
4481 &callbackData
, DPENUMGROUPS_ALL
);
4482 checkHR( DP_OK
, hr
);
4483 check( 4, callbackData
.dwCounter1
);
4484 checkStr( "5432", callbackData
.szTrace1
);
4485 checkStr( "SHORTCUT:STAGINGAREA:HIDDEN:ALL:", callbackData
.szTrace2
);
4487 callbackData
.dwCounter1
= 0;
4488 callbackData
.szTrace2
[0] = 0;
4489 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], dpid
[1], NULL
, EnumGroups_cb
,
4490 &callbackData
, DPENUMGROUPS_HIDDEN
);
4491 checkHR( DP_OK
, hr
);
4492 check( 1, callbackData
.dwCounter1
);
4493 checkStr( "3", callbackData
.szTrace1
);
4494 checkStr( "HIDDEN:", callbackData
.szTrace2
);
4496 callbackData
.dwCounter1
= 0;
4497 callbackData
.szTrace2
[0] = 0;
4498 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], dpid
[1], NULL
, EnumGroups_cb
,
4499 &callbackData
, DPENUMGROUPS_LOCAL
);
4500 checkHR( DP_OK
, hr
);
4501 check( 4, callbackData
.dwCounter1
);
4502 checkStr( "5432", callbackData
.szTrace1
);
4503 checkStr( "LOCAL,DPENUMGROUPS_SHORTCUT:"
4504 "LOCAL,DPENUMGROUPS_STAGINGAREA:"
4505 "LOCAL,DPENUMGROUPS_HIDDEN:LOCAL:", callbackData
.szTrace2
);
4507 callbackData
.dwCounter1
= 0;
4508 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], dpid
[1], NULL
, EnumGroups_cb
,
4509 &callbackData
, DPENUMGROUPS_REMOTE
);
4510 checkHR( DP_OK
, hr
);
4511 check( 0, callbackData
.dwCounter1
);
4513 callbackData
.dwCounter1
= 0;
4514 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[1], dpid
[1], NULL
, EnumGroups_cb
,
4515 &callbackData
, DPENUMGROUPS_LOCAL
);
4516 checkHR( DP_OK
, hr
);
4517 check( 0, callbackData
.dwCounter1
);
4519 callbackData
.dwCounter1
= 0;
4520 callbackData
.szTrace2
[0] = 0;
4521 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[1], dpid
[1], NULL
, EnumGroups_cb
,
4522 &callbackData
, DPENUMGROUPS_REMOTE
);
4523 checkHR( DP_OK
, hr
);
4524 check( 4, callbackData
.dwCounter1
);
4525 checkStr( "5432", callbackData
.szTrace1
);
4526 checkStr( "REMOTE,DPENUMGROUPS_SHORTCUT:"
4527 "REMOTE,DPENUMGROUPS_STAGINGAREA:"
4528 "REMOTE,DPENUMGROUPS_HIDDEN:REMOTE:", callbackData
.szTrace2
);
4530 callbackData
.dwCounter1
= 0;
4531 callbackData
.szTrace2
[0] = 0;
4532 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], dpid
[1], NULL
, EnumGroups_cb
,
4533 &callbackData
, DPENUMGROUPS_SHORTCUT
);
4534 checkHR( DP_OK
, hr
);
4535 check( 1, callbackData
.dwCounter1
);
4536 checkStr( "5", callbackData
.szTrace1
);
4537 checkStr( "SHORTCUT:", callbackData
.szTrace2
);
4539 callbackData
.dwCounter1
= 0;
4540 callbackData
.szTrace2
[0] = 0;
4541 hr
= IDirectPlayX_EnumGroupsInGroup( pDP
[0], dpid
[1], NULL
, EnumGroups_cb
,
4543 DPENUMGROUPS_STAGINGAREA
);
4544 checkHR( DP_OK
, hr
);
4545 check( 1, callbackData
.dwCounter1
);
4546 checkStr( "4", callbackData
.szTrace1
);
4547 checkStr( "STAGINGAREA:", callbackData
.szTrace2
);
4550 IDirectPlayX_Release( pDP
[0] );
4551 IDirectPlayX_Release( pDP
[1] );
4555 static void test_groups_p2p(void)
4558 IDirectPlay4
*pDP
[2];
4559 DPSESSIONDESC2 dpsd
;
4560 DPID idPlayer
[6], idGroup
[3];
4564 DWORD dwDataSize
= 1024;
4565 LPVOID lpData
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, 1024 );
4566 CallbackData callbackData
;
4571 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
4572 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
4573 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
4574 if (FAILED(hr
)) return;
4576 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
4577 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
4578 dpsd
.guidApplication
= appGuid
;
4579 dpsd
.dwMaxPlayers
= 10;
4582 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
4583 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
4585 hr
= IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
4586 todo_wine
checkHR( DP_OK
, hr
);
4587 hr
= IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
4589 todo_wine
checkHR( DP_OK
, hr
);
4591 if ( hr
== DPERR_UNINITIALIZED
)
4593 todo_wine
win_skip( "dplay not implemented enough for this test yet\n" );
4598 /* Create players */
4599 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &idPlayer
[0],
4600 NULL
, NULL
, NULL
, 0, 0 );
4601 checkHR( DP_OK
, hr
);
4602 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &idPlayer
[1],
4603 NULL
, NULL
, NULL
, 0, 0 );
4604 checkHR( DP_OK
, hr
);
4605 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &idPlayer
[2],
4606 NULL
, NULL
, NULL
, 0, 0 );
4607 checkHR( DP_OK
, hr
);
4608 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &idPlayer
[3],
4609 NULL
, NULL
, NULL
, 0, 0 );
4610 checkHR( DP_OK
, hr
);
4611 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &idPlayer
[4],
4612 NULL
, NULL
, NULL
, 0, 0 );
4613 checkHR( DP_OK
, hr
);
4614 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &idPlayer
[5],
4615 NULL
, NULL
, NULL
, 0, 0 );
4616 checkHR( DP_OK
, hr
);
4618 hr
= IDirectPlayX_CreateGroup( pDP
[0], &idGroup
[0],
4620 checkHR( DP_OK
, hr
);
4621 hr
= IDirectPlayX_CreateGroup( pDP
[1], &idGroup
[2],
4623 checkHR( DP_OK
, hr
);
4624 hr
= IDirectPlayX_CreateGroupInGroup( pDP
[1], idGroup
[2], &idGroup
[1],
4626 checkHR( DP_OK
, hr
);
4630 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4631 checkStr( "S0," "S1,S0,"
4632 "S2,S1,S0," "S2,S1,S0,"
4633 "S2,S1,S0," "S2,S1,S0,"
4634 "S2,S1,S0," "S2,S1,S0,", callbackData
.szTrace1
);
4635 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4636 checkStr( "S3," "S4,S3,"
4637 "S5,S4,S3," "S5,S4,S3,"
4638 "S5,S4,S3,", callbackData
.szTrace1
);
4643 * Player 1 | Group 0 | pDP 0
4645 * Player 3 | Group 1 ) |
4646 * Player 4 | | Group 2 | pDP 1
4651 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[0], idGroup
[0], idPlayer
[0] );
4652 checkHR( DP_OK
, hr
);
4653 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[0], idGroup
[0], idPlayer
[1] );
4654 checkHR( DP_OK
, hr
);
4655 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[0], idGroup
[0], idPlayer
[2] );
4656 checkHR( DP_OK
, hr
);
4657 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[1], idGroup
[1], idPlayer
[3] );
4658 checkHR( DP_OK
, hr
);
4659 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[1], idGroup
[1], idPlayer
[4] );
4660 checkHR( DP_OK
, hr
);
4661 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[1], idGroup
[2], idPlayer
[4] );
4662 checkHR( DP_OK
, hr
);
4663 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[1], idGroup
[2], idPlayer
[5] );
4664 checkHR( DP_OK
, hr
);
4666 hr
= IDirectPlayX_AddGroupToGroup( pDP
[1], idGroup
[2], idGroup
[1] );
4667 checkHR( DP_OK
, hr
);
4670 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4671 checkStr( "S2,S1,S0," "S2,S1,S0," "S2,S1,S0,"
4672 "S2,S1,S0," "S2,S1,S0," "S2,S1,S0,"
4673 "S2,S1,S0,", callbackData
.szTrace1
);
4674 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4675 checkStr( "S5,S4,S3," "S5,S4,S3," "S5,S4,S3,"
4676 "S5,S4,S3," "S5,S4,S3," "S5,S4,S3,"
4677 "S5,S4,S3,", callbackData
.szTrace1
);
4680 /* Sending broadcast messages, and checking who receives them */
4684 hr
= IDirectPlayX_Send( pDP
[0], idPlayer
[0], DPID_ALLPLAYERS
, 0,
4685 lpData
, dwDataSize
);
4686 checkHR( DP_OK
, hr
);
4687 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4688 checkStr( "02,01,", callbackData
.szTrace1
);
4689 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4690 checkStr( "05,04,03,", callbackData
.szTrace1
);
4693 hr
= IDirectPlayX_Send( pDP
[0], idPlayer
[0], idGroup
[0], 0,
4694 lpData
, dwDataSize
);
4695 checkHR( DP_OK
, hr
);
4696 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4697 checkStr( "02,01,", callbackData
.szTrace1
);
4698 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4699 checkStr( "", callbackData
.szTrace1
);
4701 hr
= IDirectPlayX_Send( pDP
[0], idPlayer
[0], idGroup
[1], 0,
4702 lpData
, dwDataSize
);
4703 checkHR( DP_OK
, hr
);
4704 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4705 checkStr( "", callbackData
.szTrace1
);
4706 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4707 checkStr( "04,03,", callbackData
.szTrace1
);
4709 hr
= IDirectPlayX_Send( pDP
[0], idPlayer
[0], idGroup
[2], 0,
4710 lpData
, dwDataSize
);
4711 checkHR( DP_OK
, hr
);
4712 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4713 checkStr( "", callbackData
.szTrace1
);
4714 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4715 checkStr( "05,04,", callbackData
.szTrace1
);
4718 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[3], DPID_ALLPLAYERS
, 0,
4719 lpData
, dwDataSize
);
4720 checkHR( DP_OK
, hr
);
4721 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4722 checkStr( "32,31,30,", callbackData
.szTrace1
);
4723 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4724 checkStr( "35,34,", callbackData
.szTrace1
);
4726 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[3], idGroup
[0], 0,
4727 lpData
, dwDataSize
);
4728 checkHR( DP_OK
, hr
);
4729 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4730 checkStr( "32,31,30,", callbackData
.szTrace1
);
4731 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4732 checkStr( "", callbackData
.szTrace1
);
4734 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[3], idGroup
[1], 0,
4735 lpData
, dwDataSize
);
4736 checkHR( DP_OK
, hr
);
4737 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4738 checkStr( "", callbackData
.szTrace1
);
4739 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4740 checkStr( "34,", callbackData
.szTrace1
);
4742 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[3], idGroup
[2], 0,
4743 lpData
, dwDataSize
);
4744 checkHR( DP_OK
, hr
);
4745 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4746 checkStr( "", callbackData
.szTrace1
);
4747 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4748 checkStr( "35,34,", callbackData
.szTrace1
);
4751 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[5], DPID_ALLPLAYERS
, 0,
4752 lpData
, dwDataSize
);
4753 checkHR( DP_OK
, hr
);
4754 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4755 checkStr( "52,51,50,", callbackData
.szTrace1
);
4756 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4757 checkStr( "54,53,", callbackData
.szTrace1
);
4759 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[5], idGroup
[0], 0,
4760 lpData
, dwDataSize
);
4761 checkHR( DP_OK
, hr
);
4762 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4763 checkStr( "52,51,50,", callbackData
.szTrace1
);
4764 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4765 checkStr( "", callbackData
.szTrace1
);
4767 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[5], idGroup
[1], 0,
4768 lpData
, dwDataSize
);
4769 checkHR( DP_OK
, hr
);
4770 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4771 checkStr( "", callbackData
.szTrace1
);
4772 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4773 checkStr( "54,53,", callbackData
.szTrace1
);
4775 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[5], idGroup
[2], 0,
4776 lpData
, dwDataSize
);
4777 checkHR( DP_OK
, hr
);
4778 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4779 checkStr( "", callbackData
.szTrace1
);
4780 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4781 checkStr( "54,", callbackData
.szTrace1
);
4784 HeapFree( GetProcessHeap(), 0, lpData
);
4785 IDirectPlayX_Release( pDP
[0] );
4786 IDirectPlayX_Release( pDP
[1] );
4790 static void test_groups_cs(void)
4793 IDirectPlay4
*pDP
[2];
4794 DPSESSIONDESC2 dpsd
;
4795 DPID idPlayer
[6], idGroup
[3];
4796 CallbackData callbackData
;
4800 DWORD dwDataSize
= 1024;
4801 LPVOID lpData
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, 1024 );
4806 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
4807 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
4808 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
4809 if (FAILED(hr
)) return;
4811 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
4812 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
4813 dpsd
.guidApplication
= appGuid
;
4814 dpsd
.dwMaxPlayers
= 10;
4817 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
4818 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
4820 dpsd
.dwFlags
= DPSESSION_CLIENTSERVER
;
4821 hr
= IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
4822 todo_wine
checkHR( DP_OK
, hr
);
4824 hr
= IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
4826 todo_wine
checkHR( DP_OK
, hr
);
4828 if ( hr
== DPERR_UNINITIALIZED
)
4830 todo_wine
win_skip( "dplay not implemented enough for this test yet\n" );
4835 /* Create players */
4836 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &idPlayer
[0],
4837 NULL
, NULL
, NULL
, 0, 0 );
4838 checkHR( DPERR_ACCESSDENIED
, hr
);
4839 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &idPlayer
[0],
4840 NULL
, NULL
, NULL
, 0,
4841 DPPLAYER_SERVERPLAYER
);
4842 checkHR( DP_OK
, hr
);
4843 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &idPlayer
[1],
4844 NULL
, NULL
, NULL
, 0, 0 );
4845 checkHR( DPERR_ACCESSDENIED
, hr
);
4846 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &idPlayer
[1],
4847 NULL
, NULL
, NULL
, 0, 0 );
4848 checkHR( DP_OK
, hr
);
4849 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &idPlayer
[2],
4850 NULL
, NULL
, NULL
, 0, 0 );
4851 checkHR( DP_OK
, hr
);
4852 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &idPlayer
[3],
4853 NULL
, NULL
, NULL
, 0, 0 );
4854 checkHR( DP_OK
, hr
);
4855 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &idPlayer
[4],
4856 NULL
, NULL
, NULL
, 0, 0 );
4857 checkHR( DP_OK
, hr
);
4858 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &idPlayer
[5],
4859 NULL
, NULL
, NULL
, 0, 0 );
4860 checkHR( DP_OK
, hr
);
4862 hr
= IDirectPlayX_CreateGroup( pDP
[0], &idGroup
[0],
4864 checkHR( DP_OK
, hr
);
4865 hr
= IDirectPlayX_CreateGroup( pDP
[1], &idGroup
[2],
4867 checkHR( DP_OK
, hr
);
4868 hr
= IDirectPlayX_CreateGroupInGroup( pDP
[1], idGroup
[2], &idGroup
[1],
4870 checkHR( DP_OK
, hr
);
4874 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4875 checkStr( "S0,S0,S0,S0,S0,S0,", callbackData
.szTrace1
);
4876 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4877 checkStr( "S1," "S2,S1," "S3,S2,S1," "S4,S3,S2,S1,"
4878 "S5,S4,S3,S2,S1," "S5,S4,S3,S2,S1,", callbackData
.szTrace1
);
4881 * Player 0 | | pDP 0
4882 * Player 1 | Group 0 |
4884 * Player 3 | Group 1 ) |
4885 * Player 4 | | Group 2 | pDP 1
4890 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[0], idGroup
[0], idPlayer
[0] );
4891 checkHR( DP_OK
, hr
);
4892 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[0], idGroup
[0], idPlayer
[1] );
4893 checkHR( DP_OK
, hr
);
4894 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[0], idGroup
[0], idPlayer
[2] );
4895 checkHR( DP_OK
, hr
);
4896 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[1], idGroup
[1], idPlayer
[3] );
4897 checkHR( DP_OK
, hr
);
4898 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[1], idGroup
[1], idPlayer
[4] );
4899 checkHR( DP_OK
, hr
);
4900 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[1], idGroup
[2], idPlayer
[4] );
4901 checkHR( DP_OK
, hr
);
4902 hr
= IDirectPlayX_AddPlayerToGroup( pDP
[1], idGroup
[2], idPlayer
[5] );
4903 checkHR( DP_OK
, hr
);
4905 hr
= IDirectPlayX_AddGroupToGroup( pDP
[1], idGroup
[2], idGroup
[1] );
4906 checkHR( DP_OK
, hr
);
4909 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4910 checkStr( "S0,S0,S0,S0,", callbackData
.szTrace1
);
4911 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4912 checkStr( "S5," "S4,S3,S2,S1," "S5,S4,S3,S2,S1,"
4913 "S5,S4,S3,S2,S1," "S5,S4,S3,S2,S1,", callbackData
.szTrace1
);
4916 /* Sending broadcast messages, and checking who receives them */
4919 hr
= IDirectPlayX_Send( pDP
[0], idPlayer
[0], DPID_ALLPLAYERS
, 0,
4920 lpData
, dwDataSize
);
4921 checkHR( DP_OK
, hr
);
4922 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4923 checkStr( "", callbackData
.szTrace1
);
4924 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4925 checkStr( "05,04,03,02,01,", callbackData
.szTrace1
);
4928 hr
= IDirectPlayX_Send( pDP
[0], idPlayer
[0], idGroup
[0], 0,
4929 lpData
, dwDataSize
);
4930 checkHR( DP_OK
, hr
);
4931 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4932 checkStr( "", callbackData
.szTrace1
);
4933 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4934 checkStr( "02,01,", callbackData
.szTrace1
);
4936 hr
= IDirectPlayX_Send( pDP
[0], idPlayer
[0], idGroup
[1], 0,
4937 lpData
, dwDataSize
);
4938 checkHR( DPERR_INVALIDPARAMS
, hr
);
4939 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4940 checkStr( "", callbackData
.szTrace1
);
4941 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4942 checkStr( "", callbackData
.szTrace1
);
4944 hr
= IDirectPlayX_Send( pDP
[0], idPlayer
[0], idGroup
[2], 0,
4945 lpData
, dwDataSize
);
4946 checkHR( DPERR_INVALIDPARAMS
, hr
);
4947 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4948 checkStr( "", callbackData
.szTrace1
);
4949 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4950 checkStr( "", callbackData
.szTrace1
);
4953 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[3], DPID_ALLPLAYERS
, 0,
4954 lpData
, dwDataSize
);
4955 checkHR( DP_OK
, hr
);
4956 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4957 checkStr( "30,", callbackData
.szTrace1
);
4958 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4959 checkStr( "35,34,32,31,", callbackData
.szTrace1
);
4961 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[3], idGroup
[0], 0,
4962 lpData
, dwDataSize
);
4963 checkHR( DPERR_INVALIDPARAMS
, hr
);
4964 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4965 checkStr( "", callbackData
.szTrace1
);
4966 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4967 checkStr( "", callbackData
.szTrace1
);
4969 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[3], idGroup
[1], 0,
4970 lpData
, dwDataSize
);
4971 checkHR( DP_OK
, hr
);
4972 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4973 checkStr( "", callbackData
.szTrace1
);
4974 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4975 checkStr( "34,", callbackData
.szTrace1
);
4977 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[3], idGroup
[2], 0,
4978 lpData
, dwDataSize
);
4979 checkHR( DP_OK
, hr
);
4980 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4981 checkStr( "", callbackData
.szTrace1
);
4982 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4983 checkStr( "35,34,", callbackData
.szTrace1
);
4986 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[5], DPID_ALLPLAYERS
, 0,
4987 lpData
, dwDataSize
);
4988 checkHR( DP_OK
, hr
);
4989 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4990 checkStr( "50,", callbackData
.szTrace1
);
4991 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
4992 checkStr( "54,53,52,51,", callbackData
.szTrace1
);
4994 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[5], idGroup
[0], 0,
4995 lpData
, dwDataSize
);
4996 checkHR( DPERR_INVALIDPARAMS
, hr
);
4997 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
4998 checkStr( "", callbackData
.szTrace1
);
4999 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
5000 checkStr( "", callbackData
.szTrace1
);
5002 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[5], idGroup
[1], 0,
5003 lpData
, dwDataSize
);
5004 checkHR( DP_OK
, hr
);
5005 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
5006 checkStr( "", callbackData
.szTrace1
);
5007 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
5008 checkStr( "54,53,", callbackData
.szTrace1
);
5010 hr
= IDirectPlayX_Send( pDP
[1], idPlayer
[5], idGroup
[2], 0,
5011 lpData
, dwDataSize
);
5012 checkHR( DP_OK
, hr
);
5013 check_messages( pDP
[0], idPlayer
, 6, &callbackData
);
5014 checkStr( "", callbackData
.szTrace1
);
5015 check_messages( pDP
[1], idPlayer
, 6, &callbackData
);
5016 checkStr( "54,", callbackData
.szTrace1
);
5019 HeapFree( GetProcessHeap(), 0, lpData
);
5020 IDirectPlayX_Release( pDP
[0] );
5021 IDirectPlayX_Release( pDP
[1] );
5027 static void test_Send(void)
5030 IDirectPlay4
*pDP
[2];
5031 DPSESSIONDESC2 dpsd
;
5032 DPID dpid
[4], idFrom
, idTo
;
5033 CallbackData callbackData
;
5035 LPCSTR message
= "message";
5036 DWORD messageSize
= strlen(message
) + 1;
5037 DWORD dwDataSize
= 1024;
5038 LPDPMSG_GENERIC lpData
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, dwDataSize
);
5039 LPDPMSG_SECUREMESSAGE lpDataSecure
;
5045 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
5046 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
5047 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
5048 if (FAILED(hr
)) return;
5050 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
5053 /* Uninitialized service provider */
5054 hr
= IDirectPlayX_Send( pDP
[0], 0, 0, 0,
5055 (LPVOID
) message
, messageSize
);
5056 checkHR( DPERR_UNINITIALIZED
, hr
);
5059 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
5060 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
5062 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
5063 dpsd
.guidApplication
= appGuid
;
5064 dpsd
.dwMaxPlayers
= 10;
5065 IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
5066 IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
5068 IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
5071 /* Incorrect players */
5072 hr
= IDirectPlayX_Send( pDP
[0], 0, 1, 2,
5073 (LPVOID
) message
, messageSize
);
5074 todo_wine
checkHR( DPERR_INVALIDPLAYER
, hr
);
5076 if ( hr
== DPERR_UNINITIALIZED
)
5078 todo_wine
win_skip( "Send not implemented\n" );
5083 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[0], NULL
, NULL
, NULL
, 0, 0 );
5084 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[1], NULL
, NULL
, NULL
, 0, 0 );
5085 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[2], NULL
, NULL
, NULL
, 0, 0 );
5086 IDirectPlayX_CreatePlayer( pDP
[1], &dpid
[3], NULL
, NULL
, NULL
, 0, 0 );
5088 /* Purge player creation messages */
5089 check_messages( pDP
[0], dpid
, 4, &callbackData
);
5090 checkStr( "S0," "S1,S0," "S2,S1,S0,", callbackData
.szTrace1
);
5091 check_messages( pDP
[1], dpid
, 4, &callbackData
);
5092 checkStr( "", callbackData
.szTrace1
);
5095 /* Message to self: no error, but no message is sent */
5096 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[0], 0,
5097 (LPVOID
) message
, messageSize
);
5098 checkHR( DP_OK
, hr
);
5100 /* Send a message from a remote player */
5101 hr
= IDirectPlayX_Send( pDP
[1], dpid
[0], dpid
[1], 0,
5102 (LPVOID
) message
, messageSize
);
5103 checkHR( DPERR_ACCESSDENIED
, hr
);
5104 hr
= IDirectPlayX_Send( pDP
[1], dpid
[0], dpid
[3], 0,
5105 (LPVOID
) message
, messageSize
);
5106 checkHR( DPERR_ACCESSDENIED
, hr
);
5109 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1], 0,
5110 NULL
, messageSize
);
5111 checkHR( DPERR_INVALIDPARAMS
, hr
);
5112 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1], 0,
5113 (LPVOID
) message
, 0 );
5114 checkHR( DPERR_INVALIDPARAMS
, hr
);
5117 /* Checking no message was sent */
5118 check_messages( pDP
[0], dpid
, 4, &callbackData
);
5119 checkStr( "", callbackData
.szTrace1
);
5120 check_messages( pDP
[1], dpid
, 4, &callbackData
);
5121 checkStr( "", callbackData
.szTrace1
);
5124 /* Regular parameters */
5125 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5127 (LPVOID
) message
, messageSize
);
5128 checkHR( DP_OK
, hr
);
5130 hr
= IDirectPlayX_Receive( pDP
[0], &dpid
[0], &dpid
[1],
5131 DPRECEIVE_FROMPLAYER
| DPRECEIVE_TOPLAYER
,
5132 lpData
, &dwDataSize
);
5133 checkHR( DP_OK
, hr
);
5134 checkStr( message
, (LPSTR
) lpData
);
5135 check( strlen(message
)+1, dwDataSize
);
5137 check_messages( pDP
[0], dpid
, 4, &callbackData
);
5138 checkStr( "", callbackData
.szTrace1
);
5139 check_messages( pDP
[1], dpid
, 4, &callbackData
);
5140 checkStr( "", callbackData
.szTrace1
);
5143 /* Message to a remote player */
5144 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[3], 0,
5145 (LPVOID
) message
, messageSize
);
5146 checkHR( DP_OK
, hr
);
5148 hr
= IDirectPlayX_Receive( pDP
[0], &dpid
[0], &dpid
[3],
5149 DPRECEIVE_FROMPLAYER
| DPRECEIVE_TOPLAYER
,
5150 lpData
, &dwDataSize
);
5151 checkHR( DPERR_NOMESSAGES
, hr
);
5152 hr
= IDirectPlayX_Receive( pDP
[1], &dpid
[0], &dpid
[3],
5153 DPRECEIVE_FROMPLAYER
| DPRECEIVE_TOPLAYER
,
5154 lpData
, &dwDataSize
);
5155 checkHR( DP_OK
, hr
);
5156 checkStr( message
, (LPSTR
) lpData
);
5157 check( strlen(message
)+1, dwDataSize
);
5159 check_messages( pDP
[0], dpid
, 4, &callbackData
);
5160 checkStr( "", callbackData
.szTrace1
);
5161 check_messages( pDP
[1], dpid
, 4, &callbackData
);
5162 checkStr( "", callbackData
.szTrace1
);
5167 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], DPID_ALLPLAYERS
, 0,
5168 (LPVOID
) message
, messageSize
);
5169 checkHR( DP_OK
, hr
);
5173 hr
= IDirectPlayX_Receive( pDP
[0], &dpid
[0], &dpid
[i
],
5174 DPRECEIVE_FROMPLAYER
| DPRECEIVE_TOPLAYER
,
5175 lpData
, &dwDataSize
);
5176 checkHR( DP_OK
, hr
);
5177 checkStr( message
, (LPSTR
) lpData
);
5179 hr
= IDirectPlayX_Receive( pDP
[1], &dpid
[0], &dpid
[3],
5180 DPRECEIVE_FROMPLAYER
| DPRECEIVE_TOPLAYER
,
5181 lpData
, &dwDataSize
);
5182 checkHR( DP_OK
, hr
);
5183 checkStr( message
, (LPSTR
) lpData
);
5185 check_messages( pDP
[0], dpid
, 4, &callbackData
);
5186 checkStr( "", callbackData
.szTrace1
);
5187 check_messages( pDP
[1], dpid
, 4, &callbackData
);
5188 checkStr( "", callbackData
.szTrace1
);
5191 hr
= IDirectPlayX_Send( pDP
[0], DPID_ALLPLAYERS
, dpid
[1],
5193 (LPVOID
) message
, messageSize
);
5194 checkHR( DPERR_INVALIDPLAYER
, hr
);
5195 hr
= IDirectPlayX_Send( pDP
[0], DPID_ALLPLAYERS
, DPID_ALLPLAYERS
,
5197 (LPVOID
) message
, messageSize
);
5198 checkHR( DPERR_INVALIDPLAYER
, hr
);
5202 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5204 (LPVOID
) message
, messageSize
);
5205 checkHR( DP_OK
, hr
);
5207 hr
= IDirectPlayX_Receive( pDP
[0], &dpid
[0], &dpid
[1],
5208 DPRECEIVE_FROMPLAYER
| DPRECEIVE_TOPLAYER
,
5209 lpData
, &dwDataSize
);
5210 checkHR( DP_OK
, hr
);
5211 checkStr( message
, (LPSTR
)lpData
);
5213 /* - Inorrect flags */
5214 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5216 (LPVOID
) message
, messageSize
);
5217 checkHR( DPERR_INVALIDPARAMS
, hr
);
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],
5223 DPSEND_ENCRYPTED
| DPSEND_SIGNED
,
5224 (LPVOID
) message
, messageSize
);
5225 checkHR( DPERR_INVALIDPARAMS
, hr
);
5227 /* - Correct flags, but session is not secure */
5228 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5229 DPSEND_ENCRYPTED
| DPSEND_GUARANTEED
,
5230 (LPVOID
) message
, messageSize
);
5231 checkHR( DPERR_INVALIDPARAMS
, hr
);
5232 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5233 DPSEND_SIGNED
| DPSEND_GUARANTEED
,
5234 (LPVOID
) message
, messageSize
);
5235 checkHR( DPERR_INVALIDPARAMS
, hr
);
5236 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5237 ( DPSEND_ENCRYPTED
|
5239 DPSEND_GUARANTEED
),
5240 (LPVOID
) message
, messageSize
);
5241 checkHR( DPERR_INVALIDPARAMS
, hr
);
5243 /* - Correct flags, secure session incorrectly opened (without flags) */
5244 hr
= IDirectPlayX_Close( pDP
[0] );
5245 checkHR( DP_OK
, hr
);
5248 hr
= IDirectPlayX_SecureOpen( pDP
[0], &dpsd
, DPOPEN_CREATE
, NULL
, NULL
);
5249 checkHR( DP_OK
, hr
);
5251 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[i
], NULL
, NULL
, NULL
, 0, 0 );
5253 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5254 DPSEND_ENCRYPTED
| DPSEND_GUARANTEED
,
5255 (LPVOID
) message
, messageSize
);
5256 checkHR( DPERR_INVALIDPARAMS
, hr
);
5257 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5258 DPSEND_SIGNED
| DPSEND_GUARANTEED
,
5259 (LPVOID
) message
, messageSize
);
5260 checkHR( DPERR_INVALIDPARAMS
, hr
);
5261 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5262 ( DPSEND_ENCRYPTED
|
5264 DPSEND_GUARANTEED
),
5265 (LPVOID
) message
, messageSize
);
5266 checkHR( DPERR_INVALIDPARAMS
, hr
);
5268 /* - Correct flags, secure session */
5269 hr
= IDirectPlayX_Close( pDP
[0] );
5270 checkHR( DP_OK
, hr
);
5272 dpsd
.dwFlags
= DPSESSION_SECURESERVER
;
5273 hr
= IDirectPlayX_SecureOpen( pDP
[0], &dpsd
, DPOPEN_CREATE
, NULL
, NULL
);
5274 checkHR( DP_OK
, hr
);
5275 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[0], NULL
, NULL
, NULL
, 0, 0 );
5276 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[1], NULL
, NULL
, NULL
, 0, 0 );
5279 check_messages( pDP
[0], dpid
, 6, &callbackData
);
5280 checkStr( "S0,", callbackData
.szTrace1
);
5283 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5284 DPSEND_ENCRYPTED
| DPSEND_GUARANTEED
,
5285 (LPVOID
) message
, messageSize
);
5286 checkHR( DP_OK
, hr
);
5287 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5288 DPSEND_SIGNED
| DPSEND_GUARANTEED
,
5289 (LPVOID
) message
, messageSize
);
5290 checkHR( DP_OK
, hr
);
5291 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5292 ( DPSEND_ENCRYPTED
|
5294 DPSEND_GUARANTEED
),
5295 (LPVOID
) message
, messageSize
);
5296 checkHR( DP_OK
, hr
);
5302 hr
= IDirectPlayX_Receive( pDP
[0], &idFrom
, &idTo
, 0, lpData
,
5305 lpDataSecure
= (LPDPMSG_SECUREMESSAGE
) lpData
;
5307 checkHR( DP_OK
, hr
);
5308 checkConv( DPSYS_SECUREMESSAGE
, lpData
->dwType
, dpMsgType2str
);
5309 check( DPID_SYSMSG
, idFrom
);
5310 check( dpid
[1], idTo
);
5311 check( dpid
[0], lpDataSecure
->dpIdFrom
);
5312 checkStr( message
, (LPSTR
) lpDataSecure
->lpData
);
5313 check( strlen(message
)+1, lpDataSecure
->dwDataSize
);
5318 checkFlags( DPSEND_ENCRYPTED
,
5319 lpDataSecure
->dwFlags
,
5323 checkFlags( DPSEND_SIGNED
,
5324 lpDataSecure
->dwFlags
,
5328 checkFlags( DPSEND_SIGNED
| DPSEND_ENCRYPTED
,
5329 lpDataSecure
->dwFlags
,
5335 check_messages( pDP
[0], dpid
, 4, &callbackData
);
5336 checkStr( "", callbackData
.szTrace1
);
5339 /* - Even in a secure session, incorrect flags still not working */
5340 hr
= IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1],
5342 (LPVOID
) message
, messageSize
);
5343 checkHR( DPERR_INVALIDPARAMS
, hr
);
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],
5349 DPSEND_ENCRYPTED
| DPSEND_SIGNED
,
5350 (LPVOID
) message
, messageSize
);
5351 checkHR( DPERR_INVALIDPARAMS
, hr
);
5354 HeapFree( GetProcessHeap(), 0, lpData
);
5355 IDirectPlayX_Release( pDP
[0] );
5356 IDirectPlayX_Release( pDP
[1] );
5362 static void test_Receive(void)
5366 DPSESSIONDESC2 dpsd
;
5367 DPID dpid
[4], idFrom
, idTo
;
5369 LPCSTR message
= "message";
5370 DWORD messageSize
= strlen(message
) + 1;
5371 DWORD dwDataSize
= 1024;
5372 LPDPMSG_GENERIC lpData
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
5374 LPDPMSG_CREATEPLAYERORGROUP lpDataCreate
;
5375 LPDPMSG_DESTROYPLAYERORGROUP lpDataDestroy
;
5381 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
5382 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
);
5383 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
5384 if (FAILED(hr
)) return;
5386 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
5387 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
5388 dpsd
.guidApplication
= appGuid
;
5390 init_TCPIP_provider( pDP
, "127.0.0.1", 0 );
5392 IDirectPlayX_Open( pDP
, &dpsd
, DPOPEN_CREATE
);
5395 /* Invalid parameters */
5396 hr
= IDirectPlayX_Receive( pDP
, NULL
, &idTo
, 0,
5397 lpData
, &dwDataSize
);
5398 todo_wine
checkHR( DPERR_INVALIDPARAMS
, hr
);
5400 if ( hr
== DPERR_UNINITIALIZED
)
5402 todo_wine
win_skip( "Receive not implemented\n" );
5406 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, NULL
, 0,
5407 lpData
, &dwDataSize
);
5408 checkHR( DPERR_INVALIDPARAMS
, hr
);
5409 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0,
5411 checkHR( DPERR_INVALIDPARAMS
, hr
);
5413 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0,
5414 lpData
, &dwDataSize
);
5415 checkHR( DPERR_INVALIDPARAMS
, hr
);
5417 /* No messages yet */
5418 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0,
5419 NULL
, &dwDataSize
);
5420 checkHR( DPERR_NOMESSAGES
, hr
);
5422 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0,
5423 lpData
, &dwDataSize
);
5424 checkHR( DPERR_NOMESSAGES
, hr
);
5427 IDirectPlayX_CreatePlayer( pDP
, &dpid
[0], NULL
, 0, NULL
, 0, 0 );
5428 IDirectPlayX_CreatePlayer( pDP
, &dpid
[1], NULL
, 0, NULL
, 0,
5429 DPPLAYER_SPECTATOR
);
5430 IDirectPlayX_CreatePlayer( pDP
, &dpid
[2], NULL
, 0, NULL
, 0, 0 );
5431 IDirectPlayX_CreatePlayer( pDP
, &dpid
[3], NULL
, 0, NULL
, 0, 0 );
5438 IDirectPlayX_GetMessageCount( pDP
, dpid
[i
], &dwCount
);
5439 check( 3-i
, dwCount
);
5443 IDirectPlayX_DestroyPlayer( pDP
, dpid
[3] );
5444 IDirectPlayX_DestroyPlayer( pDP
, dpid
[1] );
5449 IDirectPlayX_GetMessageCount( pDP
, dpid
[0], &dwCount
);
5450 check( 5, dwCount
);
5451 IDirectPlayX_GetMessageCount( pDP
, dpid
[1], &dwCount
);
5452 check( 5, dwCount
);
5453 IDirectPlayX_GetMessageCount( pDP
, dpid
[2], &dwCount
);
5454 check( 3, dwCount
);
5455 IDirectPlayX_GetMessageCount( pDP
, dpid
[3], &dwCount
);
5456 check( 3, dwCount
);
5459 /* Buffer too small */
5460 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idFrom
, 0,
5461 NULL
, &dwDataSize
);
5462 checkHR( DPERR_BUFFERTOOSMALL
, hr
);
5463 check( 48, dwDataSize
);
5465 hr
= IDirectPlayX_Receive( pDP
, &idTo
, &idFrom
, 0,
5466 lpData
, &dwDataSize
);
5467 checkHR( DPERR_BUFFERTOOSMALL
, hr
);
5468 check( 48, dwDataSize
);
5471 /* Checking the order or reception */
5472 for (i
=0; i
<11; i
++)
5475 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0,
5476 lpData
, &dwDataSize
);
5478 checkHR( DP_OK
, hr
);
5479 check( DPID_SYSMSG
, idFrom
);
5481 if (i
<6) /* Player creation */
5483 checkConv( DPSYS_CREATEPLAYERORGROUP
, lpData
->dwType
, dpMsgType2str
);
5484 check( 48, dwDataSize
);
5485 lpDataCreate
= (LPDPMSG_CREATEPLAYERORGROUP
) lpData
;
5486 check( DPPLAYERTYPE_PLAYER
, lpDataCreate
->dwPlayerType
);
5487 checkLP( NULL
, lpDataCreate
->lpData
);
5488 check( 0, lpDataCreate
->dwDataSize
);
5489 checkLP( NULL
, U1(lpDataCreate
->dpnName
).lpszShortNameA
);
5490 check( 0, lpDataCreate
->dpIdParent
);
5492 else /* Player destruction */
5494 checkConv( DPSYS_DESTROYPLAYERORGROUP
, lpData
->dwType
,
5496 check( 52, dwDataSize
);
5497 lpDataDestroy
= (LPDPMSG_DESTROYPLAYERORGROUP
) lpData
;
5498 check( DPPLAYERTYPE_PLAYER
, lpDataDestroy
->dwPlayerType
);
5499 checkLP( NULL
, lpDataDestroy
->lpLocalData
);
5500 check( 0, lpDataDestroy
->dwLocalDataSize
);
5501 checkLP( NULL
, lpDataDestroy
->lpRemoteData
);
5502 check( 0, lpDataDestroy
->dwRemoteDataSize
);
5503 checkLP( NULL
, U1(lpDataDestroy
->dpnName
).lpszShortNameA
);
5504 check( 0, lpDataDestroy
->dpIdParent
);
5511 lpDataCreate
= (LPDPMSG_CREATEPLAYERORGROUP
) lpData
;
5512 check( dpid
[0], idTo
);
5513 check( dpid
[1], lpDataCreate
->dpId
);
5514 check( 1, lpDataCreate
->dwCurrentPlayers
);
5515 checkFlags( DPPLAYER_LOCAL
|DPPLAYER_SPECTATOR
, lpDataCreate
->dwFlags
,
5516 FLAGS_DPPLAYER
|FLAGS_DPGROUP
);
5521 check( dpid
[1], idTo
);
5522 lpDataCreate
= (LPDPMSG_CREATEPLAYERORGROUP
) lpData
;
5523 check( dpid
[2], lpDataCreate
->dpId
);
5524 check( 2, lpDataCreate
->dwCurrentPlayers
);
5525 checkFlags( DPPLAYER_LOCAL
, lpDataCreate
->dwFlags
,
5526 FLAGS_DPPLAYER
| FLAGS_DPGROUP
);
5529 check( dpid
[0], idTo
);
5530 lpDataCreate
= (LPDPMSG_CREATEPLAYERORGROUP
) lpData
;
5531 check( dpid
[2], lpDataCreate
->dpId
);
5532 check( 2, lpDataCreate
->dwCurrentPlayers
);
5533 checkFlags( DPPLAYER_LOCAL
, lpDataCreate
->dwFlags
,
5534 FLAGS_DPPLAYER
| FLAGS_DPGROUP
);
5539 check( dpid
[2], idTo
);
5540 lpDataCreate
= (LPDPMSG_CREATEPLAYERORGROUP
) lpData
;
5541 check( dpid
[3], lpDataCreate
->dpId
);
5542 check( 3, lpDataCreate
->dwCurrentPlayers
);
5543 checkFlags( DPPLAYER_LOCAL
, lpDataCreate
->dwFlags
,
5544 FLAGS_DPPLAYER
| FLAGS_DPGROUP
);
5547 check( dpid
[1], idTo
);
5548 lpDataCreate
= (LPDPMSG_CREATEPLAYERORGROUP
) lpData
;
5549 check( dpid
[3], lpDataCreate
->dpId
);
5550 check( 3, lpDataCreate
->dwCurrentPlayers
);
5551 checkFlags( DPPLAYER_LOCAL
, lpDataCreate
->dwFlags
,
5552 FLAGS_DPPLAYER
| FLAGS_DPGROUP
);
5555 check( dpid
[0], idTo
);
5556 lpDataCreate
= (LPDPMSG_CREATEPLAYERORGROUP
) lpData
;
5557 check( dpid
[3], lpDataCreate
->dpId
);
5558 check( 3, lpDataCreate
->dwCurrentPlayers
);
5559 checkFlags( DPPLAYER_LOCAL
, lpDataCreate
->dwFlags
,
5560 FLAGS_DPPLAYER
| FLAGS_DPGROUP
);
5565 check( dpid
[2], idTo
);
5566 lpDataDestroy
= (LPDPMSG_DESTROYPLAYERORGROUP
) lpData
;
5567 check( dpid
[3], lpDataDestroy
->dpId
);
5568 checkFlags( DPPLAYER_LOCAL
, lpDataDestroy
->dwFlags
,
5569 FLAGS_DPPLAYER
| FLAGS_DPGROUP
);
5572 check( dpid
[1], idTo
);
5573 lpDataDestroy
= (LPDPMSG_DESTROYPLAYERORGROUP
) lpData
;
5574 check( dpid
[3], lpDataDestroy
->dpId
);
5575 checkFlags( DPPLAYER_LOCAL
, lpDataDestroy
->dwFlags
,
5576 FLAGS_DPPLAYER
| FLAGS_DPGROUP
);
5579 check( dpid
[0], idTo
);
5580 lpDataDestroy
= (LPDPMSG_DESTROYPLAYERORGROUP
) lpData
;
5581 check( dpid
[3], lpDataDestroy
->dpId
);
5582 checkFlags( DPPLAYER_LOCAL
, lpDataDestroy
->dwFlags
,
5583 FLAGS_DPPLAYER
| FLAGS_DPGROUP
);
5588 check( dpid
[2], idTo
);
5589 lpDataDestroy
= (LPDPMSG_DESTROYPLAYERORGROUP
) lpData
;
5590 check( dpid
[1], lpDataDestroy
->dpId
);
5591 checkFlags( DPPLAYER_LOCAL
|
5592 DPPLAYER_SPECTATOR
, lpDataDestroy
->dwFlags
,
5593 FLAGS_DPPLAYER
| FLAGS_DPGROUP
);
5596 check( dpid
[0], idTo
);
5597 lpDataDestroy
= (LPDPMSG_DESTROYPLAYERORGROUP
) lpData
;
5598 check( dpid
[1], lpDataDestroy
->dpId
);
5599 checkFlags( DPPLAYER_LOCAL
|
5600 DPPLAYER_SPECTATOR
, lpDataDestroy
->dwFlags
,
5601 FLAGS_DPPLAYER
| FLAGS_DPGROUP
);
5605 trace( "%s\n", dpMsgType2str(lpData
->dwType
) );
5610 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0, lpData
, &dwDataSize
);
5611 checkHR( DPERR_NOMESSAGES
, hr
);
5614 /* New data message */
5615 hr
= IDirectPlayX_Send( pDP
, dpid
[0], dpid
[2], 0,
5616 (LPVOID
) message
, messageSize
);
5617 checkHR( DP_OK
, hr
);
5620 /* Ensuring DPRECEIVE_PEEK doesn't remove the messages from the queue */
5621 for (i
=0; i
<10; i
++)
5623 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, DPRECEIVE_PEEK
,
5624 lpData
, &dwDataSize
);
5625 checkHR( DP_OK
, hr
);
5626 checkStr( message
, (LPSTR
) lpData
);
5629 /* Removing the message from the queue */
5630 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0, lpData
, &dwDataSize
);
5631 checkHR( DP_OK
, hr
);
5632 check( idFrom
, dpid
[0] );
5633 check( idTo
, dpid
[2] );
5634 checkStr( message
, (LPSTR
) lpData
);
5636 hr
= IDirectPlayX_Receive( pDP
, &idFrom
, &idTo
, 0, lpData
, &dwDataSize
);
5637 checkHR( DPERR_NOMESSAGES
, hr
);
5640 HeapFree( GetProcessHeap(), 0, lpData
);
5641 IDirectPlayX_Release( pDP
);
5645 /* GetMessageCount */
5647 static void test_GetMessageCount(void)
5650 IDirectPlay4
*pDP
[2];
5651 DPSESSIONDESC2 dpsd
;
5657 DWORD dwDataSize
= 1024;
5658 LPVOID lpData
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, dwDataSize
);
5659 CallbackData callbackData
;
5664 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
5665 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
5666 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
5667 if (FAILED(hr
)) return;
5669 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
5672 hr
= IDirectPlayX_GetMessageCount( pDP
[0], 0, &dwCount
);
5673 todo_wine
checkHR( DPERR_UNINITIALIZED
, hr
);
5674 check( -1, dwCount
);
5678 todo_wine
win_skip( "GetMessageCount not implemented\n" );
5683 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
5684 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
5688 hr
= IDirectPlayX_GetMessageCount( pDP
[0], 0, &dwCount
);
5689 checkHR( DP_OK
, hr
);
5690 check( 0, dwCount
);
5693 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
5694 dpsd
.guidApplication
= appGuid
;
5695 dpsd
.dwMaxPlayers
= 10;
5696 IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
5697 IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
5700 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[0], NULL
, NULL
, NULL
, 0, 0 );
5701 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[1], NULL
, NULL
, NULL
, 0, 0 );
5702 IDirectPlayX_CreatePlayer( pDP
[1], &dpid
[3], NULL
, NULL
, NULL
, 0, 0 );
5703 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[2], NULL
, NULL
, NULL
, 0, 0 );
5706 /* Incorrect parameters */
5708 hr
= IDirectPlayX_GetMessageCount( pDP
[0], dpid
[0], NULL
);
5709 checkHR( DPERR_INVALIDPARAMS
, hr
);
5710 check( -1, dwCount
);
5713 hr
= IDirectPlayX_GetMessageCount( pDP
[0], 0, NULL
);
5714 checkHR( DPERR_INVALIDPARAMS
, hr
);
5715 check( -1, dwCount
);
5718 hr
= IDirectPlayX_GetMessageCount( pDP
[0], -1, &dwCount
);
5719 checkHR( DPERR_INVALIDPLAYER
, hr
);
5720 check( -1, dwCount
);
5723 /* Correct parameters */
5724 /* Player creation messages */
5726 hr
= IDirectPlayX_GetMessageCount( pDP
[0], 0, &dwCount
);
5727 checkHR( DP_OK
, hr
);
5728 check( 5, dwCount
);
5731 hr
= IDirectPlayX_GetMessageCount( pDP
[1], 0, &dwCount
);
5732 checkHR( DP_OK
, hr
);
5733 check( 1, dwCount
);
5736 hr
= IDirectPlayX_GetMessageCount( pDP
[0], dpid
[0], &dwCount
);
5737 checkHR( DP_OK
, hr
);
5738 check( 3, dwCount
);
5741 hr
= IDirectPlayX_GetMessageCount( pDP
[0], dpid
[1], &dwCount
);
5742 checkHR( DP_OK
, hr
);
5743 check( 2, dwCount
);
5746 hr
= IDirectPlayX_GetMessageCount( pDP
[0], dpid
[3], &dwCount
);
5747 checkHR( DP_OK
, hr
);
5748 /* Remote player: doesn't throw error but result is 0 and not 1 */
5749 check( 0, dwCount
);
5752 hr
= IDirectPlayX_GetMessageCount( pDP
[1], dpid
[3], &dwCount
);
5753 checkHR( DP_OK
, hr
);
5754 check( 1, dwCount
);
5757 hr
= IDirectPlayX_GetMessageCount( pDP
[0], dpid
[1], &dwCount
);
5758 checkHR( DP_OK
, hr
);
5759 check( 2, dwCount
);
5763 check_messages( pDP
[0], dpid
, 6, &callbackData
);
5764 checkStr( "S0,S1,S0,S1,S0,", callbackData
.szTrace1
);
5765 check_messages( pDP
[1], dpid
, 6, &callbackData
);
5766 checkStr( "S3,", callbackData
.szTrace1
);
5769 /* Ensure queues is purged */
5771 hr
= IDirectPlayX_GetMessageCount( pDP
[0], 0, &dwCount
);
5772 checkHR( DP_OK
, hr
);
5773 check( 0, dwCount
);
5776 hr
= IDirectPlayX_GetMessageCount( pDP
[1], 0, &dwCount
);
5777 checkHR( DP_OK
, hr
);
5778 check( 0, dwCount
);
5781 /* Send data messages */
5783 IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1], 0, lpData
, dwDataSize
);
5785 IDirectPlayX_Send( pDP
[0], dpid
[1], dpid
[2], 0, lpData
, dwDataSize
);
5787 IDirectPlayX_Send( pDP
[0], dpid
[2], dpid
[3], 0, lpData
, dwDataSize
);
5790 /* Check all messages are in the queues */
5792 hr
= IDirectPlayX_GetMessageCount( pDP
[0], 0, &dwCount
);
5793 checkHR( DP_OK
, hr
);
5794 check( 11, dwCount
);
5797 hr
= IDirectPlayX_GetMessageCount( pDP
[1], 0, &dwCount
);
5798 checkHR( DP_OK
, hr
);
5799 check( 7, dwCount
);
5802 hr
= IDirectPlayX_GetMessageCount( pDP
[0], dpid
[0], &dwCount
);
5803 checkHR( DP_OK
, hr
);
5804 check( 0, dwCount
);
5807 hr
= IDirectPlayX_GetMessageCount( pDP
[0], dpid
[1], &dwCount
);
5808 checkHR( DP_OK
, hr
);
5809 check( 5, dwCount
);
5812 hr
= IDirectPlayX_GetMessageCount( pDP
[0], dpid
[2], &dwCount
);
5813 checkHR( DP_OK
, hr
);
5814 check( 6, dwCount
);
5817 hr
= IDirectPlayX_GetMessageCount( pDP
[1], dpid
[3], &dwCount
);
5818 checkHR( DP_OK
, hr
);
5819 check( 7, dwCount
);
5822 /* Purge queues again */
5823 check_messages( pDP
[0], dpid
, 6, &callbackData
);
5824 checkStr( "01,01,01,01,01,"
5825 "12,12,12,12,12,12,", callbackData
.szTrace1
);
5826 check_messages( pDP
[1], dpid
, 6, &callbackData
);
5827 checkStr( "23,23,23,23,23,23,23,", callbackData
.szTrace1
);
5830 /* Check queues are purged */
5832 hr
= IDirectPlayX_GetMessageCount( pDP
[0], 0, &dwCount
);
5833 checkHR( DP_OK
, hr
);
5834 check( 0, dwCount
);
5837 hr
= IDirectPlayX_GetMessageCount( pDP
[1], 0, &dwCount
);
5838 checkHR( DP_OK
, hr
);
5839 check( 0, dwCount
);
5842 hr
= IDirectPlayX_GetMessageCount( pDP
[0], dpid
[0], &dwCount
);
5843 checkHR( DP_OK
, hr
);
5844 check( 0, dwCount
);
5847 hr
= IDirectPlayX_GetMessageCount( pDP
[0], dpid
[1], &dwCount
);
5848 checkHR( DP_OK
, hr
);
5849 check( 0, dwCount
);
5852 hr
= IDirectPlayX_GetMessageCount( pDP
[0], dpid
[2], &dwCount
);
5853 checkHR( DP_OK
, hr
);
5854 check( 0, dwCount
);
5857 hr
= IDirectPlayX_GetMessageCount( pDP
[1], dpid
[3], &dwCount
);
5858 checkHR( DP_OK
, hr
);
5859 check( 0, dwCount
);
5862 HeapFree( GetProcessHeap(), 0, lpData
);
5863 IDirectPlayX_Release( pDP
[0] );
5864 IDirectPlayX_Release( pDP
[1] );
5868 /* GetMessageQueue */
5870 static void test_GetMessageQueue(void)
5873 IDirectPlay4
*pDP
[2];
5874 DPSESSIONDESC2 dpsd
;
5876 CallbackData callbackData
;
5879 DWORD dwNumMsgs
, dwNumBytes
;
5881 DWORD dwDataSize
= 1024;
5882 LPVOID lpData
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, dwDataSize
);
5887 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
5888 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
5889 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
5890 if (FAILED(hr
)) return;
5892 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
5895 dwNumMsgs
= dwNumBytes
= -1;
5896 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], 0, 0, 0,
5897 &dwNumMsgs
, &dwNumBytes
);
5898 todo_wine
checkHR( DPERR_UNINITIALIZED
, hr
);
5899 check( -1, dwNumMsgs
);
5900 check( -1, dwNumBytes
);
5904 todo_wine
win_skip( "GetMessageQueue not implemented\n" );
5909 init_TCPIP_provider( pDP
[0], "127.0.0.1", 0 );
5910 init_TCPIP_provider( pDP
[1], "127.0.0.1", 0 );
5913 dwNumMsgs
= dwNumBytes
= -1;
5914 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], 0, 0, 0,
5915 &dwNumMsgs
, &dwNumBytes
);
5916 checkHR( DP_OK
, hr
);
5917 check( 0, dwNumMsgs
);
5918 check( 0, dwNumBytes
);
5921 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
5922 dpsd
.guidApplication
= appGuid
;
5923 dpsd
.dwMaxPlayers
= 10;
5924 IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
5925 IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
5928 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[0], NULL
, NULL
, NULL
, 0, 0 );
5929 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[1], NULL
, NULL
, NULL
, 0, 0 );
5930 IDirectPlayX_CreatePlayer( pDP
[1], &dpid
[3], NULL
, NULL
, NULL
, 0, 0 );
5931 IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[2], NULL
, NULL
, NULL
, 0, 0 );
5935 /* Incorrect parameters */
5936 dwNumMsgs
= dwNumBytes
= -1;
5937 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], -1, dpid
[1],
5939 &dwNumMsgs
, &dwNumBytes
);
5940 checkHR( DPERR_INVALIDPLAYER
, hr
);
5941 check( -1, dwNumMsgs
);
5942 check( -1, dwNumBytes
);
5944 dwNumMsgs
= dwNumBytes
= -1;
5945 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], -1,
5947 &dwNumMsgs
, &dwNumBytes
);
5948 checkHR( DPERR_INVALIDPLAYER
, hr
);
5949 check( -1, dwNumMsgs
);
5950 check( -1, dwNumBytes
);
5952 dwNumMsgs
= dwNumBytes
= -1;
5953 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], dpid
[0],
5955 &dwNumMsgs
, &dwNumBytes
);
5956 checkHR( DPERR_INVALIDFLAGS
, hr
);
5957 check( -1, dwNumMsgs
);
5958 check( -1, dwNumBytes
);
5960 dwNumMsgs
= dwNumBytes
= -1;
5961 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], dpid
[1],
5962 ( DPMESSAGEQUEUE_SEND
|
5963 DPMESSAGEQUEUE_RECEIVE
),
5964 &dwNumMsgs
, &dwNumBytes
);
5965 checkHR( DPERR_INVALIDFLAGS
, hr
);
5966 check( -1, dwNumMsgs
);
5967 check( -1, dwNumBytes
);
5969 /* - Remote players */
5972 /* Crash under Win7 */
5973 dwNumMsgs
= dwNumBytes
= -1;
5974 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], 0, dpid
[3],
5975 DPMESSAGEQUEUE_RECEIVE
,
5976 &dwNumMsgs
, &dwNumBytes
);
5977 checkHR( DPERR_INVALIDPLAYER
, hr
); /* Player 3 is remote */
5978 check( -1, dwNumMsgs
);
5979 check( -1, dwNumBytes
);
5982 dwNumMsgs
= dwNumBytes
= -1;
5983 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[3], 0,
5984 DPMESSAGEQUEUE_SEND
,
5985 &dwNumMsgs
, &dwNumBytes
);
5986 checkHR( DPERR_INVALIDPLAYER
, hr
); /* Player 3 is remote */
5987 check( -1, dwNumMsgs
);
5988 check( -1, dwNumBytes
);
5990 /* - Remote players, this time in the right place */
5991 dwNumMsgs
= dwNumBytes
= -1;
5992 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], 0, dpid
[3],
5993 DPMESSAGEQUEUE_SEND
,
5994 &dwNumMsgs
, &dwNumBytes
);
5995 checkHR( DP_OK
, hr
);
5996 check( 0, dwNumMsgs
);
5997 check( 0, dwNumBytes
);
5999 dwNumMsgs
= dwNumBytes
= -1;
6000 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[3], 0,
6001 DPMESSAGEQUEUE_RECEIVE
,
6002 &dwNumMsgs
, &dwNumBytes
);
6003 checkHR( DP_OK
, hr
);
6004 check( 0, dwNumMsgs
);
6005 check( 0, dwNumBytes
);
6008 /* Correct parameters */
6009 dwNumMsgs
= dwNumBytes
= -1;
6010 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], 0, dpid
[1],
6011 DPMESSAGEQUEUE_RECEIVE
,
6012 &dwNumMsgs
, &dwNumBytes
);
6013 checkHR( DP_OK
, hr
);
6014 check( 2, dwNumMsgs
);
6015 check( 96, dwNumBytes
);
6017 dwNumMsgs
= dwNumBytes
= -1;
6018 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], 0,
6019 DPMESSAGEQUEUE_RECEIVE
,
6020 &dwNumMsgs
, &dwNumBytes
);
6021 checkHR( DP_OK
, hr
);
6022 check( 0, dwNumMsgs
);
6023 check( 0, dwNumBytes
);
6025 dwNumMsgs
= dwNumBytes
= -1;
6026 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], 0, 0,
6027 DPMESSAGEQUEUE_RECEIVE
,
6028 &dwNumMsgs
, &dwNumBytes
);
6029 checkHR( DP_OK
, hr
);
6030 check( 5, dwNumMsgs
);
6031 check( 240, dwNumBytes
);
6033 dwNumMsgs
= dwNumBytes
= -1;
6034 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], dpid
[1],
6035 DPMESSAGEQUEUE_RECEIVE
,
6036 NULL
, &dwNumBytes
);
6037 checkHR( DP_OK
, hr
);
6038 check( -1, dwNumMsgs
);
6039 check( 0, dwNumBytes
);
6041 dwNumMsgs
= dwNumBytes
= -1;
6042 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], dpid
[1],
6043 DPMESSAGEQUEUE_RECEIVE
,
6045 checkHR( DP_OK
, hr
);
6046 check( 0, dwNumMsgs
);
6047 check( -1, dwNumBytes
);
6049 dwNumMsgs
= dwNumBytes
= -1;
6050 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], dpid
[1],
6051 DPMESSAGEQUEUE_RECEIVE
,
6053 checkHR( DP_OK
, hr
);
6054 check( -1, dwNumMsgs
);
6055 check( -1, dwNumBytes
);
6057 dwNumMsgs
= dwNumBytes
= -1;
6058 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], dpid
[1],
6059 DPMESSAGEQUEUE_RECEIVE
,
6060 &dwNumMsgs
, &dwNumBytes
);
6061 checkHR( DP_OK
, hr
);
6062 check( 0, dwNumMsgs
);
6063 check( 0, dwNumBytes
);
6066 /* Purge messages */
6067 check_messages( pDP
[0], dpid
, 6, &callbackData
);
6068 checkStr( "S0,S1,S0,S1,S0,", callbackData
.szTrace1
);
6069 check_messages( pDP
[1], dpid
, 6, &callbackData
);
6070 checkStr( "S3,", callbackData
.szTrace1
);
6072 /* Check queues are empty */
6073 dwNumMsgs
= dwNumBytes
= -1;
6074 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], 0, 0,
6075 DPMESSAGEQUEUE_RECEIVE
,
6076 &dwNumMsgs
, &dwNumBytes
);
6077 checkHR( DP_OK
, hr
);
6078 check( 0, dwNumMsgs
);
6079 check( 0, dwNumBytes
);
6082 /* Sending 4 data messages from 0 to 1 */
6086 IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[1], 0, lpData
, dwDataSize
);
6088 IDirectPlayX_Send( pDP
[0], dpid
[0], dpid
[3], 0, lpData
, dwDataSize
);
6090 IDirectPlayX_Send( pDP
[0], dpid
[1], dpid
[3], 0, lpData
, dwDataSize
);
6093 dwNumMsgs
= dwNumBytes
= -1;
6094 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], dpid
[1],
6095 DPMESSAGEQUEUE_RECEIVE
,
6096 &dwNumMsgs
, &dwNumBytes
);
6097 checkHR( DP_OK
, hr
);
6098 check( 4, dwNumMsgs
);
6099 check( 4*dwDataSize
, dwNumBytes
);
6101 dwNumMsgs
= dwNumBytes
= -1;
6102 hr
= IDirectPlayX_GetMessageQueue( pDP
[1], dpid
[0], dpid
[3],
6103 DPMESSAGEQUEUE_RECEIVE
,
6104 &dwNumMsgs
, &dwNumBytes
);
6105 checkHR( DP_OK
, hr
);
6106 check( 3, dwNumMsgs
);
6107 check( 3*dwDataSize
, dwNumBytes
);
6109 dwNumMsgs
= dwNumBytes
= -1;
6110 hr
= IDirectPlayX_GetMessageQueue( pDP
[1], dpid
[1], dpid
[3],
6111 DPMESSAGEQUEUE_RECEIVE
,
6112 &dwNumMsgs
, &dwNumBytes
);
6113 checkHR( DP_OK
, hr
);
6114 check( 2, dwNumMsgs
);
6115 check( 2*dwDataSize
, dwNumBytes
);
6117 dwNumMsgs
= dwNumBytes
= -1;
6118 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], 0,
6119 DPMESSAGEQUEUE_RECEIVE
,
6120 &dwNumMsgs
, &dwNumBytes
);
6121 checkHR( DP_OK
, hr
);
6122 check( 4, dwNumMsgs
);
6123 check( 4*dwDataSize
, dwNumBytes
);
6125 dwNumMsgs
= dwNumBytes
= -1;
6126 hr
= IDirectPlayX_GetMessageQueue( pDP
[1], dpid
[0], 0,
6127 DPMESSAGEQUEUE_RECEIVE
,
6128 &dwNumMsgs
, &dwNumBytes
);
6129 checkHR( DP_OK
, hr
);
6130 check( 3, dwNumMsgs
);
6131 check( 3*dwDataSize
, dwNumBytes
);
6133 dwNumMsgs
= dwNumBytes
= -1;
6134 hr
= IDirectPlayX_GetMessageQueue( pDP
[1], 0, dpid
[3],
6135 DPMESSAGEQUEUE_RECEIVE
,
6136 &dwNumMsgs
, &dwNumBytes
);
6137 checkHR( DP_OK
, hr
);
6138 check( 5, dwNumMsgs
);
6139 check( 5*dwDataSize
, dwNumBytes
);
6141 dwNumMsgs
= dwNumBytes
= -1;
6142 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], 0, 0,
6143 DPMESSAGEQUEUE_RECEIVE
,
6144 &dwNumMsgs
, &dwNumBytes
);
6145 checkHR( DP_OK
, hr
);
6146 check( 4, dwNumMsgs
);
6147 check( 4*dwDataSize
, dwNumBytes
);
6149 dwNumMsgs
= dwNumBytes
= -1;
6150 hr
= IDirectPlayX_GetMessageQueue( pDP
[1], 0, 0,
6151 DPMESSAGEQUEUE_RECEIVE
,
6152 &dwNumMsgs
, &dwNumBytes
);
6153 checkHR( DP_OK
, hr
);
6154 check( 5, dwNumMsgs
);
6155 check( 5*dwDataSize
, dwNumBytes
);
6158 dwNumMsgs
= dwNumBytes
= -1;
6159 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], dpid
[1],
6160 DPMESSAGEQUEUE_SEND
,
6161 &dwNumMsgs
, &dwNumBytes
);
6162 checkHR( DP_OK
, hr
);
6163 check( 0, dwNumMsgs
);
6164 check( 0, dwNumBytes
);
6166 dwNumMsgs
= dwNumBytes
= -1;
6167 hr
= IDirectPlayX_GetMessageQueue( pDP
[0], dpid
[0], dpid
[1],
6169 &dwNumMsgs
, &dwNumBytes
);
6170 checkHR( DP_OK
, hr
);
6171 check( 0, dwNumMsgs
);
6172 check( 0, dwNumBytes
);
6175 HeapFree( GetProcessHeap(), 0, lpData
);
6176 IDirectPlayX_Release( pDP
[0] );
6177 IDirectPlayX_Release( pDP
[1] );
6181 /* Remote data replication */
6183 static void test_remote_data_replication(void)
6186 IDirectPlay4
*pDP
[2];
6187 DPSESSIONDESC2 dpsd
;
6188 DPID dpid
[2], idFrom
, idTo
;
6189 CallbackData callbackData
;
6192 DWORD dwFlags
, dwDataSize
= 1024;
6195 LPDPMSG_SETPLAYERORGROUPDATA lpData
= HeapAlloc( GetProcessHeap(),
6199 LPCSTR lpDataLocal
[] = { "local_0", "local_1" };
6200 LPCSTR lpDataRemote
[] = { "remote_0", "remote_1" };
6201 LPCSTR lpDataFake
= "ugly_fake_data";
6202 LPSTR lpDataGet
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, 32 );
6203 DWORD dwDataSizeLocal
= strlen(lpDataLocal
[0])+1,
6204 dwDataSizeRemote
= strlen(lpDataRemote
[0])+1,
6205 dwDataSizeFake
= strlen(lpDataFake
)+1,
6211 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
6212 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
6213 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
6214 if (FAILED(hr
)) return;
6215 init_TCPIP_provider( pDP
[i
], "127.0.0.1", 0 );
6217 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
6218 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
6219 dpsd
.guidApplication
= appGuid
;
6222 hr
= IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
6223 todo_wine
checkHR( DP_OK
, hr
);
6225 if ( hr
== DPERR_UNINITIALIZED
)
6227 todo_wine
win_skip( "dplay not implemented enough for this test yet\n" );
6231 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[0],
6232 NULL
, NULL
, NULL
, 0, 0 );
6233 checkHR( DP_OK
, hr
);
6236 hr
= IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
6238 checkHR( DP_OK
, hr
);
6240 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &dpid
[1],
6241 NULL
, NULL
, NULL
, 0, 0 );
6242 checkHR( DP_OK
, hr
);
6247 /* Local (0,0) (1,1) */
6248 IDirectPlayX_GetPlayerFlags( pDP
[i
], dpid
[i
], &dwFlags
);
6249 checkFlags( DPPLAYER_LOCAL
, dwFlags
, FLAGS_DPPLAYER
);
6250 /* Remote (0,1) (1,0) */
6251 IDirectPlayX_GetPlayerFlags( pDP
[i
], dpid
[!i
], &dwFlags
);
6252 checkFlags( 0, dwFlags
, FLAGS_DPPLAYER
);
6255 /* Set data for a local player */
6258 hr
= IDirectPlayX_SetPlayerData( pDP
[i
], dpid
[i
],
6259 (LPVOID
) lpDataLocal
[i
],
6262 checkHR( DP_OK
, hr
);
6263 hr
= IDirectPlayX_SetPlayerData( pDP
[i
], dpid
[i
],
6264 (LPVOID
) lpDataRemote
[i
],
6267 checkHR( DP_OK
, hr
);
6270 /* Retrieve data locally (0->0, 1->1) */
6273 dwDataSizeGet
= dwDataSizeFake
;
6274 strcpy( lpDataGet
, lpDataFake
);
6275 hr
= IDirectPlayX_GetPlayerData( pDP
[i
], dpid
[i
],
6276 lpDataGet
, &dwDataSizeGet
,
6278 checkHR( DP_OK
, hr
);
6279 check( dwDataSizeLocal
, dwDataSizeGet
);
6280 checkStr( lpDataLocal
[i
], lpDataGet
);
6282 dwDataSizeGet
= dwDataSizeFake
;
6283 strcpy( lpDataGet
, lpDataFake
);
6284 hr
= IDirectPlayX_GetPlayerData( pDP
[i
], dpid
[i
],
6285 lpDataGet
, &dwDataSizeGet
,
6287 checkHR( DP_OK
, hr
);
6288 check( dwDataSizeRemote
, dwDataSizeGet
);
6289 checkStr( lpDataRemote
[i
], lpDataGet
);
6293 /* Set data for a remote player */
6294 /* This should fail with DPERR_ACCESSDENIED,
6295 but for some reason it doesn't */
6298 IDirectPlayX_SetPlayerData( pDP
[i
], dpid
[!i
],
6299 (LPVOID
) lpDataLocal
[!i
],
6302 checkHR( DP_OK
, hr
);
6303 IDirectPlayX_SetPlayerData( pDP
[i
], dpid
[!i
],
6304 (LPVOID
) lpDataRemote
[!i
],
6307 checkHR( DP_OK
, hr
);
6310 /* Retrieve crossed data (0->1, 1->0) */
6313 dwDataSizeGet
= dwDataSizeFake
;
6314 strcpy( lpDataGet
, lpDataFake
);
6315 hr
= IDirectPlayX_GetPlayerData( pDP
[i
], dpid
[!i
],
6316 lpDataGet
, &dwDataSizeGet
,
6318 checkHR( DP_OK
, hr
);
6319 check( dwDataSizeLocal
, dwDataSizeGet
);
6320 checkStr( lpDataLocal
[!i
], lpDataGet
);
6322 dwDataSizeGet
= dwDataSizeFake
;
6323 strcpy( lpDataGet
, lpDataFake
);
6324 hr
= IDirectPlayX_GetPlayerData( pDP
[i
], dpid
[!i
],
6325 lpDataGet
, &dwDataSizeGet
,
6327 checkHR( DP_OK
, hr
);
6328 check( dwDataSizeRemote
, dwDataSizeGet
);
6329 checkStr( lpDataRemote
[!i
], lpDataGet
);
6333 /* Purge "new player" messages from queue */
6334 hr
= IDirectPlayX_Receive( pDP
[0], &idFrom
, &idTo
, 0, lpData
, &dwDataSize
);
6335 checkHR( DP_OK
, hr
);
6336 checkConv( DPSYS_CREATEPLAYERORGROUP
, lpData
->dwType
, dpMsgType2str
);
6338 /* Check number of messages in queue */
6341 IDirectPlayX_GetMessageCount( pDP
[i
], dpid
[i
], &dwCount
);
6342 check( 2, dwCount
);
6343 IDirectPlayX_GetMessageCount( pDP
[i
], dpid
[!i
], &dwCount
);
6344 check( 0, dwCount
);
6347 /* Checking system messages */
6352 hr
= IDirectPlayX_Receive( pDP
[i
], &idFrom
, &idTo
, 0, lpData
,
6354 checkHR( DP_OK
, hr
);
6355 check( 29, dwDataSize
);
6356 check( DPID_SYSMSG
, idFrom
);
6357 check( dpid
[i
], idTo
);
6358 checkConv( DPSYS_SETPLAYERORGROUPDATA
, lpData
->dwType
,
6360 check( DPPLAYERTYPE_PLAYER
, lpData
->dwPlayerType
);
6361 check( dpid
[j
], lpData
->dpId
);
6362 checkStr( lpDataRemote
[j
], (LPSTR
) lpData
->lpData
);
6363 check( dwDataSizeRemote
, lpData
->dwDataSize
);
6366 hr
= IDirectPlayX_Receive( pDP
[i
], &idFrom
, &idTo
, 0,
6367 lpData
, &dwDataSize
);
6368 checkHR( DPERR_NOMESSAGES
, hr
);
6372 /* Changing remote data */
6373 hr
= IDirectPlayX_SetPlayerData( pDP
[0], dpid
[0],
6374 (LPVOID
) lpDataRemote
[0], dwDataSizeRemote
,
6376 checkHR( DP_OK
, hr
);
6378 /* Checking system messages (j=0) */
6381 hr
= IDirectPlayX_Receive( pDP
[i
], &idFrom
, &idTo
, 0,
6382 lpData
, &dwDataSize
);
6383 checkHR( DP_OK
, hr
);
6384 check( 29, dwDataSize
);
6385 check( DPID_SYSMSG
, idFrom
);
6386 check( dpid
[i
], idTo
);
6387 checkConv( DPSYS_SETPLAYERORGROUPDATA
, lpData
->dwType
, dpMsgType2str
);
6388 check( DPPLAYERTYPE_PLAYER
, lpData
->dwPlayerType
);
6389 check( dpid
[0], lpData
->dpId
);
6390 checkStr( lpDataRemote
[0], (LPSTR
) lpData
->lpData
);
6391 check( dwDataSizeRemote
, lpData
->dwDataSize
);
6395 /* Queue is empty */
6396 check_messages( pDP
[0], dpid
, 2, &callbackData
);
6397 checkStr( "", callbackData
.szTrace1
);
6398 check_messages( pDP
[1], dpid
, 2, &callbackData
);
6399 checkStr( "", callbackData
.szTrace1
);
6402 HeapFree( GetProcessHeap(), 0, lpDataGet
);
6403 HeapFree( GetProcessHeap(), 0, lpData
);
6404 IDirectPlayX_Release( pDP
[0] );
6405 IDirectPlayX_Release( pDP
[1] );
6409 /* Host migration */
6411 static void test_host_migration(void)
6414 IDirectPlay4
*pDP
[2];
6415 DPSESSIONDESC2 dpsd
;
6416 DPID dpid
[2], idFrom
, idTo
;
6421 DWORD dwDataSize
= 1024;
6422 LPDPMSG_DESTROYPLAYERORGROUP lpData
= HeapAlloc( GetProcessHeap(),
6429 hr
= CoCreateInstance( &CLSID_DirectPlay
, NULL
, CLSCTX_ALL
,
6430 &IID_IDirectPlay4A
, (LPVOID
*) &pDP
[i
] );
6431 ok( SUCCEEDED(hr
), "CCI of CLSID_DirectPlay / IID_IDirectPlay4A failed\n" );
6432 if (FAILED(hr
)) return;
6433 init_TCPIP_provider( pDP
[i
], "127.0.0.1", 0 );
6435 ZeroMemory( &dpsd
, sizeof(DPSESSIONDESC2
) );
6436 dpsd
.dwSize
= sizeof(DPSESSIONDESC2
);
6437 dpsd
.guidApplication
= appGuid
;
6438 dpsd
.dwMaxPlayers
= 10;
6439 dpsd
.dwFlags
= DPSESSION_MIGRATEHOST
;
6442 hr
= IDirectPlayX_Open( pDP
[0], &dpsd
, DPOPEN_CREATE
);
6443 todo_wine
checkHR( DP_OK
, hr
);
6447 todo_wine
win_skip( "dplay not implemented enough for this test yet\n" );
6451 hr
= IDirectPlayX_CreatePlayer( pDP
[0], &dpid
[0], NULL
, NULL
, NULL
, 0, 0 );
6452 checkHR( DP_OK
, hr
);
6455 hr
= IDirectPlayX_EnumSessions( pDP
[1], &dpsd
, 0, EnumSessions_cb_join
,
6457 checkHR( DP_OK
, hr
);
6459 hr
= IDirectPlayX_CreatePlayer( pDP
[1], &dpid
[1], NULL
, NULL
, NULL
, 0, 0 );
6460 checkHR( DP_OK
, hr
);
6463 /* Host: One message in queue */
6464 IDirectPlayX_GetMessageCount( pDP
[0], dpid
[0], &dwCount
);
6465 check( 1, dwCount
);
6467 hr
= IDirectPlayX_Receive( pDP
[0], &idFrom
, &idTo
, DPRECEIVE_PEEK
,
6468 lpData
, &dwDataSize
);
6469 checkHR( DP_OK
, hr
);
6470 checkConv( DPSYS_CREATEPLAYERORGROUP
, lpData
->dwType
, dpMsgType2str
);
6472 /* Peer: No messages */
6473 IDirectPlayX_GetMessageCount( pDP
[1], dpid
[1], &dwCount
);
6474 check( 0, dwCount
);
6475 hr
= IDirectPlayX_Receive( pDP
[1], &idFrom
, &idTo
, DPRECEIVE_PEEK
,
6476 lpData
, &dwDataSize
);
6477 checkHR( DPERR_NOMESSAGES
, hr
);
6481 IDirectPlayX_Close( pDP
[0] );
6484 /* Host: Queue is cleaned */
6485 IDirectPlayX_GetMessageCount( pDP
[0], dpid
[0], &dwCount
);
6486 check( 0, dwCount
);
6487 hr
= IDirectPlayX_Receive( pDP
[0], &idFrom
, &idTo
, DPRECEIVE_PEEK
,
6488 lpData
, &dwDataSize
);
6489 checkHR( DPERR_NOMESSAGES
, hr
);
6491 /* Peer: gets message of player destruction */
6492 IDirectPlayX_GetMessageCount( pDP
[1], dpid
[1], &dwCount
);
6493 check( 2, dwCount
);
6495 hr
= IDirectPlayX_Receive( pDP
[1], &idFrom
, &idTo
, DPRECEIVE_PEEK
,
6496 lpData
, &dwDataSize
);
6497 checkHR( DP_OK
, hr
);
6498 checkConv( DPSYS_DESTROYPLAYERORGROUP
, lpData
->dwType
, dpMsgType2str
);
6501 /* Message analysis */
6504 hr
= IDirectPlayX_Receive( pDP
[1], &idFrom
, &idTo
, 0,
6505 lpData
, &dwDataSize
);
6506 checkHR( DP_OK
, hr
);
6507 check( DPID_SYSMSG
, idFrom
);
6508 check( dpid
[1], idTo
); /* Peer player id */
6512 checkConv( DPSYS_DESTROYPLAYERORGROUP
, lpData
->dwType
,
6514 check( DPPLAYERTYPE_PLAYER
, lpData
->dwPlayerType
);
6515 check( dpid
[0], lpData
->dpId
); /* Host player id */
6516 checkLP( NULL
, lpData
->lpLocalData
);
6517 check( 0, lpData
->dwLocalDataSize
);
6518 checkLP( NULL
, lpData
->lpRemoteData
);
6519 check( 0, lpData
->dwRemoteDataSize
);
6520 checkLP( NULL
, U1(lpData
->dpnName
).lpszShortNameA
);
6521 check( 0, lpData
->dpIdParent
);
6522 checkFlags( 0, lpData
->dwFlags
,
6523 FLAGS_DPPLAYER
| FLAGS_DPGROUP
);
6526 checkConv( DPSYS_HOST
, lpData
->dwType
, dpMsgType2str
);
6533 hr
= IDirectPlayX_Receive( pDP
[1], &idFrom
, &idTo
, 0, lpData
, &dwDataSize
);
6534 checkHR( DPERR_NOMESSAGES
, hr
);
6537 HeapFree( GetProcessHeap(), 0, lpData
);
6538 IDirectPlayX_Release( pDP
[0] );
6539 IDirectPlayX_Release( pDP
[1] );
6543 static void test_COM(void)
6546 IDirectPlay2A
*dp2A
;
6548 IDirectPlay3A
*dp3A
;
6550 IDirectPlay4A
*dp4A
;
6551 IDirectPlay4
*dp4
= (IDirectPlay4
*)0xdeadbeef;
6556 /* COM aggregation */
6557 hr
= CoCreateInstance(&CLSID_DirectPlay
, (IUnknown
*)0xdeadbeef, CLSCTX_INPROC_SERVER
,
6558 &IID_IUnknown
, (void**)&dp4
);
6559 ok(hr
== CLASS_E_NOAGGREGATION
|| broken(hr
== E_INVALIDARG
),
6560 "DirectPlay create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr
);
6561 ok(!dp4
|| dp4
== (IDirectPlay4
*)0xdeadbeef, "dp4 = %p\n", dp4
);
6564 hr
= CoCreateInstance(&CLSID_DirectPlay
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectPlayLobby
,
6566 ok(hr
== E_NOINTERFACE
, "DirectPlay create failed: %08x, expected E_NOINTERFACE\n", hr
);
6568 /* Different refcount for all DirectPlay Interfaces */
6569 hr
= CoCreateInstance(&CLSID_DirectPlay
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectPlay4
,
6571 ok(hr
== S_OK
, "DirectPlay create failed: %08x, expected S_OK\n", hr
);
6572 refcount
= IDirectPlayX_AddRef(dp4
);
6573 ok(refcount
== 2, "refcount == %u, expected 2\n", refcount
);
6575 hr
= IDirectPlayX_QueryInterface(dp4
, &IID_IDirectPlay2A
, (void**)&dp2A
);
6576 ok(hr
== S_OK
, "QueryInterface for IID_IDirectPlay2A failed: %08x\n", hr
);
6577 refcount
= IDirectPlay2_AddRef(dp2A
);
6578 ok(refcount
== 2, "refcount == %u, expected 2\n", refcount
);
6579 IDirectPlay2_Release(dp2A
);
6581 hr
= IDirectPlayX_QueryInterface(dp4
, &IID_IDirectPlay2
, (void**)&dp2
);
6582 ok(hr
== S_OK
, "QueryInterface for IID_IDirectPlay2 failed: %08x\n", hr
);
6583 refcount
= IDirectPlay2_AddRef(dp2
);
6584 ok(refcount
== 2, "refcount == %u, expected 2\n", refcount
);
6585 IDirectPlay2_Release(dp2
);
6587 hr
= IDirectPlayX_QueryInterface(dp4
, &IID_IDirectPlay3A
, (void**)&dp3A
);
6588 ok(hr
== S_OK
, "QueryInterface for IID_IDirectPlay3A failed: %08x\n", hr
);
6589 refcount
= IDirectPlay3_AddRef(dp3A
);
6590 ok(refcount
== 2, "refcount == %u, expected 2\n", refcount
);
6591 IDirectPlay3_Release(dp3A
);
6593 hr
= IDirectPlayX_QueryInterface(dp4
, &IID_IDirectPlay3
, (void**)&dp3
);
6594 ok(hr
== S_OK
, "QueryInterface for IID_IDirectPlay3 failed: %08x\n", hr
);
6595 refcount
= IDirectPlay3_AddRef(dp3
);
6596 ok(refcount
== 2, "refcount == %u, expected 2\n", refcount
);
6597 IDirectPlay3_Release(dp3
);
6599 hr
= IDirectPlayX_QueryInterface(dp4
, &IID_IDirectPlay4A
, (void**)&dp4A
);
6600 ok(hr
== S_OK
, "QueryInterface for IID_IDirectPlay4A failed: %08x\n", hr
);
6601 refcount
= IDirectPlayX_AddRef(dp4A
);
6602 ok(refcount
== 2, "refcount == %u, expected 2\n", refcount
);
6603 IDirectPlayX_Release(dp4A
);
6605 /* IDirectPlay and IUnknown share a refcount */
6606 hr
= IDirectPlayX_QueryInterface(dp4
, &IID_IDirectPlay
, (void**)&dp
);
6607 ok(hr
== S_OK
, "QueryInterface for IID_IDirectPlay failed: %08x\n", hr
);
6608 refcount
= IDirectPlayX_AddRef(dp
);
6609 ok(refcount
== 2, "refcount == %u, expected 2\n", refcount
);
6610 IDirectPlay_Release(dp
);
6612 hr
= IDirectPlayX_QueryInterface(dp4
, &IID_IUnknown
, (void**)&unk
);
6613 ok(hr
== S_OK
, "QueryInterface for IID_IUnknown failed: %08x\n", hr
);
6614 refcount
= IUnknown_AddRef(unk
);
6615 ok(refcount
== 3, "refcount == %u, expected 3\n", refcount
);
6616 refcount
= IUnknown_Release(unk
);
6617 ok(refcount
== 2, "refcount == %u, expected 2\n", refcount
);
6619 IUnknown_Release(unk
);
6620 IDirectPlay_Release(dp
);
6621 IDirectPlayX_Release(dp4A
);
6622 IDirectPlay3_Release(dp3
);
6623 IDirectPlay3_Release(dp3A
);
6624 IDirectPlay2_Release(dp2
);
6625 IDirectPlay2_Release(dp2A
);
6626 IDirectPlayX_Release(dp4
);
6627 refcount
= IDirectPlayX_Release(dp4
);
6628 ok(refcount
== 0, "refcount == %u, expected 0\n", refcount
);
6631 static void test_COM_dplobby(void)
6633 IDirectPlayLobby
*dpl
= (IDirectPlayLobby
*)0xdeadbeef;
6634 IDirectPlayLobbyA
*dplA
;
6635 IDirectPlayLobby2A
*dpl2A
;
6636 IDirectPlayLobby2
*dpl2
;
6637 IDirectPlayLobby3A
*dpl3A
;
6638 IDirectPlayLobby3
*dpl3
;
6643 /* COM aggregation */
6644 hr
= CoCreateInstance(&CLSID_DirectPlayLobby
, (IUnknown
*)0xdeadbeef, CLSCTX_INPROC_SERVER
,
6645 &IID_IUnknown
, (void**)&dpl
);
6646 ok(hr
== CLASS_E_NOAGGREGATION
|| broken(hr
== E_INVALIDARG
),
6647 "DirectPlayLobby create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr
);
6648 ok(!dpl
|| dpl
== (IDirectPlayLobby
*)0xdeadbeef, "dpl = %p\n", dpl
);
6651 hr
= CoCreateInstance(&CLSID_DirectPlayLobby
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectPlay
,
6653 ok(hr
== E_NOINTERFACE
, "DirectPlayLobby create failed: %08x, expected E_NOINTERFACE\n", hr
);
6655 /* Different refcount for all DirectPlayLobby Interfaces */
6656 hr
= CoCreateInstance(&CLSID_DirectPlayLobby
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectPlayLobby
,
6658 ok(hr
== S_OK
, "DirectPlayLobby create failed: %08x, expected S_OK\n", hr
);
6659 refcount
= IDirectPlayLobby_AddRef(dpl
);
6660 ok(refcount
== 2, "refcount == %u, expected 2\n", refcount
);
6662 hr
= IDirectPlayLobby_QueryInterface(dpl
, &IID_IDirectPlayLobbyA
, (void**)&dplA
);
6663 ok(hr
== S_OK
, "QueryInterface for IID_IDirectPlayLobbyA failed: %08x\n", hr
);
6664 refcount
= IDirectPlayLobby_AddRef(dplA
);
6665 ok(refcount
== 2, "refcount == %u, expected 2\n", refcount
);
6666 IDirectPlayLobby_Release(dplA
);
6668 hr
= IDirectPlayLobby_QueryInterface(dpl
, &IID_IDirectPlayLobby2
, (void**)&dpl2
);
6669 ok(hr
== S_OK
, "QueryInterface for IID_IDirectPlayLobby2 failed: %08x\n", hr
);
6670 refcount
= IDirectPlayLobby_AddRef(dpl2
);
6671 ok(refcount
== 2, "refcount == %u, expected 2\n", refcount
);
6672 IDirectPlayLobby_Release(dpl2
);
6674 hr
= IDirectPlayLobby_QueryInterface(dpl
, &IID_IDirectPlayLobby2A
, (void**)&dpl2A
);
6675 ok(hr
== S_OK
, "QueryInterface for IID_IDirectPlayLobby2A failed: %08x\n", hr
);
6676 refcount
= IDirectPlayLobby_AddRef(dpl2A
);
6677 ok(refcount
== 2, "refcount == %u, expected 2\n", refcount
);
6678 IDirectPlayLobby_Release(dpl2A
);
6680 hr
= IDirectPlayLobby_QueryInterface(dpl
, &IID_IDirectPlayLobby3
, (void**)&dpl3
);
6681 ok(hr
== S_OK
, "QueryInterface for IID_IDirectPlayLobby3 failed: %08x\n", hr
);
6682 refcount
= IDirectPlayLobby_AddRef(dpl3
);
6683 ok(refcount
== 2, "refcount == %u, expected 2\n", refcount
);
6684 IDirectPlayLobby_Release(dpl3
);
6686 hr
= IDirectPlayLobby_QueryInterface(dpl
, &IID_IDirectPlayLobby3A
, (void**)&dpl3A
);
6687 ok(hr
== S_OK
, "QueryInterface for IID_IDirectPlayLobby3A failed: %08x\n", hr
);
6688 refcount
= IDirectPlayLobby_AddRef(dpl3A
);
6689 ok(refcount
== 2, "refcount == %u, expected 2\n", refcount
);
6690 IDirectPlayLobby_Release(dpl3A
);
6692 /* IDirectPlayLobby and IUnknown share a refcount */
6693 hr
= IDirectPlayX_QueryInterface(dpl
, &IID_IUnknown
, (void**)&unk
);
6694 ok(hr
== S_OK
, "QueryInterface for IID_IUnknown failed: %08x\n", hr
);
6695 refcount
= IUnknown_AddRef(unk
);
6696 ok(refcount
== 4, "refcount == %u, expected 4\n", refcount
);
6697 IDirectPlayLobby_Release(unk
);
6699 IUnknown_Release(unk
);
6700 IDirectPlayLobby_Release(dpl3
);
6701 IDirectPlayLobby_Release(dpl3A
);
6702 IDirectPlayLobby_Release(dpl2
);
6703 IDirectPlayLobby_Release(dpl2A
);
6704 IDirectPlayLobby_Release(dplA
);
6705 IDirectPlayLobby_Release(dpl
);
6706 refcount
= IDirectPlayLobby_Release(dpl
);
6707 ok(refcount
== 0, "refcount == %u, expected 0\n", refcount
);
6716 static BOOL
is_process_elevated(void)
6719 if (OpenProcessToken( GetCurrentProcess(), TOKEN_QUERY
, &token
))
6721 TOKEN_ELEVATION_TYPE type
;
6725 ret
= GetTokenInformation( token
, TokenElevationType
, &type
, sizeof(type
), &size
);
6726 CloseHandle( token
);
6727 return (ret
&& type
== TokenElevationTypeFull
);
6732 static BOOL
is_firewall_enabled(void)
6735 INetFwMgr
*mgr
= NULL
;
6736 INetFwPolicy
*policy
= NULL
;
6737 INetFwProfile
*profile
= NULL
;
6738 VARIANT_BOOL enabled
= VARIANT_FALSE
;
6740 init
= CoInitializeEx( 0, COINIT_APARTMENTTHREADED
);
6742 hr
= CoCreateInstance( &CLSID_NetFwMgr
, NULL
, CLSCTX_INPROC_SERVER
, &IID_INetFwMgr
,
6744 ok( hr
== S_OK
, "got %08x\n", hr
);
6745 if (hr
!= S_OK
) goto done
;
6747 hr
= INetFwMgr_get_LocalPolicy( mgr
, &policy
);
6748 ok( hr
== S_OK
, "got %08x\n", hr
);
6749 if (hr
!= S_OK
) goto done
;
6751 hr
= INetFwPolicy_get_CurrentProfile( policy
, &profile
);
6752 if (hr
!= S_OK
) goto done
;
6754 hr
= INetFwProfile_get_FirewallEnabled( profile
, &enabled
);
6755 ok( hr
== S_OK
, "got %08x\n", hr
);
6758 if (policy
) INetFwPolicy_Release( policy
);
6759 if (profile
) INetFwProfile_Release( profile
);
6760 if (mgr
) INetFwMgr_Release( mgr
);
6761 if (SUCCEEDED( init
)) CoUninitialize();
6762 return (enabled
== VARIANT_TRUE
);
6765 static HRESULT
set_firewall( enum firewall_op op
)
6768 INetFwMgr
*mgr
= NULL
;
6769 INetFwPolicy
*policy
= NULL
;
6770 INetFwProfile
*profile
= NULL
;
6771 INetFwAuthorizedApplication
*app
= NULL
;
6772 INetFwAuthorizedApplications
*apps
= NULL
;
6773 BSTR name
, image
= SysAllocStringLen( NULL
, MAX_PATH
);
6774 WCHAR path
[MAX_PATH
];
6776 if (!GetModuleFileNameW( NULL
, image
, MAX_PATH
))
6778 SysFreeString( image
);
6782 if(!GetSystemDirectoryW(path
, MAX_PATH
))
6784 SysFreeString( image
);
6787 lstrcatW( path
, L
"\\dplaysvr.exe" );
6789 init
= CoInitializeEx( 0, COINIT_APARTMENTTHREADED
);
6791 hr
= CoCreateInstance( &CLSID_NetFwMgr
, NULL
, CLSCTX_INPROC_SERVER
, &IID_INetFwMgr
,
6793 ok( hr
== S_OK
, "got %08x\n", hr
);
6794 if (hr
!= S_OK
) goto done
;
6796 hr
= INetFwMgr_get_LocalPolicy( mgr
, &policy
);
6797 ok( hr
== S_OK
, "got %08x\n", hr
);
6798 if (hr
!= S_OK
) goto done
;
6800 hr
= INetFwPolicy_get_CurrentProfile( policy
, &profile
);
6801 if (hr
!= S_OK
) goto done
;
6803 hr
= INetFwProfile_get_AuthorizedApplications( profile
, &apps
);
6804 ok( hr
== S_OK
, "got %08x\n", hr
);
6805 if (hr
!= S_OK
) goto done
;
6807 hr
= CoCreateInstance( &CLSID_NetFwAuthorizedApplication
, NULL
, CLSCTX_INPROC_SERVER
,
6808 &IID_INetFwAuthorizedApplication
, (void **)&app
);
6809 ok( hr
== S_OK
, "got %08x\n", hr
);
6810 if (hr
!= S_OK
) goto done
;
6812 hr
= INetFwAuthorizedApplication_put_ProcessImageFileName( app
, image
);
6813 if (hr
!= S_OK
) goto done
;
6815 name
= SysAllocString( L
"dplay_client" );
6816 hr
= INetFwAuthorizedApplication_put_Name( app
, name
);
6817 SysFreeString( name
);
6818 ok( hr
== S_OK
, "got %08x\n", hr
);
6819 if (hr
!= S_OK
) goto done
;
6822 hr
= INetFwAuthorizedApplications_Add( apps
, app
);
6823 else if (op
== APP_REMOVE
)
6824 hr
= INetFwAuthorizedApplications_Remove( apps
, image
);
6827 if (hr
!= S_OK
) goto done
;
6829 INetFwAuthorizedApplication_Release( app
);
6830 hr
= CoCreateInstance( &CLSID_NetFwAuthorizedApplication
, NULL
, CLSCTX_INPROC_SERVER
,
6831 &IID_INetFwAuthorizedApplication
, (void **)&app
);
6832 ok( hr
== S_OK
, "got %08x\n", hr
);
6833 if (hr
!= S_OK
) goto done
;
6835 SysFreeString( image
);
6836 image
= SysAllocString( path
);
6837 hr
= INetFwAuthorizedApplication_put_ProcessImageFileName( app
, image
);
6838 if (hr
!= S_OK
) goto done
;
6840 name
= SysAllocString( L
"dplay_server" );
6841 hr
= INetFwAuthorizedApplication_put_Name( app
, name
);
6842 SysFreeString( name
);
6843 ok( hr
== S_OK
, "got %08x\n", hr
);
6844 if (hr
!= S_OK
) goto done
;
6847 hr
= INetFwAuthorizedApplications_Add( apps
, app
);
6848 else if (op
== APP_REMOVE
)
6849 hr
= INetFwAuthorizedApplications_Remove( apps
, image
);
6854 if (app
) INetFwAuthorizedApplication_Release( app
);
6855 if (apps
) INetFwAuthorizedApplications_Release( apps
);
6856 if (policy
) INetFwPolicy_Release( policy
);
6857 if (profile
) INetFwProfile_Release( profile
);
6858 if (mgr
) INetFwMgr_Release( mgr
);
6859 if (SUCCEEDED( init
)) CoUninitialize();
6860 SysFreeString( image
);
6864 /* taken from programs/winetest/main.c */
6865 static BOOL
is_stub_dll(const char *filename
)
6868 BOOL isstub
= FALSE
;
6871 size
= GetFileVersionInfoSizeA(filename
, &ver
);
6872 if (!size
) return FALSE
;
6874 data
= HeapAlloc(GetProcessHeap(), 0, size
);
6875 if (!data
) return FALSE
;
6877 if (GetFileVersionInfoA(filename
, ver
, size
, data
))
6881 sprintf(buf
, "\\StringFileInfo\\%04x%04x\\OriginalFilename", MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), 1200);
6882 if (VerQueryValueA(data
, buf
, (void**)&p
, &size
))
6883 isstub
= !lstrcmpiA("wcodstub.dll", p
);
6885 HeapFree(GetProcessHeap(), 0, data
);
6892 BOOL firewall_enabled
;
6894 char path
[MAX_PATH
];
6897 if(!GetSystemDirectoryA(path
, MAX_PATH
))
6899 skip("Failed to get systems directory\n");
6902 strcat(path
, "\\dplayx.dll");
6904 if (!winetest_interactive
&& is_stub_dll(path
))
6906 win_skip("dpnet is a stub dll, skipping tests\n");
6910 if ((firewall_enabled
= is_firewall_enabled()) && !is_process_elevated())
6912 skip("no privileges, skipping tests to avoid firewall dialog\n");
6916 if (firewall_enabled
)
6918 hr
= set_firewall(APP_ADD
);
6921 skip("can't authorize app in firewall %08x\n", hr
);
6926 CoInitialize( NULL
);
6928 module
= LoadLibraryA("dplayx.dll");
6930 pDirectPlayEnumerateA
= (void *)GetProcAddress(module
, "DirectPlayEnumerateA");
6931 pDirectPlayEnumerateW
= (void *)GetProcAddress(module
, "DirectPlayEnumerateW");
6932 pDirectPlayCreate
= (void *)GetProcAddress(module
, "DirectPlayCreate");
6936 test_EnumerateProviders();
6937 test_DirectPlayCreate();
6938 test_EnumConnections();
6939 test_InitializeConnection();
6941 test_EnumAddressTypes();
6943 if (!winetest_interactive
)
6945 skip("Run in interactive mode to run all dplayx tests.\n");
6949 trace("Running in interactive mode, tests will take a while\n");
6951 /* test_Open() takes almost a minute, */
6953 /* test_EnumSession takes three minutes */
6954 test_EnumSessions();
6957 /* test_CreatePlayer() takes over a minute */
6958 test_CreatePlayer();
6959 test_GetPlayerCaps();
6963 /* test_GetPlayerAccount() takes over 30s */
6964 test_GetPlayerAccount();
6965 test_GetPlayerAddress();
6966 test_GetPlayerFlags();
6973 test_EnumGroupsInGroup();
6980 test_GetMessageCount();
6981 test_GetMessageQueue();
6983 test_remote_data_replication();
6984 test_host_migration();
6987 FreeLibrary(module
);
6989 if (firewall_enabled
) set_firewall(APP_REMOVE
);