2014-03-13 23:50:05 +01:00
|
|
|
/*
|
|
|
|
* 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>
|
|
|
|
|
2015-06-10 00:59:32 +02:00
|
|
|
DEFINE_GUID(IID_IDirectMusicWavePRIVATE, 0x69e934e4, 0x97f1, 0x4f1d, 0x88, 0xe8, 0xf2, 0xac, 0x88,
|
|
|
|
0x67, 0x13, 0x27);
|
|
|
|
|
2014-03-13 23:50:05 +01:00
|
|
|
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 */
|
2017-04-25 13:49:07 +02:00
|
|
|
hr = CoCreateInstance(&CLSID_DirectSoundWave, (IUnknown*)0xdeadbeef, CLSCTX_INPROC_SERVER,
|
2014-03-13 23:50:05 +01:00
|
|
|
&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);
|
2015-06-08 21:33:09 +02:00
|
|
|
ok(hr == E_NOINTERFACE, "DirectSoundWave create failed: %08x, expected E_NOINTERFACE\n", hr);
|
2014-03-13 23:50:05 +01:00
|
|
|
|
|
|
|
/* 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);
|
2015-01-15 13:10:21 +01:00
|
|
|
IPersistStream_Release(ps);
|
2014-03-13 23:50:05 +01:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2015-06-10 00:59:32 +02:00
|
|
|
hr = IDirectMusicObject_QueryInterface(dmo, &IID_IDirectMusicWavePRIVATE, (void**)&unk);
|
|
|
|
todo_wine ok(hr == S_OK, "QueryInterface for IID_IDirectMusicWavePRIVATE failed: %08x\n", hr);
|
|
|
|
if (hr == S_OK) {
|
|
|
|
refcount = IUnknown_AddRef(unk);
|
|
|
|
ok(refcount == 6, "refcount == %u, expected 6\n", refcount);
|
|
|
|
refcount = IUnknown_Release(unk);
|
|
|
|
}
|
|
|
|
|
2014-03-13 23:50:05 +01:00
|
|
|
/* Interfaces that native does not support */
|
|
|
|
hr = IDirectMusicObject_QueryInterface(dmo, &IID_IDirectMusicSegment, (void**)&unk);
|
2015-06-08 21:33:09 +02:00
|
|
|
ok(hr == E_NOINTERFACE, "QueryInterface for IID_IDirectMusicSegment failed: %08x\n", hr);
|
2014-03-13 23:50:05 +01:00
|
|
|
hr = IDirectMusicObject_QueryInterface(dmo, &IID_IDirectMusicSegment8, (void**)&unk);
|
2015-06-08 21:33:09 +02:00
|
|
|
ok(hr == E_NOINTERFACE, "QueryInterface for IID_IDirectMusicSegment8 failed: %08x\n", hr);
|
2014-03-13 23:50:05 +01:00
|
|
|
|
|
|
|
while (IDirectMusicObject_Release(dmo));
|
|
|
|
}
|
|
|
|
|
2014-05-27 22:43:58 +02:00
|
|
|
static void test_dswave(void)
|
|
|
|
{
|
|
|
|
IDirectMusicObject *dmo;
|
|
|
|
IPersistStream *ps;
|
|
|
|
CLSID class = { 0 };
|
|
|
|
ULARGE_INTEGER size;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
/* IPersistStream */
|
|
|
|
hr = IDirectMusicObject_QueryInterface(dmo, &IID_IPersistStream, (void**)&ps);
|
|
|
|
ok(hr == S_OK, "QueryInterface for IID_IPersistStream failed: %08x\n", hr);
|
|
|
|
hr = IPersistStream_GetClassID(ps, &class);
|
2015-06-10 01:04:56 +02:00
|
|
|
ok(hr == S_OK, "IPersistStream_GetClassID failed: %08x\n", hr);
|
|
|
|
ok(IsEqualGUID(&class, &CLSID_DirectSoundWave),
|
2014-05-27 22:43:58 +02:00
|
|
|
"Expected class CLSID_DirectSoundWave got %s\n", wine_dbgstr_guid(&class));
|
|
|
|
|
|
|
|
/* Unimplemented IPersistStream methods */
|
|
|
|
hr = IPersistStream_IsDirty(ps);
|
2015-06-10 01:04:56 +02:00
|
|
|
ok(hr == S_FALSE, "IPersistStream_IsDirty failed: %08x\n", hr);
|
2014-05-27 22:43:58 +02:00
|
|
|
hr = IPersistStream_GetSizeMax(ps, &size);
|
|
|
|
ok(hr == E_NOTIMPL, "IPersistStream_GetSizeMax failed: %08x\n", hr);
|
|
|
|
hr = IPersistStream_Save(ps, NULL, TRUE);
|
|
|
|
ok(hr == E_NOTIMPL, "IPersistStream_Save failed: %08x\n", hr);
|
|
|
|
|
|
|
|
while (IDirectMusicObject_Release(dmo));
|
|
|
|
}
|
|
|
|
|
2014-03-13 23:50:05 +01:00
|
|
|
START_TEST(dswave)
|
|
|
|
{
|
|
|
|
CoInitialize(NULL);
|
|
|
|
|
|
|
|
if (missing_dswave())
|
|
|
|
{
|
|
|
|
skip("dswave not available\n");
|
|
|
|
CoUninitialize();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
test_COM();
|
2014-05-27 22:43:58 +02:00
|
|
|
test_dswave();
|
2014-03-13 23:50:05 +01:00
|
|
|
|
|
|
|
CoUninitialize();
|
|
|
|
}
|