From: David McFarland corngood@gmail.com
--- dlls/mmdevapi/tests/Makefile.in | 1 + dlls/mmdevapi/tests/devicetopology.c | 104 +++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 dlls/mmdevapi/tests/devicetopology.c
diff --git a/dlls/mmdevapi/tests/Makefile.in b/dlls/mmdevapi/tests/Makefile.in index dd180a253b9..b63bd47043f 100644 --- a/dlls/mmdevapi/tests/Makefile.in +++ b/dlls/mmdevapi/tests/Makefile.in @@ -4,6 +4,7 @@ IMPORTS = ole32 version user32 advapi32 winmm C_SRCS = \ capture.c \ dependency.c \ + devicetopology.c \ mmdevenum.c \ propstore.c \ render.c \ diff --git a/dlls/mmdevapi/tests/devicetopology.c b/dlls/mmdevapi/tests/devicetopology.c new file mode 100644 index 00000000000..9762bae2d57 --- /dev/null +++ b/dlls/mmdevapi/tests/devicetopology.c @@ -0,0 +1,104 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <math.h> +#include <stdio.h> + +#include "wine/test.h" + +#define COBJMACROS + +#include "mmdeviceapi.h" +#include "devicetopology.h" +#include "mmsystem.h" + +static IMMDeviceEnumerator *mme = NULL; +static IMMDevice *dev = NULL; +static IDeviceTopology *dt = NULL; + +static void test_connectors(void) +{ + HRESULT hr; + UINT connector_count; + + hr = IDeviceTopology_GetConnectorCount(dt, &connector_count); + ok(hr == S_OK, "GetConnectorCount returns 0x%08lx\n", hr); + trace("connector count: %u\n", connector_count); + + if (hr == S_OK && connector_count > 0) + { + IConnector *connector; + + hr = IDeviceTopology_GetConnector(dt, 0, &connector); + ok(hr == S_OK, "GetConnector returns 0x%08lx\n", hr); + + if (hr == S_OK) + { + ConnectorType type; + + hr = IConnector_GetType(connector, &type); + ok(hr == S_OK, "GetConnector returns 0x%08lx\n", hr); + trace("connector 0 type: %u\n", connector_count); + } + } +} + +START_TEST(devicetopology) +{ + HRESULT hr; + + CoInitializeEx(NULL, COINIT_MULTITHREADED); + hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, (void**)&mme); + if (FAILED(hr)) + { + skip("mmdevapi not available: 0x%08lx\n", hr); + goto cleanup; + } + + hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(mme, eRender, eMultimedia, &dev); + ok(hr == S_OK || hr == E_NOTFOUND, "GetDefaultAudioEndpoint failed: 0x%08lx\n", hr); + if (hr != S_OK || !dev) + { + if (hr == E_NOTFOUND) + win_skip("No sound card available\n"); + else + skip("GetDefaultAudioEndpoint returns 0x%08lx\n", hr); + goto cleanup; + } + + hr = IMMDevice_Activate(dev, &IID_IDeviceTopology, CLSCTX_INPROC_SERVER, NULL, (void**)&dt); + ok(hr == S_OK || hr == E_NOINTERFACE, "IDeviceTopology Activation failed: 0x%08lx\n", hr); + if (hr != S_OK || !dev) + { + if (hr == E_NOINTERFACE) + todo_wine + win_skip("IDeviceTopology interface not found\n"); + else + skip("IDeviceTopology Activation returns 0x%08lx\n", hr); + goto cleanup; + } + + test_connectors(); + + IDeviceTopology_Release(dt); + +cleanup: + if (dev) + IMMDevice_Release(dev); + if (mme) + IMMDeviceEnumerator_Release(mme); + CoUninitialize(); +}