Ismael Barros : dplayx: Tests for GetCaps.

Alexandre Julliard julliard at winehq.org
Fri Aug 1 05:33:58 CDT 2008


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

Author: Ismael Barros <razielmine at gmail.com>
Date:   Thu Jul 31 20:17:26 2008 +0300

dplayx: Tests for GetCaps.

---

 dlls/dplayx/dplay.c        |    5 ++
 dlls/dplayx/tests/dplayx.c |  120 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 125 insertions(+), 0 deletions(-)

diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c
index 91ba4d6..1ba7d7e 100644
--- a/dlls/dplayx/dplay.c
+++ b/dlls/dplayx/dplay.c
@@ -2380,6 +2380,11 @@ static HRESULT WINAPI DP_IF_GetPlayerCaps
 
   TRACE("(%p)->(0x%08x,%p,0x%08x)\n", This, idPlayer, lpDPCaps, dwFlags);
 
+  if ( This->dp2->connectionInitialized == NO_PROVIDER )
+  {
+    return DPERR_UNINITIALIZED;
+  }
+
   /* Query the service provider */
   data.idPlayer = idPlayer;
   data.dwFlags  = dwFlags;
diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c
index 3a442c9..5dccfe1 100644
--- a/dlls/dplayx/tests/dplayx.c
+++ b/dlls/dplayx/tests/dplayx.c
@@ -529,6 +529,56 @@ static LPCSTR dwFlags2str(DWORD dwFlags, DWORD flagType)
     return flags;
 }
 
+static void init_TCPIP_provider( LPDIRECTPLAY4 pDP,
+                                 LPCSTR strIPAddressString,
+                                 WORD port )
+{
+
+    DPCOMPOUNDADDRESSELEMENT addressElements[3];
+    LPVOID pAddress = NULL;
+    DWORD dwAddressSize = 0;
+    LPDIRECTPLAYLOBBY3 pDPL;
+    HRESULT hr;
+
+    CoCreateInstance( &CLSID_DirectPlayLobby, NULL, CLSCTX_ALL,
+                      &IID_IDirectPlayLobby3A, (LPVOID*) &pDPL );
+
+    /* Service provider */
+    addressElements[0].guidDataType = DPAID_ServiceProvider;
+    addressElements[0].dwDataSize   = sizeof(GUID);
+    addressElements[0].lpData       = (LPVOID) &DPSPGUID_TCPIP;
+
+    /* IP address string */
+    addressElements[1].guidDataType = DPAID_INet;
+    addressElements[1].dwDataSize   = lstrlen(strIPAddressString) + 1;
+    addressElements[1].lpData       = (LPVOID) strIPAddressString;
+
+    /* Optional Port number */
+    if( port > 0 )
+    {
+        addressElements[2].guidDataType = DPAID_INetPort;
+        addressElements[2].dwDataSize   = sizeof(WORD);
+        addressElements[2].lpData       = &port;
+    }
+
+
+    hr = IDirectPlayLobby_CreateCompoundAddress( pDPL, addressElements, 2,
+                                                 NULL, &dwAddressSize );
+    checkHR( DPERR_BUFFERTOOSMALL, hr );
+
+    if( hr == DPERR_BUFFERTOOSMALL )
+    {
+        pAddress = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwAddressSize );
+        hr = IDirectPlayLobby_CreateCompoundAddress( pDPL, addressElements, 2,
+                                                     pAddress, &dwAddressSize );
+        checkHR( DP_OK, hr );
+    }
+
+    hr = IDirectPlayX_InitializeConnection( pDP, pAddress, 0 );
+    todo_wine checkHR( DP_OK, hr );
+
+}
+
 
 /* DirectPlayCreate */
 
@@ -753,6 +803,74 @@ static void test_InitializeConnection(void)
     IDirectPlayX_Release( pDP );
 }
 
+/* GetCaps */
+
+static void test_GetCaps(void)
+{
+
+    LPDIRECTPLAY4 pDP;
+    DPCAPS dpcaps;
+    DWORD dwFlags;
+    HRESULT hr;
+
+
+    CoCreateInstance( &CLSID_DirectPlay, NULL, CLSCTX_ALL,
+                      &IID_IDirectPlay4A, (LPVOID*) &pDP );
+    ZeroMemory( &dpcaps, sizeof(DPCAPS) );
+
+    /* Service provider not ininitialized */
+    hr = IDirectPlayX_GetCaps( pDP, &dpcaps, 0 );
+    checkHR( DPERR_UNINITIALIZED, hr );
+
+    init_TCPIP_provider( pDP, "127.0.0.1", 0 );
+
+    /* dpcaps not ininitialized */
+    hr = IDirectPlayX_GetCaps( pDP, &dpcaps, 0 );
+    todo_wine checkHR( DPERR_INVALIDPARAMS, hr );
+
+    dpcaps.dwSize = sizeof(DPCAPS);
+
+    for (dwFlags=0;
+         dwFlags<=DPGETCAPS_GUARANTEED;
+         dwFlags+=DPGETCAPS_GUARANTEED)
+    {
+
+        hr = IDirectPlayX_GetCaps( pDP, &dpcaps, dwFlags );
+        todo_wine checkHR( DP_OK, hr );
+
+
+        if ( hr == DP_OK )
+        {
+            check( sizeof(DPCAPS), dpcaps.dwSize );
+            check( DPCAPS_ASYNCSUPPORTED |
+                   DPCAPS_GUARANTEEDOPTIMIZED |
+                   DPCAPS_GUARANTEEDSUPPORTED,
+                   dpcaps.dwFlags );
+            check( 0,     dpcaps.dwMaxQueueSize );
+            check( 0,     dpcaps.dwHundredBaud );
+            check( 500,   dpcaps.dwLatency );
+            check( 65536, dpcaps.dwMaxLocalPlayers );
+            check( 20,    dpcaps.dwHeaderLength );
+            check( 5000,  dpcaps.dwTimeout );
+
+            switch (dwFlags)
+            {
+            case 0:
+                check( 65479,   dpcaps.dwMaxBufferSize );
+                check( 65536,   dpcaps.dwMaxPlayers );
+                break;
+            case DPGETCAPS_GUARANTEED:
+                check( 1048547, dpcaps.dwMaxBufferSize );
+                check( 64,      dpcaps.dwMaxPlayers );
+                break;
+            default: break;
+            }
+        }
+    }
+
+    IDirectPlayX_Release( pDP );
+}
+
 
 START_TEST(dplayx)
 {
@@ -762,5 +880,7 @@ START_TEST(dplayx)
     test_EnumConnections();
     test_InitializeConnection();
 
+    test_GetCaps();
+
     CoUninitialize();
 }




More information about the wine-cvs mailing list