Michael Stefaniuc : dmusic/tests: Add some IDirectMusic_SetDirectSound() tests.
Alexandre Julliard
julliard at winehq.org
Fri May 5 15:05:58 CDT 2017
Module: wine
Branch: master
Commit: cf943820eb88e01e3b237ded9f07547473ff824d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=cf943820eb88e01e3b237ded9f07547473ff824d
Author: Michael Stefaniuc <mstefani at winehq.org>
Date: Fri May 5 01:07:00 2017 +0200
dmusic/tests: Add some IDirectMusic_SetDirectSound() tests.
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dmusic/tests/Makefile.in | 2 +-
dlls/dmusic/tests/dmusic.c | 73 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 74 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..8473a40 100644
--- a/dlls/dmusic/tests/dmusic.c
+++ b/dlls/dmusic/tests/dmusic.c
@@ -122,6 +122,78 @@ 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 = DirectSoundCreate(NULL, &dsound, NULL);
+ if (hr == DSERR_NODRIVER ) {
+ skip("No driver\n");
+ return;
+ }
+ ok(hr == S_OK, "DirectSoundCreate failed: %08x\n", hr);
+ hr = CoCreateInstance(&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic8,
+ (void **)&dmusic);
+ ok(hr == S_OK, "DirectMusic create 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 +522,7 @@ START_TEST(dmusic)
test_COM_dmcoll();
test_COM_synthport();
test_dmusic();
+ test_setdsound();
test_dmbuffer();
test_dmcoll();
More information about the wine-cvs
mailing list