2 * Unit test suite for IDirectMusicPerformance
4 * Copyright 2010 Austin Lund
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
24 #include <wine/test.h>
29 DEFINE_GUID(GUID_NULL
,0,0,0,0,0,0,0,0,0,0,0);
30 DEFINE_GUID(GUID_Bunk
,0xFFFFFFFF,0xFFFF,0xFFFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF);
32 static const char *debugstr_guid(REFIID riid
)
36 sprintf(buf
, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
37 riid
->Data1
, riid
->Data2
, riid
->Data3
, riid
->Data4
[0],
38 riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3], riid
->Data4
[4],
39 riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7]);
44 static HRESULT
test_InitAudio(void)
46 IDirectMusicPerformance8
*idmusicperformance
;
47 IDirectSound
*pDirectSound
;
48 IDirectMusicPort
*pDirectMusicPort
;
49 IDirectMusicAudioPath
*pDirectMusicAudioPath
;
52 hr
= CoCreateInstance(&CLSID_DirectMusicPerformance
, NULL
,
53 CLSCTX_INPROC_SERVER
, &IID_IDirectMusicPerformance8
, (LPVOID
*)&idmusicperformance
);
55 skip("Cannot create DirectMusicPerformance object (%x)\n", hr
);
61 hr
= IDirectMusicPerformance8_InitAudio(idmusicperformance
,NULL
,
62 &pDirectSound
, NULL
, DMUS_APATH_SHARED_STEREOPLUSREVERB
, 128, DMUS_AUDIOF_ALL
, NULL
);
66 pDirectMusicPort
= NULL
;
67 hr
= IDirectMusicPerformance8_PChannelInfo(idmusicperformance
, 0, &pDirectMusicPort
, NULL
, NULL
);
68 ok(hr
== S_OK
, "Failed to call PChannelInfo (%x)\n", hr
);
69 ok(pDirectMusicPort
!= NULL
, "IDirectMusicPort not set\n");
70 if (hr
== S_OK
&& pDirectMusicPort
!= NULL
)
71 IDirectMusicPort_Release(pDirectMusicPort
);
73 hr
= IDirectMusicPerformance8_GetDefaultAudioPath(idmusicperformance
, &pDirectMusicAudioPath
);
74 ok(hr
== S_OK
, "Failed to call GetDefaultAudioPath (%x)\n", hr
);
76 IDirectMusicAudioPath_Release(pDirectMusicAudioPath
);
78 hr
= IDirectMusicPerformance8_CloseDown(idmusicperformance
);
79 ok(hr
== S_OK
, "Failed to call CloseDown (%x)\n", hr
);
81 IDirectMusicPerformance8_Release(idmusicperformance
);
86 static void test_createport(void)
88 IDirectMusicPerformance8
*perf
;
89 IDirectMusic
*music
= NULL
;
90 IDirectMusicPort
*port
= NULL
;
91 DMUS_PORTCAPS portcaps
;
92 DMUS_PORTPARAMS portparams
;
96 hr
= CoCreateInstance(&CLSID_DirectMusicPerformance
, NULL
,
97 CLSCTX_INPROC_SERVER
, &IID_IDirectMusicPerformance8
, (void**)&perf
);
98 ok(hr
== S_OK
, "CoCreateInstance failed: %08x\n", hr
);
100 hr
= IDirectMusicPerformance8_Init(perf
, &music
, NULL
, NULL
);
101 ok(hr
== S_OK
, "Init failed: %08x\n", hr
);
102 ok(music
!= NULL
, "Didn't get IDirectMusic pointer\n");
106 portcaps
.dwSize
= sizeof(portcaps
);
108 hr
= IDirectMusic_EnumPort(music
, i
, &portcaps
);
109 ok(hr
== S_OK
|| hr
== S_FALSE
|| (i
== 0 && hr
== E_INVALIDARG
), "EnumPort failed: %08x\n", hr
);
113 ok(portcaps
.dwSize
== sizeof(portcaps
), "Got unexpected portcaps struct size: %08x\n", portcaps
.dwSize
);
114 trace("portcaps(%u).dwFlags: %08x\n", i
, portcaps
.dwFlags
);
115 trace("portcaps(%u).guidPort: %s\n", i
, debugstr_guid(&portcaps
.guidPort
));
116 trace("portcaps(%u).dwClass: %08x\n", i
, portcaps
.dwClass
);
117 trace("portcaps(%u).dwType: %08x\n", i
, portcaps
.dwType
);
118 trace("portcaps(%u).dwMemorySize: %08x\n", i
, portcaps
.dwMemorySize
);
119 trace("portcaps(%u).dwMaxChannelGroups: %08x\n", i
, portcaps
.dwMaxChannelGroups
);
120 trace("portcaps(%u).dwMaxVoices: %08x\n", i
, portcaps
.dwMaxVoices
);
121 trace("portcaps(%u).dwMaxAudioChannels: %08x\n", i
, portcaps
.dwMaxAudioChannels
);
122 trace("portcaps(%u).dwEffectFlags: %08x\n", i
, portcaps
.dwEffectFlags
);
123 trace("portcaps(%u).wszDescription: %s\n", i
, wine_dbgstr_w(portcaps
.wszDescription
));
129 win_skip("No ports available, skipping tests\n");
133 portparams
.dwSize
= sizeof(portparams
);
135 /* dwValidParams == 0 -> S_OK, filled struct */
136 portparams
.dwValidParams
= 0;
137 hr
= IDirectMusic_CreatePort(music
, &CLSID_DirectMusicSynth
,
138 &portparams
, &port
, NULL
);
139 ok(hr
== S_OK
, "CreatePort failed: %08x\n", hr
);
140 ok(port
!= NULL
, "Didn't get IDirectMusicPort pointer\n");
142 IDirectMusicPort_Release(port
);
145 todo_wine
ok(portparams
.dwValidParams
!= 0, "portparams struct was not filled in\n");
147 /* dwValidParams != 0, invalid param -> S_FALSE, filled struct */
148 portparams
.dwValidParams
= DMUS_PORTPARAMS_CHANNELGROUPS
;
149 portparams
.dwChannelGroups
= 0;
150 hr
= IDirectMusic_CreatePort(music
, &CLSID_DirectMusicSynth
,
151 &portparams
, &port
, NULL
);
152 todo_wine
ok(hr
== S_FALSE
, "CreatePort failed: %08x\n", hr
);
153 ok(port
!= NULL
, "Didn't get IDirectMusicPort pointer\n");
155 IDirectMusicPort_Release(port
);
158 ok(portparams
.dwValidParams
!= 0, "portparams struct was not filled in\n");
160 /* dwValidParams != 0, valid params -> S_OK */
161 hr
= IDirectMusic_CreatePort(music
, &CLSID_DirectMusicSynth
,
162 &portparams
, &port
, NULL
);
163 ok(hr
== S_OK
, "CreatePort failed: %08x\n", hr
);
164 ok(port
!= NULL
, "Didn't get IDirectMusicPort pointer\n");
166 IDirectMusicPort_Release(port
);
169 /* GUID_NULL succeeds */
170 portparams
.dwValidParams
= 0;
171 hr
= IDirectMusic_CreatePort(music
, &GUID_NULL
, &portparams
, &port
, NULL
);
172 ok(hr
== S_OK
, "CreatePort failed: %08x\n", hr
);
173 ok(port
!= NULL
, "Didn't get IDirectMusicPort pointer\n");
175 IDirectMusicPort_Release(port
);
178 todo_wine
ok(portparams
.dwValidParams
!= 0, "portparams struct was not filled in\n");
180 /* null GUID fails */
181 portparams
.dwValidParams
= 0;
182 hr
= IDirectMusic_CreatePort(music
, NULL
, &portparams
, &port
, NULL
);
183 ok(hr
== E_POINTER
, "CreatePort failed: %08x\n", hr
);
184 ok(port
== NULL
, "Get IDirectMusicPort pointer? %p\n", port
);
185 ok(portparams
.dwValidParams
== 0, "portparams struct was filled in?\n");
187 /* garbage GUID fails */
188 portparams
.dwValidParams
= 0;
189 hr
= IDirectMusic_CreatePort(music
, &GUID_Bunk
, &portparams
, &port
, NULL
);
190 ok(hr
== E_NOINTERFACE
, "CreatePort failed: %08x\n", hr
);
191 ok(port
== NULL
, "Get IDirectMusicPort pointer? %p\n", port
);
192 ok(portparams
.dwValidParams
== 0, "portparams struct was filled in?\n");
194 IDirectMusic_Release(music
);
195 IDirectMusicPerformance_Release(perf
);
198 START_TEST( performance
)
202 hr
= CoInitialize(NULL
);
204 skip("Cannot initialize COM (%x)\n", hr
);
208 hr
= test_InitAudio();
210 skip("InitAudio failed (%x)\n", hr
);