urlmon: Added Seek implementations for streams using cache file.
[wine.git] / dlls / dmband / tests / dmband.c
blobe1f00ae7015308fa9ca7d9113e44f3eb9608eeab
1 /*
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
21 #define COBJMACROS
23 #include <stdio.h>
25 #include "wine/test.h"
26 #include "uuids.h"
27 #include "ole2.h"
28 #include "initguid.h"
29 #include "dmusici.h"
30 #include "dmplugin.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);
43 return FALSE;
45 return TRUE;
48 static void test_COM(void)
50 IDirectMusicBand *dmb = (IDirectMusicBand*)0xdeadbeef;
51 IDirectMusicObject *dmo;
52 IPersistStream *ps;
53 IUnknown *unk;
54 ULONG refcount;
55 HRESULT hr;
57 /* COM aggregation */
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);
64 /* Invalid RIID */
65 hr = CoCreateInstance(&CLSID_DirectMusicBand, NULL, CLSCTX_INPROC_SERVER, &IID_IClassFactory,
66 (void**)&dmb);
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,
71 (void**)&dmb);
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;
100 IPersistStream *ps;
101 IUnknown *private;
102 IUnknown *unk;
103 ULONG refcount;
104 HRESULT hr;
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);
113 /* Invalid RIID */
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,
138 (void**)&private);
139 todo_wine ok(hr == S_OK, "QueryInterface for IID_IDirectMusicBandTrackPrivate failed: %08x\n", hr);
140 if (hr == S_OK) {
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;
152 IPersistStream *ps;
153 CLSID class;
154 ULARGE_INTEGER size;
155 HRESULT hr;
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;
179 IPersistStream *ps;
180 CLSID class;
181 ULARGE_INTEGER size;
182 HRESULT hr;
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 */
189 todo_wine {
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);
197 todo_wine {
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);
211 todo_wine {
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);
226 /* IPersistStream */
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));
245 START_TEST(dmband)
247 CoInitializeEx(NULL, COINIT_MULTITHREADED);
249 if (missing_dmband())
251 skip("dmband not available\n");
252 CoUninitialize();
253 return;
256 test_COM();
257 test_COM_bandtrack();
258 test_dmband();
259 test_bandtrack();
261 CoUninitialize();