dplayx: Tests for DirectPlayCreate.
This commit is contained in:
parent
a1b76460a1
commit
42165af840
|
@ -5406,6 +5406,12 @@ HRESULT WINAPI DirectPlayCreate
|
|||
return CLASS_E_NOAGGREGATION;
|
||||
}
|
||||
|
||||
if( (lplpDP == NULL) || (lpGUID == NULL) )
|
||||
{
|
||||
return DPERR_INVALIDPARAMS;
|
||||
}
|
||||
|
||||
|
||||
/* Create an IDirectPlay object. We don't support that so we'll cheat and
|
||||
give them an IDirectPlay2A object and hope that doesn't cause problems */
|
||||
if( DP_CreateInterface( &IID_IDirectPlay2A, (LPVOID*)lplpDP ) != DP_OK )
|
||||
|
|
|
@ -3,7 +3,7 @@ TOPOBJDIR = ../../..
|
|||
SRCDIR = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
TESTDLL = dplayx.dll
|
||||
IMPORTS = ole32 kernel32
|
||||
IMPORTS = dplayx ole32 kernel32
|
||||
|
||||
CTESTS = \
|
||||
dplayx.c
|
||||
|
|
|
@ -18,77 +18,154 @@
|
|||
*/
|
||||
|
||||
#include "wine/test.h"
|
||||
#include <stdio.h>
|
||||
#define INITGUID
|
||||
#include <dplay.h>
|
||||
#include <dplobby.h>
|
||||
|
||||
static BOOL validSP = FALSE; /*This global variable is needed until wine has a working service provider
|
||||
implementation*/
|
||||
|
||||
static BOOL CALLBACK EnumConnectionsCallback(LPCGUID lpguidSP, LPVOID lpConnection,
|
||||
DWORD dwConnectionSize, LPCDPNAME lpName, DWORD dwFlags, LPVOID lpContext)
|
||||
#define checkHR(expected, result) \
|
||||
ok( (expected) == (result), \
|
||||
"expected=%s got=%s\n", \
|
||||
dpResult2str(expected), dpResult2str(result) );
|
||||
|
||||
|
||||
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
|
||||
|
||||
|
||||
static LPSTR get_temp_buffer(void)
|
||||
{
|
||||
static UINT index = 0;
|
||||
static char buff[10][256];
|
||||
|
||||
index = (index + 1) % 10;
|
||||
*buff[index] = 0;
|
||||
|
||||
return buff[index];
|
||||
}
|
||||
|
||||
|
||||
static LPCSTR dpResult2str(HRESULT hr)
|
||||
{
|
||||
switch (hr)
|
||||
{
|
||||
case DP_OK: return "DP_OK";
|
||||
case DPERR_ALREADYINITIALIZED: return "DPERR_ALREADYINITIALIZED";
|
||||
case DPERR_ACCESSDENIED: return "DPERR_ACCESSDENIED";
|
||||
case DPERR_ACTIVEPLAYERS: return "DPERR_ACTIVEPLAYERS";
|
||||
case DPERR_BUFFERTOOSMALL: return "DPERR_BUFFERTOOSMALL";
|
||||
case DPERR_CANTADDPLAYER: return "DPERR_CANTADDPLAYER";
|
||||
case DPERR_CANTCREATEGROUP: return "DPERR_CANTCREATEGROUP";
|
||||
case DPERR_CANTCREATEPLAYER: return "DPERR_CANTCREATEPLAYER";
|
||||
case DPERR_CANTCREATESESSION: return "DPERR_CANTCREATESESSION";
|
||||
case DPERR_CAPSNOTAVAILABLEYET: return "DPERR_CAPSNOTAVAILABLEYET";
|
||||
case DPERR_EXCEPTION: return "DPERR_EXCEPTION";
|
||||
case DPERR_GENERIC: return "DPERR_GENERIC";
|
||||
case DPERR_INVALIDFLAGS: return "DPERR_INVALIDFLAGS";
|
||||
case DPERR_INVALIDOBJECT: return "DPERR_INVALIDOBJECT";
|
||||
case DPERR_INVALIDPARAMS: return "DPERR_INVALIDPARAMS";
|
||||
/* symbol with the same value: DPERR_INVALIDPARAM */
|
||||
case DPERR_INVALIDPLAYER: return "DPERR_INVALIDPLAYER";
|
||||
case DPERR_INVALIDGROUP: return "DPERR_INVALIDGROUP";
|
||||
case DPERR_NOCAPS: return "DPERR_NOCAPS";
|
||||
case DPERR_NOCONNECTION: return "DPERR_NOCONNECTION";
|
||||
case DPERR_NOMEMORY: return "DPERR_NOMEMORY";
|
||||
/* symbol with the same value: DPERR_OUTOFMEMORY */
|
||||
case DPERR_NOMESSAGES: return "DPERR_NOMESSAGES";
|
||||
case DPERR_NONAMESERVERFOUND: return "DPERR_NONAMESERVERFOUND";
|
||||
case DPERR_NOPLAYERS: return "DPERR_NOPLAYERS";
|
||||
case DPERR_NOSESSIONS: return "DPERR_NOSESSIONS";
|
||||
case DPERR_PENDING: return "DPERR_PENDING";
|
||||
case DPERR_SENDTOOBIG: return "DPERR_SENDTOOBIG";
|
||||
case DPERR_TIMEOUT: return "DPERR_TIMEOUT";
|
||||
case DPERR_UNAVAILABLE: return "DPERR_UNAVAILABLE";
|
||||
case DPERR_UNSUPPORTED: return "DPERR_UNSUPPORTED";
|
||||
case DPERR_BUSY: return "DPERR_BUSY";
|
||||
case DPERR_USERCANCEL: return "DPERR_USERCANCEL";
|
||||
case DPERR_NOINTERFACE: return "DPERR_NOINTERFACE";
|
||||
case DPERR_CANNOTCREATESERVER: return "DPERR_CANNOTCREATESERVER";
|
||||
case DPERR_PLAYERLOST: return "DPERR_PLAYERLOST";
|
||||
case DPERR_SESSIONLOST: return "DPERR_SESSIONLOST";
|
||||
case DPERR_UNINITIALIZED: return "DPERR_UNINITIALIZED";
|
||||
case DPERR_NONEWPLAYERS: return "DPERR_NONEWPLAYERS";
|
||||
case DPERR_INVALIDPASSWORD: return "DPERR_INVALIDPASSWORD";
|
||||
case DPERR_CONNECTING: return "DPERR_CONNECTING";
|
||||
case DPERR_CONNECTIONLOST: return "DPERR_CONNECTIONLOST";
|
||||
case DPERR_UNKNOWNMESSAGE: return "DPERR_UNKNOWNMESSAGE";
|
||||
case DPERR_CANCELFAILED: return "DPERR_CANCELFAILED";
|
||||
case DPERR_INVALIDPRIORITY: return "DPERR_INVALIDPRIORITY";
|
||||
case DPERR_NOTHANDLED: return "DPERR_NOTHANDLED";
|
||||
case DPERR_CANCELLED: return "DPERR_CANCELLED";
|
||||
case DPERR_ABORTED: return "DPERR_ABORTED";
|
||||
case DPERR_BUFFERTOOLARGE: return "DPERR_BUFFERTOOLARGE";
|
||||
case DPERR_CANTCREATEPROCESS: return "DPERR_CANTCREATEPROCESS";
|
||||
case DPERR_APPNOTSTARTED: return "DPERR_APPNOTSTARTED";
|
||||
case DPERR_INVALIDINTERFACE: return "DPERR_INVALIDINTERFACE";
|
||||
case DPERR_NOSERVICEPROVIDER: return "DPERR_NOSERVICEPROVIDER";
|
||||
case DPERR_UNKNOWNAPPLICATION: return "DPERR_UNKNOWNAPPLICATION";
|
||||
case DPERR_NOTLOBBIED: return "DPERR_NOTLOBBIED";
|
||||
case DPERR_SERVICEPROVIDERLOADED: return "DPERR_SERVICEPROVIDERLOADED";
|
||||
case DPERR_ALREADYREGISTERED: return "DPERR_ALREADYREGISTERED";
|
||||
case DPERR_NOTREGISTERED: return "DPERR_NOTREGISTERED";
|
||||
case DPERR_AUTHENTICATIONFAILED: return "DPERR_AUTHENTICATIONFAILED";
|
||||
case DPERR_CANTLOADSSPI: return "DPERR_CANTLOADSSPI";
|
||||
case DPERR_ENCRYPTIONFAILED: return "DPERR_ENCRYPTIONFAILED";
|
||||
case DPERR_SIGNFAILED: return "DPERR_SIGNFAILED";
|
||||
case DPERR_CANTLOADSECURITYPACKAGE: return "DPERR_CANTLOADSECURITYPACKAGE";
|
||||
case DPERR_ENCRYPTIONNOTSUPPORTED: return "DPERR_ENCRYPTIONNOTSUPPORTED";
|
||||
case DPERR_CANTLOADCAPI: return "DPERR_CANTLOADCAPI";
|
||||
case DPERR_NOTLOGGEDIN: return "DPERR_NOTLOGGEDIN";
|
||||
case DPERR_LOGONDENIED: return "DPERR_LOGONDENIED";
|
||||
case CLASS_E_NOAGGREGATION: return "CLASS_E_NOAGGREGATION";
|
||||
|
||||
default:
|
||||
{
|
||||
LPSTR buffer = get_temp_buffer();
|
||||
sprintf( buffer, "%d", HRESULT_CODE(hr) );
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* DirectPlayCreate */
|
||||
|
||||
static void test_DirectPlayCreate(void)
|
||||
{
|
||||
|
||||
LPDIRECTPLAY pDP;
|
||||
HRESULT hr;
|
||||
|
||||
if(IsEqualGUID(lpguidSP,&DPSPGUID_TCPIP))
|
||||
{
|
||||
/*I'm forcing the TCP/IP Service provider*/
|
||||
hr = IDirectPlayX_InitializeConnection((LPDIRECTPLAY4) lpContext, lpConnection, 0);
|
||||
if( SUCCEEDED( hr ))
|
||||
validSP = TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
/* TODO: Check how it behaves with pUnk!=NULL */
|
||||
|
||||
/* pDP==NULL */
|
||||
hr = DirectPlayCreate( NULL, NULL, NULL );
|
||||
checkHR( DPERR_INVALIDPARAMS, hr );
|
||||
hr = DirectPlayCreate( (LPGUID) &GUID_NULL, NULL, NULL );
|
||||
checkHR( DPERR_INVALIDPARAMS, hr );
|
||||
hr = DirectPlayCreate( (LPGUID) &DPSPGUID_TCPIP, NULL, NULL );
|
||||
checkHR( DPERR_INVALIDPARAMS, hr );
|
||||
|
||||
/* pUnk==NULL, pDP!=NULL */
|
||||
hr = DirectPlayCreate( NULL, &pDP, NULL );
|
||||
checkHR( DPERR_INVALIDPARAMS, hr );
|
||||
hr = DirectPlayCreate( (LPGUID) &GUID_NULL, &pDP, NULL );
|
||||
checkHR( DP_OK, hr );
|
||||
if ( hr == DP_OK )
|
||||
IDirectPlayX_Release( pDP );
|
||||
hr = DirectPlayCreate( (LPGUID) &DPSPGUID_TCPIP, &pDP, NULL );
|
||||
todo_wine checkHR( DP_OK, hr );
|
||||
if ( hr == DP_OK )
|
||||
IDirectPlayX_Release( pDP );
|
||||
|
||||
}
|
||||
|
||||
static void test_session_guid(LPDIRECTPLAY4 pDP)
|
||||
{
|
||||
GUID appGuid;
|
||||
GUID zeroGuid;
|
||||
DPSESSIONDESC2 sessionDesc;
|
||||
LPDPSESSIONDESC2 newSession;
|
||||
DWORD sessionSize;
|
||||
static char name[] = "DPlay conformance test";
|
||||
|
||||
CoCreateGuid( &appGuid );
|
||||
IDirectPlayX_EnumConnections(pDP, &appGuid, EnumConnectionsCallback, pDP, 0);
|
||||
|
||||
if( !validSP )
|
||||
{
|
||||
skip("Tests will not work without a valid service provider, skipping.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
memset(&sessionDesc, 0, sizeof( DPSESSIONDESC2 ));
|
||||
memset(&zeroGuid, 0, 16);
|
||||
|
||||
sessionDesc.dwSize = sizeof( DPSESSIONDESC2 );
|
||||
memcpy(&sessionDesc.guidApplication, &appGuid, 16);
|
||||
sessionDesc.dwFlags = DPSESSION_CLIENTSERVER;
|
||||
U1(sessionDesc).lpszSessionNameA = name;
|
||||
sessionDesc.dwMaxPlayers = 10;
|
||||
sessionDesc.dwCurrentPlayers = 0;
|
||||
IDirectPlayX_Open(pDP, &sessionDesc, DPOPEN_CREATE);
|
||||
|
||||
/* I read the sessiondesc from directplay in a fresh memory location,
|
||||
because directplay does not touch the original struct, but saves
|
||||
internally a version with the session guid set*/
|
||||
|
||||
IDirectPlayX_GetSessionDesc(pDP, NULL, &sessionSize);
|
||||
newSession = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sessionSize);
|
||||
IDirectPlayX_GetSessionDesc(pDP, newSession, &sessionSize);
|
||||
todo_wine ok( !IsEqualGUID(&newSession->guidInstance, &zeroGuid), "Session guid not initialized\n");
|
||||
HeapFree(GetProcessHeap(), 0, newSession);
|
||||
}
|
||||
|
||||
START_TEST(dplayx)
|
||||
{
|
||||
LPDIRECTPLAY4 pDP;
|
||||
|
||||
CoInitialize( NULL );
|
||||
CoCreateInstance(&CLSID_DirectPlay, NULL, CLSCTX_ALL, &IID_IDirectPlay4A, (VOID**)&pDP);
|
||||
|
||||
test_session_guid( pDP );
|
||||
test_DirectPlayCreate();
|
||||
|
||||
IDirectPlayX_Release( pDP );
|
||||
CoUninitialize();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue