quartz/tests: Clean up test_query_interface().
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
fd2412fbe5
commit
cbb7fd5256
|
@ -26,104 +26,122 @@
|
||||||
#include "amaudio.h"
|
#include "amaudio.h"
|
||||||
#include "wine/test.h"
|
#include "wine/test.h"
|
||||||
|
|
||||||
#define QI_SUCCEED(iface, riid, ppv) hr = IUnknown_QueryInterface(iface, &riid, (LPVOID*)&ppv); \
|
static IBaseFilter *create_dsound_render(void)
|
||||||
ok(hr == S_OK, "IUnknown_QueryInterface returned %x\n", hr); \
|
|
||||||
ok(ppv != NULL, "Pointer is NULL\n");
|
|
||||||
|
|
||||||
#define RELEASE_EXPECT(iface, num) if (iface) { \
|
|
||||||
hr = IUnknown_Release((IUnknown*)iface); \
|
|
||||||
ok(hr == num, "IUnknown_Release should return %d, got %d\n", num, hr); \
|
|
||||||
}
|
|
||||||
|
|
||||||
static IUnknown *pDSRender = NULL;
|
|
||||||
|
|
||||||
static BOOL create_dsound_renderer(void)
|
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
IBaseFilter *filter = NULL;
|
||||||
|
HRESULT hr = CoCreateInstance(&CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER,
|
||||||
hr = CoCreateInstance(&CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER,
|
&IID_IBaseFilter, (void **)&filter);
|
||||||
&IID_IUnknown, (LPVOID*)&pDSRender);
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
return (hr == S_OK && pDSRender != NULL);
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void release_dsound_renderer(void)
|
static HRESULT WINAPI property_bag_QueryInterface(IPropertyBag *iface, REFIID iid, void **out)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
ok(0, "Unexpected call (iid %s).\n", wine_dbgstr_guid(iid));
|
||||||
|
return E_NOINTERFACE;
|
||||||
hr = IUnknown_Release(pDSRender);
|
|
||||||
ok(hr == 0, "IUnknown_Release failed with %x\n", hr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ULONG WINAPI property_bag_AddRef(IPropertyBag *iface)
|
||||||
|
{
|
||||||
|
ok(0, "Unexpected call.\n");
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ULONG WINAPI property_bag_Release(IPropertyBag *iface)
|
||||||
|
{
|
||||||
|
ok(0, "Unexpected call.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI property_bag_Read(IPropertyBag *iface, const WCHAR *name, VARIANT *var, IErrorLog *log)
|
||||||
|
{
|
||||||
|
static const WCHAR dsguidW[] = {'D','S','G','u','i','d',0};
|
||||||
|
WCHAR guidstr[39];
|
||||||
|
|
||||||
|
ok(!lstrcmpW(name, dsguidW), "Got unexpected name %s.\n", wine_dbgstr_w(name));
|
||||||
|
ok(V_VT(var) == VT_BSTR, "Got unexpected type %u.\n", V_VT(var));
|
||||||
|
StringFromGUID2(&DSDEVID_DefaultPlayback, guidstr, ARRAY_SIZE(guidstr));
|
||||||
|
V_BSTR(var) = SysAllocString(guidstr);
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI property_bag_Write(IPropertyBag *iface, const WCHAR *name, VARIANT *var)
|
||||||
|
{
|
||||||
|
ok(0, "Unexpected call (name %s).\n", wine_dbgstr_w(name));
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const IPropertyBagVtbl property_bag_vtbl =
|
||||||
|
{
|
||||||
|
property_bag_QueryInterface,
|
||||||
|
property_bag_AddRef,
|
||||||
|
property_bag_Release,
|
||||||
|
property_bag_Read,
|
||||||
|
property_bag_Write,
|
||||||
|
};
|
||||||
|
|
||||||
static void test_property_bag(void)
|
static void test_property_bag(void)
|
||||||
{
|
{
|
||||||
|
IPropertyBag property_bag = {&property_bag_vtbl};
|
||||||
IPersistPropertyBag *ppb;
|
IPersistPropertyBag *ppb;
|
||||||
ICreateDevEnum *devenum;
|
|
||||||
IEnumMoniker *enummon;
|
|
||||||
IPropertyBag *propbag;
|
|
||||||
IMoniker *mon;
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
ULONG ref;
|
||||||
|
|
||||||
CoCreateInstance(&CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
|
hr = CoCreateInstance(&CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER,
|
||||||
&IID_ICreateDevEnum, (void **)&devenum);
|
&IID_IPersistPropertyBag, (void **)&ppb);
|
||||||
ICreateDevEnum_CreateClassEnumerator(devenum, &CLSID_AudioRendererCategory, &enummon, 0);
|
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
|
if (hr != S_OK) return;
|
||||||
|
|
||||||
while (IEnumMoniker_Next(enummon, 1, &mon, NULL) == S_OK)
|
hr = IPersistPropertyBag_InitNew(ppb);
|
||||||
{
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
hr = CoCreateInstance(&CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER,
|
|
||||||
&IID_IPersistPropertyBag, (void **)&ppb);
|
|
||||||
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
|
|
||||||
if (hr != S_OK) break;
|
|
||||||
|
|
||||||
IMoniker_BindToStorage(mon, NULL, NULL, &IID_IPropertyBag, (void **)&propbag);
|
hr = IPersistPropertyBag_Load(ppb, &property_bag, NULL);
|
||||||
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
|
|
||||||
hr = IPersistPropertyBag_InitNew(ppb);
|
ref = IPersistPropertyBag_Release(ppb);
|
||||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
ok(!ref, "Got unexpected refcount %d.\n", ref);
|
||||||
|
|
||||||
hr = IPersistPropertyBag_Load(ppb, propbag, NULL);
|
|
||||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
|
||||||
|
|
||||||
IPersistPropertyBag_Release(ppb);
|
|
||||||
IPropertyBag_Release(propbag);
|
|
||||||
IMoniker_Release(mon);
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumMoniker_Release(enummon);
|
|
||||||
ICreateDevEnum_Release(devenum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_query_interface(void)
|
#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)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
IUnknown *iface = iface_ptr;
|
||||||
IBaseFilter *pBaseFilter = NULL;
|
HRESULT hr, expected_hr;
|
||||||
IBasicAudio *pBasicAudio = NULL;
|
IUnknown *unk;
|
||||||
IMediaPosition *pMediaPosition = NULL;
|
|
||||||
IMediaSeeking *pMediaSeeking = NULL;
|
|
||||||
IQualityControl *pQualityControl = NULL;
|
|
||||||
IPersistPropertyBag *ppb = NULL;
|
|
||||||
IDirectSound3DBuffer *ds3dbuf = NULL;
|
|
||||||
IReferenceClock *clock = NULL;
|
|
||||||
IAMDirectSound *pAMDirectSound = NULL;
|
|
||||||
|
|
||||||
QI_SUCCEED(pDSRender, IID_IBaseFilter, pBaseFilter);
|
expected_hr = supported ? S_OK : E_NOINTERFACE;
|
||||||
RELEASE_EXPECT(pBaseFilter, 1);
|
|
||||||
QI_SUCCEED(pDSRender, IID_IBasicAudio, pBasicAudio);
|
hr = IUnknown_QueryInterface(iface, iid, (void **)&unk);
|
||||||
RELEASE_EXPECT(pBasicAudio, 1);
|
ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x, expected %#x.\n", hr, expected_hr);
|
||||||
QI_SUCCEED(pDSRender, IID_IMediaSeeking, pMediaSeeking);
|
if (SUCCEEDED(hr))
|
||||||
RELEASE_EXPECT(pMediaSeeking, 1);
|
IUnknown_Release(unk);
|
||||||
QI_SUCCEED(pDSRender, IID_IReferenceClock, clock);
|
}
|
||||||
RELEASE_EXPECT(clock, 1);
|
|
||||||
QI_SUCCEED(pDSRender, IID_IAMDirectSound, pAMDirectSound);
|
static void test_interfaces(void)
|
||||||
RELEASE_EXPECT( pAMDirectSound, 1);
|
{
|
||||||
todo_wine {
|
IBaseFilter *filter = create_dsound_render();
|
||||||
QI_SUCCEED(pDSRender, IID_IDirectSound3DBuffer, ds3dbuf);
|
|
||||||
RELEASE_EXPECT(ds3dbuf, 1);
|
check_interface(filter, &IID_IAMDirectSound, TRUE);
|
||||||
QI_SUCCEED(pDSRender, IID_IPersistPropertyBag, ppb);
|
check_interface(filter, &IID_IBaseFilter, TRUE);
|
||||||
RELEASE_EXPECT(ppb, 1);
|
check_interface(filter, &IID_IBasicAudio, TRUE);
|
||||||
}
|
todo_wine check_interface(filter, &IID_IDirectSound3DBuffer, TRUE);
|
||||||
QI_SUCCEED(pDSRender, IID_IMediaPosition, pMediaPosition);
|
check_interface(filter, &IID_IMediaFilter, TRUE);
|
||||||
RELEASE_EXPECT(pMediaPosition, 1);
|
check_interface(filter, &IID_IMediaPosition, TRUE);
|
||||||
QI_SUCCEED(pDSRender, IID_IQualityControl, pQualityControl);
|
check_interface(filter, &IID_IMediaSeeking, TRUE);
|
||||||
RELEASE_EXPECT(pQualityControl, 1);
|
check_interface(filter, &IID_IPersist, TRUE);
|
||||||
|
todo_wine check_interface(filter, &IID_IPersistPropertyBag, TRUE);
|
||||||
|
check_interface(filter, &IID_IQualityControl, TRUE);
|
||||||
|
check_interface(filter, &IID_IReferenceClock, TRUE);
|
||||||
|
check_interface(filter, &IID_IUnknown, TRUE);
|
||||||
|
|
||||||
|
todo_wine check_interface(filter, &IID_IAMFilterMiscFlags, FALSE);
|
||||||
|
check_interface(filter, &IID_IBasicVideo, FALSE);
|
||||||
|
check_interface(filter, &IID_IKsPropertySet, FALSE);
|
||||||
|
check_interface(filter, &IID_IPin, FALSE);
|
||||||
|
check_interface(filter, &IID_IQualProp, FALSE);
|
||||||
|
check_interface(filter, &IID_IVideoWindow, FALSE);
|
||||||
|
|
||||||
|
IBaseFilter_Release(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_pin(IPin *pin)
|
static void test_pin(IPin *pin)
|
||||||
|
@ -145,19 +163,11 @@ static void test_pin(IPin *pin)
|
||||||
static void test_basefilter(void)
|
static void test_basefilter(void)
|
||||||
{
|
{
|
||||||
IEnumPins *pin_enum = NULL;
|
IEnumPins *pin_enum = NULL;
|
||||||
IBaseFilter *base = NULL;
|
IBaseFilter *base = create_dsound_render();
|
||||||
IPin *pins[2];
|
IPin *pins[2];
|
||||||
ULONG ref;
|
ULONG ref;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
IUnknown_QueryInterface(pDSRender, &IID_IBaseFilter, (void **)&base);
|
|
||||||
if (base == NULL)
|
|
||||||
{
|
|
||||||
/* test_query_interface handles this case */
|
|
||||||
skip("No IBaseFilter\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
hr = IBaseFilter_EnumPins(base, NULL);
|
hr = IBaseFilter_EnumPins(base, NULL);
|
||||||
ok(hr == E_POINTER, "hr = %08x and not E_POINTER\n", hr);
|
ok(hr == E_POINTER, "hr = %08x and not E_POINTER\n", hr);
|
||||||
|
|
||||||
|
@ -192,15 +202,25 @@ static void test_basefilter(void)
|
||||||
|
|
||||||
START_TEST(dsoundrender)
|
START_TEST(dsoundrender)
|
||||||
{
|
{
|
||||||
|
IBaseFilter *filter;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
CoInitialize(NULL);
|
CoInitialize(NULL);
|
||||||
if (!create_dsound_renderer())
|
|
||||||
|
hr = CoCreateInstance(&CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER,
|
||||||
|
&IID_IBaseFilter, (void **)&filter);
|
||||||
|
if (hr == VFW_E_NO_AUDIO_HARDWARE)
|
||||||
|
{
|
||||||
|
skip("No audio hardware.\n");
|
||||||
|
CoUninitialize();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||||
|
IBaseFilter_Release(filter);
|
||||||
|
|
||||||
test_property_bag();
|
test_property_bag();
|
||||||
test_query_interface();
|
test_interfaces();
|
||||||
test_basefilter();
|
test_basefilter();
|
||||||
|
|
||||||
release_dsound_renderer();
|
|
||||||
|
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue