Ismael Barros : dplayx: Tests for CreatePlayer.

Alexandre Julliard julliard at winehq.org
Mon Aug 4 08:53:54 CDT 2008


Module: wine
Branch: master
Commit: 724f0ea4d6bab954b9840a19e55eaa790028ab89
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=724f0ea4d6bab954b9840a19e55eaa790028ab89

Author: Ismael Barros <razielmine at gmail.com>
Date:   Sun Aug  3 13:22:40 2008 +0200

dplayx: Tests for CreatePlayer.

---

 dlls/dplayx/dplay.c        |   10 +++
 dlls/dplayx/tests/dplayx.c |  169 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 179 insertions(+), 0 deletions(-)

diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c
index 468b439..b5f94d3 100644
--- a/dlls/dplayx/dplay.c
+++ b/dlls/dplayx/dplay.c
@@ -1611,6 +1611,11 @@ static HRESULT WINAPI DirectPlay2AImpl_CreatePlayer
 {
   IDirectPlay2Impl *This = (IDirectPlay2Impl *)iface;
 
+  if( lpidPlayer == NULL )
+  {
+    return DPERR_INVALIDPARAMS;
+  }
+
   if( dwFlags & DPPLAYER_SERVERPLAYER )
   {
     *lpidPlayer = DPID_SERVERPLAYER;
@@ -1630,6 +1635,11 @@ static HRESULT WINAPI DirectPlay2WImpl_CreatePlayer
 {
   IDirectPlay2Impl *This = (IDirectPlay2Impl *)iface;
 
+  if( lpidPlayer == NULL )
+  {
+    return DPERR_INVALIDPARAMS;
+  }
+
   if( dwFlags & DPPLAYER_SERVERPLAYER )
   {
     *lpidPlayer = DPID_SERVERPLAYER;
diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c
index ac9da5d..7cac4b5 100644
--- a/dlls/dplayx/tests/dplayx.c
+++ b/dlls/dplayx/tests/dplayx.c
@@ -1759,6 +1759,173 @@ static void test_SessionDesc(void)
 
 }
 
+/* CreatePlayer */
+
+static void test_CreatePlayer(void)
+{
+
+    LPDIRECTPLAY4 pDP[2];
+    DPSESSIONDESC2 dpsd;
+    DPNAME name;
+    DPID dpid;
+    HRESULT hr;
+
+
+    CoCreateInstance( &CLSID_DirectPlay, NULL, CLSCTX_ALL,
+                      &IID_IDirectPlay4A, (LPVOID*) &pDP[0] );
+    CoCreateInstance( &CLSID_DirectPlay, NULL, CLSCTX_ALL,
+                      &IID_IDirectPlay4A, (LPVOID*) &pDP[1] );
+    ZeroMemory( &dpsd, sizeof(DPSESSIONDESC2) );
+    ZeroMemory( &name, sizeof(DPNAME) );
+
+
+    /* Connection not initialized */
+    hr = IDirectPlayX_CreatePlayer( pDP[0], &dpid, NULL, NULL, NULL, 0, 0 );
+    checkHR( DPERR_UNINITIALIZED, hr );
+
+
+    init_TCPIP_provider( pDP[0], "127.0.0.1", 0 );
+    init_TCPIP_provider( pDP[1], "127.0.0.1", 0 );
+
+
+    /* Session not open */
+    hr = IDirectPlayX_CreatePlayer( pDP[0], &dpid, NULL, NULL, NULL, 0, 0 );
+    todo_wine checkHR( DPERR_INVALIDPARAMS, hr );
+
+    if ( hr == DPERR_UNINITIALIZED )
+    {
+        skip( "CreatePlayer not implemented\n" );
+        return;
+    }
+
+    dpsd.dwSize = sizeof(DPSESSIONDESC2);
+    dpsd.guidApplication = appGuid;
+    IDirectPlayX_Open( pDP[0], &dpsd, DPOPEN_CREATE );
+
+
+    /* Player name */
+    hr = IDirectPlayX_CreatePlayer( pDP[0], &dpid, NULL, NULL, NULL, 0, 0 );
+    checkHR( DP_OK, hr );
+
+
+    name.dwSize = -1;
+
+
+    hr = IDirectPlayX_CreatePlayer( pDP[0], &dpid, &name, NULL, NULL, 0, 0 );
+    checkHR( DP_OK, hr );
+
+
+    name.dwSize = sizeof(DPNAME);
+    name.lpszShortNameA = (LPSTR) "test";
+    name.lpszLongNameA = NULL;
+
+
+    hr = IDirectPlayX_CreatePlayer( pDP[0], &dpid, &name, NULL, NULL,
+                                    0, 0 );
+    checkHR( DP_OK, hr );
+
+
+    /* Null dpid */
+    hr = IDirectPlayX_CreatePlayer( pDP[0], NULL, NULL, NULL, NULL,
+                                    0, 0 );
+    checkHR( DPERR_INVALIDPARAMS, hr );
+
+
+    /* There can only be one server player */
+    hr = IDirectPlayX_CreatePlayer( pDP[0], &dpid, NULL, NULL, NULL,
+                                    0, DPPLAYER_SERVERPLAYER );
+    checkHR( DP_OK, hr );
+    check( DPID_SERVERPLAYER, dpid );
+
+    hr = IDirectPlayX_CreatePlayer( pDP[0], &dpid, NULL, NULL, NULL,
+                                    0, DPPLAYER_SERVERPLAYER );
+    checkHR( DPERR_CANTCREATEPLAYER, hr );
+
+    IDirectPlayX_DestroyPlayer( pDP[0], dpid );
+
+    hr = IDirectPlayX_CreatePlayer( pDP[0], &dpid, NULL, NULL, NULL,
+                                    0, DPPLAYER_SERVERPLAYER );
+    checkHR( DP_OK, hr );
+    check( DPID_SERVERPLAYER, dpid );
+    IDirectPlayX_DestroyPlayer( pDP[0], dpid );
+
+
+    /* Flags */
+    hr = IDirectPlayX_CreatePlayer( pDP[0], &dpid, NULL, NULL, NULL,
+                                    0, 0 );
+    checkHR( DP_OK, hr );
+
+    hr = IDirectPlayX_CreatePlayer( pDP[0], &dpid, NULL, NULL, NULL,
+                                    0, DPPLAYER_SERVERPLAYER );
+    checkHR( DP_OK, hr );
+    check( DPID_SERVERPLAYER, dpid );
+    IDirectPlayX_DestroyPlayer( pDP[0], dpid );
+
+    hr = IDirectPlayX_CreatePlayer( pDP[0], &dpid, NULL, NULL, NULL,
+                                    0, DPPLAYER_SPECTATOR );
+    checkHR( DP_OK, hr );
+
+    hr = IDirectPlayX_CreatePlayer( pDP[0], &dpid, NULL, NULL, NULL,
+                                    0, ( DPPLAYER_SERVERPLAYER |
+                                         DPPLAYER_SPECTATOR ) );
+    checkHR( DP_OK, hr );
+    check( DPID_SERVERPLAYER, dpid );
+    IDirectPlayX_DestroyPlayer( pDP[0], dpid );
+
+
+    /* Session with DPSESSION_NEWPLAYERSDISABLED */
+    IDirectPlayX_Close( pDP[0] );
+    dpsd.dwFlags = DPSESSION_NEWPLAYERSDISABLED;
+    hr = IDirectPlayX_Open( pDP[0], &dpsd, DPOPEN_CREATE );
+    checkHR( DP_OK, hr );
+
+
+    hr = IDirectPlayX_CreatePlayer( pDP[0], &dpid, NULL, NULL, NULL,
+                                    0, 0 );
+    checkHR( DPERR_CANTCREATEPLAYER, hr );
+
+    hr = IDirectPlayX_CreatePlayer( pDP[0], &dpid, NULL, NULL, NULL,
+                                    0, DPPLAYER_SERVERPLAYER );
+    checkHR( DPERR_CANTCREATEPLAYER, hr );
+
+    hr = IDirectPlayX_CreatePlayer( pDP[0], &dpid, NULL, NULL, NULL,
+                                    0, DPPLAYER_SPECTATOR );
+    checkHR( DPERR_CANTCREATEPLAYER, hr );
+
+
+    /* Creating players in a Client/Server session */
+    IDirectPlayX_Close( pDP[0] );
+    dpsd.dwFlags = DPSESSION_CLIENTSERVER;
+    hr = IDirectPlayX_Open( pDP[0], &dpsd, DPOPEN_CREATE );
+    checkHR( DP_OK, hr );
+    hr = IDirectPlayX_EnumSessions( pDP[1], &dpsd, 0, EnumSessions_cb_join,
+                                    (LPVOID) pDP[1], 0 );
+    checkHR( DP_OK, hr );
+
+
+    hr = IDirectPlayX_CreatePlayer( pDP[0], &dpid, NULL, NULL, NULL,
+                                    0, 0 );
+    checkHR( DPERR_ACCESSDENIED, hr );
+
+    hr = IDirectPlayX_CreatePlayer( pDP[0], &dpid, NULL, NULL, NULL,
+                                    0, DPPLAYER_SERVERPLAYER );
+    checkHR( DP_OK, hr );
+    check( DPID_SERVERPLAYER, dpid );
+
+    hr = IDirectPlayX_CreatePlayer( pDP[1], &dpid, NULL, NULL, NULL,
+                                    0, DPPLAYER_SERVERPLAYER );
+    checkHR( DPERR_INVALIDFLAGS, hr );
+
+    hr = IDirectPlayX_CreatePlayer( pDP[1], &dpid, NULL, NULL, NULL,
+                                    0, 0 );
+    checkHR( DP_OK, hr );
+
+
+    IDirectPlayX_Release( pDP[0] );
+    IDirectPlayX_Release( pDP[1] );
+
+}
+
 
 START_TEST(dplayx)
 {
@@ -1773,5 +1940,7 @@ START_TEST(dplayx)
     test_EnumSessions();
     test_SessionDesc();
 
+    test_CreatePlayer();
+
     CoUninitialize();
 }




More information about the wine-cvs mailing list