dmusic/tests: Add some IDirectMusic_SetDirectSound() tests.
Michael Stefaniuc
mstefani at winehq.org
Thu May 4 17:23:05 CDT 2017
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
dlls/dmusic/tests/Makefile.in | 2 +-
dlls/dmusic/tests/dmusic.c | 69 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 70 insertions(+), 1 deletion(-)
diff --git a/dlls/dmusic/tests/Makefile.in b/dlls/dmusic/tests/Makefile.in
index e9721ca..2f8d6a8 100644
--- a/dlls/dmusic/tests/Makefile.in
+++ b/dlls/dmusic/tests/Makefile.in
@@ -1,5 +1,5 @@
TESTDLL = dmusic.dll
-IMPORTS = oleaut32 ole32 uuid
+IMPORTS = oleaut32 ole32 uuid user32 dsound
C_SRCS = \
dmusic.c
diff --git a/dlls/dmusic/tests/dmusic.c b/dlls/dmusic/tests/dmusic.c
index 0a1eca6..9b5de9a 100644
--- a/dlls/dmusic/tests/dmusic.c
+++ b/dlls/dmusic/tests/dmusic.c
@@ -122,6 +122,74 @@ static void test_dmusic(void)
IDirectMusic_Release(dmusic);
}
+static ULONG get_refcount(IDirectSound *iface)
+{
+ IDirectSound_AddRef(iface);
+ return IDirectSound_Release(iface);
+}
+
+static void test_setdsound(void)
+{
+ IDirectMusic *dmusic;
+ IDirectSound *dsound, *dsound2;
+ HRESULT hr;
+ ULONG ref;
+
+ /* Old dsound without SetCooperativeLevel() */
+ hr = CoCreateInstance(&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic8,
+ (void **)&dmusic);
+ ok(hr == S_OK, "DirectMusic create failed: %08x\n", hr);
+ hr = DirectSoundCreate(NULL, &dsound, NULL);
+ ok(hr == S_OK, "DirectSoundCreate failed: %08x\n", hr);
+ hr = IDirectMusic_SetDirectSound(dmusic, dsound, NULL);
+ ok(hr == S_OK, "SetDirectSound failed: %08x\n", hr);
+ IDirectMusic_Release(dmusic);
+ IDirectSound_Release(dsound);
+
+ /* dsound ref counting */
+ hr = CoCreateInstance(&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic8,
+ (void **)&dmusic);
+ ok(hr == S_OK, "DirectMusic create failed: %08x\n", hr);
+ hr = DirectSoundCreate8(NULL, (IDirectSound8 **)&dsound, NULL);
+ ok(hr == S_OK, "DirectSoundCreate failed: %08x\n", hr);
+ hr = IDirectSound_SetCooperativeLevel(dsound, GetForegroundWindow(), DSSCL_PRIORITY);
+ ok(hr == S_OK, "SetCooperativeLevel failed: %08x\n", hr);
+ hr = IDirectMusic_SetDirectSound(dmusic, dsound, NULL);
+ ok(hr == S_OK, "SetDirectSound failed: %08x\n", hr);
+ ref = get_refcount(dsound);
+ todo_wine ok(ref == 2, "dsound ref count got %d expected 2\n", ref);
+
+ /* Releasing dsound from dmusic */
+ hr = IDirectMusic_SetDirectSound(dmusic, NULL, NULL);
+ ok(hr == S_OK, "SetDirectSound failed: %08x\n", hr);
+ ref = get_refcount(dsound);
+ ok(ref == 1, "dsound ref count got %d expected 1\n", ref);
+
+ /* Setting the same dsound twice */
+ hr = IDirectMusic_SetDirectSound(dmusic, dsound, NULL);
+ ok(hr == S_OK, "SetDirectSound failed: %08x\n", hr);
+ ref = get_refcount(dsound);
+ todo_wine ok(ref == 2, "dsound ref count got %d expected 2\n", ref);
+ hr = IDirectMusic_SetDirectSound(dmusic, dsound, NULL);
+ ok(hr == S_OK, "SetDirectSound failed: %08x\n", hr);
+ ref = get_refcount(dsound);
+ todo_wine ok(ref == 2, "dsound ref count got %d expected 2\n", ref);
+
+ /* Replacing one dsound with another */
+ hr = DirectSoundCreate8(NULL, (IDirectSound8 **)&dsound2, NULL);
+ ok(hr == S_OK, "DirectSoundCreate failed: %08x\n", hr);
+ hr = IDirectMusic_SetDirectSound(dmusic, dsound2, NULL);
+ ok(hr == S_OK, "SetDirectSound failed: %08x\n", hr);
+ ref = get_refcount(dsound);
+ ok(ref == 1, "dsound ref count got %d expected 1\n", ref);
+ ref = get_refcount(dsound2);
+ todo_wine ok(ref == 2, "dsound2 ref count got %d expected 2\n", ref);
+
+ IDirectMusic_Release(dmusic);
+ IDirectSound_Release(dsound);
+ IDirectSound_Release(dsound2);
+}
+
static void test_dmbuffer(void)
{
IDirectMusic *dmusic;
@@ -450,6 +518,7 @@ START_TEST(dmusic)
test_COM_dmcoll();
test_COM_synthport();
test_dmusic();
+ test_setdsound();
test_dmbuffer();
test_dmcoll();
--
2.9.3
More information about the wine-patches
mailing list