[PATCH 3/6] qcap/tests: Add some more tests for IBaseFilter::EnumPins() on the smart tee filter.
Zebediah Figura
z.figura12 at gmail.com
Fri Apr 12 00:20:53 CDT 2019
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
dlls/qcap/tests/smartteefilter.c | 148 +++++++++++++++++++++++++++++++
1 file changed, 148 insertions(+)
diff --git a/dlls/qcap/tests/smartteefilter.c b/dlls/qcap/tests/smartteefilter.c
index 5bcb82d154..cdd09f06d3 100644
--- a/dlls/qcap/tests/smartteefilter.c
+++ b/dlls/qcap/tests/smartteefilter.c
@@ -33,6 +33,13 @@ static IBaseFilter *create_smart_tee(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,146 @@ static void test_interfaces(void)
ok(!ref, "Got unexpected refcount %d.\n", ref);
}
+static void test_enum_pins(void)
+{
+ IBaseFilter *filter = create_smart_tee();
+ IEnumPins *enum1, *enum2;
+ ULONG count, ref;
+ IPin *pins[4];
+ HRESULT hr;
+
+ 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);
+ ok(ref == 3, "Got unexpected refcount %d.\n", ref);
+ ref = get_refcount(pins[0]);
+ 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_OK, "Got hr %#x.\n", hr);
+ ref = get_refcount(filter);
+ ok(ref == 3, "Got unexpected refcount %d.\n", ref);
+ ref = get_refcount(pins[0]);
+ 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_OK, "Got hr %#x.\n", hr);
+ ref = get_refcount(filter);
+ ok(ref == 3, "Got unexpected refcount %d.\n", ref);
+ ref = get_refcount(pins[0]);
+ 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_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_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_OK, "Got hr %#x.\n", hr);
+ ok(count == 2, "Got count %u.\n", count);
+ IPin_Release(pins[0]);
+ IPin_Release(pins[1]);
+
+ 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_Next(enum1, 4, pins, &count);
+ ok(hr == S_FALSE, "Got hr %#x.\n", hr);
+ ok(count == 3, "Got count %u.\n", count);
+ IPin_Release(pins[0]);
+ IPin_Release(pins[1]);
+ IPin_Release(pins[2]);
+
+ 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, 4);
+ ok(hr == S_FALSE, "Got hr %#x.\n", hr);
+
+ hr = IEnumPins_Skip(enum1, 3);
+ 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);
+}
+
typedef struct {
IBaseFilter IBaseFilter_iface;
LONG ref;
@@ -2068,6 +2215,7 @@ START_TEST(smartteefilter)
event = CreateEventW(NULL, FALSE, FALSE, NULL);
test_interfaces();
+ test_enum_pins();
test_smart_tee_filter_aggregation();
test_smart_tee_filter();
--
2.21.0
More information about the wine-devel
mailing list