Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/tests/filtermapper.c | 230 ++++++++++++++++++++++++++++++- 1 file changed, 229 insertions(+), 1 deletion(-)
diff --git a/dlls/quartz/tests/filtermapper.c b/dlls/quartz/tests/filtermapper.c index 21bf8891f7f..ee61ad33164 100644 --- a/dlls/quartz/tests/filtermapper.c +++ b/dlls/quartz/tests/filtermapper.c @@ -19,7 +19,8 @@ */
#define COBJMACROS - +#define NONAMELESSSTRUCT +#define NONAMELESSUNION #include "wine/test.h" #include "winbase.h" #include "dshow.h" @@ -27,6 +28,9 @@ #include "initguid.h" #include "wine/fil_data.h"
+static const GUID testclsid = {0x77777777}; +static const GUID testtype = {0x66666666}; + static IFilterMapper3 *create_mapper(void) { IFilterMapper3 *ret; @@ -602,6 +606,228 @@ static void test_aggregation(void) ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref); }
+static void test_enum_reg_filters(void) +{ + static const REGPINTYPES reg_mt = {&testtype, &GUID_NULL}; + static const REGFILTERPINS2 reg_pin = + { + .nMediaTypes = 1, + .lpMediaType = ®_mt, + }; + static const REGFILTER2 reg_filter = + { + .dwVersion = 2, + .dwMerit = MERIT_PREFERRED, + .u.s2.cPins2 = 1, + .u.s2.rgPins2 = ®_pin, + }; + + IFilterMapper3 *mapper = create_mapper(); + IEnumRegFilters *enum1, *enum2; + IFilterMapper *mapper1; + REGFILTER *filters[2]; + ULONG ref, count; + HRESULT hr; + + IFilterMapper3_QueryInterface(mapper, &IID_IFilterMapper, (void **)&mapper1); + + ref = get_refcount(mapper); + ok(ref == 2, "Got refcount %d.\n", ref); + + hr = IFilterMapper_EnumMatchingFilters(mapper1, &enum1, MERIT_PREFERRED, TRUE, + testtype, GUID_NULL, FALSE, FALSE, GUID_NULL, GUID_NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + ref = get_refcount(mapper); + ok(ref == 2, "Got refcount %d.\n", ref); + ref = get_refcount(enum1); + ok(ref == 1, "Got refcount %d.\n", ref); + + hr = IEnumRegFilters_Next(enum1, 1, filters, NULL); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IEnumRegFilters_Skip(enum1, 1); + ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr); + + hr = IEnumRegFilters_Clone(enum1, &enum2); + ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr); + + hr = IEnumRegFilters_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IFilterMapper3_RegisterFilter(mapper, &testclsid, L"filter name", NULL, NULL, NULL, ®_filter); + if (hr == E_ACCESSDENIED) + { + IEnumRegFilters_Release(enum1); + IFilterMapper_Release(mapper1); + IFilterMapper3_Release(mapper); + return; + } + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumRegFilters_Next(enum1, 1, filters, NULL); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + if (hr == S_OK) + { + ok(IsEqualGUID(&filters[0]->Clsid, &testclsid), "Got clsid %s.\n", wine_dbgstr_guid(&filters[0]->Clsid)); + ok(!wcscmp(filters[0]->Name, L"filter name"), "Got name %s.\n", wine_dbgstr_w(filters[0]->Name)); + CoTaskMemFree(filters[0]); + } + + hr = IEnumRegFilters_Next(enum1, 1, filters, NULL); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IEnumRegFilters_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumRegFilters_Next(enum1, 1, filters, &count); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine ok(count == 1, "Got count %u.\n", count); + if (hr == S_OK) + { + ok(IsEqualGUID(&filters[0]->Clsid, &testclsid), "Got clsid %s.\n", wine_dbgstr_guid(&filters[0]->Clsid)); + ok(!wcscmp(filters[0]->Name, L"filter name"), "Got name %s.\n", wine_dbgstr_w(filters[0]->Name)); + CoTaskMemFree(filters[0]); + } + + hr = IEnumRegFilters_Next(enum1, 1, filters, &count); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(!count, "Got count %u.\n", count); + + hr = IEnumRegFilters_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumRegFilters_Next(enum1, 2, filters, NULL); + todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + hr = IEnumRegFilters_Next(enum1, 2, filters, &count); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + todo_wine ok(count == 1, "Got count %u.\n", count); + if (count) + { + ok(IsEqualGUID(&filters[0]->Clsid, &testclsid), "Got clsid %s.\n", wine_dbgstr_guid(&filters[0]->Clsid)); + ok(!wcscmp(filters[0]->Name, L"filter name"), "Got name %s.\n", wine_dbgstr_w(filters[0]->Name)); + CoTaskMemFree(filters[0]); + } + + hr = IFilterMapper3_UnregisterFilter(mapper, NULL, NULL, &testclsid); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumRegFilters_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumRegFilters_Next(enum1, 1, filters, NULL); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + IEnumRegFilters_Release(enum1); + IFilterMapper_Release(mapper1); + ref = IFilterMapper3_Release(mapper); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + +static void test_enum_moniker(void) +{ + static const REGPINTYPES reg_mt = {&testtype, &GUID_NULL}; + static const REGFILTERPINS2 reg_pin = + { + .nMediaTypes = 1, + .lpMediaType = ®_mt, + }; + static const REGFILTER2 reg_filter = + { + .dwVersion = 2, + .dwMerit = MERIT_PREFERRED, + .u.s2.cPins2 = 1, + .u.s2.rgPins2 = ®_pin, + }; + + GUID enumtypes[2] = {testtype, GUID_NULL}; + IFilterMapper3 *mapper = create_mapper(); + IEnumMoniker *enum1, *enum2; + IMoniker *filters[2]; + ULONG ref, count; + HRESULT hr; + + ref = get_refcount(mapper); + ok(ref == 1, "Got refcount %d.\n", ref); + + hr = IFilterMapper3_EnumMatchingFilters(mapper, &enum1, 0, TRUE, 0, TRUE, 1, + enumtypes, NULL, NULL, FALSE, FALSE, 0, NULL, NULL, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + ref = get_refcount(mapper); + ok(ref == 1, "Got refcount %d.\n", ref); + ref = get_refcount(enum1); + ok(ref == 1, "Got refcount %d.\n", ref); + + hr = IEnumMoniker_Next(enum1, 1, filters, NULL); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IEnumMoniker_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMoniker_Skip(enum1, 1); + todo_wine ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr); + + hr = IEnumMoniker_Clone(enum1, &enum2); + ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr); + + hr = IFilterMapper3_RegisterFilter(mapper, &testclsid, L"filter name", NULL, NULL, NULL, ®_filter); + if (hr == E_ACCESSDENIED) + { + IEnumMoniker_Release(enum1); + IFilterMapper3_Release(mapper); + return; + } + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMoniker_Next(enum1, 1, filters, NULL); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + if (hr == S_OK) + IMoniker_Release(filters[0]); + + hr = IEnumMoniker_Next(enum1, 1, filters, NULL); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IEnumMoniker_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMoniker_Next(enum1, 1, filters, &count); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine ok(count == 1, "Got count %u.\n", count); + if (hr == S_OK) + IMoniker_Release(filters[0]); + + hr = IEnumMoniker_Next(enum1, 1, filters, &count); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(!count, "Got count %u.\n", count); + + hr = IEnumMoniker_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMoniker_Next(enum1, 2, filters, NULL); + todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + hr = IEnumMoniker_Next(enum1, 2, filters, &count); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + todo_wine ok(count == 1, "Got count %u.\n", count); + if (count) + IMoniker_Release(filters[0]); + + hr = IFilterMapper3_UnregisterFilter(mapper, NULL, NULL, &testclsid); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMoniker_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMoniker_Next(enum1, 1, filters, NULL); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + IEnumMoniker_Release(enum1); + ref = IFilterMapper3_Release(mapper); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + START_TEST(filtermapper) { CoInitialize(NULL); @@ -612,6 +838,8 @@ START_TEST(filtermapper) test_register_filter_with_null_clsMinorType(); test_parse_filter_data(); test_aggregation(); + test_enum_reg_filters(); + test_enum_moniker();
CoUninitialize(); }