po: Fix a mistake in Dutch translation.
[wine.git] / dlls / dmband / tests / dmband.c
blobe2ba8d8f43a29d7b1f93595733e734431f60682f
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 todo_wine 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 START_TEST(dmband)
178 CoInitializeEx(NULL, COINIT_MULTITHREADED);
180 if (missing_dmband())
182 skip("dmband not available\n");
183 CoUninitialize();
184 return;
187 test_COM();
188 test_COM_bandtrack();
189 test_dmband();
191 CoUninitialize();