Michael Stefaniuc : dsound/tests: Add IDirectSound refcount and COM aggregation tests.

Alexandre Julliard julliard at winehq.org
Thu Jul 19 13:23:43 CDT 2012


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

Author: Michael Stefaniuc <mstefani at redhat.de>
Date:   Thu Jul 19 10:48:26 2012 +0200

dsound/tests: Add IDirectSound refcount and COM aggregation tests.

---

 dlls/dsound/tests/dsound.c  |    8 ++++++-
 dlls/dsound/tests/dsound8.c |   51 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 1 deletions(-)

diff --git a/dlls/dsound/tests/dsound.c b/dlls/dsound/tests/dsound.c
index 4c46f67..894079d 100644
--- a/dlls/dsound/tests/dsound.c
+++ b/dlls/dsound/tests/dsound.c
@@ -173,7 +173,7 @@ EXIT:
 static void IDirectSound_tests(void)
 {
     HRESULT rc;
-    LPDIRECTSOUND dso=NULL;
+    IDirectSound *dso=(IDirectSound*)0xdeadbeef;
     LPCLASSFACTORY cf=NULL;
 
     trace("Testing IDirectSound\n");
@@ -188,6 +188,12 @@ static void IDirectSound_tests(void)
     ok(rc==S_OK,"CoGetClassObject(CLSID_DirectSound, IID_IUnknown) "
        "failed: %08x\n", rc);
 
+    /* COM aggregation */
+    rc=CoCreateInstance(&CLSID_DirectSound, (IUnknown*)&dso, CLSCTX_INPROC_SERVER,
+                        &IID_IDirectSound, (void**)&dso);
+    ok(rc==CLASS_E_NOAGGREGATION || broken(rc==DSERR_INVALIDPARAM),
+       "DirectMusicPerformance create failed: %08x, expected CLASS_E_NOAGGREGATION\n", rc);
+
     /* try the COM class factory method of creation with no device specified */
     rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
                         &IID_IDirectSound, (void**)&dso);
diff --git a/dlls/dsound/tests/dsound8.c b/dlls/dsound/tests/dsound8.c
index c1e672f..d76d4f6 100644
--- a/dlls/dsound/tests/dsound8.c
+++ b/dlls/dsound/tests/dsound8.c
@@ -1116,6 +1116,56 @@ static void test_first_device(void)
     ok(hr == S_OK, "DirectSoundEnumerateA failed: %08x\n", hr);
 }
 
+static void test_COM(void)
+{
+    IDirectSound *ds;
+    IDirectSound8 *ds8 = (IDirectSound8*)0xdeadbeef;
+    IUnknown *unk, *unk8;
+    ULONG refcount;
+    HRESULT hr;
+
+    /* COM aggregation */
+    hr = CoCreateInstance(&CLSID_DirectSound8, (IUnknown*)&ds, CLSCTX_INPROC_SERVER,
+            &IID_IUnknown, (void**)&ds8);
+    ok(hr == CLASS_E_NOAGGREGATION,
+            "DirectSound create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr);
+    ok(!ds8, "ds8 = %p\n", ds8);
+
+    /* Invalid RIID */
+    hr = CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
+            &IID_IDirectSound3DBuffer, (void**)&ds8);
+    ok(hr == E_NOINTERFACE,
+            "DirectSound create failed: %08x, expected E_NOINTERFACE\n", hr);
+
+    /* Same refcount for IDirectSound and IDirectSound8 */
+    hr = CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectSound8,
+            (void**)&ds8);
+    ok(hr == S_OK, "DirectSound create failed: %08x, expected S_OK\n", hr);
+    refcount = IDirectSound8_AddRef(ds8);
+    ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
+    hr = IDirectSound8_QueryInterface(ds8, &IID_IDirectSound, (void**)&ds);
+    ok(hr == S_OK, "QueryInterface for IID_IDirectSound failed: %08x\n", hr);
+    refcount = IDirectSound8_AddRef(ds8);
+    todo_wine ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
+    refcount = IDirectSound_AddRef(ds);
+    todo_wine ok(refcount == 5, "refcount == %u, expected 5\n", refcount);
+
+    /* Separate refcount for IUnknown */
+    hr = IDirectSound_QueryInterface(ds, &IID_IUnknown, (void**)&unk);
+    ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
+    refcount = IUnknown_AddRef(unk);
+    ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
+    hr = IDirectSound_QueryInterface(ds8, &IID_IUnknown, (void**)&unk8);
+    ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
+    refcount = IUnknown_AddRef(unk8);
+    ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
+    refcount = IDirectSound_AddRef(ds);
+    todo_wine ok(refcount == 6, "refcount == %u, expected 6\n", refcount);
+
+    while (IDirectSound_Release(ds));
+    while (IUnknown_Release(unk));
+}
+
 START_TEST(dsound8)
 {
     HMODULE hDsound;
@@ -1132,6 +1182,7 @@ START_TEST(dsound8)
             "DirectSoundCreate8");
         if (pDirectSoundCreate8)
         {
+            test_COM();
             IDirectSound8_tests();
             dsound8_tests();
             test_hw_buffers();




More information about the wine-cvs mailing list