dplayx: Tests for EnumPlayers.
This commit is contained in:
parent
1278ea3aea
commit
44fe844edf
|
@ -697,10 +697,10 @@ static void init_TCPIP_provider( LPDIRECTPLAY4 pDP,
|
|||
|
||||
}
|
||||
|
||||
static BOOL FAR PASCAL EnumSessions_cb_join( LPCDPSESSIONDESC2 lpThisSD,
|
||||
LPDWORD lpdwTimeOut,
|
||||
DWORD dwFlags,
|
||||
LPVOID lpContext )
|
||||
static BOOL CALLBACK EnumSessions_cb_join( LPCDPSESSIONDESC2 lpThisSD,
|
||||
LPDWORD lpdwTimeOut,
|
||||
DWORD dwFlags,
|
||||
LPVOID lpContext )
|
||||
{
|
||||
LPDIRECTPLAY4 pDP = (LPDIRECTPLAY4) lpContext;
|
||||
DPSESSIONDESC2 dpsd;
|
||||
|
@ -757,10 +757,10 @@ static void test_DirectPlayCreate(void)
|
|||
|
||||
/* EnumConnections */
|
||||
|
||||
static BOOL FAR PASCAL EnumAddress_cb2( REFGUID guidDataType,
|
||||
DWORD dwDataSize,
|
||||
LPCVOID lpData,
|
||||
LPVOID lpContext )
|
||||
static BOOL CALLBACK EnumAddress_cb2( REFGUID guidDataType,
|
||||
DWORD dwDataSize,
|
||||
LPCVOID lpData,
|
||||
LPVOID lpContext )
|
||||
{
|
||||
lpCallbackData callbackData = (lpCallbackData) lpContext;
|
||||
|
||||
|
@ -1016,10 +1016,10 @@ static void test_GetCaps(void)
|
|||
|
||||
/* Open */
|
||||
|
||||
static BOOL FAR PASCAL EnumSessions_cb2( LPCDPSESSIONDESC2 lpThisSD,
|
||||
LPDWORD lpdwTimeOut,
|
||||
DWORD dwFlags,
|
||||
LPVOID lpContext )
|
||||
static BOOL CALLBACK EnumSessions_cb2( LPCDPSESSIONDESC2 lpThisSD,
|
||||
LPDWORD lpdwTimeOut,
|
||||
DWORD dwFlags,
|
||||
LPVOID lpContext )
|
||||
{
|
||||
LPDIRECTPLAY4 pDP = (LPDIRECTPLAY4) lpContext;
|
||||
DPSESSIONDESC2 dpsd;
|
||||
|
@ -1183,10 +1183,10 @@ static void test_Open(void)
|
|||
|
||||
/* EnumSessions */
|
||||
|
||||
static BOOL FAR PASCAL EnumSessions_cb( LPCDPSESSIONDESC2 lpThisSD,
|
||||
LPDWORD lpdwTimeOut,
|
||||
DWORD dwFlags,
|
||||
LPVOID lpContext )
|
||||
static BOOL CALLBACK EnumSessions_cb( LPCDPSESSIONDESC2 lpThisSD,
|
||||
LPDWORD lpdwTimeOut,
|
||||
DWORD dwFlags,
|
||||
LPVOID lpContext )
|
||||
{
|
||||
lpCallbackData callbackData = (lpCallbackData) lpContext;
|
||||
callbackData->dwCounter1++;
|
||||
|
@ -2634,10 +2634,10 @@ static void test_PlayerName(void)
|
|||
|
||||
/* GetPlayerAccount */
|
||||
|
||||
static BOOL FAR PASCAL EnumSessions_cb_join_secure( LPCDPSESSIONDESC2 lpThisSD,
|
||||
LPDWORD lpdwTimeOut,
|
||||
DWORD dwFlags,
|
||||
LPVOID lpContext )
|
||||
static BOOL CALLBACK EnumSessions_cb_join_secure( LPCDPSESSIONDESC2 lpThisSD,
|
||||
LPDWORD lpdwTimeOut,
|
||||
DWORD dwFlags,
|
||||
LPVOID lpContext )
|
||||
{
|
||||
LPDIRECTPLAY4 pDP = (LPDIRECTPLAY4) lpContext;
|
||||
DPSESSIONDESC2 dpsd;
|
||||
|
@ -2810,10 +2810,10 @@ static void test_GetPlayerAccount(void)
|
|||
|
||||
/* GetPlayerAddress */
|
||||
|
||||
static BOOL FAR PASCAL EnumAddress_cb( REFGUID guidDataType,
|
||||
DWORD dwDataSize,
|
||||
LPCVOID lpData,
|
||||
LPVOID lpContext )
|
||||
static BOOL CALLBACK EnumAddress_cb( REFGUID guidDataType,
|
||||
DWORD dwDataSize,
|
||||
LPCVOID lpData,
|
||||
LPVOID lpContext )
|
||||
{
|
||||
lpCallbackData callbackData = (lpCallbackData) lpContext;
|
||||
static REFGUID types[] = { &DPAID_TotalSize,
|
||||
|
@ -3474,6 +3474,347 @@ static void test_GroupOwner(void)
|
|||
|
||||
}
|
||||
|
||||
/* EnumPlayers */
|
||||
|
||||
static BOOL CALLBACK EnumPlayers_cb( DPID dpId,
|
||||
DWORD dwPlayerType,
|
||||
LPCDPNAME lpName,
|
||||
DWORD dwFlags,
|
||||
LPVOID lpContext )
|
||||
{
|
||||
lpCallbackData callbackData = (lpCallbackData) lpContext;
|
||||
char playerIndex = dpid2char( callbackData->dpid,
|
||||
callbackData->dpidSize,
|
||||
dpId );
|
||||
|
||||
|
||||
/* Trace to study player ids */
|
||||
callbackData->szTrace1[ callbackData->dwCounter1 ] = playerIndex;
|
||||
callbackData->dwCounter1++;
|
||||
callbackData->szTrace1[ callbackData->dwCounter1 ] = '\0';
|
||||
|
||||
/* Trace to study flags received */
|
||||
strcat( callbackData->szTrace2,
|
||||
( dwFlags2str(dwFlags, FLAGS_DPENUMPLAYERS) +
|
||||
strlen("DPENUMPLAYERS_") ) );
|
||||
strcat( callbackData->szTrace2, ":" );
|
||||
|
||||
|
||||
if ( playerIndex < '5' )
|
||||
{
|
||||
check( DPPLAYERTYPE_PLAYER, dwPlayerType );
|
||||
}
|
||||
else
|
||||
{
|
||||
check( DPPLAYERTYPE_GROUP, dwPlayerType );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
static BOOL CALLBACK EnumSessions_cb_EnumPlayers( LPCDPSESSIONDESC2 lpThisSD,
|
||||
LPDWORD lpdwTimeOut,
|
||||
DWORD dwFlags,
|
||||
LPVOID lpContext )
|
||||
{
|
||||
lpCallbackData callbackData = (lpCallbackData) lpContext;
|
||||
HRESULT hr;
|
||||
|
||||
if (dwFlags & DPESC_TIMEDOUT)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* guid = NULL */
|
||||
callbackData->dwCounter1 = 0;
|
||||
hr = IDirectPlayX_EnumPlayers( callbackData->pDP, NULL,
|
||||
EnumPlayers_cb,
|
||||
(LPVOID) &callbackData, 0 );
|
||||
checkHR( DPERR_NOSESSIONS, hr );
|
||||
check( 0, callbackData->dwCounter1 );
|
||||
|
||||
/* guid = appGuid */
|
||||
callbackData->dwCounter1 = 0;
|
||||
hr = IDirectPlayX_EnumPlayers( callbackData->pDP, (LPGUID) &appGuid,
|
||||
EnumPlayers_cb,
|
||||
(LPVOID) &callbackData, 0 );
|
||||
checkHR( DPERR_NOSESSIONS, hr );
|
||||
check( 0, callbackData->dwCounter1 );
|
||||
|
||||
callbackData->dwCounter1 = 0;
|
||||
hr = IDirectPlayX_EnumPlayers( callbackData->pDP, (LPGUID) &appGuid,
|
||||
EnumPlayers_cb,
|
||||
(LPVOID) &callbackData,
|
||||
DPENUMPLAYERS_SESSION );
|
||||
checkHR( DPERR_NOSESSIONS, hr );
|
||||
check( 0, callbackData->dwCounter1 );
|
||||
|
||||
/* guid = guidInstance */
|
||||
callbackData->dwCounter1 = 0;
|
||||
hr = IDirectPlayX_EnumPlayers( callbackData->pDP,
|
||||
(LPGUID) &lpThisSD->guidInstance,
|
||||
EnumPlayers_cb,
|
||||
(LPVOID) &callbackData, 0 );
|
||||
checkHR( DPERR_NOSESSIONS, hr );
|
||||
check( 0, callbackData->dwCounter1 );
|
||||
|
||||
callbackData->dwCounter1 = 0;
|
||||
hr = IDirectPlayX_EnumPlayers( callbackData->pDP,
|
||||
(LPGUID) &lpThisSD->guidInstance,
|
||||
EnumPlayers_cb,
|
||||
(LPVOID) &callbackData,
|
||||
DPENUMPLAYERS_SESSION );
|
||||
checkHR( DPERR_GENERIC, hr ); /* Why? */
|
||||
check( 0, callbackData->dwCounter1 );
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
static void test_EnumPlayers(void)
|
||||
{
|
||||
LPDIRECTPLAY4 pDP[3];
|
||||
DPSESSIONDESC2 dpsd[3];
|
||||
DPID dpid[5+2]; /* 5 players, 2 groups */
|
||||
CallbackData callbackData;
|
||||
HRESULT hr;
|
||||
UINT i;
|
||||
|
||||
|
||||
for (i=0; i<3; i++)
|
||||
{
|
||||
CoCreateInstance( &CLSID_DirectPlay, NULL, CLSCTX_ALL,
|
||||
&IID_IDirectPlay4A, (LPVOID*) &pDP[i] );
|
||||
|
||||
ZeroMemory( &dpsd[i], sizeof(DPSESSIONDESC2) );
|
||||
dpsd[i].dwSize = sizeof(DPSESSIONDESC2);
|
||||
}
|
||||
|
||||
dpsd[0].guidApplication = appGuid;
|
||||
dpsd[1].guidApplication = appGuid2;
|
||||
dpsd[2].guidApplication = GUID_NULL;
|
||||
|
||||
callbackData.dpid = dpid;
|
||||
callbackData.dpidSize = 5+2;
|
||||
|
||||
|
||||
/* Uninitialized service provider */
|
||||
callbackData.dwCounter1 = 0;
|
||||
hr = IDirectPlayX_EnumPlayers( pDP[0], (LPGUID) &appGuid, NULL,
|
||||
(LPVOID) &callbackData, 0 );
|
||||
checkHR( DPERR_UNINITIALIZED, hr );
|
||||
check( 0, callbackData.dwCounter1 );
|
||||
|
||||
|
||||
init_TCPIP_provider( pDP[0], "127.0.0.1", 0 );
|
||||
init_TCPIP_provider( pDP[1], "127.0.0.1", 0 );
|
||||
init_TCPIP_provider( pDP[2], "127.0.0.1", 0 );
|
||||
|
||||
|
||||
/* No session */
|
||||
callbackData.dwCounter1 = 0;
|
||||
hr = IDirectPlayX_EnumPlayers( pDP[0], NULL, EnumPlayers_cb,
|
||||
(LPVOID) &callbackData, 0 );
|
||||
todo_wine checkHR( DPERR_NOSESSIONS, hr );
|
||||
check( 0, callbackData.dwCounter1 );
|
||||
|
||||
if ( hr == DPERR_UNINITIALIZED )
|
||||
{
|
||||
skip( "EnumPlayers not implemented\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
callbackData.dwCounter1 = 0;
|
||||
hr = IDirectPlayX_EnumPlayers( pDP[0], (LPGUID) &appGuid, EnumPlayers_cb,
|
||||
(LPVOID) &callbackData, 0 );
|
||||
checkHR( DPERR_NOSESSIONS, hr );
|
||||
check( 0, callbackData.dwCounter1 );
|
||||
|
||||
callbackData.dwCounter1 = 0;
|
||||
hr = IDirectPlayX_EnumPlayers( pDP[0], (LPGUID) &appGuid, EnumPlayers_cb,
|
||||
(LPVOID) &callbackData,
|
||||
DPENUMPLAYERS_SESSION );
|
||||
checkHR( DPERR_NOSESSIONS, hr );
|
||||
check( 0, callbackData.dwCounter1 );
|
||||
|
||||
|
||||
hr = IDirectPlayX_Open( pDP[0], &dpsd[0], DPOPEN_CREATE );
|
||||
checkHR( DP_OK, hr );
|
||||
hr = IDirectPlayX_Open( pDP[1], &dpsd[1], DPOPEN_CREATE );
|
||||
checkHR( DP_OK, hr );
|
||||
|
||||
|
||||
/* No players */
|
||||
callbackData.dwCounter1 = 0;
|
||||
hr = IDirectPlayX_EnumPlayers( pDP[0], NULL, EnumPlayers_cb,
|
||||
(LPVOID) &callbackData, 0 );
|
||||
checkHR( DP_OK, hr );
|
||||
check( 0, callbackData.dwCounter1 );
|
||||
|
||||
|
||||
/* Create players */
|
||||
hr = IDirectPlayX_CreatePlayer( pDP[0], &dpid[0],
|
||||
NULL, NULL, NULL, 0,
|
||||
DPPLAYER_SERVERPLAYER );
|
||||
checkHR( DP_OK, hr );
|
||||
hr = IDirectPlayX_CreatePlayer( pDP[1], &dpid[1],
|
||||
NULL, NULL, NULL, 0,
|
||||
0 );
|
||||
checkHR( DP_OK, hr );
|
||||
|
||||
hr = IDirectPlayX_CreatePlayer( pDP[0], &dpid[2],
|
||||
NULL, NULL, NULL, 0,
|
||||
0 );
|
||||
checkHR( DP_OK, hr );
|
||||
hr = IDirectPlayX_CreateGroup( pDP[0], &dpid[5],
|
||||
NULL, NULL, 0, 0 );
|
||||
checkHR( DP_OK, hr );
|
||||
|
||||
|
||||
/* Invalid parameters */
|
||||
callbackData.dwCounter1 = 0;
|
||||
hr = IDirectPlayX_EnumPlayers( pDP[0], (LPGUID) &appGuid, NULL,
|
||||
(LPVOID) &callbackData, 0 );
|
||||
checkHR( DPERR_INVALIDPARAMS, hr );
|
||||
check( 0, callbackData.dwCounter1 );
|
||||
|
||||
callbackData.dwCounter1 = 0;
|
||||
hr = IDirectPlayX_EnumPlayers( pDP[0], NULL, EnumPlayers_cb,
|
||||
(LPVOID) &callbackData,
|
||||
DPENUMPLAYERS_SESSION );
|
||||
checkHR( DPERR_INVALIDPARAMS, hr );
|
||||
check( 0, callbackData.dwCounter1 );
|
||||
|
||||
|
||||
/* Regular operation */
|
||||
callbackData.dwCounter1 = 0;
|
||||
callbackData.szTrace2[0] = 0;
|
||||
hr = IDirectPlayX_EnumPlayers( pDP[0], NULL, EnumPlayers_cb,
|
||||
(LPVOID) &callbackData, 0 );
|
||||
checkHR( DP_OK, hr );
|
||||
check( 2, callbackData.dwCounter1 );
|
||||
checkStr( "20", callbackData.szTrace1 );
|
||||
checkStr( "ALL:SERVERPLAYER:", callbackData.szTrace2 );
|
||||
|
||||
callbackData.dwCounter1 = 0;
|
||||
callbackData.szTrace2[0] = 0;
|
||||
hr = IDirectPlayX_EnumPlayers( pDP[1], NULL, EnumPlayers_cb,
|
||||
(LPVOID) &callbackData, 0 );
|
||||
checkHR( DP_OK, hr );
|
||||
check( 1, callbackData.dwCounter1 );
|
||||
checkStr( "1", callbackData.szTrace1 );
|
||||
checkStr( "ALL:", callbackData.szTrace2 );
|
||||
|
||||
callbackData.dwCounter1 = 0;
|
||||
callbackData.szTrace2[0] = 0;
|
||||
hr = IDirectPlayX_EnumPlayers( pDP[0], (LPGUID) &appGuid, EnumPlayers_cb,
|
||||
(LPVOID) &callbackData, 0 );
|
||||
checkHR( DP_OK, hr );
|
||||
check( 2, callbackData.dwCounter1 ); /* Guid is ignored */
|
||||
checkStr( "20", callbackData.szTrace1 );
|
||||
checkStr( "ALL:SERVERPLAYER:", callbackData.szTrace2 );
|
||||
|
||||
|
||||
/* Enumerating from a remote session */
|
||||
/* - Session not open */
|
||||
callbackData.pDP = pDP[2];
|
||||
hr = IDirectPlayX_EnumSessions( pDP[2], &dpsd[2], 0,
|
||||
EnumSessions_cb_EnumPlayers,
|
||||
(LPVOID) &callbackData, 0 );
|
||||
checkHR( DP_OK, hr );
|
||||
|
||||
|
||||
/* - Open session */
|
||||
callbackData.pDP = pDP[2];
|
||||
hr = IDirectPlayX_EnumSessions( pDP[2], &dpsd[0], 0, EnumSessions_cb_join,
|
||||
(LPVOID) pDP[2], 0 );
|
||||
checkHR( DP_OK, hr );
|
||||
hr = IDirectPlayX_CreatePlayer( pDP[2], &dpid[3],
|
||||
NULL, NULL, NULL, 0,
|
||||
DPPLAYER_SPECTATOR );
|
||||
checkHR( DP_OK, hr );
|
||||
hr = IDirectPlayX_CreatePlayer( pDP[2], &dpid[4],
|
||||
NULL, NULL, NULL, 0,
|
||||
0 );
|
||||
checkHR( DP_OK, hr );
|
||||
hr = IDirectPlayX_CreateGroup( pDP[2], &dpid[6],
|
||||
NULL, NULL, 0, 0 );
|
||||
checkHR( DP_OK, hr );
|
||||
|
||||
callbackData.dwCounter1 = 0;
|
||||
callbackData.szTrace2[0] = 0;
|
||||
hr = IDirectPlayX_EnumPlayers( pDP[2], NULL, EnumPlayers_cb,
|
||||
(LPVOID) &callbackData, 0 );
|
||||
checkHR( DP_OK, hr );
|
||||
check( 4, callbackData.dwCounter1 );
|
||||
checkStr( "4302", callbackData.szTrace1 );
|
||||
checkStr( "ALL:SPECTATOR:SERVERPLAYER:ALL:", callbackData.szTrace2 );
|
||||
|
||||
|
||||
/* Flag tests */
|
||||
|
||||
callbackData.dwCounter1 = 0;
|
||||
callbackData.szTrace2[0] = 0;
|
||||
hr = IDirectPlayX_EnumPlayers( pDP[2], NULL, EnumPlayers_cb,
|
||||
(LPVOID) &callbackData,
|
||||
DPENUMPLAYERS_ALL );
|
||||
checkHR( DP_OK, hr );
|
||||
check( 4, callbackData.dwCounter1 );
|
||||
checkStr( "4302", callbackData.szTrace1 );
|
||||
checkStr( "ALL:SPECTATOR:SERVERPLAYER:ALL:", callbackData.szTrace2 );
|
||||
|
||||
callbackData.dwCounter1 = 0;
|
||||
callbackData.szTrace2[0] = 0;
|
||||
hr = IDirectPlayX_EnumPlayers( pDP[2], NULL, EnumPlayers_cb,
|
||||
(LPVOID) &callbackData,
|
||||
DPENUMPLAYERS_GROUP );
|
||||
checkHR( DP_OK, hr );
|
||||
check( 6, callbackData.dwCounter1 );
|
||||
checkStr( "430256", callbackData.szTrace1 );
|
||||
checkStr( "GROUP:"
|
||||
"GROUP,DPENUMPLAYERS_SPECTATOR:"
|
||||
"GROUP,DPENUMPLAYERS_SERVERPLAYER:"
|
||||
"GROUP:ALL:ALL:", callbackData.szTrace2 );
|
||||
|
||||
callbackData.dwCounter1 = 0;
|
||||
callbackData.szTrace2[0] = 0;
|
||||
hr = IDirectPlayX_EnumPlayers( pDP[2], NULL, EnumPlayers_cb,
|
||||
(LPVOID) &callbackData,
|
||||
DPENUMPLAYERS_LOCAL );
|
||||
checkHR( DP_OK, hr );
|
||||
check( 2, callbackData.dwCounter1 );
|
||||
checkStr( "43", callbackData.szTrace1 );
|
||||
checkStr( "LOCAL:"
|
||||
"LOCAL,DPENUMPLAYERS_SPECTATOR:", callbackData.szTrace2 );
|
||||
|
||||
callbackData.dwCounter1 = 0;
|
||||
callbackData.szTrace2[0] = 0;
|
||||
hr = IDirectPlayX_EnumPlayers( pDP[2], NULL, EnumPlayers_cb,
|
||||
(LPVOID) &callbackData,
|
||||
DPENUMPLAYERS_SERVERPLAYER );
|
||||
checkHR( DP_OK, hr );
|
||||
check( 1, callbackData.dwCounter1 );
|
||||
checkStr( "0", callbackData.szTrace1 );
|
||||
checkStr( "SERVERPLAYER:", callbackData.szTrace2 );
|
||||
|
||||
callbackData.dwCounter1 = 0;
|
||||
callbackData.szTrace2[0] = 0;
|
||||
hr = IDirectPlayX_EnumPlayers( pDP[2], NULL, EnumPlayers_cb,
|
||||
(LPVOID) &callbackData,
|
||||
DPENUMPLAYERS_SPECTATOR );
|
||||
checkHR( DP_OK, hr );
|
||||
check( 1, callbackData.dwCounter1 );
|
||||
checkStr( "3", callbackData.szTrace1 );
|
||||
checkStr( "SPECTATOR:", callbackData.szTrace2 );
|
||||
|
||||
|
||||
IDirectPlayX_Release( pDP[0] );
|
||||
IDirectPlayX_Release( pDP[1] );
|
||||
IDirectPlayX_Release( pDP[2] );
|
||||
|
||||
}
|
||||
|
||||
|
||||
START_TEST(dplayx)
|
||||
{
|
||||
|
@ -3499,5 +3840,7 @@ START_TEST(dplayx)
|
|||
test_CreateGroup();
|
||||
test_GroupOwner();
|
||||
|
||||
test_EnumPlayers();
|
||||
|
||||
CoUninitialize();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue