msvcp110: Add tr2_sys__Make_dir_wchar implementation and test.
[wine/multimedia.git] / dlls / dmsynth / tests / dmsynth.c
blobba094a1044127ad6c101d401ac67ea68dc76d117
1 /*
2 * Unit tests for dmsynth 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 "dmusics.h"
30 #include "dmusici.h"
31 #include "dmksctrl.h"
33 static void test_dmsynth(void)
35 IDirectMusicSynth *dmsynth = NULL;
36 IDirectMusicSynthSink *dmsynth_sink = NULL;
37 IReferenceClock* clock_synth = NULL;
38 IReferenceClock* clock_sink = NULL;
39 IKsControl* control_synth = NULL;
40 IKsControl* control_sink = NULL;
41 HRESULT hr;
42 KSPROPERTY property;
43 ULONG value;
44 ULONG bytes;
46 hr = CoCreateInstance(&CLSID_DirectMusicSynth, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynth, (LPVOID*)&dmsynth);
47 if (hr != S_OK)
49 skip("Cannot create DirectMusicSync object (%x)\n", hr);
50 return;
53 hr = CoCreateInstance(&CLSID_DirectMusicSynthSink, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynthSink, (LPVOID*)&dmsynth_sink);
54 ok(hr == S_OK, "CoCreateInstance returned: %x\n", hr);
56 hr = IDirectMusicSynth_QueryInterface(dmsynth, &IID_IKsControl, (LPVOID*)&control_synth);
57 ok(hr == S_OK, "IDirectMusicSynth_QueryInterface returned: %x\n", hr);
59 S(U(property)).Id = 0;
60 S(U(property)).Flags = KSPROPERTY_TYPE_GET;
62 S(U(property)).Set = GUID_DMUS_PROP_INSTRUMENT2;
63 hr = IKsControl_KsProperty(control_synth, &property, sizeof(property), &value, sizeof(value), &bytes);
64 ok(hr == S_OK, "IKsControl_KsProperty returned: %x\n", hr);
65 ok(bytes == sizeof(DWORD), "Returned bytes: %u, should be 4\n", bytes);
66 ok(value == TRUE, "Return value: %u, should be 1\n", value);
67 S(U(property)).Set = GUID_DMUS_PROP_DLS2;
68 hr = IKsControl_KsProperty(control_synth, &property, sizeof(property), &value, sizeof(value), &bytes);
69 ok(hr == S_OK, "IKsControl_KsProperty returned: %x\n", hr);
70 ok(bytes == sizeof(DWORD), "Returned bytes: %u, should be 4\n", bytes);
71 ok(value == TRUE, "Return value: %u, should be 1\n", value);
72 S(U(property)).Set = GUID_DMUS_PROP_GM_Hardware;
73 hr = IKsControl_KsProperty(control_synth, &property, sizeof(property), &value, sizeof(value), &bytes);
74 ok(hr == S_OK, "IKsControl_KsProperty returned: %x\n", hr);
75 ok(bytes == sizeof(DWORD), "Returned bytes: %u, should be 4\n", bytes);
76 ok(value == FALSE, "Return value: %u, should be 0\n", value);
77 S(U(property)).Set = GUID_DMUS_PROP_GS_Hardware;
78 hr = IKsControl_KsProperty(control_synth, &property, sizeof(property), &value, sizeof(value), &bytes);
79 ok(hr == S_OK, "IKsControl_KsProperty returned: %x\n", hr);
80 ok(bytes == sizeof(DWORD), "Returned bytes: %u, should be 4\n", bytes);
81 ok(value == FALSE, "Return value: %u, should be 0\n", value);
82 S(U(property)).Set = GUID_DMUS_PROP_XG_Hardware;
83 hr = IKsControl_KsProperty(control_synth, &property, sizeof(property), &value, sizeof(value), &bytes);
84 ok(hr == S_OK, "IKsControl_KsProperty returned: %x\n", hr);
85 ok(bytes == sizeof(DWORD), "Returned bytes: %u, should be 4\n", bytes);
86 ok(value == FALSE, "Return value: %u, should be 0\n", value);
88 hr = IDirectMusicSynthSink_QueryInterface(dmsynth_sink, &IID_IKsControl, (LPVOID*)&control_sink);
89 ok(hr == S_OK, "IDirectMusicSynthSink_QueryInterface returned: %x\n", hr);
91 S(U(property)).Set = GUID_DMUS_PROP_SinkUsesDSound;
92 hr = IKsControl_KsProperty(control_sink, &property, sizeof(property), &value, sizeof(value), &bytes);
93 ok(hr == S_OK, "IKsControl_KsProperty returned: %x\n", hr);
94 ok(bytes == sizeof(DWORD), "Returned bytes: %u, should be 4\n", bytes);
95 ok(value == TRUE, "Return value: %u, should be 1\n", value);
97 /* Synth has no default clock */
98 hr = IDirectMusicSynth_GetLatencyClock(dmsynth, &clock_synth);
99 ok(hr == DMUS_E_NOSYNTHSINK, "IDirectMusicSynth_GetLatencyClock returned: %x\n", hr);
101 /* SynthSink has a default clock */
102 hr = IDirectMusicSynthSink_GetLatencyClock(dmsynth_sink, &clock_sink);
103 ok(hr == S_OK, "IDirectMusicSynth_GetLatencyClock returned: %x\n", hr);
104 ok(clock_sink != NULL, "No clock returned\n");
106 /* This will set clock to Synth */
107 hr = IDirectMusicSynth_SetSynthSink(dmsynth, dmsynth_sink);
108 ok(hr == S_OK, "IDirectMusicSynth_SetSynthSink returned: %x\n", hr);
110 /* Check clocks are the same */
111 hr = IDirectMusicSynth_GetLatencyClock(dmsynth, &clock_synth);
112 ok(hr == S_OK, "IDirectMusicSynth_GetLatencyClock returned: %x\n", hr);
113 ok(clock_synth != NULL, "No clock returned\n");
114 ok(clock_synth == clock_sink, "Synth and SynthSink clocks are not the same\n");
116 if (control_synth)
117 IDirectMusicSynth_Release(control_synth);
118 if (control_sink)
119 IDirectMusicSynth_Release(control_sink);
120 if (clock_synth)
121 IReferenceClock_Release(clock_synth);
122 if (clock_sink)
123 IReferenceClock_Release(clock_sink);
124 if (dmsynth_sink)
125 IDirectMusicSynthSink_Release(dmsynth_sink);
126 IDirectMusicSynth_Release(dmsynth);
129 START_TEST(dmsynth)
131 CoInitializeEx(NULL, COINIT_MULTITHREADED);
133 test_dmsynth();
135 CoUninitialize();