Commit edcf723b authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

dmime/tests: Add some COM tests for DirectMusicSegment.

parent f998b267
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#define COBJMACROS
#include <stdarg.h> #include <stdarg.h>
#include <windef.h> #include <windef.h>
#include <initguid.h> #include <initguid.h>
...@@ -239,6 +241,55 @@ static void test_COM(void) ...@@ -239,6 +241,55 @@ static void test_COM(void)
ok (refcount == 0, "refcount == %u, expected 0\n", refcount); ok (refcount == 0, "refcount == %u, expected 0\n", refcount);
} }
static void test_dms_COM(void)
{
IDirectMusicSegment8 *dms = (IDirectMusicSegment8*)0xdeadbeef;
IDirectMusicObject *dmo;
IPersistStream *stream;
IUnknown *unk;
ULONG refcount;
HRESULT hr;
/* COM aggregation */
hr = CoCreateInstance(&CLSID_DirectMusicSegment, (IUnknown*)&dms, CLSCTX_INPROC_SERVER,
&IID_IUnknown, (void**)&dms);
ok(hr == CLASS_E_NOAGGREGATION,
"DirectMusicSegment create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr);
ok(!dms, "dms = %p\n", dms);
/* Invalid RIID */
hr = CoCreateInstance(&CLSID_DirectMusicSegment, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectSound, (void**)&dms);
ok(hr == E_NOINTERFACE,
"DirectMusicSegment create failed: %08x, expected E_NOINTERFACE\n", hr);
/* Same refcount */
hr = CoCreateInstance(&CLSID_DirectMusicSegment, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectMusicSegment8, (void**)&dms);
ok(hr == S_OK, "DirectMusicSegment create failed: %08x, expected S_OK\n", hr);
refcount = IDirectMusicSegment8_AddRef(dms);
ok (refcount == 2, "refcount == %u, expected 2\n", refcount);
hr = IDirectMusicSegment8_QueryInterface(dms, &IID_IDirectMusicObject, (void**)&dmo);
ok(hr == S_OK, "QueryInterface for IID_IDirectMusicObject failed: %08x\n", hr);
IDirectMusicSegment8_AddRef(dms);
refcount = IDirectMusicSegment8_Release(dms);
ok (refcount == 3, "refcount == %u, expected 3\n", refcount);
hr = IDirectMusicSegment8_QueryInterface(dms, &IID_IPersistStream, (void**)&stream);
ok(hr == S_OK, "QueryInterface for IID_IPersistStream failed: %08x\n", hr);
refcount = IDirectMusicSegment8_Release(dms);
ok (refcount == 3, "refcount == %u, expected 3\n", refcount);
hr = IDirectMusicSegment8_QueryInterface(dms, &IID_IUnknown, (void**)&unk);
ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
refcount = IUnknown_Release(unk);
ok (refcount == 3, "refcount == %u, expected 3\n", refcount);
refcount = IDirectMusicObject_Release(dmo);
ok (refcount == 2, "refcount == %u, expected 2\n", refcount);
refcount = IPersistStream_Release(stream);
ok (refcount == 1, "refcount == %u, expected 1\n", refcount);
refcount = IDirectMusicSegment8_Release(dms);
ok (refcount == 0, "refcount == %u, expected 0\n", refcount);
}
START_TEST( performance ) START_TEST( performance )
{ {
HRESULT hr; HRESULT hr;
...@@ -258,5 +309,7 @@ START_TEST( performance ) ...@@ -258,5 +309,7 @@ START_TEST( performance )
test_COM(); test_COM();
test_createport(); test_createport();
test_dms_COM();
CoUninitialize(); CoUninitialize();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment