qcap/tests: Add more tests for aggregation.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e19235f12b
commit
5e1ed74c9f
|
@ -22,6 +22,13 @@
|
|||
#include "dshow.h"
|
||||
#include "wine/test.h"
|
||||
|
||||
static ULONG get_refcount(void *iface)
|
||||
{
|
||||
IUnknown *unknown = iface;
|
||||
IUnknown_AddRef(unknown);
|
||||
return IUnknown_Release(unknown);
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
|
@ -58,6 +65,100 @@ static void test_interfaces(IBaseFilter *filter)
|
|||
check_interface(filter, &IID_IVideoWindow, FALSE);
|
||||
}
|
||||
|
||||
static const GUID test_iid = {0x33333333};
|
||||
static LONG outer_ref = 1;
|
||||
|
||||
static HRESULT WINAPI outer_QueryInterface(IUnknown *iface, REFIID iid, void **out)
|
||||
{
|
||||
if (IsEqualGUID(iid, &IID_IUnknown)
|
||||
|| IsEqualGUID(iid, &IID_IBaseFilter)
|
||||
|| IsEqualGUID(iid, &test_iid))
|
||||
{
|
||||
*out = (IUnknown *)0xdeadbeef;
|
||||
return S_OK;
|
||||
}
|
||||
ok(0, "unexpected call %s\n", wine_dbgstr_guid(iid));
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static ULONG WINAPI outer_AddRef(IUnknown *iface)
|
||||
{
|
||||
return InterlockedIncrement(&outer_ref);
|
||||
}
|
||||
|
||||
static ULONG WINAPI outer_Release(IUnknown *iface)
|
||||
{
|
||||
return InterlockedDecrement(&outer_ref);
|
||||
}
|
||||
|
||||
static const IUnknownVtbl outer_vtbl =
|
||||
{
|
||||
outer_QueryInterface,
|
||||
outer_AddRef,
|
||||
outer_Release,
|
||||
};
|
||||
|
||||
static IUnknown test_outer = {&outer_vtbl};
|
||||
|
||||
static void test_aggregation(void)
|
||||
{
|
||||
IBaseFilter *filter, *filter2;
|
||||
IUnknown *unk, *unk2;
|
||||
HRESULT hr;
|
||||
ULONG ref;
|
||||
|
||||
filter = (IBaseFilter *)0xdeadbeef;
|
||||
hr = CoCreateInstance(&CLSID_AudioRecord, &test_outer, CLSCTX_INPROC_SERVER,
|
||||
&IID_IBaseFilter, (void **)&filter);
|
||||
ok(hr == E_NOINTERFACE, "Got hr %#x.\n", hr);
|
||||
ok(!filter, "Got interface %p.\n", filter);
|
||||
|
||||
hr = CoCreateInstance(&CLSID_AudioRecord, &test_outer, CLSCTX_INPROC_SERVER,
|
||||
&IID_IUnknown, (void **)&unk);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
|
||||
ok(unk != &test_outer, "Returned IUnknown should not be outer IUnknown.\n");
|
||||
ref = get_refcount(unk);
|
||||
ok(ref == 1, "Got unexpected refcount %d.\n", ref);
|
||||
|
||||
ref = IUnknown_AddRef(unk);
|
||||
ok(ref == 2, "Got unexpected refcount %d.\n", ref);
|
||||
ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
|
||||
|
||||
ref = IUnknown_Release(unk);
|
||||
ok(ref == 1, "Got unexpected refcount %d.\n", ref);
|
||||
ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
|
||||
|
||||
hr = IUnknown_QueryInterface(unk, &IID_IUnknown, (void **)&unk2);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(unk2 == unk, "Got unexpected IUnknown %p.\n", unk2);
|
||||
IUnknown_Release(unk2);
|
||||
|
||||
hr = IUnknown_QueryInterface(unk, &IID_IBaseFilter, (void **)&filter);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
|
||||
hr = IBaseFilter_QueryInterface(filter, &IID_IUnknown, (void **)&unk2);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2);
|
||||
|
||||
hr = IBaseFilter_QueryInterface(filter, &IID_IBaseFilter, (void **)&filter2);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(filter2 == (IBaseFilter *)0xdeadbeef, "Got unexpected IBaseFilter %p.\n", filter2);
|
||||
|
||||
hr = IUnknown_QueryInterface(unk, &test_iid, (void **)&unk2);
|
||||
ok(hr == E_NOINTERFACE, "Got hr %#x.\n", hr);
|
||||
ok(!unk2, "Got unexpected IUnknown %p.\n", unk2);
|
||||
|
||||
hr = IBaseFilter_QueryInterface(filter, &test_iid, (void **)&unk2);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2);
|
||||
|
||||
IBaseFilter_Release(filter);
|
||||
ref = IUnknown_Release(unk);
|
||||
ok(!ref, "Got unexpected refcount %d.\n", ref);
|
||||
ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI property_bag_QueryInterface(IPropertyBag *iface, REFIID iid, void **out)
|
||||
{
|
||||
ok(0, "Unexpected call (iid %s).\n", wine_dbgstr_guid(iid));
|
||||
|
@ -169,6 +270,8 @@ START_TEST(audiorecord)
|
|||
}
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
|
||||
test_aggregation();
|
||||
|
||||
while (IEnumMoniker_Next(enummon, 1, &mon, NULL) == S_OK)
|
||||
{
|
||||
hr = IMoniker_GetDisplayName(mon, NULL, NULL, &name);
|
||||
|
|
|
@ -98,6 +98,100 @@ static void test_interfaces(IBaseFilter *filter)
|
|||
IPin_Release(pin);
|
||||
}
|
||||
|
||||
static const GUID test_iid = {0x33333333};
|
||||
static LONG outer_ref = 1;
|
||||
|
||||
static HRESULT WINAPI outer_QueryInterface(IUnknown *iface, REFIID iid, void **out)
|
||||
{
|
||||
if (IsEqualGUID(iid, &IID_IUnknown)
|
||||
|| IsEqualGUID(iid, &IID_IBaseFilter)
|
||||
|| IsEqualGUID(iid, &test_iid))
|
||||
{
|
||||
*out = (IUnknown *)0xdeadbeef;
|
||||
return S_OK;
|
||||
}
|
||||
ok(0, "unexpected call %s\n", wine_dbgstr_guid(iid));
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static ULONG WINAPI outer_AddRef(IUnknown *iface)
|
||||
{
|
||||
return InterlockedIncrement(&outer_ref);
|
||||
}
|
||||
|
||||
static ULONG WINAPI outer_Release(IUnknown *iface)
|
||||
{
|
||||
return InterlockedDecrement(&outer_ref);
|
||||
}
|
||||
|
||||
static const IUnknownVtbl outer_vtbl =
|
||||
{
|
||||
outer_QueryInterface,
|
||||
outer_AddRef,
|
||||
outer_Release,
|
||||
};
|
||||
|
||||
static IUnknown test_outer = {&outer_vtbl};
|
||||
|
||||
static void test_aggregation(void)
|
||||
{
|
||||
IBaseFilter *filter, *filter2;
|
||||
IUnknown *unk, *unk2;
|
||||
HRESULT hr;
|
||||
ULONG ref;
|
||||
|
||||
filter = (IBaseFilter *)0xdeadbeef;
|
||||
hr = CoCreateInstance(&CLSID_AVICo, &test_outer, CLSCTX_INPROC_SERVER,
|
||||
&IID_IBaseFilter, (void **)&filter);
|
||||
ok(hr == E_NOINTERFACE, "Got hr %#x.\n", hr);
|
||||
ok(!filter, "Got interface %p.\n", filter);
|
||||
|
||||
hr = CoCreateInstance(&CLSID_AVICo, &test_outer, CLSCTX_INPROC_SERVER,
|
||||
&IID_IUnknown, (void **)&unk);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
|
||||
ok(unk != &test_outer, "Returned IUnknown should not be outer IUnknown.\n");
|
||||
ref = get_refcount(unk);
|
||||
ok(ref == 1, "Got unexpected refcount %d.\n", ref);
|
||||
|
||||
ref = IUnknown_AddRef(unk);
|
||||
ok(ref == 2, "Got unexpected refcount %d.\n", ref);
|
||||
ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
|
||||
|
||||
ref = IUnknown_Release(unk);
|
||||
ok(ref == 1, "Got unexpected refcount %d.\n", ref);
|
||||
ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
|
||||
|
||||
hr = IUnknown_QueryInterface(unk, &IID_IUnknown, (void **)&unk2);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(unk2 == unk, "Got unexpected IUnknown %p.\n", unk2);
|
||||
IUnknown_Release(unk2);
|
||||
|
||||
hr = IUnknown_QueryInterface(unk, &IID_IBaseFilter, (void **)&filter);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
|
||||
hr = IBaseFilter_QueryInterface(filter, &IID_IUnknown, (void **)&unk2);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
todo_wine ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2);
|
||||
|
||||
hr = IBaseFilter_QueryInterface(filter, &IID_IBaseFilter, (void **)&filter2);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
todo_wine ok(filter2 == (IBaseFilter *)0xdeadbeef, "Got unexpected IBaseFilter %p.\n", filter2);
|
||||
|
||||
hr = IUnknown_QueryInterface(unk, &test_iid, (void **)&unk2);
|
||||
ok(hr == E_NOINTERFACE, "Got hr %#x.\n", hr);
|
||||
ok(!unk2, "Got unexpected IUnknown %p.\n", unk2);
|
||||
|
||||
hr = IBaseFilter_QueryInterface(filter, &test_iid, (void **)&unk2);
|
||||
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
todo_wine ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2);
|
||||
|
||||
IBaseFilter_Release(filter);
|
||||
ref = IUnknown_Release(unk);
|
||||
todo_wine ok(!ref, "Got unexpected refcount %d.\n", ref);
|
||||
ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
|
||||
}
|
||||
|
||||
static void test_enum_pins(IBaseFilter *filter)
|
||||
{
|
||||
IEnumPins *enum1, *enum2;
|
||||
|
@ -525,6 +619,7 @@ START_TEST(avico)
|
|||
hr = IMoniker_BindToObject(mon, NULL, NULL, &IID_IBaseFilter, (void **)&filter);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
|
||||
test_aggregation();
|
||||
test_interfaces(filter);
|
||||
test_enum_pins(filter);
|
||||
test_find_pin(filter);
|
||||
|
|
|
@ -34,6 +34,13 @@ static IBaseFilter *create_avi_mux(void)
|
|||
return filter;
|
||||
}
|
||||
|
||||
static ULONG get_refcount(void *iface)
|
||||
{
|
||||
IUnknown *unknown = iface;
|
||||
IUnknown_AddRef(unknown);
|
||||
return IUnknown_Release(unknown);
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
|
@ -78,6 +85,101 @@ static void test_interfaces(void)
|
|||
IBaseFilter_Release(filter);
|
||||
}
|
||||
|
||||
static const GUID test_iid = {0x33333333};
|
||||
static LONG outer_ref = 1;
|
||||
|
||||
static HRESULT WINAPI outer_QueryInterface(IUnknown *iface, REFIID iid, void **out)
|
||||
{
|
||||
if (IsEqualGUID(iid, &IID_IUnknown)
|
||||
|| IsEqualGUID(iid, &IID_IBaseFilter)
|
||||
|| IsEqualGUID(iid, &test_iid))
|
||||
{
|
||||
*out = (IUnknown *)0xdeadbeef;
|
||||
return S_OK;
|
||||
}
|
||||
ok(0, "unexpected call %s\n", wine_dbgstr_guid(iid));
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static ULONG WINAPI outer_AddRef(IUnknown *iface)
|
||||
{
|
||||
return InterlockedIncrement(&outer_ref);
|
||||
}
|
||||
|
||||
static ULONG WINAPI outer_Release(IUnknown *iface)
|
||||
{
|
||||
return InterlockedDecrement(&outer_ref);
|
||||
}
|
||||
|
||||
static const IUnknownVtbl outer_vtbl =
|
||||
{
|
||||
outer_QueryInterface,
|
||||
outer_AddRef,
|
||||
outer_Release,
|
||||
};
|
||||
|
||||
static IUnknown test_outer = {&outer_vtbl};
|
||||
|
||||
static void test_aggregation(void)
|
||||
{
|
||||
IBaseFilter *filter, *filter2;
|
||||
IUnknown *unk, *unk2;
|
||||
HRESULT hr;
|
||||
ULONG ref;
|
||||
|
||||
filter = (IBaseFilter *)0xdeadbeef;
|
||||
hr = CoCreateInstance(&CLSID_AviDest, &test_outer, CLSCTX_INPROC_SERVER,
|
||||
&IID_IBaseFilter, (void **)&filter);
|
||||
ok(hr == E_NOINTERFACE, "Got hr %#x.\n", hr);
|
||||
ok(!filter, "Got interface %p.\n", filter);
|
||||
|
||||
hr = CoCreateInstance(&CLSID_AviDest, &test_outer, CLSCTX_INPROC_SERVER,
|
||||
&IID_IUnknown, (void **)&unk);
|
||||
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
if (FAILED(hr)) return;
|
||||
ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
|
||||
ok(unk != &test_outer, "Returned IUnknown should not be outer IUnknown.\n");
|
||||
ref = get_refcount(unk);
|
||||
ok(ref == 1, "Got unexpected refcount %d.\n", ref);
|
||||
|
||||
ref = IUnknown_AddRef(unk);
|
||||
ok(ref == 2, "Got unexpected refcount %d.\n", ref);
|
||||
ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
|
||||
|
||||
ref = IUnknown_Release(unk);
|
||||
ok(ref == 1, "Got unexpected refcount %d.\n", ref);
|
||||
ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
|
||||
|
||||
hr = IUnknown_QueryInterface(unk, &IID_IUnknown, (void **)&unk2);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(unk2 == unk, "Got unexpected IUnknown %p.\n", unk2);
|
||||
IUnknown_Release(unk2);
|
||||
|
||||
hr = IUnknown_QueryInterface(unk, &IID_IBaseFilter, (void **)&filter);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
|
||||
hr = IBaseFilter_QueryInterface(filter, &IID_IUnknown, (void **)&unk2);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2);
|
||||
|
||||
hr = IBaseFilter_QueryInterface(filter, &IID_IBaseFilter, (void **)&filter2);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(filter2 == (IBaseFilter *)0xdeadbeef, "Got unexpected IBaseFilter %p.\n", filter2);
|
||||
|
||||
hr = IUnknown_QueryInterface(unk, &test_iid, (void **)&unk2);
|
||||
ok(hr == E_NOINTERFACE, "Got hr %#x.\n", hr);
|
||||
ok(!unk2, "Got unexpected IUnknown %p.\n", unk2);
|
||||
|
||||
hr = IBaseFilter_QueryInterface(filter, &test_iid, (void **)&unk2);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2);
|
||||
|
||||
IBaseFilter_Release(filter);
|
||||
ref = IUnknown_Release(unk);
|
||||
ok(!ref, "Got unexpected refcount %d.\n", ref);
|
||||
ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
|
||||
}
|
||||
|
||||
static void test_seeking(void)
|
||||
{
|
||||
IBaseFilter *filter = create_avi_mux();
|
||||
|
@ -217,6 +319,7 @@ START_TEST(avimux)
|
|||
CoInitialize(NULL);
|
||||
|
||||
test_interfaces();
|
||||
test_aggregation();
|
||||
test_seeking();
|
||||
|
||||
CoUninitialize();
|
||||
|
|
Loading…
Reference in New Issue