From 1e16595c33fe06e1c067de3489af76368f6659d2 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Mon, 14 Jun 2021 22:47:31 -0500 Subject: [PATCH] qcap/tests: Add some tests for filter state on the video capture filter. Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/qcap/tests/videocapture.c | 57 ++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/dlls/qcap/tests/videocapture.c b/dlls/qcap/tests/videocapture.c index fafd18009f4..7733dfdc8ed 100644 --- a/dlls/qcap/tests/videocapture.c +++ b/dlls/qcap/tests/videocapture.c @@ -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);