dswave/tests: Check for the private interface in DirectSoundWave.
[wine.git] / dlls / dswave / tests / dswave.c
blobc2fc08f06a4019984807c98b651094cd9d9d5c37
1 /*
2 * Copyright 2014 Michael Stefaniuc
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define COBJMACROS
21 #include <stdarg.h>
22 #include <windef.h>
23 #include <initguid.h>
24 #include <wine/test.h>
25 #include <dmusici.h>
27 DEFINE_GUID(IID_IDirectMusicWavePRIVATE, 0x69e934e4, 0x97f1, 0x4f1d, 0x88, 0xe8, 0xf2, 0xac, 0x88,
28 0x67, 0x13, 0x27);
30 static BOOL missing_dswave(void)
32 IDirectMusicObject *dmo;
33 HRESULT hr = CoCreateInstance(&CLSID_DirectSoundWave, NULL, CLSCTX_INPROC_SERVER,
34 &IID_IDirectMusicObject, (void**)&dmo);
36 if (hr == S_OK && dmo)
38 IDirectMusicObject_Release(dmo);
39 return FALSE;
41 return TRUE;
44 static void test_COM(void)
46 IDirectMusicObject *dmo = (IDirectMusicObject*)0xdeadbeef;
47 IPersistStream *ps;
48 IUnknown *unk;
49 ULONG refcount;
50 HRESULT hr;
52 /* COM aggregation */
53 hr = CoCreateInstance(&CLSID_DirectSoundWave, (IUnknown*)&dmo, CLSCTX_INPROC_SERVER,
54 &IID_IUnknown, (void**)&dmo);
55 ok(hr == CLASS_E_NOAGGREGATION,
56 "DirectSoundWave create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr);
57 ok(!dmo, "dmo = %p\n", dmo);
59 /* Invalid RIID */
60 hr = CoCreateInstance(&CLSID_DirectSoundWave, NULL, CLSCTX_INPROC_SERVER,
61 &IID_IDirectMusicSegment8, (void**)&dmo);
62 ok(hr == E_NOINTERFACE, "DirectSoundWave create failed: %08x, expected E_NOINTERFACE\n", hr);
64 /* Same refcount for all DirectSoundWave interfaces */
65 hr = CoCreateInstance(&CLSID_DirectSoundWave, NULL, CLSCTX_INPROC_SERVER,
66 &IID_IDirectMusicObject, (void**)&dmo);
67 ok(hr == S_OK, "DirectSoundWave create failed: %08x, expected S_OK\n", hr);
68 refcount = IDirectMusicObject_AddRef(dmo);
69 ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
71 hr = IDirectMusicObject_QueryInterface(dmo, &IID_IPersistStream, (void**)&ps);
72 ok(hr == S_OK, "QueryInterface for IID_IPersistStream failed: %08x\n", hr);
73 refcount = IPersistStream_AddRef(ps);
74 ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
75 IPersistStream_Release(ps);
77 hr = IDirectMusicObject_QueryInterface(dmo, &IID_IUnknown, (void**)&unk);
78 ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
79 refcount = IUnknown_AddRef(unk);
80 ok(refcount == 5, "refcount == %u, expected 5\n", refcount);
81 refcount = IUnknown_Release(unk);
83 hr = IDirectMusicObject_QueryInterface(dmo, &IID_IDirectMusicWavePRIVATE, (void**)&unk);
84 todo_wine ok(hr == S_OK, "QueryInterface for IID_IDirectMusicWavePRIVATE failed: %08x\n", hr);
85 if (hr == S_OK) {
86 refcount = IUnknown_AddRef(unk);
87 ok(refcount == 6, "refcount == %u, expected 6\n", refcount);
88 refcount = IUnknown_Release(unk);
91 /* Interfaces that native does not support */
92 hr = IDirectMusicObject_QueryInterface(dmo, &IID_IDirectMusicSegment, (void**)&unk);
93 ok(hr == E_NOINTERFACE, "QueryInterface for IID_IDirectMusicSegment failed: %08x\n", hr);
94 hr = IDirectMusicObject_QueryInterface(dmo, &IID_IDirectMusicSegment8, (void**)&unk);
95 ok(hr == E_NOINTERFACE, "QueryInterface for IID_IDirectMusicSegment8 failed: %08x\n", hr);
97 while (IDirectMusicObject_Release(dmo));
100 static void test_dswave(void)
102 IDirectMusicObject *dmo;
103 IPersistStream *ps;
104 CLSID class = { 0 };
105 ULARGE_INTEGER size;
106 HRESULT hr;
108 hr = CoCreateInstance(&CLSID_DirectSoundWave, NULL, CLSCTX_INPROC_SERVER,
109 &IID_IDirectMusicObject, (void**)&dmo);
110 ok(hr == S_OK, "DirectSoundWave create failed: %08x, expected S_OK\n", hr);
112 /* IPersistStream */
113 hr = IDirectMusicObject_QueryInterface(dmo, &IID_IPersistStream, (void**)&ps);
114 ok(hr == S_OK, "QueryInterface for IID_IPersistStream failed: %08x\n", hr);
115 hr = IPersistStream_GetClassID(ps, &class);
116 todo_wine ok(hr == S_OK, "IPersistStream_GetClassID failed: %08x\n", hr);
117 todo_wine ok(IsEqualGUID(&class, &CLSID_DirectSoundWave),
118 "Expected class CLSID_DirectSoundWave got %s\n", wine_dbgstr_guid(&class));
120 /* Unimplemented IPersistStream methods */
121 hr = IPersistStream_IsDirty(ps);
122 todo_wine ok(hr == S_FALSE, "IPersistStream_IsDirty failed: %08x\n", hr);
123 hr = IPersistStream_GetSizeMax(ps, &size);
124 ok(hr == E_NOTIMPL, "IPersistStream_GetSizeMax failed: %08x\n", hr);
125 hr = IPersistStream_Save(ps, NULL, TRUE);
126 ok(hr == E_NOTIMPL, "IPersistStream_Save failed: %08x\n", hr);
128 while (IDirectMusicObject_Release(dmo));
131 START_TEST(dswave)
133 CoInitialize(NULL);
135 if (missing_dswave())
137 skip("dswave not available\n");
138 CoUninitialize();
139 return;
141 test_COM();
142 test_dswave();
144 CoUninitialize();