Michael Stefaniuc : dswave/tests: Add COM tests for DirectSoundWave.

Alexandre Julliard julliard at winehq.org
Fri Mar 14 15:39:29 CDT 2014


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

Author: Michael Stefaniuc <mstefani at redhat.de>
Date:   Thu Mar 13 23:50:05 2014 +0100

dswave/tests: Add COM tests for DirectSoundWave.

---

 configure                     |    1 +
 configure.ac                  |    1 +
 dlls/dswave/tests/Makefile.in |    5 ++
 dlls/dswave/tests/dswave.c    |  102 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 109 insertions(+)

diff --git a/configure b/configure
index 7a9f1dd..847dbee 100755
--- a/configure
+++ b/configure
@@ -16840,6 +16840,7 @@ wine_fn_config_test dlls/dsound/tests dsound_test
 wine_fn_config_dll dssenh enable_dssenh
 wine_fn_config_test dlls/dssenh/tests dssenh_test
 wine_fn_config_dll dswave enable_dswave clean
+wine_fn_config_test dlls/dswave/tests dswave_test
 wine_fn_config_dll dwmapi enable_dwmapi implib
 wine_fn_config_dll dwrite enable_dwrite implib
 wine_fn_config_test dlls/dwrite/tests dwrite_test
diff --git a/configure.ac b/configure.ac
index 2ff3113..4a7bca2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2844,6 +2844,7 @@ WINE_CONFIG_TEST(dlls/dsound/tests)
 WINE_CONFIG_DLL(dssenh)
 WINE_CONFIG_TEST(dlls/dssenh/tests)
 WINE_CONFIG_DLL(dswave,,[clean])
+WINE_CONFIG_TEST(dlls/dswave/tests)
 WINE_CONFIG_DLL(dwmapi,,[implib])
 WINE_CONFIG_DLL(dwrite,,[implib])
 WINE_CONFIG_TEST(dlls/dwrite/tests)
diff --git a/dlls/dswave/tests/Makefile.in b/dlls/dswave/tests/Makefile.in
new file mode 100644
index 0000000..0745348
--- /dev/null
+++ b/dlls/dswave/tests/Makefile.in
@@ -0,0 +1,5 @@
+TESTDLL   = dswave.dll
+IMPORTS   = ole32
+
+C_SRCS = \
+	dswave.c
diff --git a/dlls/dswave/tests/dswave.c b/dlls/dswave/tests/dswave.c
new file mode 100644
index 0000000..154c899
--- /dev/null
+++ b/dlls/dswave/tests/dswave.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2014 Michael Stefaniuc
+ *
+ * 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
+ */
+
+#define COBJMACROS
+
+#include <stdarg.h>
+#include <windef.h>
+#include <initguid.h>
+#include <wine/test.h>
+#include <dmusici.h>
+
+static BOOL missing_dswave(void)
+{
+    IDirectMusicObject *dmo;
+    HRESULT hr = CoCreateInstance(&CLSID_DirectSoundWave, NULL, CLSCTX_INPROC_SERVER,
+            &IID_IDirectMusicObject, (void**)&dmo);
+
+    if (hr == S_OK && dmo)
+    {
+        IDirectMusicObject_Release(dmo);
+        return FALSE;
+    }
+    return TRUE;
+}
+
+static void test_COM(void)
+{
+    IDirectMusicObject *dmo = (IDirectMusicObject*)0xdeadbeef;
+    IPersistStream *ps;
+    IUnknown *unk;
+    ULONG refcount;
+    HRESULT hr;
+
+    /* COM aggregation */
+    hr = CoCreateInstance(&CLSID_DirectSoundWave, (IUnknown*)&dmo, CLSCTX_INPROC_SERVER,
+            &IID_IUnknown, (void**)&dmo);
+    ok(hr == CLASS_E_NOAGGREGATION,
+            "DirectSoundWave create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr);
+    ok(!dmo, "dmo = %p\n", dmo);
+
+    /* Invalid RIID */
+    hr = CoCreateInstance(&CLSID_DirectSoundWave, NULL, CLSCTX_INPROC_SERVER,
+            &IID_IDirectMusicSegment8, (void**)&dmo);
+    todo_wine ok(hr == E_NOINTERFACE, "DirectSoundWave create failed: %08x, expected E_NOINTERFACE\n", hr);
+
+    /* Same refcount for all DirectSoundWave interfaces */
+    hr = CoCreateInstance(&CLSID_DirectSoundWave, NULL, CLSCTX_INPROC_SERVER,
+            &IID_IDirectMusicObject, (void**)&dmo);
+    ok(hr == S_OK, "DirectSoundWave create failed: %08x, expected S_OK\n", hr);
+    refcount = IDirectMusicObject_AddRef(dmo);
+    ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
+
+    hr = IDirectMusicObject_QueryInterface(dmo, &IID_IPersistStream, (void**)&ps);
+    ok(hr == S_OK, "QueryInterface for IID_IPersistStream failed: %08x\n", hr);
+    refcount = IPersistStream_AddRef(ps);
+    ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
+    refcount = IPersistStream_Release(ps);
+
+    hr = IDirectMusicObject_QueryInterface(dmo, &IID_IUnknown, (void**)&unk);
+    ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
+    refcount = IUnknown_AddRef(unk);
+    ok(refcount == 5, "refcount == %u, expected 5\n", refcount);
+    refcount = IUnknown_Release(unk);
+
+    /* Interfaces that native does not support */
+    hr = IDirectMusicObject_QueryInterface(dmo, &IID_IDirectMusicSegment, (void**)&unk);
+    todo_wine ok(hr == E_NOINTERFACE, "QueryInterface for IID_IDirectMusicSegment failed: %08x\n", hr);
+    hr = IDirectMusicObject_QueryInterface(dmo, &IID_IDirectMusicSegment8, (void**)&unk);
+    todo_wine ok(hr == E_NOINTERFACE, "QueryInterface for IID_IDirectMusicSegment8 failed: %08x\n", hr);
+
+    while (IDirectMusicObject_Release(dmo));
+}
+
+START_TEST(dswave)
+{
+    CoInitialize(NULL);
+
+    if (missing_dswave())
+    {
+        skip("dswave not available\n");
+        CoUninitialize();
+        return;
+    }
+    test_COM();
+
+    CoUninitialize();
+}




More information about the wine-cvs mailing list