2 * Unit tests for dmband functions
4 * Copyright (C) 2012 Christian Costa
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "wine/test.h"
32 DEFINE_GUID(IID_IDirectMusicBandTrackPrivate
, 0x53466056, 0x6dc4, 0x11d1, 0xbf, 0x7b, 0x00, 0xc0, 0x4f, 0xbf, 0x8f, 0xef);
34 static BOOL
missing_dmband(void)
36 IDirectMusicBand
*dmb
;
37 HRESULT hr
= CoCreateInstance(&CLSID_DirectMusicBand
, NULL
, CLSCTX_INPROC_SERVER
,
38 &IID_IDirectMusicBand
, (void**)&dmb
);
40 if (hr
== S_OK
&& dmb
)
42 IDirectMusicBand_Release(dmb
);
48 static void test_COM(void)
50 IDirectMusicBand
*dmb
= (IDirectMusicBand
*)0xdeadbeef;
51 IDirectMusicObject
*dmo
;
58 hr
= CoCreateInstance(&CLSID_DirectMusicBand
, (IUnknown
*)&dmb
, CLSCTX_INPROC_SERVER
,
59 &IID_IUnknown
, (void**)&dmb
);
60 ok(hr
== CLASS_E_NOAGGREGATION
,
61 "DirectMusicBand create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr
);
62 ok(!dmb
, "dmb = %p\n", dmb
);
65 hr
= CoCreateInstance(&CLSID_DirectMusicBand
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IClassFactory
,
67 ok(hr
== E_NOINTERFACE
, "DirectMusicBand create failed: %08x, expected E_NOINTERFACE\n", hr
);
69 /* Same refcount for all DirectMusicBand interfaces */
70 hr
= CoCreateInstance(&CLSID_DirectMusicBand
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectMusicBand
,
72 ok(hr
== S_OK
, "DirectMusicBand create failed: %08x, expected S_OK\n", hr
);
73 refcount
= IDirectMusicBand_AddRef(dmb
);
74 ok(refcount
== 2, "refcount == %u, expected 2\n", refcount
);
76 hr
= IDirectMusicBand_QueryInterface(dmb
, &IID_IDirectMusicObject
, (void**)&dmo
);
77 ok(hr
== S_OK
, "QueryInterface for IID_IDirectMusicObject failed: %08x\n", hr
);
78 refcount
= IDirectMusicObject_AddRef(dmo
);
79 ok(refcount
== 4, "refcount == %u, expected 4\n", refcount
);
80 refcount
= IDirectMusicObject_Release(dmo
);
82 hr
= IDirectMusicBand_QueryInterface(dmb
, &IID_IPersistStream
, (void**)&ps
);
83 ok(hr
== S_OK
, "QueryInterface for IID_IPersistStream failed: %08x\n", hr
);
84 refcount
= IPersistStream_AddRef(ps
);
85 ok(refcount
== 5, "refcount == %u, expected 5\n", refcount
);
86 refcount
= IPersistStream_Release(ps
);
88 hr
= IDirectMusicBand_QueryInterface(dmb
, &IID_IUnknown
, (void**)&unk
);
89 ok(hr
== S_OK
, "QueryInterface for IID_IUnknown failed: %08x\n", hr
);
90 refcount
= IUnknown_AddRef(unk
);
91 ok(refcount
== 6, "refcount == %u, expected 6\n", refcount
);
92 refcount
= IUnknown_Release(unk
);
94 while (IDirectMusicBand_Release(dmb
));
97 static void test_COM_bandtrack(void)
99 IDirectMusicTrack
*dmbt
= (IDirectMusicTrack
*)0xdeadbeef;
106 /* COM aggregation */
107 hr
= CoCreateInstance(&CLSID_DirectMusicBandTrack
, (IUnknown
*)&dmbt
, CLSCTX_INPROC_SERVER
,
108 &IID_IUnknown
, (void**)&dmbt
);
109 ok(hr
== CLASS_E_NOAGGREGATION
,
110 "DirectMusicBandTrack create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr
);
111 ok(!dmbt
, "dmbt = %p\n", dmbt
);
114 hr
= CoCreateInstance(&CLSID_DirectMusicBandTrack
, NULL
, CLSCTX_INPROC_SERVER
,
115 &IID_IDirectMusicObject
, (void**)&dmbt
);
116 ok(hr
== E_NOINTERFACE
, "DirectMusicBandTrack create failed: %08x, expected E_NOINTERFACE\n", hr
);
118 /* Same refcount for all DirectMusicBandTrack interfaces */
119 hr
= CoCreateInstance(&CLSID_DirectMusicBandTrack
, NULL
, CLSCTX_INPROC_SERVER
,
120 &IID_IDirectMusicTrack
, (void**)&dmbt
);
121 ok(hr
== S_OK
, "DirectMusicBandTrack create failed: %08x, expected S_OK\n", hr
);
122 refcount
= IDirectMusicTrack_AddRef(dmbt
);
123 ok(refcount
== 2, "refcount == %u, expected 2\n", refcount
);
125 hr
= IDirectMusicTrack_QueryInterface(dmbt
, &IID_IPersistStream
, (void**)&ps
);
126 ok(hr
== S_OK
, "QueryInterface for IID_IPersistStream failed: %08x\n", hr
);
127 refcount
= IPersistStream_AddRef(ps
);
128 ok(refcount
== 4, "refcount == %u, expected 4\n", refcount
);
129 IPersistStream_Release(ps
);
131 hr
= IDirectMusicTrack_QueryInterface(dmbt
, &IID_IUnknown
, (void**)&unk
);
132 ok(hr
== S_OK
, "QueryInterface for IID_IUnknown failed: %08x\n", hr
);
133 refcount
= IUnknown_AddRef(unk
);
134 ok(refcount
== 5, "refcount == %u, expected 5\n", refcount
);
135 refcount
= IUnknown_Release(unk
);
137 hr
= IDirectMusicTrack_QueryInterface(dmbt
, &IID_IDirectMusicBandTrackPrivate
,
139 todo_wine
ok(hr
== S_OK
, "QueryInterface for IID_IDirectMusicBandTrackPrivate failed: %08x\n", hr
);
141 refcount
= IUnknown_AddRef(private);
142 ok(refcount
== 6, "refcount == %u, expected 6\n", refcount
);
143 refcount
= IUnknown_Release(private);
146 while (IDirectMusicTrack_Release(dmbt
));
149 static void test_dmband(void)
151 IDirectMusicBand
*dmb
;
157 hr
= CoCreateInstance(&CLSID_DirectMusicBand
, NULL
, CLSCTX_INPROC_SERVER
,
158 &IID_IDirectMusicBand
, (void**)&dmb
);
159 ok(hr
== S_OK
, "DirectMusicBand create failed: %08x, expected S_OK\n", hr
);
161 /* Unimplemented IPersistStream methods */
162 hr
= IDirectMusicBand_QueryInterface(dmb
, &IID_IPersistStream
, (void**)&ps
);
163 ok(hr
== S_OK
, "QueryInterface for IID_IPersistStream failed: %08x\n", hr
);
164 hr
= IPersistStream_GetClassID(ps
, &class);
165 ok(hr
== E_NOTIMPL
, "IPersistStream_GetClassID failed: %08x\n", hr
);
166 hr
= IPersistStream_IsDirty(ps
);
167 ok(hr
== S_FALSE
, "IPersistStream_IsDirty failed: %08x\n", hr
);
168 hr
= IPersistStream_GetSizeMax(ps
, &size
);
169 ok(hr
== E_NOTIMPL
, "IPersistStream_GetSizeMax failed: %08x\n", hr
);
170 hr
= IPersistStream_Save(ps
, NULL
, TRUE
);
171 ok(hr
== E_NOTIMPL
, "IPersistStream_Save failed: %08x\n", hr
);
173 while (IDirectMusicBand_Release(dmb
));
176 static void test_bandtrack(void)
178 IDirectMusicTrack8
*dmt8
;
184 hr
= CoCreateInstance(&CLSID_DirectMusicBandTrack
, NULL
, CLSCTX_INPROC_SERVER
,
185 &IID_IDirectMusicTrack8
, (void**)&dmt8
);
186 ok(hr
== S_OK
, "DirectMusicBandTrack create failed: %08x, expected S_OK\n", hr
);
188 /* IDirectMusicTrack8 */
190 hr
= IDirectMusicTrack8_Init(dmt8
, NULL
);
191 ok(hr
== E_POINTER
, "IDirectMusicTrack8_Init failed: %08x\n", hr
);
192 hr
= IDirectMusicTrack8_InitPlay(dmt8
, NULL
, NULL
, NULL
, 0, 0);
193 ok(hr
== E_POINTER
, "IDirectMusicTrack8_InitPlay failed: %08x\n", hr
);
195 hr
= IDirectMusicTrack8_EndPlay(dmt8
, NULL
);
196 ok(hr
== S_OK
, "IDirectMusicTrack8_EndPlay failed: %08x\n", hr
);
198 hr
= IDirectMusicTrack8_Play(dmt8
, NULL
, 0, 0, 0, 0, NULL
, NULL
, 0);
199 ok(hr
== DMUS_S_END
, "IDirectMusicTrack8_Play failed: %08x\n", hr
);
200 hr
= IDirectMusicTrack8_GetParam(dmt8
, NULL
, 0, NULL
, NULL
);
201 ok(hr
== E_POINTER
, "IDirectMusicTrack8_GetParam failed: %08x\n", hr
);
202 hr
= IDirectMusicTrack8_SetParam(dmt8
, NULL
, 0, NULL
);
203 ok(hr
== E_POINTER
, "IDirectMusicTrack8_SetParam failed: %08x\n", hr
);
205 hr
= IDirectMusicTrack8_IsParamSupported(dmt8
, NULL
);
206 ok(hr
== E_POINTER
, "IDirectMusicTrack8_IsParamSupported failed: %08x\n", hr
);
207 hr
= IDirectMusicTrack8_AddNotificationType(dmt8
, NULL
);
208 ok(hr
== E_NOTIMPL
, "IDirectMusicTrack8_AddNotificationType failed: %08x\n", hr
);
209 hr
= IDirectMusicTrack8_RemoveNotificationType(dmt8
, NULL
);
210 ok(hr
== E_NOTIMPL
, "IDirectMusicTrack8_RemoveNotificationType failed: %08x\n", hr
);
212 hr
= IDirectMusicTrack8_Clone(dmt8
, 0, 0, NULL
);
213 ok(hr
== E_POINTER
, "IDirectMusicTrack8_Clone failed: %08x\n", hr
);
214 hr
= IDirectMusicTrack8_PlayEx(dmt8
, NULL
, 0, 0, 0, 0, NULL
, NULL
, 0);
215 ok(hr
== DMUS_S_END
, "IDirectMusicTrack8_PlayEx failed: %08x\n", hr
);
216 hr
= IDirectMusicTrack8_GetParamEx(dmt8
, NULL
, 0, NULL
, NULL
, NULL
, 0);
217 ok(hr
== E_POINTER
, "IDirectMusicTrack8_GetParamEx failed: %08x\n", hr
);
218 hr
= IDirectMusicTrack8_SetParamEx(dmt8
, NULL
, 0, NULL
, NULL
, 0);
219 ok(hr
== E_POINTER
, "IDirectMusicTrack8_SetParamEx failed: %08x\n", hr
);
221 hr
= IDirectMusicTrack8_Compose(dmt8
, NULL
, 0, NULL
);
222 ok(hr
== E_NOTIMPL
, "IDirectMusicTrack8_Compose failed: %08x\n", hr
);
223 hr
= IDirectMusicTrack8_Join(dmt8
, NULL
, 0, NULL
, 0, NULL
);
224 todo_wine
ok(hr
== E_POINTER
, "IDirectMusicTrack8_Join failed: %08x\n", hr
);
227 hr
= IDirectMusicTrack8_QueryInterface(dmt8
, &IID_IPersistStream
, (void**)&ps
);
228 ok(hr
== S_OK
, "QueryInterface for IID_IPersistStream failed: %08x\n", hr
);
229 hr
= IPersistStream_GetClassID(ps
, &class);
230 ok(hr
== S_OK
, "IPersistStream_GetClassID failed: %08x\n", hr
);
231 ok(IsEqualGUID(&class, &CLSID_DirectMusicBandTrack
),
232 "Expected class CLSID_DirectMusicBandTrack got %s\n", wine_dbgstr_guid(&class));
234 /* Unimplemented IPersistStream methods */
235 hr
= IPersistStream_IsDirty(ps
);
236 ok(hr
== S_FALSE
, "IPersistStream_IsDirty failed: %08x\n", hr
);
237 hr
= IPersistStream_GetSizeMax(ps
, &size
);
238 ok(hr
== E_NOTIMPL
, "IPersistStream_GetSizeMax failed: %08x\n", hr
);
239 hr
= IPersistStream_Save(ps
, NULL
, TRUE
);
240 ok(hr
== E_NOTIMPL
, "IPersistStream_Save failed: %08x\n", hr
);
242 while (IDirectMusicTrack8_Release(dmt8
));
247 CoInitializeEx(NULL
, COINIT_MULTITHREADED
);
249 if (missing_dmband())
251 skip("dmband not available\n");
257 test_COM_bandtrack();