Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/tests/videorenderer.c | 115 ++++++++++++------------------ 1 file changed, 46 insertions(+), 69 deletions(-)
diff --git a/dlls/quartz/tests/videorenderer.c b/dlls/quartz/tests/videorenderer.c index 35e6f10185..e487e65ef6 100644 --- a/dlls/quartz/tests/videorenderer.c +++ b/dlls/quartz/tests/videorenderer.c @@ -19,71 +19,60 @@ */
#define COBJMACROS - -#include "wine/test.h" #include "dshow.h" +#include "wine/test.h"
-#define QI_SUCCEED(iface, riid, ppv) hr = IUnknown_QueryInterface(iface, &riid, (LPVOID*)&ppv); \ - 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 *pVideoRenderer = NULL; - -static int create_video_renderer(void) +static IBaseFilter *create_video_renderer(void) { - HRESULT hr; - - hr = CoCreateInstance(&CLSID_VideoRenderer, NULL, CLSCTX_INPROC_SERVER, - &IID_IUnknown, (LPVOID*)&pVideoRenderer); - return (hr == S_OK && pVideoRenderer != NULL); + IBaseFilter *filter = NULL; + HRESULT hr = CoCreateInstance(&CLSID_VideoRenderer, NULL, CLSCTX_INPROC_SERVER, + &IID_IBaseFilter, (void **)&filter); + ok(hr == S_OK, "Got hr %#x.\n", hr); + return filter; }
-static void release_video_renderer(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; + HRESULT hr, expected_hr; + IUnknown *unk; + + expected_hr = supported ? S_OK : E_NOINTERFACE;
- hr = IUnknown_Release(pVideoRenderer); - ok(hr == 0, "IUnknown_Release failed with %x\n", hr); + 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_query_interface(void) +static void test_interfaces(void) { - HRESULT hr; - IBaseFilter *pBaseFilter = NULL; - IBasicVideo *pBasicVideo = NULL; - IDirectDrawVideo *pDirectDrawVideo = NULL; - IKsPropertySet *pKsPropertySet = NULL; - IMediaPosition *pMediaPosition = NULL; - IMediaSeeking *pMediaSeeking = NULL; - IQualityControl *pQualityControl = NULL; - IQualProp *pQualProp = NULL; - IVideoWindow *pVideoWindow = NULL; - - QI_SUCCEED(pVideoRenderer, IID_IBaseFilter, pBaseFilter); - RELEASE_EXPECT(pBaseFilter, 1); - QI_SUCCEED(pVideoRenderer, IID_IBasicVideo, pBasicVideo); - RELEASE_EXPECT(pBasicVideo, 1); - QI_SUCCEED(pVideoRenderer, IID_IMediaSeeking, pMediaSeeking); - RELEASE_EXPECT(pMediaSeeking, 1); - QI_SUCCEED(pVideoRenderer, IID_IQualityControl, pQualityControl); - RELEASE_EXPECT(pQualityControl, 1); - todo_wine { - QI_SUCCEED(pVideoRenderer, IID_IDirectDrawVideo, pDirectDrawVideo); - RELEASE_EXPECT(pDirectDrawVideo, 1); - QI_SUCCEED(pVideoRenderer, IID_IKsPropertySet, pKsPropertySet); - RELEASE_EXPECT(pKsPropertySet, 1); - QI_SUCCEED(pVideoRenderer, IID_IQualProp, pQualProp); - RELEASE_EXPECT(pQualProp, 1); - } - QI_SUCCEED(pVideoRenderer, IID_IMediaPosition, pMediaPosition); - RELEASE_EXPECT(pMediaPosition, 1); - QI_SUCCEED(pVideoRenderer, IID_IVideoWindow, pVideoWindow); - RELEASE_EXPECT(pVideoWindow, 1); + IBaseFilter *filter = create_video_renderer(); + + check_interface(filter, &IID_IBaseFilter, TRUE); + check_interface(filter, &IID_IBasicVideo, TRUE); + todo_wine check_interface(filter, &IID_IBasicVideo2, TRUE); + todo_wine check_interface(filter, &IID_IDirectDrawVideo, TRUE); + todo_wine check_interface(filter, &IID_IKsPropertySet, TRUE); + check_interface(filter, &IID_IMediaFilter, TRUE); + check_interface(filter, &IID_IMediaPosition, TRUE); + check_interface(filter, &IID_IMediaSeeking, TRUE); + check_interface(filter, &IID_IPersist, TRUE); + check_interface(filter, &IID_IQualityControl, TRUE); + todo_wine check_interface(filter, &IID_IQualProp, TRUE); + check_interface(filter, &IID_IUnknown, TRUE); + check_interface(filter, &IID_IVideoWindow, TRUE); + + todo_wine check_interface(filter, &IID_IAMFilterMiscFlags, FALSE); + check_interface(filter, &IID_IBasicAudio, FALSE); + check_interface(filter, &IID_IDispatch, FALSE); + check_interface(filter, &IID_IOverlay, FALSE); + check_interface(filter, &IID_IPersistPropertyBag, FALSE); + check_interface(filter, &IID_IPin, FALSE); + check_interface(filter, &IID_IReferenceClock, FALSE); + + IBaseFilter_Release(filter); }
static void test_pin(IPin *pin) @@ -105,19 +94,11 @@ static void test_pin(IPin *pin) static void test_basefilter(void) { IEnumPins *pin_enum = NULL; - IBaseFilter *base = NULL; + IBaseFilter *base = create_video_renderer(); IPin *pins[2]; ULONG ref; HRESULT hr;
- IUnknown_QueryInterface(pVideoRenderer, &IID_IBaseFilter, (void **)&base); - if (base == NULL) - { - /* test_query_interface handles this case */ - skip("No IBaseFilter\n"); - return; - } - hr = IBaseFilter_EnumPins(base, NULL); ok(hr == E_POINTER, "hr = %08x and not E_POINTER\n", hr);
@@ -153,13 +134,9 @@ static void test_basefilter(void) START_TEST(videorenderer) { CoInitialize(NULL); - if (!create_video_renderer()) - return;
- test_query_interface(); + test_interfaces(); test_basefilter();
- release_video_renderer(); - CoUninitialize(); }
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/tests/videorenderer.c | 102 ++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+)
diff --git a/dlls/quartz/tests/videorenderer.c b/dlls/quartz/tests/videorenderer.c index e487e65ef6..c4e64ec6b5 100644 --- a/dlls/quartz/tests/videorenderer.c +++ b/dlls/quartz/tests/videorenderer.c @@ -31,6 +31,13 @@ static IBaseFilter *create_video_renderer(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) { @@ -75,6 +82,100 @@ static void test_interfaces(void) IBaseFilter_Release(filter); }
+ +static void test_enum_pins(void) +{ + IBaseFilter *filter = create_video_renderer(); + IEnumPins *enum1, *enum2; + IPin *pins[2]; + ULONG count; + HRESULT hr; + ULONG ref; + + ref = get_refcount(filter); + ok(ref == 1, "Got unexpected refcount %d.\n", ref); + + hr = IBaseFilter_EnumPins(filter, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IBaseFilter_EnumPins(filter, &enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ref = get_refcount(filter); + ok(ref == 2, "Got unexpected refcount %d.\n", ref); + ref = get_refcount(enum1); + ok(ref == 1, "Got unexpected refcount %d.\n", ref); + + hr = IEnumPins_Next(enum1, 1, NULL, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IEnumPins_Next(enum1, 1, pins, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ref = get_refcount(filter); +todo_wine + ok(ref == 3, "Got unexpected refcount %d.\n", ref); + ref = get_refcount(pins[0]); +todo_wine + ok(ref == 3, "Got unexpected refcount %d.\n", ref); + ref = get_refcount(enum1); + ok(ref == 1, "Got unexpected refcount %d.\n", ref); + IPin_Release(pins[0]); + ref = get_refcount(filter); + ok(ref == 2, "Got unexpected refcount %d.\n", ref); + + hr = IEnumPins_Next(enum1, 1, pins, NULL); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IEnumPins_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumPins_Next(enum1, 1, pins, &count); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(count == 1, "Got count %u.\n", count); + IPin_Release(pins[0]); + + hr = IEnumPins_Next(enum1, 1, pins, &count); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(!count, "Got count %u.\n", count); + + hr = IEnumPins_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumPins_Next(enum1, 2, pins, NULL); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + hr = IEnumPins_Next(enum1, 2, pins, &count); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(count == 1, "Got count %u.\n", count); + IPin_Release(pins[0]); + + hr = IEnumPins_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumPins_Clone(enum1, &enum2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumPins_Skip(enum1, 2); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IEnumPins_Skip(enum1, 1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumPins_Skip(enum1, 1); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IEnumPins_Next(enum1, 1, pins, NULL); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IEnumPins_Next(enum2, 1, pins, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + IPin_Release(pins[0]); + + IEnumPins_Release(enum2); + IEnumPins_Release(enum1); + ref = IBaseFilter_Release(filter); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + static void test_pin(IPin *pin) { IMemInputPin *mpin = NULL; @@ -136,6 +237,7 @@ START_TEST(videorenderer) CoInitialize(NULL);
test_interfaces(); + test_enum_pins(); test_basefilter();
CoUninitialize();
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/tests/videorenderer.c | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
diff --git a/dlls/quartz/tests/videorenderer.c b/dlls/quartz/tests/videorenderer.c index c4e64ec6b5..7315d8d0e2 100644 --- a/dlls/quartz/tests/videorenderer.c +++ b/dlls/quartz/tests/videorenderer.c @@ -22,6 +22,8 @@ #include "dshow.h" #include "wine/test.h"
+static const WCHAR sink_id[] = {'I','n',0}; + static IBaseFilter *create_video_renderer(void) { IBaseFilter *filter = NULL; @@ -176,6 +178,35 @@ todo_wine ok(!ref, "Got outstanding refcount %d.\n", ref); }
+static void test_find_pin(void) +{ + static const WCHAR input_pinW[] = {'i','n','p','u','t',' ','p','i','n',0}; + IBaseFilter *filter = create_video_renderer(); + IEnumPins *enum_pins; + IPin *pin, *pin2; + HRESULT hr; + ULONG ref; + + hr = IBaseFilter_FindPin(filter, input_pinW, &pin); + ok(hr == VFW_E_NOT_FOUND, "Got hr %#x.\n", hr); + + hr = IBaseFilter_FindPin(filter, sink_id, &pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IBaseFilter_EnumPins(filter, &enum_pins); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumPins_Next(enum_pins, 1, &pin2, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(pin == pin2, "Expected pin %p, got %p.\n", pin2, pin); + IPin_Release(pin); + IPin_Release(pin2); + + IEnumPins_Release(enum_pins); + ref = IBaseFilter_Release(filter); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + static void test_pin(IPin *pin) { IMemInputPin *mpin = NULL; @@ -238,6 +269,7 @@ START_TEST(videorenderer)
test_interfaces(); test_enum_pins(); + test_find_pin(); test_basefilter();
CoUninitialize();
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/tests/videorenderer.c | 48 +++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
diff --git a/dlls/quartz/tests/videorenderer.c b/dlls/quartz/tests/videorenderer.c index 7315d8d0e2..3d3d939cdb 100644 --- a/dlls/quartz/tests/videorenderer.c +++ b/dlls/quartz/tests/videorenderer.c @@ -207,6 +207,53 @@ static void test_find_pin(void) ok(!ref, "Got outstanding refcount %d.\n", ref); }
+static void test_pin_info(void) +{ + static const WCHAR sink_name[] = {'I','n','p','u','t',0}; + IBaseFilter *filter = create_video_renderer(); + PIN_DIRECTION dir; + PIN_INFO info; + HRESULT hr; + WCHAR *id; + ULONG ref; + IPin *pin; + + hr = IBaseFilter_FindPin(filter, sink_id, &pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ref = get_refcount(filter); + todo_wine ok(ref == 2, "Got unexpected refcount %d.\n", ref); + ref = get_refcount(pin); + ok(ref == 2, "Got unexpected refcount %d.\n", ref); + + hr = IPin_QueryPinInfo(pin, &info); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(info.pFilter == filter, "Expected filter %p, got %p.\n", filter, info.pFilter); + ok(info.dir == PINDIR_INPUT, "Got direction %d.\n", info.dir); +todo_wine + ok(!lstrcmpW(info.achName, sink_name), "Got name %s.\n", wine_dbgstr_w(info.achName)); + ref = get_refcount(filter); + todo_wine ok(ref == 3, "Got unexpected refcount %d.\n", ref); + ref = get_refcount(pin); + todo_wine ok(ref == 3, "Got unexpected refcount %d.\n", ref); + IBaseFilter_Release(info.pFilter); + + hr = IPin_QueryDirection(pin, &dir); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(dir == PINDIR_INPUT, "Got direction %d.\n", dir); + + hr = IPin_QueryId(pin, &id); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!lstrcmpW(id, sink_id), "Got id %s.\n", wine_dbgstr_w(id)); + CoTaskMemFree(id); + + hr = IPin_QueryInternalConnections(pin, NULL, NULL); + ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr); + + IPin_Release(pin); + ref = IBaseFilter_Release(filter); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + static void test_pin(IPin *pin) { IMemInputPin *mpin = NULL; @@ -270,6 +317,7 @@ START_TEST(videorenderer) test_interfaces(); test_enum_pins(); test_find_pin(); + test_pin_info(); test_basefilter();
CoUninitialize();
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/tests/videorenderer.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/dlls/quartz/tests/videorenderer.c b/dlls/quartz/tests/videorenderer.c index 3d3d939cdb..c7f0df4d16 100644 --- a/dlls/quartz/tests/videorenderer.c +++ b/dlls/quartz/tests/videorenderer.c @@ -58,6 +58,7 @@ static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOO static void test_interfaces(void) { IBaseFilter *filter = create_video_renderer(); + IPin *pin;
check_interface(filter, &IID_IBaseFilter, TRUE); check_interface(filter, &IID_IBasicVideo, TRUE); @@ -81,6 +82,20 @@ static void test_interfaces(void) check_interface(filter, &IID_IPin, FALSE); check_interface(filter, &IID_IReferenceClock, FALSE);
+ IBaseFilter_FindPin(filter, sink_id, &pin); + + check_interface(pin, &IID_IMemInputPin, TRUE); + todo_wine check_interface(pin, &IID_IOverlay, TRUE); + check_interface(pin, &IID_IPin, TRUE); + todo_wine check_interface(pin, &IID_IPinConnection, TRUE); + todo_wine check_interface(pin, &IID_IQualityControl, TRUE); + check_interface(pin, &IID_IUnknown, TRUE); + + check_interface(pin, &IID_IAsyncReader, FALSE); + check_interface(pin, &IID_IMediaPosition, FALSE); + todo_wine check_interface(pin, &IID_IMediaSeeking, FALSE); + + IPin_Release(pin); IBaseFilter_Release(filter); }