[PATCH 1/2] quartz/tests: move shareable code to a separate file
Anton Khirnov
wyskas at gmail.com
Sat Aug 21 09:34:10 CDT 2010
---
dlls/quartz/tests/Makefile.in | 1 +
dlls/quartz/tests/avisplitter.c | 64 +----------------------
dlls/quartz/tests/dsoundrender.c | 76 +--------------------------
dlls/quartz/tests/misc.c | 19 +------
dlls/quartz/tests/quartz_test_common.c | 90 ++++++++++++++++++++++++++++++++
dlls/quartz/tests/quartz_test_common.h | 46 ++++++++++++++++
dlls/quartz/tests/videorenderer.c | 76 +--------------------------
7 files changed, 144 insertions(+), 228 deletions(-)
create mode 100644 dlls/quartz/tests/quartz_test_common.c
create mode 100644 dlls/quartz/tests/quartz_test_common.h
diff --git a/dlls/quartz/tests/Makefile.in b/dlls/quartz/tests/Makefile.in
index a83adfc..0ccb48e 100644
--- a/dlls/quartz/tests/Makefile.in
+++ b/dlls/quartz/tests/Makefile.in
@@ -12,6 +12,7 @@ C_SRCS = \
filtermapper.c \
memallocator.c \
misc.c \
+ quartz_test_common.c \
referenceclock.c \
videorenderer.c
diff --git a/dlls/quartz/tests/avisplitter.c b/dlls/quartz/tests/avisplitter.c
index 33a0d6d..ff0ceab 100644
--- a/dlls/quartz/tests/avisplitter.c
+++ b/dlls/quartz/tests/avisplitter.c
@@ -24,6 +24,7 @@
#include "wine/test.h"
#include "dshow.h"
#include "tlhelp32.h"
+#include "quartz_test_common.h"
static HANDLE (WINAPI *pCreateToolhelp32Snapshot)(DWORD, DWORD);
static BOOL (WINAPI *pThread32First)(HANDLE, LPTHREADENTRY32);
@@ -114,67 +115,6 @@ static void test_query_interface(void)
*/
}
-static void test_pin(IPin *pin)
-{
- IMemInputPin *mpin = NULL;
-
- IPin_QueryInterface(pin, &IID_IMemInputPin, (void **)&mpin);
-
- ok(mpin == NULL, "IMemInputPin found!\n");
- if (mpin)
- 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(pAviSplitter, &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);
-}
-
static const WCHAR wfile[] = {'t','e','s','t','.','a','v','i',0};
static const char afile[] = "test.avi";
@@ -468,7 +408,7 @@ START_TEST(avisplitter)
}
test_query_interface();
- test_basefilter();
+ test_basefilter(pAviSplitter);
test_threads();
release_avisplitter();
diff --git a/dlls/quartz/tests/dsoundrender.c b/dlls/quartz/tests/dsoundrender.c
index 5ecdaaa..a4111ad 100644
--- a/dlls/quartz/tests/dsoundrender.c
+++ b/dlls/quartz/tests/dsoundrender.c
@@ -27,15 +27,7 @@
#include "initguid.h"
#include "dsound.h"
#include "amaudio.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(iface); \
- ok(hr == num, "IUnknown_Release should return %d, got %d\n", num, hr); \
-}
+#include "quartz_test_common.h"
static IUnknown *pDSRender = NULL;
@@ -155,70 +147,6 @@ static void test_query_interface(void)
}
}
-static void test_pin(IPin *pin)
-{
- 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");
- ok(IMemInputPin_NotifyAllocator(mpin, NULL, 0) == E_POINTER, "NotifyAllocator likes a NULL pointer argument\n");
- 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(pDSRender, &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(dsoundrender)
{
CoInitialize(NULL);
@@ -226,7 +154,7 @@ START_TEST(dsoundrender)
return;
test_query_interface();
- test_basefilter();
+ test_basefilter(pDSRender);
release_dsound_renderer();
diff --git a/dlls/quartz/tests/misc.c b/dlls/quartz/tests/misc.c
index 74c386b..6b3c327 100644
--- a/dlls/quartz/tests/misc.c
+++ b/dlls/quartz/tests/misc.c
@@ -22,24 +22,7 @@
#include "wine/test.h"
#include "dshow.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 QI_FAIL(iface, riid, ppv) hr = IUnknown_QueryInterface(iface, &riid, (LPVOID*)&ppv); \
- ok(hr == E_NOINTERFACE, "IUnknown_QueryInterface returned %x\n", hr); \
- ok(ppv == NULL, "Pointer is %p\n", ppv);
-
-#define ADDREF_EXPECT(iface, num) if (iface) { \
- refCount = IUnknown_AddRef(iface); \
- ok(refCount == num, "IUnknown_AddRef should return %d, got %d\n", num, refCount); \
-}
-
-#define RELEASE_EXPECT(iface, num) if (iface) { \
- refCount = IUnknown_Release(iface); \
- ok(refCount == num, "IUnknown_Release should return %d, got %d\n", num, refCount); \
-}
+#include "quartz_test_common.h"
static void test_aggregation(const CLSID clsidOuter, const CLSID clsidInner,
const IID iidOuter, const IID iidInner)
diff --git a/dlls/quartz/tests/quartz_test_common.c b/dlls/quartz/tests/quartz_test_common.c
new file mode 100644
index 0000000..e6e2b25
--- /dev/null
+++ b/dlls/quartz/tests/quartz_test_common.c
@@ -0,0 +1,90 @@
+/*
+ * Common code for quartz unit tests
+ *
+ * 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"
+
+void test_pin(IPin *pin)
+{
+ 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");
+ ok(IMemInputPin_NotifyAllocator(mpin, NULL, 0) == E_POINTER, "NotifyAllocator likes a NULL pointer argument\n");
+ IMemInputPin_Release(mpin);
+ }
+ /* TODO */
+}
+
+void test_basefilter(IUnknown *basefilter)
+{
+ IEnumPins *pin_enum = NULL;
+ IBaseFilter *base = NULL;
+ IPin *pins[2];
+ ULONG ref;
+ HRESULT hr;
+
+ IUnknown_QueryInterface(basefilter, &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);
+}
+
diff --git a/dlls/quartz/tests/quartz_test_common.h b/dlls/quartz/tests/quartz_test_common.h
new file mode 100644
index 0000000..e25861f
--- /dev/null
+++ b/dlls/quartz/tests/quartz_test_common.h
@@ -0,0 +1,46 @@
+/*
+ * Common code for quartz unit tests
+ *
+ * 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
+ */
+
+#ifndef QUARTZ_TEST_COMMON_H
+#define QUARTZ_TEST_COMMON_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 QI_FAIL(iface, riid, ppv) hr = IUnknown_QueryInterface(iface, &riid, (LPVOID*)&ppv); \
+ ok(hr == E_NOINTERFACE, "IUnknown_QueryInterface returned %x\n", hr); \
+ ok(ppv == NULL, "Pointer is %p\n", ppv);
+
+#define RELEASE_EXPECT(iface, num) if (iface) { \
+ hr = IUnknown_Release(iface); \
+ ok(hr == num, "IUnknown_Release should return %d, got %d\n", num, hr); \
+}
+
+#define ADDREF_EXPECT(iface, num) if (iface) { \
+ refCount = IUnknown_AddRef(iface); \
+ ok(refCount == num, "IUnknown_AddRef should return %d, got %d\n", num, refCount); \
+}
+
+void test_basefilter(IUnknown *basefilter);
+void test_pin(IPin *pin);
+
+#endif // QUARTZ_TEST_COMMON_H
diff --git a/dlls/quartz/tests/videorenderer.c b/dlls/quartz/tests/videorenderer.c
index 967abd4..f09735f 100644
--- a/dlls/quartz/tests/videorenderer.c
+++ b/dlls/quartz/tests/videorenderer.c
@@ -22,15 +22,7 @@
#include "wine/test.h"
#include "dshow.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(iface); \
- ok(hr == num, "IUnknown_Release should return %d, got %d\n", num, hr); \
-}
+#include "quartz_test_common.h"
static IUnknown *pVideoRenderer = NULL;
@@ -86,70 +78,6 @@ static void test_query_interface(void)
RELEASE_EXPECT(pVideoWindow, 1);
}
-static void test_pin(IPin *pin)
-{
- 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");
- ok(IMemInputPin_NotifyAllocator(mpin, NULL, 0) == E_POINTER, "NotifyAllocator likes a NULL pointer argument\n");
- 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(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);
-
- 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(videorenderer)
{
CoInitialize(NULL);
@@ -157,7 +85,7 @@ START_TEST(videorenderer)
return;
test_query_interface();
- test_basefilter();
+ test_basefilter(pVideoRenderer);
release_video_renderer();
--
1.7.1
More information about the wine-patches
mailing list