dmusic: Check wrong params when creating a port + tests.

This commit is contained in:
Christian Costa 2012-04-10 22:30:38 +02:00 committed by Alexandre Julliard
parent 7776591ff4
commit c05c04952e
2 changed files with 22 additions and 2 deletions

View File

@ -167,7 +167,8 @@ static HRESULT WINAPI IDirectMusic8Impl_CreateMusicBuffer (LPDIRECTMUSIC8 iface,
return DMUSIC_CreateDirectMusicBufferImpl(&IID_IDirectMusicBuffer, (LPVOID)ppBuffer, NULL);
}
static HRESULT WINAPI IDirectMusic8Impl_CreatePort (LPDIRECTMUSIC8 iface, REFCLSID rclsidPort, LPDMUS_PORTPARAMS pPortParams, LPDIRECTMUSICPORT* ppPort, LPUNKNOWN pUnkOuter) {
static HRESULT WINAPI IDirectMusic8Impl_CreatePort(LPDIRECTMUSIC8 iface, REFCLSID rclsidPort, LPDMUS_PORTPARAMS pPortParams, LPDIRECTMUSICPORT* ppPort, LPUNKNOWN pUnkOuter)
{
IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
int i;
DMUS_PORTCAPS PortCaps;
@ -181,8 +182,17 @@ static HRESULT WINAPI IDirectMusic8Impl_CreatePort (LPDIRECTMUSIC8 iface, REFCLS
if (TRACE_ON(dmusic))
dump_DMUS_PORTPARAMS(pPortParams);
if(!rclsidPort)
if (!rclsidPort)
return E_POINTER;
if (!pPortParams)
return E_INVALIDARG;
if (!ppPort)
return E_POINTER;
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
if (TRACE_ON(dmusic))
dump_DMUS_PORTPARAMS(pPortParams);
ZeroMemory(&PortCaps, sizeof(DMUS_PORTCAPS));
PortCaps.dwSize = sizeof(DMUS_PORTCAPS);

View File

@ -66,6 +66,16 @@ static void test_dmusic(void)
hr = IDirectMusic_SetDirectSound(dmusic, NULL, NULL);
ok(hr == S_OK, "IDirectMusic_SetDirectSound returned: %x\n", hr);
/* Check wrong params */
hr = IDirectMusic_CreatePort(dmusic, &GUID_NULL, &port_params, &port, (IUnknown*)dmusic);
ok(hr == CLASS_E_NOAGGREGATION, "IDirectMusic_CreatePort returned: %x\n", hr);
hr = IDirectMusic_CreatePort(dmusic, NULL, &port_params, &port, NULL);
ok(hr == E_POINTER, "IDirectMusic_CreatePort returned: %x\n", hr);
hr = IDirectMusic_CreatePort(dmusic, &GUID_NULL, NULL, &port, NULL);
ok(hr == E_INVALIDARG, "IDirectMusic_CreatePort returned: %x\n", hr);
hr = IDirectMusic_CreatePort(dmusic, &GUID_NULL, &port_params, NULL, NULL);
ok(hr == E_POINTER, "IDirectMusic_CreatePort returned: %x\n", hr);
/* Test creation of default port with GUID_NULL */
hr = IDirectMusic_CreatePort(dmusic, &GUID_NULL, &port_params, &port, NULL);
ok(hr == S_OK, "IDirectMusic_CreatePort returned: %x\n", hr);