qcap/tests: Add some tests for filter state on the video capture filter.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-06-14 22:47:31 -05:00 committed by Alexandre Julliard
parent bcb261b4f9
commit 1e16595c33
1 changed files with 57 additions and 0 deletions

View File

@ -360,12 +360,65 @@ static void testfilter_init(struct testfilter *filter)
strmbase_sink_init(&filter->sink, &filter->filter, L"sink", &testsink_ops, NULL);
}
static void test_filter_state(IMediaControl *control)
{
OAFilterState state;
HRESULT hr;
hr = IMediaControl_GetState(control, 0, &state);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(state == State_Stopped, "Got state %u.\n", state);
hr = IMediaControl_Pause(control);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IMediaControl_GetState(control, 0, &state);
ok(hr == VFW_S_CANT_CUE, "Got hr %#x.\n", hr);
ok(state == State_Paused, "Got state %u.\n", state);
hr = IMediaControl_Run(control);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IMediaControl_GetState(control, 0, &state);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(state == State_Running, "Got state %u.\n", state);
hr = IMediaControl_Pause(control);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IMediaControl_GetState(control, 0, &state);
ok(hr == VFW_S_CANT_CUE, "Got hr %#x.\n", hr);
ok(state == State_Paused, "Got state %u.\n", state);
hr = IMediaControl_Stop(control);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IMediaControl_GetState(control, 0, &state);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(state == State_Stopped, "Got state %u.\n", state);
hr = IMediaControl_Run(control);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IMediaControl_GetState(control, 0, &state);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(state == State_Running, "Got state %u.\n", state);
hr = IMediaControl_Stop(control);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IMediaControl_GetState(control, 0, &state);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(state == State_Stopped, "Got state %u.\n", state);
}
static void test_connect_pin(IBaseFilter *filter, IPin *source)
{
AM_MEDIA_TYPE req_mt, default_mt, mt, *mts[2];
IAMStreamConfig *stream_config;
struct testfilter testsink;
IEnumMediaTypes *enummt;
IMediaControl *control;
IFilterGraph2 *graph;
ULONG count, ref;
HRESULT hr;
@ -373,6 +426,7 @@ static void test_connect_pin(IBaseFilter *filter, IPin *source)
CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
&IID_IFilterGraph2, (void **)&graph);
IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control);
testfilter_init(&testsink);
IFilterGraph2_AddFilter(graph, &testsink.filter.IBaseFilter_iface, L"sink");
IFilterGraph2_AddFilter(graph, filter, L"source");
@ -406,6 +460,8 @@ static void test_connect_pin(IBaseFilter *filter, IPin *source)
hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt);
ok(hr == S_OK, "Got hr %#x.\n", hr);
test_filter_state(control);
hr = IPin_ConnectedTo(source, &peer);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(peer == &testsink.sink.pin.IPin_iface, "Got peer %p.\n", peer);
@ -445,6 +501,7 @@ static void test_connect_pin(IBaseFilter *filter, IPin *source)
FreeMediaType(&req_mt);
FreeMediaType(&default_mt);
IAMStreamConfig_Release(stream_config);
IMediaControl_Release(control);
ref = IFilterGraph2_Release(graph);
ok(!ref, "Got outstanding refcount %d.\n", ref);
ref = IBaseFilter_Release(&testsink.filter.IBaseFilter_iface);