From 4cbac03677dbc979354488a80ddbea3e8b78ce93 Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Tue, 13 May 2008 10:07:43 -0700 Subject: [PATCH] quartz: Add basic tests for vmr-9 --- dlls/quartz/tests/Makefile.in | 3 +- dlls/quartz/tests/avisplitter.c | 1 - dlls/quartz/tests/vmr9.c | 308 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 310 insertions(+), 2 deletions(-) create mode 100644 dlls/quartz/tests/vmr9.c diff --git a/dlls/quartz/tests/Makefile.in b/dlls/quartz/tests/Makefile.in index a3e2bc4..16fed7e 100644 --- a/dlls/quartz/tests/Makefile.in +++ b/dlls/quartz/tests/Makefile.in @@ -11,7 +11,8 @@ CTESTS = \ memallocator.c \ misc.c \ referenceclock.c \ - videorenderer.c + videorenderer.c \ + vmr9.c @MAKE_TEST_RULES@ diff --git a/dlls/quartz/tests/avisplitter.c b/dlls/quartz/tests/avisplitter.c index 74713d4..a014c3c 100644 --- a/dlls/quartz/tests/avisplitter.c +++ b/dlls/quartz/tests/avisplitter.c @@ -22,7 +22,6 @@ #define COBJMACROS #include "wine/test.h" -#include "initguid.h" #include "dshow.h" #include "tlhelp32.h" diff --git a/dlls/quartz/tests/vmr9.c b/dlls/quartz/tests/vmr9.c new file mode 100644 index 0000000..1ebfef9 --- /dev/null +++ b/dlls/quartz/tests/vmr9.c @@ -0,0 +1,308 @@ +/* + * Unit tests for Video Renderer functions + * + * Copyright (C) 2007 Google (Lei Zhang) + * Copyright (C) 2008 Google (Maarten Lankhorst) + * + * 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 "wine/test.h" +#include "dshow.h" +#include "d3d9.h" +#include "vmr9.h" + +static IUnknown *pvmr9 = NULL; + +static void test_query_interface(void) +{ + HRESULT hr; + ULONG ref; + IUnknown *iface = NULL; + + hr = IUnknown_QueryInterface(pvmr9, &IID_IAMFilterMiscFlags, (LPVOID*)&iface); + ok(hr == S_OK, "IUnknown_QueryInterface returned %x\n", hr); + ok(iface != NULL, "Pointer is NULL\n"); + if (iface) + { + ref = IUnknown_Release(iface); + ok(ref == 1, "IUnknown_Release should return %d, got %d\n", 1, ref); + } + iface = NULL; + + hr = IUnknown_QueryInterface(pvmr9, &IID_IBaseFilter, (LPVOID*)&iface); + ok(hr == S_OK, "IUnknown_QueryInterface returned %x\n", hr); + ok(iface != NULL, "Pointer is NULL\n"); + if (iface) + { + ref = IUnknown_Release(iface); + ok(ref == 1, "IUnknown_Release should return %d, got %d\n", 1, ref); + } + iface = NULL; + + hr = IUnknown_QueryInterface(pvmr9, &IID_IMediaPosition, (LPVOID*)&iface); + ok(hr == S_OK, "IUnknown_QueryInterface returned %x\n", hr); + ok(iface != NULL, "Pointer is NULL\n"); + if (iface) + { + ref = IUnknown_Release(iface); + ok(ref == 1, "IUnknown_Release should return %d, got %d\n", 1, ref); + } + iface = NULL; + + hr = IUnknown_QueryInterface(pvmr9, &IID_IMediaSeeking, (LPVOID*)&iface); + ok(hr == S_OK, "IUnknown_QueryInterface returned %x\n", hr); + ok(iface != NULL, "Pointer is NULL\n"); + if (iface) + { + ref = IUnknown_Release(iface); + ok(ref == 1, "IUnknown_Release should return %d, got %d\n", 1, ref); + } + iface = NULL; + + hr = IUnknown_QueryInterface(pvmr9, &IID_IQualityControl, (LPVOID*)&iface); + ok(hr == S_OK, "IUnknown_QueryInterface returned %x\n", hr); + ok(iface != NULL, "Pointer is NULL\n"); + if (iface) + { + ref = IUnknown_Release(iface); + ok(ref == 1, "IUnknown_Release should return %d, got %d\n", 1, ref); + } + iface = NULL; + + hr = IUnknown_QueryInterface(pvmr9, &IID_IQualProp, (LPVOID*)&iface); + ok(hr == S_OK, "IUnknown_QueryInterface returned %x\n", hr); + ok(iface != NULL, "Pointer is NULL\n"); + if (iface) + { + ref = IUnknown_Release(iface); + ok(ref == 1, "IUnknown_Release should return %d, got %d\n", 1, ref); + } + iface = NULL; + + hr = IUnknown_QueryInterface(pvmr9, &IID_IVMRAspectRatioControl9, (LPVOID*)&iface); + ok(hr == S_OK, "IUnknown_QueryInterface returned %x\n", hr); + ok(iface != NULL, "Pointer is NULL\n"); + if (iface) + { + ref = IUnknown_Release(iface); + ok(ref == 1, "IUnknown_Release should return %d, got %d\n", 1, ref); + } + iface = NULL; + + hr = IUnknown_QueryInterface(pvmr9, &IID_IVMRDeinterlaceControl9, (LPVOID*)&iface); + ok(hr == S_OK, "IUnknown_QueryInterface returned %x\n", hr); + ok(iface != NULL, "Pointer is NULL\n"); + if (iface) + { + ref = IUnknown_Release(iface); + ok(ref == 1, "IUnknown_Release should return %d, got %d\n", 1, ref); + } + iface = NULL; + + hr = IUnknown_QueryInterface(pvmr9, &IID_IVMRFilterConfig9, (LPVOID*)&iface); + ok(hr == S_OK, "IUnknown_QueryInterface returned %x\n", hr); + ok(iface != NULL, "Pointer is NULL\n"); + if (iface) + { + ref = IUnknown_Release(iface); + ok(ref == 1, "IUnknown_Release should return %d, got %d\n", 1, ref); + } + iface = NULL; + + hr = IUnknown_QueryInterface(pvmr9, &IID_IVMRMixerBitmap9, (LPVOID*)&iface); + ok(hr == S_OK, "IUnknown_QueryInterface returned %x\n", hr); + ok(iface != NULL, "Pointer is NULL\n"); + if (iface) + { + ref = IUnknown_Release(iface); + ok(ref == 1, "IUnknown_Release should return %d, got %d\n", 1, ref); + } + iface = NULL; + + hr = IUnknown_QueryInterface(pvmr9, &IID_IVMRMonitorConfig9, (LPVOID*)&iface); + ok(hr == S_OK, "IUnknown_QueryInterface returned %x\n", hr); + ok(iface != NULL, "Pointer is NULL\n"); + if (iface) + { + ref = IUnknown_Release(iface); + ok(ref == 1, "IUnknown_Release should return %d, got %d\n", 1, ref); + } + iface = NULL; + +/* Apparantly this one returns E_NOINTERFACE, despite msdn saying it exists + * It might only exist in non-windowed mode + */ + hr = IUnknown_QueryInterface(pvmr9, &IID_IVMRMixerControl9, (LPVOID*)&iface); + ok(hr == E_NOINTERFACE, "IUnknown_QueryInterface returned %x\n", hr); + if (iface) + { + ref = IUnknown_Release(iface); + ok(ref == 1, "IUnknown_Release should return %d, got %d\n", 1, ref); + } + iface = NULL; + +/* Interesting part: What happens with QueryInterface when in the wrong mode? */ + hr = IUnknown_QueryInterface(pvmr9, &IID_IVMRSurfaceAllocatorNotify9, (LPVOID*)&iface); + ok(hr == E_NOINTERFACE, "IUnknown_QueryInterface returned %x\n", hr); + if (iface) + { + ref = IUnknown_Release(iface); + ok(ref == 1, "IUnknown_Release should return %d, got %d\n", 1, ref); + } + iface = NULL; + + hr = IUnknown_QueryInterface(pvmr9, &IID_IVMRSurfaceAllocatorNotify9, (LPVOID*)&iface); + ok(hr == E_NOINTERFACE, "IUnknown_QueryInterface returned %x\n", hr); + if (iface) + { + ref = IUnknown_Release(iface); + ok(ref == 1, "IUnknown_Release should return %d, got %d\n", 1, ref); + } + iface = NULL; + + hr = IUnknown_QueryInterface(pvmr9, &IID_IVMRWindowlessControl9, (LPVOID*)&iface); + ok(hr == E_NOINTERFACE, "IUnknown_QueryInterface returned %x\n", hr); + if (iface) + { + ref = IUnknown_Release(iface); + ok(ref == 1, "IUnknown_Release should return %d, got %d\n", 1, ref); + } + iface = NULL; + +/* Default is windowed mode, these should exist */ + hr = IUnknown_QueryInterface(pvmr9, &IID_IBasicVideo, (LPVOID*)&iface); + ok(hr == S_OK, "IUnknown_QueryInterface returned %x\n", hr); + ok(iface != NULL, "Pointer is NULL\n"); + if (iface) + { + ref = IUnknown_Release(iface); + ok(ref == 1, "IUnknown_Release should return %d, got %d\n", 1, ref); + } + iface = NULL; + + hr = IUnknown_QueryInterface(pvmr9, &IID_IBasicVideo2, (LPVOID*)&iface); + ok(hr == S_OK, "IUnknown_QueryInterface returned %x\n", hr); + ok(iface != NULL, "Pointer is NULL\n"); + if (iface) + { + ref = IUnknown_Release(iface); + ok(ref == 1, "IUnknown_Release should return %d, got %d\n", 1, ref); + } + iface = NULL; + + hr = IUnknown_QueryInterface(pvmr9, &IID_IVideoWindow, (LPVOID*)&iface); + ok(hr == S_OK, "IUnknown_QueryInterface returned %x\n", hr); + ok(iface != NULL, "Pointer is NULL\n"); + if (iface) + { + ref = IUnknown_Release(iface); + ok(ref == 1, "IUnknown_Release should return %d, got %d\n", 1, ref); + } + iface = NULL; +} + +static void test_pin(IPin *pin) +{ + HRESULT hr; + IMemInputPin *mpin = NULL; + + IPin_QueryInterface(pin, &IID_IMemInputPin, (void **)&mpin); + + ok(mpin != NULL, "No IMemInputPin found!\n"); + if (mpin) + { + ok(IMemInputPin_ReceiveCanBlock(mpin) == S_OK, "Receive can't block for pin!\n"); + hr = IMemInputPin_NotifyAllocator(mpin, NULL, 0); + ok(hr == E_FAIL, "NotifyAllocator with null returns %08x\n", hr); + IMemInputPin_Release(mpin); + } + /* TODO */ +} + +static void test_basefilter(void) +{ + IEnumPins *pin_enum = NULL; + IBaseFilter *base = NULL; + IPin *pins[2]; + ULONG ref; + HRESULT hr; + + IUnknown_QueryInterface(pvmr9, &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); + + hr= IBaseFilter_EnumPins(base, &pin_enum); + ok(hr == S_OK, "hr = %08x and not S_OK\n", hr); + + hr = IEnumPins_Next(pin_enum, 1, NULL, NULL); + ok(hr == E_POINTER, "hr = %08x and not E_POINTER\n", hr); + + hr = IEnumPins_Next(pin_enum, 2, pins, NULL); + ok(hr == E_INVALIDARG, "hr = %08x and not E_INVALIDARG\n", hr); + + pins[0] = (void *)0xdead; + pins[1] = (void *)0xdeed; + + hr = IEnumPins_Next(pin_enum, 2, pins, &ref); + ok(hr == S_FALSE, "hr = %08x instead of S_FALSE\n", hr); + ok(pins[0] != (void *)0xdead && pins[0] != NULL, "pins[0] = %p\n", pins[0]); + if (pins[0] != (void *)0xdead && pins[0] != NULL) + { + test_pin(pins[0]); + IPin_Release(pins[0]); + } + + ok(pins[1] == (void *)0xdeed, "pins[1] = %p\n", pins[1]); + + ref = IEnumPins_Release(pin_enum); + ok(ref == 0, "ref is %u and not 0!\n", ref); + + IBaseFilter_Release(base); +} + +START_TEST(vmr9) +{ + HRESULT hr; + CoInitialize(NULL); + + hr = CoCreateInstance(&CLSID_VideoMixingRenderer9, NULL, CLSCTX_INPROC_SERVER, + &IID_IUnknown, (LPVOID*)&pvmr9); + + if (hr == S_OK) + ok(pvmr9 != NULL, "CoCreateInstance succeeded, but no VMR-9 interface was retrieved\n"); + ok(hr == S_OK || hr == VFW_E_DDRAW_CAPS_NOT_SUITABLE || hr == REGDB_E_CLASSNOTREG, "Unexpected hr %08x returned\n", hr); + + if (hr != S_OK || !pvmr9) + { + skip("Could not create vmr9 interface, skipping tests\n"); + return; + } + + test_query_interface(); + test_basefilter(); + + hr = IUnknown_Release(pvmr9); + ok(hr == 0, "IUnknown_Release failed with %d\n", hr); +} -- 1.5.4.1