Commit f8b6b55c authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

quartz/tests: Add some tests for IEnumMediaTypes().

parent 0e9b605d
...@@ -468,7 +468,7 @@ static void test_media_types(void) ...@@ -468,7 +468,7 @@ static void test_media_types(void)
{ {
IBaseFilter *filter = create_avi_dec(); IBaseFilter *filter = create_avi_dec();
AM_MEDIA_TYPE mt = {{0}}, *pmt; AM_MEDIA_TYPE mt = {{0}}, *pmt;
VIDEOINFOHEADER vih = {0}; VIDEOINFOHEADER vih = {{0}};
IEnumMediaTypes *enummt; IEnumMediaTypes *enummt;
HRESULT hr; HRESULT hr;
ULONG ref; ULONG ref;
...@@ -543,6 +543,81 @@ static void test_media_types(void) ...@@ -543,6 +543,81 @@ static void test_media_types(void)
ok(!ref, "Got outstanding refcount %d.\n", ref); ok(!ref, "Got outstanding refcount %d.\n", ref);
} }
static void test_enum_media_types(void)
{
IBaseFilter *filter = create_avi_dec();
IEnumMediaTypes *enum1, *enum2;
AM_MEDIA_TYPE *mts[1];
ULONG ref, count;
HRESULT hr;
IPin *pin;
IBaseFilter_FindPin(filter, sink_id, &pin);
hr = IPin_EnumMediaTypes(pin, &enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, &count);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(!count, "Got count %u.\n", count);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Clone(enum1, &enum2);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 1);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum2, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
IEnumMediaTypes_Release(enum1);
IEnumMediaTypes_Release(enum2);
IPin_Release(pin);
IBaseFilter_FindPin(filter, source_id, &pin);
hr = IPin_EnumMediaTypes(pin, &enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, &count);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(!count, "Got count %u.\n", count);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Clone(enum1, &enum2);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 1);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum2, 1, mts, NULL);
todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr);
IEnumMediaTypes_Release(enum1);
IEnumMediaTypes_Release(enum2);
IPin_Release(pin);
ref = IBaseFilter_Release(filter);
ok(!ref, "Got outstanding refcount %d.\n", ref);
}
START_TEST(avidec) START_TEST(avidec)
{ {
BOOL ret; BOOL ret;
...@@ -558,6 +633,7 @@ START_TEST(avidec) ...@@ -558,6 +633,7 @@ START_TEST(avidec)
test_find_pin(); test_find_pin();
test_pin_info(); test_pin_info();
test_media_types(); test_media_types();
test_enum_media_types();
CoUninitialize(); CoUninitialize();
......
...@@ -654,6 +654,124 @@ static void test_media_types(void) ...@@ -654,6 +654,124 @@ static void test_media_types(void)
ok(ret, "Failed to delete file, error %u.\n", GetLastError()); ok(ret, "Failed to delete file, error %u.\n", GetLastError());
} }
static void test_enum_media_types(void)
{
const WCHAR *filename = load_resource(avifile);
IBaseFilter *filter = create_avi_splitter();
IFilterGraph2 *graph = connect_input(filter, filename);
IEnumMediaTypes *enum1, *enum2;
AM_MEDIA_TYPE *mts[2];
ULONG ref, count;
HRESULT hr;
IPin *pin;
BOOL ret;
IBaseFilter_FindPin(filter, sink_name, &pin);
hr = IPin_EnumMediaTypes(pin, &enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, &count);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(!count, "Got count %u.\n", count);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Clone(enum1, &enum2);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 1);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum2, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
IEnumMediaTypes_Release(enum1);
IEnumMediaTypes_Release(enum2);
IPin_Release(pin);
IBaseFilter_FindPin(filter, source0_name, &pin);
hr = IPin_EnumMediaTypes(pin, &enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_OK, "Got hr %#x.\n", hr);
CoTaskMemFree(mts[0]->pbFormat);
CoTaskMemFree(mts[0]);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, &count);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(count == 1, "Got count %u.\n", count);
CoTaskMemFree(mts[0]->pbFormat);
CoTaskMemFree(mts[0]);
hr = IEnumMediaTypes_Next(enum1, 1, mts, &count);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(!count, "Got count %u.\n", count);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 2, mts, &count);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(count == 1, "Got count %u.\n", count);
CoTaskMemFree(mts[0]->pbFormat);
CoTaskMemFree(mts[0]);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Clone(enum1, &enum2);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 2);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 1);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 1);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 1);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum2, 1, mts, NULL);
ok(hr == S_OK, "Got hr %#x.\n", hr);
CoTaskMemFree(mts[0]->pbFormat);
CoTaskMemFree(mts[0]);
IEnumMediaTypes_Release(enum1);
IEnumMediaTypes_Release(enum2);
IPin_Release(pin);
IFilterGraph2_Release(graph);
ref = IBaseFilter_Release(filter);
ok(!ref, "Got outstanding refcount %d.\n", ref);
ret = DeleteFileW(filename);
ok(ret, "Failed to delete file, error %u.\n", GetLastError());
}
static void test_filter_graph(void) static void test_filter_graph(void)
{ {
IFileSourceFilter *pfile = NULL; IFileSourceFilter *pfile = NULL;
...@@ -906,6 +1024,7 @@ START_TEST(avisplit) ...@@ -906,6 +1024,7 @@ START_TEST(avisplit)
test_find_pin(); test_find_pin();
test_pin_info(); test_pin_info();
test_media_types(); test_media_types();
test_enum_media_types();
test_filter_graph(); test_filter_graph();
CoUninitialize(); CoUninitialize();
......
...@@ -494,6 +494,87 @@ static void test_basic_audio(void) ...@@ -494,6 +494,87 @@ static void test_basic_audio(void)
ok(!ref, "Got outstanding refcount %d.\n", ref); ok(!ref, "Got outstanding refcount %d.\n", ref);
} }
static void test_enum_media_types(void)
{
IBaseFilter *filter = create_dsound_render();
IEnumMediaTypes *enum1, *enum2;
AM_MEDIA_TYPE *mts[2];
ULONG ref, count;
HRESULT hr;
IPin *pin;
IBaseFilter_FindPin(filter, sink_id, &pin);
hr = IPin_EnumMediaTypes(pin, &enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
if (hr == S_OK) CoTaskMemFree(mts[0]->pbFormat);
if (hr == S_OK) CoTaskMemFree(mts[0]);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, &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) CoTaskMemFree(mts[0]->pbFormat);
if (hr == S_OK) CoTaskMemFree(mts[0]);
hr = IEnumMediaTypes_Next(enum1, 1, mts, &count);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(!count, "Got count %u.\n", count);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 2, mts, &count);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
todo_wine ok(count == 1, "Got count %u.\n", count);
if (count > 0) CoTaskMemFree(mts[0]->pbFormat);
if (count > 0) CoTaskMemFree(mts[0]);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Clone(enum1, &enum2);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 2);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 1);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 1);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 1);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum2, 1, mts, NULL);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
if (hr == S_OK) CoTaskMemFree(mts[0]->pbFormat);
if (hr == S_OK) CoTaskMemFree(mts[0]);
IEnumMediaTypes_Release(enum1);
IEnumMediaTypes_Release(enum2);
IPin_Release(pin);
ref = IBaseFilter_Release(filter);
ok(!ref, "Got outstanding refcount %d.\n", ref);
}
static void test_pin(IPin *pin) static void test_pin(IPin *pin)
{ {
IMemInputPin *mpin = NULL; IMemInputPin *mpin = NULL;
...@@ -575,6 +656,7 @@ START_TEST(dsoundrender) ...@@ -575,6 +656,7 @@ START_TEST(dsoundrender)
test_find_pin(); test_find_pin();
test_pin_info(); test_pin_info();
test_basic_audio(); test_basic_audio();
test_enum_media_types();
test_basefilter(); test_basefilter();
CoUninitialize(); CoUninitialize();
......
...@@ -1081,6 +1081,112 @@ static void test_async_reader(void) ...@@ -1081,6 +1081,112 @@ static void test_async_reader(void)
ok(ret, "Failed to delete file, error %u.\n", GetLastError()); ok(ret, "Failed to delete file, error %u.\n", GetLastError());
} }
static void test_enum_media_types(void)
{
const WCHAR *filename = load_resource(avifile);
IBaseFilter *filter = create_file_source();
IEnumMediaTypes *enum1, *enum2;
AM_MEDIA_TYPE *mts[3];
ULONG ref, count;
HRESULT hr;
IPin *pin;
BOOL ret;
load_file(filter, filename);
IBaseFilter_FindPin(filter, source_id, &pin);
hr = IPin_EnumMediaTypes(pin, &enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_OK, "Got hr %#x.\n", hr);
CoTaskMemFree(mts[0]);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_OK, "Got hr %#x.\n", hr);
CoTaskMemFree(mts[0]);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, &count);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(count == 1, "Got count %u.\n", count);
CoTaskMemFree(mts[0]);
hr = IEnumMediaTypes_Next(enum1, 1, mts, &count);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(count == 1, "Got count %u.\n", count);
CoTaskMemFree(mts[0]);
hr = IEnumMediaTypes_Next(enum1, 1, mts, &count);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(!count, "Got count %u.\n", count);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 2, mts, &count);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(count == 2, "Got count %u.\n", count);
CoTaskMemFree(mts[0]);
CoTaskMemFree(mts[1]);
hr = IEnumMediaTypes_Next(enum1, 2, mts, &count);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(!count, "Got count %u.\n", count);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 3, mts, &count);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(count == 2, "Got count %u.\n", count);
CoTaskMemFree(mts[0]);
CoTaskMemFree(mts[1]);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Clone(enum1, &enum2);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 3);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 1);
todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 2);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 1);
todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum2, 1, mts, NULL);
ok(hr == S_OK, "Got hr %#x.\n", hr);
CoTaskMemFree(mts[0]);
IEnumMediaTypes_Release(enum1);
IEnumMediaTypes_Release(enum2);
IPin_Release(pin);
ref = IBaseFilter_Release(filter);
ok(!ref, "Got outstanding refcount %d.\n", ref);
ret = DeleteFileW(filename);
ok(ret, "Failed to delete file, error %u.\n", GetLastError());
}
START_TEST(filesource) START_TEST(filesource)
{ {
CoInitialize(NULL); CoInitialize(NULL);
...@@ -1093,6 +1199,7 @@ START_TEST(filesource) ...@@ -1093,6 +1199,7 @@ START_TEST(filesource)
test_filter_state(); test_filter_state();
test_file_source_filter(); test_file_source_filter();
test_async_reader(); test_async_reader();
test_enum_media_types();
CoUninitialize(); CoUninitialize();
} }
...@@ -810,6 +810,193 @@ done: ...@@ -810,6 +810,193 @@ done:
ok(ret, "Failed to delete file, error %u.\n", GetLastError()); ok(ret, "Failed to delete file, error %u.\n", GetLastError());
} }
static void test_enum_media_types(void)
{
const WCHAR *filename = load_resource(mp3file);
IBaseFilter *filter = create_mpeg_splitter();
IFilterGraph2 *graph = connect_input(filter, filename);
IEnumMediaTypes *enum1, *enum2;
AM_MEDIA_TYPE *mts[5];
ULONG ref, count;
unsigned int i;
HRESULT hr;
IPin *pin;
BOOL ret;
IBaseFilter_FindPin(filter, inputW, &pin);
hr = IPin_EnumMediaTypes(pin, &enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
for (i = 0; i < 4; ++i)
{
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
if (hr == S_OK) CoTaskMemFree(mts[0]);
}
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
for (i = 0; i < 4; ++i)
{
hr = IEnumMediaTypes_Next(enum1, 1, mts, &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) CoTaskMemFree(mts[0]);
}
hr = IEnumMediaTypes_Next(enum1, 1, mts, &count);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(!count, "Got count %u.\n", count);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 2, mts, &count);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
todo_wine ok(count == 2, "Got count %u.\n", count);
if (count > 0) CoTaskMemFree(mts[0]);
if (count > 1) CoTaskMemFree(mts[1]);
hr = IEnumMediaTypes_Next(enum1, 3, mts, &count);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
todo_wine ok(count == 2, "Got count %u.\n", count);
if (count > 0) CoTaskMemFree(mts[0]);
if (count > 1) CoTaskMemFree(mts[1]);
hr = IEnumMediaTypes_Next(enum1, 2, mts, &count);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(!count, "Got count %u.\n", count);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Clone(enum1, &enum2);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 5);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 1);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 4);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 1);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum2, 1, mts, NULL);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
if (hr == S_OK) CoTaskMemFree(mts[0]);
IEnumMediaTypes_Release(enum1);
IEnumMediaTypes_Release(enum2);
IPin_Release(pin);
IBaseFilter_FindPin(filter, audioW, &pin);
hr = IPin_EnumMediaTypes(pin, &enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
for (i = 0; i < 3; ++i)
{
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
todo_wine_if(i) ok(hr == S_OK, "Got hr %#x.\n", hr);
if (hr == S_OK) CoTaskMemFree(mts[0]->pbFormat);
if (hr == S_OK) CoTaskMemFree(mts[0]);
}
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
for (i = 0; i < 3; ++i)
{
hr = IEnumMediaTypes_Next(enum1, 1, mts, &count);
todo_wine_if(i) ok(hr == S_OK, "Got hr %#x.\n", hr);
todo_wine_if(i) ok(count == 1, "Got count %u.\n", count);
if (hr == S_OK) CoTaskMemFree(mts[0]->pbFormat);
if (hr == S_OK) CoTaskMemFree(mts[0]);
}
hr = IEnumMediaTypes_Next(enum1, 1, mts, &count);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(!count, "Got count %u.\n", count);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 2, mts, &count);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
todo_wine ok(count == 2, "Got count %u.\n", count);
CoTaskMemFree(mts[0]->pbFormat);
CoTaskMemFree(mts[0]);
if (count > 1) CoTaskMemFree(mts[1]->pbFormat);
if (count > 1) CoTaskMemFree(mts[1]);
hr = IEnumMediaTypes_Next(enum1, 2, mts, &count);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
todo_wine ok(count == 1, "Got count %u.\n", count);
if (count) CoTaskMemFree(mts[0]->pbFormat);
if (count) CoTaskMemFree(mts[0]);
hr = IEnumMediaTypes_Next(enum1, 2, mts, &count);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(!count, "Got count %u.\n", count);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Clone(enum1, &enum2);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 4);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 1);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 3);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 1);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum2, 1, mts, NULL);
ok(hr == S_OK, "Got hr %#x.\n", hr);
CoTaskMemFree(mts[0]->pbFormat);
CoTaskMemFree(mts[0]);
IEnumMediaTypes_Release(enum1);
IEnumMediaTypes_Release(enum2);
IPin_Release(pin);
IFilterGraph2_Release(graph);
ref = IBaseFilter_Release(filter);
ok(!ref, "Got outstanding refcount %d.\n", ref);
ret = DeleteFileW(filename);
ok(ret, "Failed to delete file, error %u.\n", GetLastError());
}
START_TEST(mpegsplit) START_TEST(mpegsplit)
{ {
CoInitialize(NULL); CoInitialize(NULL);
...@@ -820,6 +1007,7 @@ START_TEST(mpegsplit) ...@@ -820,6 +1007,7 @@ START_TEST(mpegsplit)
test_find_pin(); test_find_pin();
test_pin_info(); test_pin_info();
test_media_types(); test_media_types();
test_enum_media_types();
CoUninitialize(); CoUninitialize();
} }
...@@ -428,6 +428,50 @@ static void test_media_types(void) ...@@ -428,6 +428,50 @@ static void test_media_types(void)
ok(!ref, "Got outstanding refcount %d.\n", ref); ok(!ref, "Got outstanding refcount %d.\n", ref);
} }
static void test_enum_media_types(void)
{
IBaseFilter *filter = create_video_renderer();
IEnumMediaTypes *enum1, *enum2;
AM_MEDIA_TYPE *mts[2];
ULONG ref, count;
HRESULT hr;
IPin *pin;
IBaseFilter_FindPin(filter, sink_id, &pin);
hr = IPin_EnumMediaTypes(pin, &enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, &count);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(!count, "Got count %u.\n", count);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Clone(enum1, &enum2);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 1);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum2, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
IEnumMediaTypes_Release(enum1);
IEnumMediaTypes_Release(enum2);
IPin_Release(pin);
ref = IBaseFilter_Release(filter);
ok(!ref, "Got outstanding refcount %d.\n", ref);
}
static void test_pin(IPin *pin) static void test_pin(IPin *pin)
{ {
IMemInputPin *mpin = NULL; IMemInputPin *mpin = NULL;
...@@ -494,6 +538,7 @@ START_TEST(videorenderer) ...@@ -494,6 +538,7 @@ START_TEST(videorenderer)
test_find_pin(); test_find_pin();
test_pin_info(); test_pin_info();
test_media_types(); test_media_types();
test_enum_media_types();
test_basefilter(); test_basefilter();
CoUninitialize(); CoUninitialize();
......
...@@ -730,6 +730,51 @@ static void test_media_types(void) ...@@ -730,6 +730,51 @@ static void test_media_types(void)
ok(!ref, "Got outstanding refcount %d.\n", ref); ok(!ref, "Got outstanding refcount %d.\n", ref);
} }
static void test_enum_media_types(void)
{
WCHAR sink_id[] = {'V','M','R',' ','I','n','p','u','t','0',0};
IBaseFilter *filter = create_vmr7(0);
IEnumMediaTypes *enum1, *enum2;
AM_MEDIA_TYPE *mts[2];
ULONG ref, count;
HRESULT hr;
IPin *pin;
IBaseFilter_FindPin(filter, sink_id, &pin);
hr = IPin_EnumMediaTypes(pin, &enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, &count);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(!count, "Got count %u.\n", count);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Clone(enum1, &enum2);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 1);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum2, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
IEnumMediaTypes_Release(enum1);
IEnumMediaTypes_Release(enum2);
IPin_Release(pin);
ref = IBaseFilter_Release(filter);
ok(!ref, "Got outstanding refcount %d.\n", ref);
}
START_TEST(vmr7) START_TEST(vmr7)
{ {
CoInitialize(NULL); CoInitialize(NULL);
...@@ -741,6 +786,7 @@ START_TEST(vmr7) ...@@ -741,6 +786,7 @@ START_TEST(vmr7)
test_find_pin(); test_find_pin();
test_pin_info(); test_pin_info();
test_media_types(); test_media_types();
test_enum_media_types();
CoUninitialize(); CoUninitialize();
} }
...@@ -734,6 +734,51 @@ static void test_media_types(void) ...@@ -734,6 +734,51 @@ static void test_media_types(void)
ok(!ref, "Got outstanding refcount %d.\n", ref); ok(!ref, "Got outstanding refcount %d.\n", ref);
} }
static void test_enum_media_types(void)
{
WCHAR sink_id[] = {'V','M','R',' ','I','n','p','u','t','0',0};
IBaseFilter *filter = create_vmr9(0);
IEnumMediaTypes *enum1, *enum2;
AM_MEDIA_TYPE *mts[2];
ULONG ref, count;
HRESULT hr;
IPin *pin;
IBaseFilter_FindPin(filter, sink_id, &pin);
hr = IPin_EnumMediaTypes(pin, &enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, &count);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(!count, "Got count %u.\n", count);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Clone(enum1, &enum2);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 1);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum2, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
IEnumMediaTypes_Release(enum1);
IEnumMediaTypes_Release(enum2);
IPin_Release(pin);
ref = IBaseFilter_Release(filter);
ok(!ref, "Got outstanding refcount %d.\n", ref);
}
START_TEST(vmr9) START_TEST(vmr9)
{ {
IBaseFilter *filter; IBaseFilter *filter;
...@@ -756,6 +801,7 @@ START_TEST(vmr9) ...@@ -756,6 +801,7 @@ START_TEST(vmr9)
test_find_pin(); test_find_pin();
test_pin_info(); test_pin_info();
test_media_types(); test_media_types();
test_enum_media_types();
CoUninitialize(); CoUninitialize();
} }
...@@ -642,6 +642,124 @@ static void test_media_types(void) ...@@ -642,6 +642,124 @@ static void test_media_types(void)
ok(ret, "Failed to delete file, error %u.\n", GetLastError()); ok(ret, "Failed to delete file, error %u.\n", GetLastError());
} }
static void test_enum_media_types(void)
{
const WCHAR *filename = load_resource(wavefile);
IBaseFilter *filter = create_wave_parser();
IFilterGraph2 *graph = connect_input(filter, filename);
IEnumMediaTypes *enum1, *enum2;
AM_MEDIA_TYPE *mts[2];
ULONG ref, count;
HRESULT hr;
IPin *pin;
BOOL ret;
IBaseFilter_FindPin(filter, sink_name, &pin);
hr = IPin_EnumMediaTypes(pin, &enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, &count);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(!count, "Got count %u.\n", count);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Clone(enum1, &enum2);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 1);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum2, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
IEnumMediaTypes_Release(enum1);
IEnumMediaTypes_Release(enum2);
IPin_Release(pin);
IBaseFilter_FindPin(filter, source_name, &pin);
hr = IPin_EnumMediaTypes(pin, &enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_OK, "Got hr %#x.\n", hr);
CoTaskMemFree(mts[0]->pbFormat);
CoTaskMemFree(mts[0]);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, &count);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(count == 1, "Got count %u.\n", count);
CoTaskMemFree(mts[0]->pbFormat);
CoTaskMemFree(mts[0]);
hr = IEnumMediaTypes_Next(enum1, 1, mts, &count);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(!count, "Got count %u.\n", count);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 2, mts, &count);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(count == 1, "Got count %u.\n", count);
CoTaskMemFree(mts[0]->pbFormat);
CoTaskMemFree(mts[0]);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Clone(enum1, &enum2);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 2);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 1);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Reset(enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 1);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Skip(enum1, 1);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum2, 1, mts, NULL);
ok(hr == S_OK, "Got hr %#x.\n", hr);
CoTaskMemFree(mts[0]->pbFormat);
CoTaskMemFree(mts[0]);
IEnumMediaTypes_Release(enum1);
IEnumMediaTypes_Release(enum2);
IPin_Release(pin);
IFilterGraph2_Release(graph);
ref = IBaseFilter_Release(filter);
ok(!ref, "Got outstanding refcount %d.\n", ref);
ret = DeleteFileW(filename);
ok(ret, "Failed to delete file, error %u.\n", GetLastError());
}
START_TEST(waveparser) START_TEST(waveparser)
{ {
CoInitialize(NULL); CoInitialize(NULL);
...@@ -652,6 +770,7 @@ START_TEST(waveparser) ...@@ -652,6 +770,7 @@ START_TEST(waveparser)
test_find_pin(); test_find_pin();
test_pin_info(); test_pin_info();
test_media_types(); test_media_types();
test_enum_media_types();
CoUninitialize(); CoUninitialize();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment