From 08f2c022e58f3c1c667293cd0c4a9b12651f7666 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Sat, 6 Apr 2019 21:14:52 -0500 Subject: [PATCH] qcap/tests: Add some tests for audio capture filter interfaces. Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/qcap/tests/Makefile.in | 1 + dlls/qcap/tests/audiorecord.c | 103 ++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 dlls/qcap/tests/audiorecord.c diff --git a/dlls/qcap/tests/Makefile.in b/dlls/qcap/tests/Makefile.in index 7a6336bce24..80b19624d71 100644 --- a/dlls/qcap/tests/Makefile.in +++ b/dlls/qcap/tests/Makefile.in @@ -2,5 +2,6 @@ TESTDLL = qcap.dll IMPORTS = strmiids uuid oleaut32 ole32 advapi32 C_SRCS = \ + audiorecord.c \ qcap.c \ smartteefilter.c diff --git a/dlls/qcap/tests/audiorecord.c b/dlls/qcap/tests/audiorecord.c new file mode 100644 index 00000000000..fb292cff5f0 --- /dev/null +++ b/dlls/qcap/tests/audiorecord.c @@ -0,0 +1,103 @@ +/* + * Audio capture filter unit tests + * + * Copyright 2018 Zebediah Figura + * + * 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 + */ + +#define COBJMACROS +#include "dshow.h" +#include "wine/test.h" + +#define check_interface(a, b, c) check_interface_(__LINE__, a, b, c) +static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOOL supported) +{ + IUnknown *iface = iface_ptr; + HRESULT hr, expected_hr; + IUnknown *unk; + + expected_hr = supported ? S_OK : E_NOINTERFACE; + + hr = IUnknown_QueryInterface(iface, iid, (void **)&unk); + ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x, expected %#x.\n", hr, expected_hr); + if (SUCCEEDED(hr)) + IUnknown_Release(unk); +} + +static void test_interfaces(IBaseFilter *filter) +{ + todo_wine check_interface(filter, &IID_IAMFilterMiscFlags, TRUE); + check_interface(filter, &IID_IBaseFilter, TRUE); + check_interface(filter, &IID_IMediaFilter, TRUE); + check_interface(filter, &IID_IPersist, TRUE); + check_interface(filter, &IID_IPersistPropertyBag, TRUE); + check_interface(filter, &IID_IUnknown, TRUE); + + check_interface(filter, &IID_IBasicAudio, FALSE); + check_interface(filter, &IID_IBasicVideo, FALSE); + check_interface(filter, &IID_IKsPropertySet, FALSE); + check_interface(filter, &IID_IMediaPosition, FALSE); + check_interface(filter, &IID_IMediaSeeking, FALSE); + check_interface(filter, &IID_IPin, FALSE); + check_interface(filter, &IID_IQualityControl, FALSE); + check_interface(filter, &IID_IQualProp, FALSE); + check_interface(filter, &IID_IReferenceClock, FALSE); + check_interface(filter, &IID_IVideoWindow, FALSE); +} + +START_TEST(audiorecord) +{ + ICreateDevEnum *devenum; + IEnumMoniker *enummon; + IBaseFilter *filter; + IMoniker *mon; + WCHAR *name; + HRESULT hr; + + CoInitialize(NULL); + + hr = CoCreateInstance(&CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, + &IID_ICreateDevEnum, (void **)&devenum); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = ICreateDevEnum_CreateClassEnumerator(devenum, &CLSID_AudioInputDeviceCategory, &enummon, 0); + if (hr == S_FALSE) + { + skip("No audio input devices present.\n"); + ICreateDevEnum_Release(devenum); + CoUninitialize(); + return; + } + ok(hr == S_OK, "Got hr %#x.\n", hr); + + while (IEnumMoniker_Next(enummon, 1, &mon, NULL) == S_OK) + { + hr = IMoniker_GetDisplayName(mon, NULL, NULL, &name); + ok(hr == S_OK, "Got hr %#x.\n", hr); + trace("Testing device %s.\n", wine_dbgstr_w(name)); + CoTaskMemFree(name); + + hr = IMoniker_BindToObject(mon, NULL, NULL, &IID_IBaseFilter, (void **)&filter); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + test_interfaces(filter); + + IMoniker_Release(mon); + } + + IEnumMoniker_Release(enummon); + ICreateDevEnum_Release(devenum); + CoUninitialize(); +}