credui: Delete the static critical section when unloading the dll.
[wine] / dlls / dmime / tests / performance.c
1 /*
2  * Unit test suite for IDirectMusicPerformance
3  *
4  * Copyright 2010 Austin Lund
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include <stdarg.h>
22 #include <windef.h>
23 #include <initguid.h>
24 #include <wine/test.h>
25 #include <dmusici.h>
26
27 static IDirectMusicPerformance8 *idmusicperformance;
28
29 static HRESULT test_InitAudio(void)
30 {
31     IDirectSound *pDirectSound;
32     HRESULT hr;
33
34     pDirectSound = NULL;
35     hr = IDirectMusicPerformance8_InitAudio(idmusicperformance ,NULL,
36         &pDirectSound, NULL, DMUS_APATH_SHARED_STEREOPLUSREVERB, 128, DMUS_AUDIOF_ALL, NULL);
37     return hr;
38 }
39
40 static void test_PChannelInfo(void)
41 {
42     IDirectMusicPort *pDirectMusicPort;
43     HRESULT hr;
44
45     pDirectMusicPort = NULL;
46     hr = IDirectMusicPerformance8_PChannelInfo(idmusicperformance, 0, &pDirectMusicPort, NULL, NULL);
47     ok(hr == S_OK, "Failed to call PChannelInfo (%x)\n", hr);
48     ok(pDirectMusicPort != NULL, "IDirectMusicPort not set\n");
49     if (hr == S_OK && pDirectMusicPort != NULL)
50         IDirectMusicPort_Release(pDirectMusicPort);
51 }
52
53 static void test_GetDefaultAudioPath(void)
54 {
55     IDirectMusicAudioPath *pDirectMusicAudioPath;
56     HRESULT hr;
57
58     hr = IDirectMusicPerformance8_GetDefaultAudioPath(idmusicperformance, &pDirectMusicAudioPath);
59     ok(hr == S_OK, "Failed to call GetDefaultAudioPath (%x)\n", hr);
60     if (hr == S_OK)
61         IDirectMusicAudioPath_Release(pDirectMusicAudioPath);
62 }
63
64 static void test_CloseDown(void)
65 {
66     HRESULT hr;
67
68     hr = IDirectMusicPerformance8_CloseDown(idmusicperformance);
69     ok(hr == S_OK, "Failed to call CloseDown (%x)\n", hr);
70 }
71
72 START_TEST( performance )
73 {
74     HRESULT hr;
75
76     hr = CoInitialize(NULL);
77     if (FAILED(hr)) {
78         skip("Cannot initialize COM (%x)\n", hr);
79         return;
80     }
81
82     hr = CoCreateInstance(&CLSID_DirectMusicPerformance, NULL,
83             CLSCTX_INPROC_SERVER, &IID_IDirectMusicPerformance8, (LPVOID *)&idmusicperformance);
84     if (hr != S_OK) {
85         skip("Cannot create DirectMusicPerformance object (%x)\n", hr);
86         CoUninitialize();
87         return;
88     }
89
90     hr = test_InitAudio();
91     if (hr != S_OK) {
92         skip("InitAudio failed (%x)\n", hr);
93         return;
94     }
95
96     test_GetDefaultAudioPath();
97     test_PChannelInfo();
98     test_CloseDown();
99
100     IDirectMusicPerformance8_Release(idmusicperformance);
101     CoUninitialize();
102 }