dmime: Use the generic IPersistStream for DMParamControlTrack.
[wine.git] / dlls / dmime / tests / dmime.c
blobc370a9d5c1184180884be04db9b8a073af6072b7
1 /*
2 * Copyright 2012, 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 <wine/test.h>
24 #include <dmusici.h>
26 #define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
28 static BOOL missing_dmime(void)
30 IDirectMusicSegment8 *dms;
31 HRESULT hr = CoCreateInstance(&CLSID_DirectMusicSegment, NULL, CLSCTX_INPROC_SERVER,
32 &IID_IDirectMusicSegment, (void**)&dms);
34 if (hr == S_OK && dms)
36 IDirectMusicSegment_Release(dms);
37 return FALSE;
39 return TRUE;
42 static void test_COM_audiopath(void)
44 IDirectMusicAudioPath *dmap;
45 IUnknown *unk;
46 IDirectMusicPerformance8 *performance;
47 ULONG refcount;
48 HRESULT hr;
50 hr = CoCreateInstance(&CLSID_DirectMusicPerformance, NULL, CLSCTX_INPROC_SERVER,
51 &IID_IDirectMusicPerformance8, (void**)&performance);
52 ok(hr == S_OK || broken(hr == E_NOINTERFACE),
53 "DirectMusicPerformance create failed: %08x\n", hr);
54 if (!performance) {
55 win_skip("IDirectMusicPerformance8 not available\n");
56 return;
58 hr = IDirectMusicPerformance8_InitAudio(performance, NULL, NULL, NULL,
59 DMUS_APATH_SHARED_STEREOPLUSREVERB, 64, DMUS_AUDIOF_ALL, NULL);
60 if (hr == DSERR_NODRIVER) {
61 skip("No audio driver\n");
62 return;
64 ok(hr == S_OK, "DirectMusicPerformance_InitAudio failed: %08x\n", hr);
65 hr = IDirectMusicPerformance8_GetDefaultAudioPath(performance, &dmap);
66 ok(hr == S_OK, "DirectMusicPerformance_GetDefaultAudioPath failed: %08x\n", hr);
68 /* IDirectMusicObject and IPersistStream are not supported */
69 hr = IDirectMusicAudioPath_QueryInterface(dmap, &IID_IDirectMusicObject, (void**)&unk);
70 todo_wine ok(FAILED(hr) && !unk, "Unexpected IDirectMusicObject interface: hr=%08x, iface=%p\n",
71 hr, unk);
72 if (unk) IUnknown_Release(unk);
73 hr = IDirectMusicAudioPath_QueryInterface(dmap, &IID_IPersistStream, (void**)&unk);
74 todo_wine ok(FAILED(hr) && !unk, "Unexpected IPersistStream interface: hr=%08x, iface=%p\n",
75 hr, unk);
76 if (unk) IUnknown_Release(unk);
78 /* Same refcount for all DirectMusicAudioPath interfaces */
79 refcount = IDirectMusicAudioPath_AddRef(dmap);
80 ok(refcount == 3, "refcount == %u, expected 3\n", refcount);
82 hr = IDirectMusicAudioPath_QueryInterface(dmap, &IID_IUnknown, (void**)&unk);
83 ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
84 ok(unk == (IUnknown*)dmap, "got %p, %p\n", unk, dmap);
85 refcount = IUnknown_AddRef(unk);
86 ok(refcount == 5, "refcount == %u, expected 5\n", refcount);
87 refcount = IUnknown_Release(unk);
89 while (IDirectMusicAudioPath_Release(dmap) > 1); /* performance has a reference too */
90 IDirectMusicPerformance8_CloseDown(performance);
91 IDirectMusicPerformance8_Release(performance);
94 static void test_COM_audiopathconfig(void)
96 IDirectMusicAudioPath *dmap = (IDirectMusicAudioPath*)0xdeadbeef;
97 IDirectMusicObject *dmo;
98 IPersistStream *ps;
99 IUnknown *unk;
100 ULONG refcount;
101 HRESULT hr;
103 /* COM aggregation */
104 hr = CoCreateInstance(&CLSID_DirectMusicAudioPathConfig, (IUnknown*)&dmap, CLSCTX_INPROC_SERVER,
105 &IID_IUnknown, (void**)&dmap);
106 if (hr == REGDB_E_CLASSNOTREG) {
107 win_skip("DirectMusicAudioPathConfig not registered\n");
108 return;
110 ok(hr == CLASS_E_NOAGGREGATION,
111 "DirectMusicAudioPathConfig create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr);
112 ok(!dmap, "dmap = %p\n", dmap);
114 /* IDirectMusicAudioPath not supported */
115 hr = CoCreateInstance(&CLSID_DirectMusicAudioPathConfig, NULL, CLSCTX_INPROC_SERVER,
116 &IID_IDirectMusicAudioPath, (void**)&dmap);
117 todo_wine ok(FAILED(hr) && !dmap,
118 "Unexpected IDirectMusicAudioPath interface: hr=%08x, iface=%p\n", hr, dmap);
120 /* IDirectMusicObject and IPersistStream supported */
121 hr = CoCreateInstance(&CLSID_DirectMusicAudioPathConfig, NULL, CLSCTX_INPROC_SERVER,
122 &IID_IPersistStream, (void**)&ps);
123 ok(hr == S_OK, "DirectMusicObject create failed: %08x, expected S_OK\n", hr);
124 IPersistStream_Release(ps);
125 hr = CoCreateInstance(&CLSID_DirectMusicAudioPathConfig, NULL, CLSCTX_INPROC_SERVER,
126 &IID_IDirectMusicObject, (void**)&dmo);
127 ok(hr == S_OK, "DirectMusicObject create failed: %08x, expected S_OK\n", hr);
129 /* Same refcount for all DirectMusicObject interfaces */
130 refcount = IDirectMusicObject_AddRef(dmo);
131 ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
133 hr = IDirectMusicObject_QueryInterface(dmo, &IID_IPersistStream, (void**)&ps);
134 ok(hr == S_OK, "QueryInterface for IID_IPersistStream failed: %08x\n", hr);
135 refcount = IPersistStream_AddRef(ps);
136 ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
137 IPersistStream_Release(ps);
139 hr = IDirectMusicObject_QueryInterface(dmo, &IID_IUnknown, (void**)&unk);
140 ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
141 refcount = IUnknown_AddRef(unk);
142 ok(refcount == 5, "refcount == %u, expected 5\n", refcount);
143 refcount = IUnknown_Release(unk);
145 /* IDirectMusicAudioPath still not supported */
146 hr = IDirectMusicObject_QueryInterface(dmo, &IID_IDirectMusicAudioPath, (void**)&dmap);
147 todo_wine ok(FAILED(hr) && !dmap,
148 "Unexpected IDirectMusicAudioPath interface: hr=%08x, iface=%p\n", hr, dmap);
150 while (IDirectMusicObject_Release(dmo));
154 static void test_COM_graph(void)
156 IDirectMusicGraph *dmg = (IDirectMusicGraph*)0xdeadbeef;
157 IDirectMusicObject *dmo;
158 IPersistStream *ps;
159 IUnknown *unk;
160 ULONG refcount;
161 HRESULT hr;
163 /* COM aggregation */
164 hr = CoCreateInstance(&CLSID_DirectMusicGraph, (IUnknown*)&dmg, CLSCTX_INPROC_SERVER,
165 &IID_IUnknown, (void**)&dmg);
166 ok(hr == CLASS_E_NOAGGREGATION,
167 "DirectMusicGraph create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr);
168 ok(!dmg, "dmg = %p\n", dmg);
170 /* Invalid RIID */
171 hr = CoCreateInstance(&CLSID_DirectMusicGraph, NULL, CLSCTX_INPROC_SERVER, &IID_IClassFactory,
172 (void**)&dmg);
173 ok(hr == E_NOINTERFACE, "DirectMusicGraph create failed: %08x, expected E_NOINTERFACE\n", hr);
175 /* Same refcount for all DirectMusicGraph interfaces */
176 hr = CoCreateInstance(&CLSID_DirectMusicGraph, NULL, CLSCTX_INPROC_SERVER,
177 &IID_IDirectMusicGraph, (void**)&dmg);
178 ok(hr == S_OK, "DirectMusicGraph create failed: %08x, expected S_OK\n", hr);
179 refcount = IDirectMusicGraph_AddRef(dmg);
180 ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
182 hr = IDirectMusicGraph_QueryInterface(dmg, &IID_IDirectMusicObject, (void**)&dmo);
183 if (hr == E_NOINTERFACE) {
184 win_skip("DirectMusicGraph without IDirectMusicObject\n");
185 return;
187 ok(hr == S_OK, "QueryInterface for IID_IDirectMusicObject failed: %08x\n", hr);
188 refcount = IDirectMusicObject_AddRef(dmo);
189 ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
190 refcount = IDirectMusicObject_Release(dmo);
192 hr = IDirectMusicGraph_QueryInterface(dmg, &IID_IPersistStream, (void**)&ps);
193 ok(hr == S_OK, "QueryInterface for IID_IPersistStream failed: %08x\n", hr);
194 refcount = IPersistStream_AddRef(ps);
195 ok(refcount == 5, "refcount == %u, expected 5\n", refcount);
196 refcount = IPersistStream_Release(ps);
198 hr = IDirectMusicGraph_QueryInterface(dmg, &IID_IUnknown, (void**)&unk);
199 ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
200 refcount = IUnknown_AddRef(unk);
201 ok(refcount == 6, "refcount == %u, expected 6\n", refcount);
202 refcount = IUnknown_Release(unk);
204 while (IDirectMusicGraph_Release(dmg));
207 static void test_COM_segment(void)
209 IDirectMusicSegment8 *dms = (IDirectMusicSegment8*)0xdeadbeef;
210 IDirectMusicObject *dmo;
211 IPersistStream *stream;
212 IUnknown *unk;
213 ULONG refcount;
214 HRESULT hr;
216 /* COM aggregation */
217 hr = CoCreateInstance(&CLSID_DirectMusicSegment, (IUnknown*)&dms, CLSCTX_INPROC_SERVER,
218 &IID_IUnknown, (void**)&dms);
219 ok(hr == CLASS_E_NOAGGREGATION,
220 "DirectMusicSegment create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr);
221 ok(!dms, "dms = %p\n", dms);
223 /* Invalid RIID */
224 hr = CoCreateInstance(&CLSID_DirectMusicSegment, NULL, CLSCTX_INPROC_SERVER,
225 &IID_IDirectSound, (void**)&dms);
226 ok(hr == E_NOINTERFACE,
227 "DirectMusicSegment create failed: %08x, expected E_NOINTERFACE\n", hr);
229 /* Same refcount */
230 hr = CoCreateInstance(&CLSID_DirectMusicSegment, NULL, CLSCTX_INPROC_SERVER,
231 &IID_IDirectMusicSegment8, (void**)&dms);
232 if (hr == E_NOINTERFACE) {
233 win_skip("DirectMusicSegment without IDirectMusicSegment8\n");
234 return;
236 ok(hr == S_OK, "DirectMusicSegment create failed: %08x, expected S_OK\n", hr);
237 refcount = IDirectMusicSegment8_AddRef(dms);
238 ok (refcount == 2, "refcount == %u, expected 2\n", refcount);
239 hr = IDirectMusicSegment8_QueryInterface(dms, &IID_IDirectMusicObject, (void**)&dmo);
240 ok(hr == S_OK, "QueryInterface for IID_IDirectMusicObject failed: %08x\n", hr);
241 IDirectMusicSegment8_AddRef(dms);
242 refcount = IDirectMusicSegment8_Release(dms);
243 ok (refcount == 3, "refcount == %u, expected 3\n", refcount);
244 hr = IDirectMusicSegment8_QueryInterface(dms, &IID_IPersistStream, (void**)&stream);
245 ok(hr == S_OK, "QueryInterface for IID_IPersistStream failed: %08x\n", hr);
246 refcount = IDirectMusicSegment8_Release(dms);
247 ok (refcount == 3, "refcount == %u, expected 3\n", refcount);
248 hr = IDirectMusicSegment8_QueryInterface(dms, &IID_IUnknown, (void**)&unk);
249 ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
250 refcount = IUnknown_Release(unk);
251 ok (refcount == 3, "refcount == %u, expected 3\n", refcount);
252 refcount = IDirectMusicObject_Release(dmo);
253 ok (refcount == 2, "refcount == %u, expected 2\n", refcount);
254 refcount = IPersistStream_Release(stream);
255 ok (refcount == 1, "refcount == %u, expected 1\n", refcount);
256 refcount = IDirectMusicSegment8_Release(dms);
257 ok (refcount == 0, "refcount == %u, expected 0\n", refcount);
260 static void test_COM_segmentstate(void)
262 IDirectMusicSegmentState8 *dmss8 = (IDirectMusicSegmentState8*)0xdeadbeef;
263 IUnknown *unk;
264 ULONG refcount;
265 HRESULT hr;
267 /* COM aggregation */
268 hr = CoCreateInstance(&CLSID_DirectMusicSegmentState, (IUnknown*)&dmss8, CLSCTX_INPROC_SERVER,
269 &IID_IUnknown, (void**)&dmss8);
270 ok(hr == CLASS_E_NOAGGREGATION,
271 "DirectMusicSegmentState8 create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr);
272 ok(!dmss8, "dmss8 = %p\n", dmss8);
274 /* Invalid RIID */
275 hr = CoCreateInstance(&CLSID_DirectMusicSegmentState, NULL, CLSCTX_INPROC_SERVER,
276 &IID_IDirectMusicObject, (void**)&dmss8);
277 ok(hr == E_NOINTERFACE,
278 "DirectMusicSegmentState8 create failed: %08x, expected E_NOINTERFACE\n", hr);
280 /* Same refcount for all DirectMusicSegmentState interfaces */
281 hr = CoCreateInstance(&CLSID_DirectMusicSegmentState, NULL, CLSCTX_INPROC_SERVER,
282 &IID_IDirectMusicSegmentState8, (void**)&dmss8);
283 if (hr == E_NOINTERFACE) {
284 win_skip("DirectMusicSegmentState without IDirectMusicSegmentState8\n");
285 return;
287 ok(hr == S_OK, "DirectMusicSegmentState8 create failed: %08x, expected S_OK\n", hr);
288 refcount = IDirectMusicSegmentState8_AddRef(dmss8);
289 ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
291 hr = IDirectMusicSegmentState8_QueryInterface(dmss8, &IID_IUnknown, (void**)&unk);
292 ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
293 refcount = IUnknown_AddRef(unk);
294 ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
295 refcount = IUnknown_Release(unk);
297 hr = IDirectMusicSegmentState8_QueryInterface(dmss8, &IID_IUnknown, NULL);
298 ok(hr == E_POINTER, "got %08x\n", hr);
300 while (IDirectMusicSegmentState8_Release(dmss8));
303 static void test_COM_track(void)
305 IDirectMusicTrack *dmt;
306 IDirectMusicTrack8 *dmt8;
307 IPersistStream *ps;
308 IUnknown *unk;
309 ULONG refcount;
310 HRESULT hr;
311 #define X(class) &CLSID_ ## class, #class
312 const struct {
313 REFCLSID clsid;
314 const char *name;
315 BOOL has_dmt8;
316 } class[] = {
317 { X(DirectMusicLyricsTrack), TRUE },
318 { X(DirectMusicMarkerTrack), FALSE },
319 { X(DirectMusicParamControlTrack), TRUE },
320 { X(DirectMusicSegmentTriggerTrack), TRUE },
321 { X(DirectMusicSeqTrack), TRUE },
322 { X(DirectMusicSysExTrack), TRUE },
323 { X(DirectMusicTempoTrack), TRUE },
324 { X(DirectMusicTimeSigTrack), FALSE },
325 { X(DirectMusicWaveTrack), TRUE }
327 #undef X
328 unsigned int i;
330 for (i = 0; i < ARRAY_SIZE(class); i++) {
331 trace("Testing %s\n", class[i].name);
332 /* COM aggregation */
333 dmt8 = (IDirectMusicTrack8*)0xdeadbeef;
334 hr = CoCreateInstance(class[i].clsid, (IUnknown*)&dmt8, CLSCTX_INPROC_SERVER, &IID_IUnknown,
335 (void**)&dmt8);
336 if (hr == REGDB_E_CLASSNOTREG) {
337 win_skip("%s not registered\n", class[i].name);
338 continue;
340 ok(hr == CLASS_E_NOAGGREGATION,
341 "%s create failed: %08x, expected CLASS_E_NOAGGREGATION\n", class[i].name, hr);
342 ok(!dmt8, "dmt8 = %p\n", dmt8);
344 /* Invalid RIID */
345 hr = CoCreateInstance(class[i].clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicObject,
346 (void**)&dmt8);
347 ok(hr == E_NOINTERFACE, "%s create failed: %08x, expected E_NOINTERFACE\n",
348 class[i].name, hr);
350 /* Same refcount for all DirectMusicTrack interfaces */
351 hr = CoCreateInstance(class[i].clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicTrack,
352 (void**)&dmt);
353 ok(hr == S_OK, "%s create failed: %08x, expected S_OK\n", class[i].name, hr);
354 refcount = IDirectMusicTrack_AddRef(dmt);
355 ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
357 hr = IDirectMusicTrack_QueryInterface(dmt, &IID_IPersistStream, (void**)&ps);
358 ok(hr == S_OK, "QueryInterface for IID_IPersistStream failed: %08x\n", hr);
359 refcount = IPersistStream_AddRef(ps);
360 ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
361 IPersistStream_Release(ps);
363 hr = IDirectMusicTrack_QueryInterface(dmt, &IID_IUnknown, (void**)&unk);
364 ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
365 refcount = IUnknown_AddRef(unk);
366 ok(refcount == 5, "refcount == %u, expected 5\n", refcount);
367 refcount = IUnknown_Release(unk);
369 hr = IDirectMusicTrack_QueryInterface(dmt, &IID_IDirectMusicTrack8, (void**)&dmt8);
370 if (class[i].has_dmt8) {
371 ok(hr == S_OK, "QueryInterface for IID_IDirectMusicTrack8 failed: %08x\n", hr);
372 refcount = IDirectMusicTrack8_AddRef(dmt8);
373 ok(refcount == 6, "refcount == %u, expected 6\n", refcount);
374 refcount = IDirectMusicTrack8_Release(dmt8);
375 } else {
376 ok(hr == E_NOINTERFACE, "QueryInterface for IID_IDirectMusicTrack8 failed: %08x\n", hr);
377 refcount = IDirectMusicTrack_AddRef(dmt);
378 ok(refcount == 5, "refcount == %u, expected 5\n", refcount);
381 while (IDirectMusicTrack_Release(dmt));
385 static void test_audiopathconfig(void)
387 IDirectMusicObject *dmo;
388 IPersistStream *ps;
389 CLSID class = { 0 };
390 ULARGE_INTEGER size;
391 HRESULT hr;
393 hr = CoCreateInstance(&CLSID_DirectMusicAudioPathConfig, NULL, CLSCTX_INPROC_SERVER,
394 &IID_IDirectMusicObject, (void**)&dmo);
395 if (hr == REGDB_E_CLASSNOTREG) {
396 win_skip("DirectMusicAudioPathConfig not registered\n");
397 return;
399 ok(hr == S_OK, "DirectMusicAudioPathConfig create failed: %08x, expected S_OK\n", hr);
401 /* IPersistStream */
402 hr = IDirectMusicObject_QueryInterface(dmo, &IID_IPersistStream, (void**)&ps);
403 ok(hr == S_OK, "QueryInterface for IID_IPersistStream failed: %08x\n", hr);
404 hr = IPersistStream_GetClassID(ps, &class);
405 ok(hr == S_OK, "IPersistStream_GetClassID failed: %08x\n", hr);
406 ok(IsEqualGUID(&class, &CLSID_DirectMusicAudioPathConfig),
407 "Expected class CLSID_DirectMusicAudioPathConfig got %s\n", wine_dbgstr_guid(&class));
409 /* Unimplemented IPersistStream methods */
410 hr = IPersistStream_IsDirty(ps);
411 ok(hr == S_FALSE, "IPersistStream_IsDirty failed: %08x\n", hr);
412 hr = IPersistStream_GetSizeMax(ps, &size);
413 ok(hr == E_NOTIMPL, "IPersistStream_GetSizeMax failed: %08x\n", hr);
414 hr = IPersistStream_Save(ps, NULL, TRUE);
415 ok(hr == E_NOTIMPL, "IPersistStream_Save failed: %08x\n", hr);
417 while (IDirectMusicObject_Release(dmo));
420 static void test_graph(void)
422 IDirectMusicGraph *dmg;
423 IPersistStream *ps;
424 CLSID class = { 0 };
425 ULARGE_INTEGER size;
426 HRESULT hr;
428 hr = CoCreateInstance(&CLSID_DirectMusicGraph, NULL, CLSCTX_INPROC_SERVER,
429 &IID_IDirectMusicGraph, (void**)&dmg);
430 ok(hr == S_OK, "DirectMusicGraph create failed: %08x, expected S_OK\n", hr);
432 /* IPersistStream */
433 hr = IDirectMusicGraph_QueryInterface(dmg, &IID_IPersistStream, (void**)&ps);
434 ok(hr == S_OK, "QueryInterface for IID_IPersistStream failed: %08x\n", hr);
435 hr = IPersistStream_GetClassID(ps, &class);
436 ok(hr == S_OK || broken(hr == E_NOTIMPL) /* win2k */, "IPersistStream_GetClassID failed: %08x\n", hr);
437 if (hr == S_OK)
438 ok(IsEqualGUID(&class, &CLSID_DirectMusicGraph),
439 "Expected class CLSID_DirectMusicGraph got %s\n", wine_dbgstr_guid(&class));
441 /* Unimplemented IPersistStream methods */
442 hr = IPersistStream_IsDirty(ps);
443 ok(hr == S_FALSE, "IPersistStream_IsDirty failed: %08x\n", hr);
444 hr = IPersistStream_GetSizeMax(ps, &size);
445 ok(hr == E_NOTIMPL, "IPersistStream_GetSizeMax failed: %08x\n", hr);
446 hr = IPersistStream_Save(ps, NULL, TRUE);
447 ok(hr == E_NOTIMPL, "IPersistStream_Save failed: %08x\n", hr);
449 while (IDirectMusicGraph_Release(dmg));
452 static void test_segment(void)
454 IDirectMusicSegment *dms;
455 IPersistStream *ps;
456 CLSID class = { 0 };
457 ULARGE_INTEGER size;
458 HRESULT hr;
460 hr = CoCreateInstance(&CLSID_DirectMusicSegment, NULL, CLSCTX_INPROC_SERVER,
461 &IID_IDirectMusicSegment, (void**)&dms);
462 ok(hr == S_OK, "DirectMusicSegment create failed: %08x, expected S_OK\n", hr);
464 /* IPersistStream */
465 hr = IDirectMusicSegment_QueryInterface(dms, &IID_IPersistStream, (void**)&ps);
466 ok(hr == S_OK, "QueryInterface for IID_IPersistStream failed: %08x\n", hr);
467 hr = IPersistStream_GetClassID(ps, &class);
468 ok(hr == S_OK || broken(hr == E_NOTIMPL) /* win2k */, "IPersistStream_GetClassID failed: %08x\n", hr);
469 if (hr == S_OK)
470 ok(IsEqualGUID(&class, &CLSID_DirectMusicSegment),
471 "Expected class CLSID_DirectMusicSegment got %s\n", wine_dbgstr_guid(&class));
473 /* Unimplemented IPersistStream methods */
474 hr = IPersistStream_IsDirty(ps);
475 ok(hr == S_FALSE, "IPersistStream_IsDirty failed: %08x\n", hr);
476 hr = IPersistStream_GetSizeMax(ps, &size);
477 ok(hr == E_NOTIMPL, "IPersistStream_GetSizeMax failed: %08x\n", hr);
478 hr = IPersistStream_Save(ps, NULL, TRUE);
479 ok(hr == E_NOTIMPL, "IPersistStream_Save failed: %08x\n", hr);
481 while (IDirectMusicSegment_Release(dms));
484 static void test_track(void)
486 IDirectMusicTrack *dmt;
487 IPersistStream *ps;
488 CLSID classid;
489 ULARGE_INTEGER size;
490 HRESULT hr;
491 #define X(class) &CLSID_ ## class, #class
492 const struct {
493 REFCLSID clsid;
494 const char *name;
495 BOOL todo;
496 } class[] = {
497 { X(DirectMusicLyricsTrack), FALSE },
498 { X(DirectMusicMarkerTrack), FALSE },
499 { X(DirectMusicParamControlTrack), FALSE },
500 { X(DirectMusicSegmentTriggerTrack), FALSE },
501 { X(DirectMusicSeqTrack), FALSE },
502 { X(DirectMusicSysExTrack), FALSE },
503 { X(DirectMusicTempoTrack), FALSE },
504 { X(DirectMusicTimeSigTrack), FALSE },
505 { X(DirectMusicWaveTrack), TRUE }
507 #undef X
508 unsigned int i;
510 for (i = 0; i < ARRAY_SIZE(class); i++) {
511 trace("Testing %s\n", class[i].name);
512 hr = CoCreateInstance(class[i].clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicTrack,
513 (void**)&dmt);
514 ok(hr == S_OK, "%s create failed: %08x, expected S_OK\n", class[i].name, hr);
516 /* IPersistStream */
517 hr = IDirectMusicTrack_QueryInterface(dmt, &IID_IPersistStream, (void**)&ps);
518 ok(hr == S_OK, "QueryInterface for IID_IPersistStream failed: %08x\n", hr);
519 hr = IPersistStream_GetClassID(ps, &classid);
520 if (class[i].todo) {
521 todo_wine {
522 ok(hr == S_OK, "IPersistStream_GetClassID failed: %08x\n", hr);
523 ok(IsEqualGUID(&classid, class[i].clsid),
524 "Expected class %s got %s\n", class[i].name, wine_dbgstr_guid(&classid));
525 hr = IPersistStream_IsDirty(ps);
526 ok(hr == S_FALSE, "IPersistStream_IsDirty failed: %08x\n", hr);
528 } else {
529 ok(hr == S_OK, "IPersistStream_GetClassID failed: %08x\n", hr);
530 ok(IsEqualGUID(&classid, class[i].clsid),
531 "Expected class %s got %s\n", class[i].name, wine_dbgstr_guid(&classid));
532 hr = IPersistStream_IsDirty(ps);
533 ok(hr == S_FALSE, "IPersistStream_IsDirty failed: %08x\n", hr);
536 /* Unimplemented IPersistStream methods */
537 hr = IPersistStream_GetSizeMax(ps, &size);
538 ok(hr == E_NOTIMPL, "IPersistStream_GetSizeMax failed: %08x\n", hr);
539 hr = IPersistStream_Save(ps, NULL, TRUE);
540 ok(hr == E_NOTIMPL, "IPersistStream_Save failed: %08x\n", hr);
542 while (IDirectMusicTrack_Release(dmt));
546 START_TEST(dmime)
548 CoInitialize(NULL);
550 if (missing_dmime())
552 skip("dmime not available\n");
553 CoUninitialize();
554 return;
556 test_COM_audiopath();
557 test_COM_audiopathconfig();
558 test_COM_graph();
559 test_COM_segment();
560 test_COM_segmentstate();
561 test_COM_track();
562 test_audiopathconfig();
563 test_graph();
564 test_segment();
565 test_track();
567 CoUninitialize();