dsound: add test for bug 7813

Robert Reif reif at earthlink.net
Tue Jun 26 22:11:27 CDT 2007


Add regression tests for BUG 7813 which I fixed about a month ago.

This patch makes IDirectSound_test in dsound.c global and adds a
flag to indicate if the DirectSound object is a real DirctSound object
or an interface from a DirectSound8 object.  Tests are added in dsound8.c
to the class factory tests to exercise a DirectSound and a DirectSound8
interface.
-------------- next part --------------
Index: dlls/dsound/tests/dsound.c
===================================================================
RCS file: /home/wine/wine/dlls/dsound/tests/dsound.c,v
retrieving revision 1.66
diff -p -u -r1.66 dsound.c
--- dlls/dsound/tests/dsound.c	25 May 2007 19:45:38 -0000	1.66
+++ dlls/dsound/tests/dsound.c	27 Jun 2007 02:55:17 -0000
@@ -39,8 +39,8 @@ static HRESULT (WINAPI *pDirectSoundEnum
 static HRESULT (WINAPI *pDirectSoundCreate)(LPCGUID,LPDIRECTSOUND*,
     LPUNKNOWN)=NULL;
 
-static void IDirectSound_test(LPDIRECTSOUND dso, BOOL initialized,
-                              LPCGUID lpGuid)
+void IDirectSound_test(LPDIRECTSOUND dso, BOOL initialized, LPCGUID lpGuid,
+                       BOOL from8)
 {
     HRESULT rc;
     DSCAPS dscaps;
@@ -64,8 +64,12 @@ static void IDirectSound_test(LPDIRECTSO
         IDirectSound_Release(ds);
 
     rc=IDirectSound_QueryInterface(dso,&IID_IDirectSound8,(LPVOID*)&ds8);
-    ok(rc==E_NOINTERFACE,"IDirectSound_QueryInterface(IID_IDirectSound8) "
-       "should have failed: %s\n",DXGetErrorString8(rc));
+    if (from8)
+        ok(rc==DS_OK,"IDirectSound_QueryInterface(IID_IDirectSound8) "
+           "failed: %s\n",DXGetErrorString8(rc));
+    else
+        ok(rc==E_NOINTERFACE,"IDirectSound_QueryInterface(IID_IDirectSound8) "
+           "should have failed: %s\n",DXGetErrorString8(rc));
     if (rc==DS_OK)
         IDirectSound8_Release(ds8);
 
@@ -195,7 +199,7 @@ static void IDirectSound_tests(void)
     ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound) failed: %s\n",
        DXGetErrorString8(rc));
     if (dso)
-        IDirectSound_test(dso, FALSE, NULL);
+        IDirectSound_test(dso, FALSE, NULL, FALSE);
 
     /* try the COM class factory method of creation with default playback
      * device specified */
@@ -204,7 +208,7 @@ static void IDirectSound_tests(void)
     ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound) failed: %s\n",
        DXGetErrorString8(rc));
     if (dso)
-        IDirectSound_test(dso, FALSE, &DSDEVID_DefaultPlayback);
+        IDirectSound_test(dso, FALSE, &DSDEVID_DefaultPlayback, FALSE);
 
     /* try the COM class factory method of creation with default voice
      * playback device specified */
@@ -213,7 +217,7 @@ static void IDirectSound_tests(void)
     ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound) failed: %s\n",
        DXGetErrorString8(rc));
     if (dso)
-        IDirectSound_test(dso, FALSE, &DSDEVID_DefaultVoicePlayback);
+        IDirectSound_test(dso, FALSE, &DSDEVID_DefaultVoicePlayback, FALSE);
 
     /* try the COM class factory method of creation with a bad
      * IID specified */
@@ -236,7 +240,7 @@ static void IDirectSound_tests(void)
     ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
        "DirectSoundCreate(NULL) failed: %s\n",DXGetErrorString8(rc));
     if (rc==S_OK && dso)
-        IDirectSound_test(dso, TRUE, NULL);
+        IDirectSound_test(dso, TRUE, NULL, FALSE);
 
     /* try with default playback device specified */
     rc=pDirectSoundCreate(&DSDEVID_DefaultPlayback,&dso,NULL);
@@ -244,7 +248,7 @@ static void IDirectSound_tests(void)
        "DirectSoundCreate(DSDEVID_DefaultPlayback) failed: %s\n",
        DXGetErrorString8(rc));
     if (rc==DS_OK && dso)
-        IDirectSound_test(dso, TRUE, NULL);
+        IDirectSound_test(dso, TRUE, NULL, FALSE);
 
     /* try with default voice playback device specified */
     rc=pDirectSoundCreate(&DSDEVID_DefaultVoicePlayback,&dso,NULL);
@@ -252,7 +256,7 @@ static void IDirectSound_tests(void)
        "DirectSoundCreate(DSDEVID_DefaultVoicePlayback) failed: %s\n",
        DXGetErrorString8(rc));
     if (rc==DS_OK && dso)
-        IDirectSound_test(dso, TRUE, NULL);
+        IDirectSound_test(dso, TRUE, NULL, FALSE);
 
     /* try with a bad device specified */
     rc=pDirectSoundCreate(&DSDEVID_DefaultVoiceCapture,&dso,NULL);
@@ -281,7 +285,7 @@ static HRESULT test_dsound(LPGUID lpGuid
         return rc;
 
     /* Try the enumerated device */
-    IDirectSound_test(dso, TRUE, lpGuid);
+    IDirectSound_test(dso, TRUE, lpGuid, FALSE);
 
     /* Try the COM class factory method of creation with enumerated device */
     rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
@@ -289,7 +293,7 @@ static HRESULT test_dsound(LPGUID lpGuid
     ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound) failed: %s\n",
        DXGetErrorString8(rc));
     if (dso)
-        IDirectSound_test(dso, FALSE, lpGuid);
+        IDirectSound_test(dso, FALSE, lpGuid, FALSE);
 
     /* Create a DirectSound object */
     rc=pDirectSoundCreate(lpGuid,&dso,NULL);
Index: dlls/dsound/tests/dsound8.c
===================================================================
RCS file: /home/wine/wine/dlls/dsound/tests/dsound8.c,v
retrieving revision 1.39
diff -p -u -r1.39 dsound8.c
--- dlls/dsound/tests/dsound8.c	14 May 2007 15:54:18 -0000	1.39
+++ dlls/dsound/tests/dsound8.c	27 Jun 2007 02:55:17 -0000
@@ -189,7 +189,8 @@ EXIT:
 static void IDirectSound8_tests(void)
 {
     HRESULT rc;
-    LPDIRECTSOUND8 dso=NULL;
+    LPDIRECTSOUND dso=NULL;
+    LPDIRECTSOUND8 dso8=NULL;
     LPCLASSFACTORY cf=NULL;
 
     trace("Testing IDirectSound8\n");
@@ -206,38 +207,38 @@ static void IDirectSound8_tests(void)
 
     /* try the COM class factory method of creation with no device specified */
     rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
-                        &IID_IDirectSound8, (void**)&dso);
+                        &IID_IDirectSound8, (void**)&dso8);
     ok(rc==S_OK||rc==REGDB_E_CLASSNOTREG,"CoCreateInstance() failed: %s\n",
        DXGetErrorString8(rc));
     if (rc==REGDB_E_CLASSNOTREG) {
         trace("  Class Not Registered\n");
         return;
     }
-    if (dso)
-        IDirectSound8_test(dso, FALSE, NULL);
+    if (dso8)
+        IDirectSound8_test(dso8, FALSE, NULL);
 
     /* try the COM class factory method of creation with default playback
      *  device specified */
     rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
-                        &IID_IDirectSound8, (void**)&dso);
+                        &IID_IDirectSound8, (void**)&dso8);
     ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound8) failed: %s\n",
        DXGetErrorString8(rc));
-    if (dso)
-        IDirectSound8_test(dso, FALSE, &DSDEVID_DefaultPlayback);
+    if (dso8)
+        IDirectSound8_test(dso8, FALSE, &DSDEVID_DefaultPlayback);
 
     /* try the COM class factory method of creation with default voice
      * playback device specified */
     rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
-                        &IID_IDirectSound8, (void**)&dso);
+                        &IID_IDirectSound8, (void**)&dso8);
     ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound8) failed: %s\n",
        DXGetErrorString8(rc));
-    if (dso)
-        IDirectSound8_test(dso, FALSE, &DSDEVID_DefaultVoicePlayback);
+    if (dso8)
+        IDirectSound8_test(dso8, FALSE, &DSDEVID_DefaultVoicePlayback);
 
     /* try the COM class factory method of creation with a bad
      * IID specified */
     rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
-                        &CLSID_DirectSoundPrivate, (void**)&dso);
+                        &CLSID_DirectSoundPrivate, (void**)&dso8);
     ok(rc==E_NOINTERFACE,
        "CoCreateInstance(CLSID_DirectSound8,CLSID_DirectSoundPrivate) "
        "should have failed: %s\n",DXGetErrorString8(rc));
@@ -245,34 +246,57 @@ static void IDirectSound8_tests(void)
     /* try the COM class factory method of creation with a bad
      * GUID and IID specified */
     rc=CoCreateInstance(&CLSID_DirectSoundPrivate, NULL, CLSCTX_INPROC_SERVER,
-                        &IID_IDirectSound8, (void**)&dso);
+                        &IID_IDirectSound8, (void**)&dso8);
     ok(rc==REGDB_E_CLASSNOTREG,
        "CoCreateInstance(CLSID_DirectSoundPrivate,IID_IDirectSound8) "
        "should have failed: %s\n",DXGetErrorString8(rc));
 
+    /* try the COM class factory method of creation with 
+     * IID_IDirectSound (BUG 7813) */
+    rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
+                        &IID_IDirectSound, (void**)&dso);
+    ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound8, IID_IDirectSound) "
+       "failed: %s\n", DXGetErrorString8(rc));
+    if (dso)
+        IDirectSound_test(dso, FALSE, NULL, TRUE);
+
+    /* try the COM class factory method of creation with 
+     * IID_IDirectSound (BUG 7813) */
+    rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
+                        &IID_IDirectSound, (void**)&dso);
+    ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound8, IID_IDirectSound) "
+       "failed: %s\n", DXGetErrorString8(rc));
+    if (dso) {
+        rc=IDirectSound8_QueryInterface(dso, &IID_IDirectSound8, (void **)&dso8);
+        ok(rc==S_OK,"IDirectSound_QueryInterface(IID_IDirectSound8) "
+           "failed: %s\n",  DXGetErrorString8(rc));
+        IDirectSound_Release(dso);
+        if (dso8)
+            IDirectSound8_test(dso8, FALSE, NULL);
+    }
     /* try with no device specified */
-    rc=pDirectSoundCreate8(NULL,&dso,NULL);
+    rc=pDirectSoundCreate8(NULL,&dso8,NULL);
     ok(rc==S_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
        "DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
-    if (rc==DS_OK && dso)
-        IDirectSound8_test(dso, TRUE, NULL);
+    if (rc==DS_OK && dso8)
+        IDirectSound8_test(dso8, TRUE, NULL);
 
     /* try with default playback device specified */
-    rc=pDirectSoundCreate8(&DSDEVID_DefaultPlayback,&dso,NULL);
+    rc=pDirectSoundCreate8(&DSDEVID_DefaultPlayback,&dso8,NULL);
     ok(rc==S_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
        "DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
-    if (rc==DS_OK && dso)
-        IDirectSound8_test(dso, TRUE, NULL);
+    if (rc==DS_OK && dso8)
+        IDirectSound8_test(dso8, TRUE, NULL);
 
     /* try with default voice playback device specified */
-    rc=pDirectSoundCreate8(&DSDEVID_DefaultVoicePlayback,&dso,NULL);
+    rc=pDirectSoundCreate8(&DSDEVID_DefaultVoicePlayback,&dso8,NULL);
     ok(rc==S_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
        "DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
-    if (rc==DS_OK && dso)
-        IDirectSound8_test(dso, TRUE, NULL);
+    if (rc==DS_OK && dso8)
+        IDirectSound8_test(dso8, TRUE, NULL);
 
     /* try with a bad device specified */
-    rc=pDirectSoundCreate8(&DSDEVID_DefaultVoiceCapture,&dso,NULL);
+    rc=pDirectSoundCreate8(&DSDEVID_DefaultVoiceCapture,&dso8,NULL);
     ok(rc==DSERR_NODRIVER,"DirectSoundCreate8(DSDEVID_DefaultVoiceCapture) "
        "should have failed: %s\n",DXGetErrorString8(rc));
 }
Index: dlls/dsound/tests/dsound_test.h
===================================================================
RCS file: /home/wine/wine/dlls/dsound/tests/dsound_test.h,v
retrieving revision 1.13
diff -p -u -r1.13 dsound_test.h
--- dlls/dsound/tests/dsound_test.h	11 Dec 2006 13:45:54 -0000	1.13
+++ dlls/dsound/tests/dsound_test.h	27 Jun 2007 02:55:17 -0000
@@ -63,3 +63,5 @@ extern const char * getDSBCAPS(DWORD xma
 extern int align(int length, int align);
 extern const char * get_file_version(const char * file_name);
 extern const char * format_string(const WAVEFORMATEX* wfx);
+extern void IDirectSound_test(LPDIRECTSOUND dso, BOOL initialized,
+                              LPCGUID lpGuid, BOOL from8);


More information about the wine-patches mailing list