Alessandro Pignotti : dplay: Directplay should initialize session Guid, with conformance tests.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Mar 1 16:27:05 CST 2007


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

Author: Alessandro Pignotti <alex.pigna at inventati.org>
Date:   Tue Feb 27 17:27:43 2007 +0100

dplay: Directplay should initialize session Guid, with conformance tests.

---

 .gitignore                    |    4 ++
 Makefile.in                   |    2 +
 configure                     |    3 +
 configure.ac                  |    1 +
 dlls/Makefile.in              |    1 +
 dlls/dplayx/dplay.c           |    6 ++-
 dlls/dplayx/tests/Makefile.in |   14 ++++++
 dlls/dplayx/tests/dplayx.c    |   89 +++++++++++++++++++++++++++++++++++++++++
 programs/winetest/Makefile.in |    3 +
 programs/winetest/winetest.rc |    1 +
 10 files changed, 123 insertions(+), 1 deletions(-)

diff --git a/.gitignore b/.gitignore
index 21f12e3..772db5f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -213,6 +213,9 @@ dlls/dnsapi/tests/testlist.c
 dlls/dplay/libdplay.def
 dlls/dplay/version.res
 dlls/dplayx/libdplayx.def
+dlls/dplayx/tests/*.ok
+dlls/dplayx/tests/dplayx_crosstest.exe
+dlls/dplayx/tests/testlist.c
 dlls/dplayx/version.res
 dlls/dpnet/libdpnet.def
 dlls/dpnet/version.res
@@ -803,6 +806,7 @@ programs/winetest/d3d9_test.exe
 programs/winetest/ddraw_test.exe
 programs/winetest/dinput_test.exe
 programs/winetest/dnsapi_test.exe
+programs/winetest/dplayx_test.exe
 programs/winetest/dsound_test.exe
 programs/winetest/gdi32_test.exe
 programs/winetest/hlink_test.exe
diff --git a/Makefile.in b/Makefile.in
index 86fa213..bc1d654 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -216,6 +216,7 @@ ALL_MAKEFILES = \
 	dlls/dnsapi/tests/Makefile \
 	dlls/dplay/Makefile \
 	dlls/dplayx/Makefile \
+	dlls/dplayx/tests/Makefile \
 	dlls/dpnet/Makefile \
 	dlls/dpnhpast/Makefile \
 	dlls/dsound/Makefile \
@@ -549,6 +550,7 @@ dlls/dnsapi/Makefile: dlls/dnsapi/Makefile.in dlls/Makedll.rules
 dlls/dnsapi/tests/Makefile: dlls/dnsapi/tests/Makefile.in dlls/Maketest.rules
 dlls/dplay/Makefile: dlls/dplay/Makefile.in dlls/Makedll.rules
 dlls/dplayx/Makefile: dlls/dplayx/Makefile.in dlls/Makedll.rules
+dlls/dplayx/tests/Makefile: dlls/dplayx/tests/Makefile.in dlls/Maketest.rules
 dlls/dpnet/Makefile: dlls/dpnet/Makefile.in dlls/Makedll.rules
 dlls/dpnhpast/Makefile: dlls/dpnhpast/Makefile.in dlls/Makedll.rules
 dlls/dsound/Makefile: dlls/dsound/Makefile.in dlls/Makedll.rules
diff --git a/configure b/configure
index 67f50c2..c7023cf 100755
--- a/configure
+++ b/configure
@@ -20563,6 +20563,8 @@ ac_config_files="$ac_config_files dlls/dplay/Makefile"
 
 ac_config_files="$ac_config_files dlls/dplayx/Makefile"
 
+ac_config_files="$ac_config_files dlls/dplayx/tests/Makefile"
+
 ac_config_files="$ac_config_files dlls/dpnet/Makefile"
 
 ac_config_files="$ac_config_files dlls/dpnhpast/Makefile"
@@ -21709,6 +21711,7 @@ do
     "dlls/dnsapi/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/dnsapi/tests/Makefile" ;;
     "dlls/dplay/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/dplay/Makefile" ;;
     "dlls/dplayx/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/dplayx/Makefile" ;;
+    "dlls/dplayx/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/dplayx/tests/Makefile" ;;
     "dlls/dpnet/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/dpnet/Makefile" ;;
     "dlls/dpnhpast/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/dpnhpast/Makefile" ;;
     "dlls/dsound/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/dsound/Makefile" ;;
diff --git a/configure.ac b/configure.ac
index f363868..7c27c34 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1586,6 +1586,7 @@ AC_CONFIG_FILES([dlls/dnsapi/Makefile])
 AC_CONFIG_FILES([dlls/dnsapi/tests/Makefile])
 AC_CONFIG_FILES([dlls/dplay/Makefile])
 AC_CONFIG_FILES([dlls/dplayx/Makefile])
+AC_CONFIG_FILES([dlls/dplayx/tests/Makefile])
 AC_CONFIG_FILES([dlls/dpnet/Makefile])
 AC_CONFIG_FILES([dlls/dpnhpast/Makefile])
 AC_CONFIG_FILES([dlls/dsound/Makefile])
diff --git a/dlls/Makefile.in b/dlls/Makefile.in
index 2e3cafc..95c98d3 100644
--- a/dlls/Makefile.in
+++ b/dlls/Makefile.in
@@ -233,6 +233,7 @@ TESTSUBDIRS = \
 	ddraw/tests \
 	dinput/tests \
 	dnsapi/tests \
+	dplayx/tests \
 	dsound/tests \
 	gdi32/tests \
 	hlink/tests \
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c
index f5c630a..3ca90db 100644
--- a/dlls/dplayx/dplay.c
+++ b/dlls/dplayx/dplay.c
@@ -3244,7 +3244,11 @@ static HRESULT WINAPI DP_SetSessionDesc
   HeapFree( GetProcessHeap(), 0, This->dp2->lpSessionDesc );
 
   This->dp2->lpSessionDesc = lpTempSessDesc;
-
+  if( bInitial )
+  {
+    /*Initializing session GUID*/
+    CoCreateGuid( &(This->dp2->lpSessionDesc->guidInstance) );
+  }
   /* Set the new */
   DP_CopySessionDesc( This->dp2->lpSessionDesc, lpSessDesc, bAnsi );
 
diff --git a/dlls/dplayx/tests/Makefile.in b/dlls/dplayx/tests/Makefile.in
new file mode 100644
index 0000000..82a9064
--- /dev/null
+++ b/dlls/dplayx/tests/Makefile.in
@@ -0,0 +1,14 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+TESTDLL   = dplayx.dll
+IMPORTS   = ole32 kernel32
+EXTRALIBS = -ldxguid
+
+CTESTS = \
+	dplayx.c
+
+ at MAKE_TEST_RULES@
+
+ at DEPENDENCIES@  # everything below this line is overwritten by make depend
diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c
new file mode 100644
index 0000000..6568f13
--- /dev/null
+++ b/dlls/dplayx/tests/dplayx.c
@@ -0,0 +1,89 @@
+/* DirectPlay Conformance Tests
+ *
+ * Copyright 2007 - Alessandro Pignotti
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "wine/test.h"
+#include <dplay.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)
+{
+    HRESULT hr;
+
+    if(IsEqualGUID(lpguidSP,&DPSPGUID_TCPIP))
+    {
+        /*I'm forcing TCP/IP Sevice provider*/
+        hr = IDirectPlayX_InitializeConnection((LPDIRECTPLAY4) lpContext, lpConnection, 0);
+        todo_wine ok( SUCCEEDED( hr ), "It's not possible to initialize TCP/IP service provider\n");
+        if( SUCCEEDED( hr ))
+            validSP = TRUE;
+        return FALSE;
+    }
+    return TRUE;
+}
+
+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 )
+    {
+        memset(&sessionDesc, 0, sizeof( DPSESSIONDESC2 ));
+        memset(&zeroGuid, 0, 16);
+
+        sessionDesc.dwSize = sizeof( DPSESSIONDESC2 );
+        memcpy(&sessionDesc.guidApplication, &appGuid, 16);
+        sessionDesc.dwFlags = DPSESSION_CLIENTSERVER;
+        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");
+        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 );
+
+    IDirectPlayX_Release( pDP );
+    CoUninitialize();
+}
diff --git a/programs/winetest/Makefile.in b/programs/winetest/Makefile.in
index f35b768..056d636 100644
--- a/programs/winetest/Makefile.in
+++ b/programs/winetest/Makefile.in
@@ -36,6 +36,7 @@ TESTBINS = \
 	ddraw_test.exe \
 	dinput_test.exe \
 	dnsapi_test.exe \
+	dplayx_test.exe \
 	dsound_test.exe \
 	gdi32_test.exe \
 	hlink_test.exe \
@@ -109,6 +110,8 @@ dinput_test.exe: $(DLLDIR)/dinput/tests/dinput_test.exe$(DLLEXT)
 	cp $(DLLDIR)/dinput/tests/dinput_test.exe$(DLLEXT) $@ && $(STRIP) $@
 dnsapi_test.exe: $(DLLDIR)/dnsapi/tests/dnsapi_test.exe$(DLLEXT)
 	cp $(DLLDIR)/dnsapi/tests/dnsapi_test.exe$(DLLEXT) $@ && $(STRIP) $@
+dplayx_test.exe: $(DLLDIR)/dplayx/tests/dplayx_test.exe$(DLLEXT)
+	cp $(DLLDIR)/dplayx/tests/dplayx_test.exe$(DLLEXT) $@ && $(STRIP) $@
 dsound_test.exe: $(DLLDIR)/dsound/tests/dsound_test.exe$(DLLEXT)
 	cp $(DLLDIR)/dsound/tests/dsound_test.exe$(DLLEXT) $@ && $(STRIP) $@
 gdi32_test.exe: $(DLLDIR)/gdi32/tests/gdi32_test.exe$(DLLEXT)
diff --git a/programs/winetest/winetest.rc b/programs/winetest/winetest.rc
index 423eb1a..2401ac1 100644
--- a/programs/winetest/winetest.rc
+++ b/programs/winetest/winetest.rc
@@ -159,6 +159,7 @@ d3d9_test.exe TESTRES "d3d9_test.exe"
 ddraw_test.exe TESTRES "ddraw_test.exe"
 dinput_test.exe TESTRES "dinput_test.exe"
 dnsapi_test.exe TESTRES "dnsapi_test.exe"
+dplayx_test.exe TESTRES "dplayx_test.exe"
 dsound_test.exe TESTRES "dsound_test.exe"
 gdi32_test.exe TESTRES "gdi32_test.exe"
 hlink_test.exe TESTRES "hlink_test.exe"




More information about the wine-cvs mailing list