dmusic/tests: Add some IDirectMusic_SetDirectSound() tests.

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
oldstable
Michael Stefaniuc 2017-05-05 01:07:00 +02:00 committed by Alexandre Julliard
parent 10db51d5c2
commit cf943820eb
2 changed files with 74 additions and 1 deletions

View File

@ -1,5 +1,5 @@
TESTDLL = dmusic.dll
IMPORTS = oleaut32 ole32 uuid
IMPORTS = oleaut32 ole32 uuid user32 dsound
C_SRCS = \
dmusic.c

View File

@ -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();