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
24 #include <wine/test.h>
27 #define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
29 static BOOL
missing_dmcompos(void)
31 IDirectMusicComposer
*dmc
;
32 HRESULT hr
= CoCreateInstance(&CLSID_DirectMusicComposer
, NULL
, CLSCTX_INPROC_SERVER
,
33 &IID_IDirectMusicComposer
, (void**)&dmc
);
35 if (hr
== S_OK
&& dmc
)
37 IDirectMusicComposer_Release(dmc
);
43 static void test_COM(void)
45 IDirectMusicComposer
*dmc
= (IDirectMusicComposer
*)0xdeadbeef;
51 hr
= CoCreateInstance(&CLSID_DirectMusicComposer
, (IUnknown
*)&dmc
, CLSCTX_INPROC_SERVER
,
52 &IID_IUnknown
, (void**)&dmc
);
53 ok(hr
== CLASS_E_NOAGGREGATION
,
54 "DirectMusicComposer create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr
);
55 ok(!dmc
, "dmc = %p\n", dmc
);
58 hr
= CoCreateInstance(&CLSID_DirectMusicComposer
, NULL
, CLSCTX_INPROC_SERVER
,
59 &IID_IDirectMusicObject
, (void**)&dmc
);
60 ok(hr
== E_NOINTERFACE
,
61 "DirectMusicComposer create failed: %08x, expected E_NOINTERFACE\n", hr
);
63 /* Same refcount for all DirectMusicComposer interfaces */
64 hr
= CoCreateInstance(&CLSID_DirectMusicComposer
, NULL
, CLSCTX_INPROC_SERVER
,
65 &IID_IDirectMusicComposer
, (void**)&dmc
);
66 ok(hr
== S_OK
, "DirectMusicComposer create failed: %08x, expected S_OK\n", hr
);
67 refcount
= IDirectMusicComposer_AddRef(dmc
);
68 ok(refcount
== 2, "refcount == %u, expected 2\n", refcount
);
70 hr
= IDirectMusicComposer_QueryInterface(dmc
, &IID_IUnknown
, (void**)&unk
);
71 ok(hr
== S_OK
, "QueryInterface for IID_IUnknown failed: %08x\n", hr
);
72 refcount
= IUnknown_AddRef(unk
);
73 ok(refcount
== 4, "refcount == %u, expected 4\n", refcount
);
74 refcount
= IUnknown_Release(unk
);
76 while (IDirectMusicComposer_Release(dmc
));
79 static void test_COM_chordmap(void)
81 IDirectMusicChordMap
*dmcm
= (IDirectMusicChordMap
*)0xdeadbeef;
82 IDirectMusicObject
*dmo
;
89 hr
= CoCreateInstance(&CLSID_DirectMusicChordMap
, (IUnknown
*)&dmcm
, CLSCTX_INPROC_SERVER
,
90 &IID_IUnknown
, (void**)&dmcm
);
91 ok(hr
== CLASS_E_NOAGGREGATION
,
92 "DirectMusicChordMap create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr
);
93 ok(!dmcm
, "dmcm = %p\n", dmcm
);
96 hr
= CoCreateInstance(&CLSID_DirectMusicChordMap
, NULL
, CLSCTX_INPROC_SERVER
,
97 &IID_IClassFactory
, (void**)&dmcm
);
98 ok(hr
== E_NOINTERFACE
,
99 "DirectMusicChordMap create failed: %08x, expected E_NOINTERFACE\n", hr
);
101 /* Same refcount for all DirectMusicChordMap interfaces */
102 hr
= CoCreateInstance(&CLSID_DirectMusicChordMap
, NULL
, CLSCTX_INPROC_SERVER
,
103 &IID_IDirectMusicChordMap
, (void**)&dmcm
);
104 ok(hr
== S_OK
, "DirectMusicChordMap create failed: %08x, expected S_OK\n", hr
);
105 refcount
= IDirectMusicChordMap_AddRef(dmcm
);
106 ok(refcount
== 2, "refcount == %u, expected 2\n", refcount
);
108 hr
= IDirectMusicChordMap_QueryInterface(dmcm
, &IID_IDirectMusicObject
, (void**)&dmo
);
109 ok(hr
== S_OK
, "QueryInterface for IID_IDirectMusicObject failed: %08x\n", hr
);
110 refcount
= IDirectMusicObject_AddRef(dmo
);
111 ok(refcount
== 4, "refcount == %u, expected 4\n", refcount
);
112 refcount
= IDirectMusicObject_Release(dmo
);
114 hr
= IDirectMusicChordMap_QueryInterface(dmcm
, &IID_IPersistStream
, (void**)&ps
);
115 ok(hr
== S_OK
, "QueryInterface for IID_IPersistStream failed: %08x\n", hr
);
116 refcount
= IPersistStream_AddRef(ps
);
117 ok(refcount
== 5, "refcount == %u, expected 5\n", refcount
);
118 refcount
= IPersistStream_Release(ps
);
120 hr
= IDirectMusicChordMap_QueryInterface(dmcm
, &IID_IUnknown
, (void**)&unk
);
121 ok(hr
== S_OK
, "QueryInterface for IID_IUnknown failed: %08x\n", hr
);
122 refcount
= IUnknown_AddRef(unk
);
123 ok(refcount
== 6, "refcount == %u, expected 6\n", refcount
);
124 refcount
= IUnknown_Release(unk
);
126 while (IDirectMusicChordMap_Release(dmcm
));
129 static void test_COM_template(void)
131 IPersistStream
*ps
= (IPersistStream
*)0xdeadbeef;
136 /* COM aggregation */
137 hr
= CoCreateInstance(&CLSID_DirectMusicTemplate
, (IUnknown
*)&ps
, CLSCTX_INPROC_SERVER
,
138 &IID_IUnknown
, (void**)&ps
);
139 ok(hr
== CLASS_E_NOAGGREGATION
,
140 "DirectMusicTemplate create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr
);
141 ok(!ps
, "ps = %p\n", ps
);
144 hr
= CoCreateInstance(&CLSID_DirectMusicTemplate
, NULL
, CLSCTX_INPROC_SERVER
,
145 &IID_IDirectMusicObject
, (void**)&ps
);
146 todo_wine
ok(hr
== E_NOINTERFACE
,
147 "DirectMusicTemplate create failed: %08x, expected E_NOINTERFACE\n", hr
);
149 /* Same refcount for all DirectMusicTemplate interfaces */
150 hr
= CoCreateInstance(&CLSID_DirectMusicTemplate
, NULL
, CLSCTX_INPROC_SERVER
,
151 &IID_IPersistStream
, (void**)&ps
);
152 todo_wine
ok(hr
== S_OK
, "DirectMusicTemplate create failed: %08x, expected S_OK\n", hr
);
154 skip("DirectMusicTemplate not implemented\n");
157 refcount
= IPersistStream_AddRef(ps
);
158 ok(refcount
== 2, "refcount == %u, expected 2\n", refcount
);
160 hr
= IPersistStream_QueryInterface(ps
, &IID_IUnknown
, (void**)&unk
);
161 ok(hr
== S_OK
, "QueryInterface for IID_IUnknown failed: %08x\n", hr
);
162 refcount
= IUnknown_AddRef(unk
);
163 ok(refcount
== 4, "refcount == %u, expected 4\n", refcount
);
164 refcount
= IUnknown_Release(unk
);
166 while (IPersistStream_Release(ps
));
169 static void test_COM_track(void)
171 IDirectMusicTrack8
*dmt8
;
176 #define X(class) &CLSID_ ## class, #class
181 { X(DirectMusicChordMapTrack
) },
182 { X(DirectMusicSignPostTrack
) },
187 for (i
= 0; i
< ARRAY_SIZE(class); i
++) {
188 /* COM aggregation */
189 dmt8
= (IDirectMusicTrack8
*)0xdeadbeef;
190 hr
= CoCreateInstance(class[i
].clsid
, (IUnknown
*)&dmt8
, CLSCTX_INPROC_SERVER
, &IID_IUnknown
,
192 if (hr
== REGDB_E_CLASSNOTREG
) {
193 win_skip("%s not registered\n", class[i
].name
);
196 ok(hr
== CLASS_E_NOAGGREGATION
,
197 "%s create failed: %08x, expected CLASS_E_NOAGGREGATION\n", class[i
].name
, hr
);
198 ok(!dmt8
, "dmt8 = %p\n", dmt8
);
201 hr
= CoCreateInstance(class[i
].clsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectMusicObject
,
203 ok(hr
== E_NOINTERFACE
, "%s create failed: %08x, expected E_NOINTERFACE\n",
206 /* Same refcount for all DirectMusicTrack interfaces */
207 hr
= CoCreateInstance(class[i
].clsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectMusicTrack8
,
209 if (hr
== E_NOINTERFACE
&& !dmt8
) {
210 skip("%s not created with CoCreateInstance()\n", class[i
].name
);
213 ok(hr
== S_OK
, "%s create failed: %08x, expected S_OK\n", class[i
].name
, hr
);
214 refcount
= IDirectMusicTrack8_AddRef(dmt8
);
215 ok(refcount
== 2, "refcount == %u, expected 2\n", refcount
);
217 hr
= IDirectMusicTrack8_QueryInterface(dmt8
, &IID_IPersistStream
, (void**)&ps
);
218 ok(hr
== S_OK
, "QueryInterface for IID_IPersistStream failed: %08x\n", hr
);
219 refcount
= IPersistStream_AddRef(ps
);
220 ok(refcount
== 4, "refcount == %u, expected 4\n", refcount
);
221 IPersistStream_Release(ps
);
223 hr
= IDirectMusicTrack8_QueryInterface(dmt8
, &IID_IUnknown
, (void**)&unk
);
224 ok(hr
== S_OK
, "QueryInterface for IID_IUnknown failed: %08x\n", hr
);
225 refcount
= IUnknown_AddRef(unk
);
226 ok(refcount
== 5, "refcount == %u, expected 5\n", refcount
);
227 refcount
= IUnknown_Release(unk
);
229 while (IDirectMusicTrack8_Release(dmt8
));
233 static void test_chordmap(void)
235 IDirectMusicChordMap
*dmcm
;
241 hr
= CoCreateInstance(&CLSID_DirectMusicChordMap
, NULL
, CLSCTX_INPROC_SERVER
,
242 &IID_IDirectMusicChordMap
, (void**)&dmcm
);
243 ok(hr
== S_OK
, "DirectMusicChordMap create failed: %08x, expected S_OK\n", hr
);
246 hr
= IDirectMusicChordMap_QueryInterface(dmcm
, &IID_IPersistStream
, (void**)&ps
);
247 ok(hr
== S_OK
, "QueryInterface for IID_IPersistStream failed: %08x\n", hr
);
248 hr
= IPersistStream_GetClassID(ps
, &class);
249 ok(hr
== S_OK
, "IPersistStream_GetClassID failed: %08x\n", hr
);
250 ok(IsEqualGUID(&class, &CLSID_DirectMusicChordMap
),
251 "Expected class CLSID_DirectMusicChordMap got %s\n", wine_dbgstr_guid(&class));
253 /* Unimplemented IPersistStream methods */
254 hr
= IPersistStream_IsDirty(ps
);
255 ok(hr
== S_FALSE
, "IPersistStream_IsDirty failed: %08x\n", hr
);
256 hr
= IPersistStream_GetSizeMax(ps
, &size
);
257 ok(hr
== E_NOTIMPL
, "IPersistStream_GetSizeMax failed: %08x\n", hr
);
258 hr
= IPersistStream_Save(ps
, NULL
, TRUE
);
259 ok(hr
== E_NOTIMPL
, "IPersistStream_Save failed: %08x\n", hr
);
261 while (IDirectMusicChordMap_Release(dmcm
));
264 static void test_chordmaptrack(void)
266 IDirectMusicTrack8
*dmt8
;
272 hr
= CoCreateInstance(&CLSID_DirectMusicChordMapTrack
, NULL
, CLSCTX_INPROC_SERVER
,
273 &IID_IDirectMusicTrack8
, (void**)&dmt8
);
274 ok(hr
== S_OK
, "DirectMusicChordMapTrack create failed: %08x, expected S_OK\n", hr
);
277 hr
= IDirectMusicTrack8_QueryInterface(dmt8
, &IID_IPersistStream
, (void**)&ps
);
278 ok(hr
== S_OK
, "QueryInterface for IID_IPersistStream failed: %08x\n", hr
);
279 hr
= IPersistStream_GetClassID(ps
, &class);
280 todo_wine
ok(hr
== S_OK
, "IPersistStream_GetClassID failed: %08x\n", hr
);
281 todo_wine
ok(IsEqualGUID(&class, &CLSID_DirectMusicChordMapTrack
),
282 "Expected class CLSID_DirectMusicChordMapTrack got %s\n", wine_dbgstr_guid(&class));
284 /* Unimplemented IPersistStream methods */
285 hr
= IPersistStream_IsDirty(ps
);
286 todo_wine
ok(hr
== S_FALSE
, "IPersistStream_IsDirty failed: %08x\n", hr
);
287 hr
= IPersistStream_GetSizeMax(ps
, &size
);
288 ok(hr
== E_NOTIMPL
, "IPersistStream_GetSizeMax failed: %08x\n", hr
);
289 hr
= IPersistStream_Save(ps
, NULL
, TRUE
);
290 ok(hr
== E_NOTIMPL
, "IPersistStream_Save failed: %08x\n", hr
);
292 while (IDirectMusicTrack8_Release(dmt8
));
295 static void test_signposttrack(void)
297 IDirectMusicTrack8
*dmt8
;
303 hr
= CoCreateInstance(&CLSID_DirectMusicSignPostTrack
, NULL
, CLSCTX_INPROC_SERVER
,
304 &IID_IDirectMusicTrack8
, (void**)&dmt8
);
305 ok(hr
== S_OK
, "DirectMusicSignPostTrack create failed: %08x, expected S_OK\n", hr
);
308 hr
= IDirectMusicTrack8_QueryInterface(dmt8
, &IID_IPersistStream
, (void**)&ps
);
309 ok(hr
== S_OK
, "QueryInterface for IID_IPersistStream failed: %08x\n", hr
);
310 hr
= IPersistStream_GetClassID(ps
, &class);
311 todo_wine
ok(hr
== S_OK
, "IPersistStream_GetClassID failed: %08x\n", hr
);
312 todo_wine
ok(IsEqualGUID(&class, &CLSID_DirectMusicSignPostTrack
),
313 "Expected class CLSID_DirectMusicSignPostTrack got %s\n", wine_dbgstr_guid(&class));
314 hr
= IPersistStream_Save(ps
, NULL
, TRUE
);
315 todo_wine
ok(hr
== E_POINTER
, "IPersistStream_Save failed: %08x\n", hr
);
317 /* Unimplemented IPersistStream methods */
318 hr
= IPersistStream_IsDirty(ps
);
319 todo_wine
ok(hr
== S_FALSE
, "IPersistStream_IsDirty failed: %08x\n", hr
);
320 hr
= IPersistStream_GetSizeMax(ps
, &size
);
321 ok(hr
== E_NOTIMPL
, "IPersistStream_GetSizeMax failed: %08x\n", hr
);
323 while (IDirectMusicTrack8_Release(dmt8
));
330 if (missing_dmcompos())
332 skip("dmcompos not available\n");
341 test_chordmaptrack();
342 test_signposttrack();