Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- dlls/mf/tests/mf.c | 53 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-)
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index c8c7e0569cc..da7e40c67fa 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -2725,17 +2725,17 @@ static ULONG WINAPI grabber_callback_Release(IMFSampleGrabberSinkCallback *iface
static HRESULT WINAPI grabber_callback_OnClockStart(IMFSampleGrabberSinkCallback *iface, MFTIME time, LONGLONG offset) { - return E_NOTIMPL; + return S_OK; }
static HRESULT WINAPI grabber_callback_OnClockStop(IMFSampleGrabberSinkCallback *iface, MFTIME time) { - return E_NOTIMPL; + return S_OK; }
static HRESULT WINAPI grabber_callback_OnClockPause(IMFSampleGrabberSinkCallback *iface, MFTIME time) { - return E_NOTIMPL; + return S_OK; }
static HRESULT WINAPI grabber_callback_OnClockRestart(IMFSampleGrabberSinkCallback *iface, MFTIME time) @@ -2782,6 +2782,28 @@ static const IMFSampleGrabberSinkCallbackVtbl grabber_callback_vtbl =
static IMFSampleGrabberSinkCallback grabber_callback = { &grabber_callback_vtbl };
+#define expect_event(s, m) expect_event_(__LINE__, s, m) +static void expect_event_(int line, IMFStreamSink *stream, MediaEventType met) +{ + HRESULT hr, hr2; + IMFMediaEvent *event; + MediaEventType got_met; + + hr = IMFStreamSink_GetEvent(stream, 0, &event); + ok_(__FILE__, line)(hr == S_OK, "Cannot get event, hr %#x.\n", hr); + ok_(__FILE__, line)(event != NULL, "Got NULL event.\n"); + + hr = IMFMediaEvent_GetStatus(event, &hr2); + ok_(__FILE__, line)(hr == S_OK, "Cannot get status, hr %#x.\n", hr); + ok_(__FILE__, line)(hr2 == S_OK, "Unexpected status, hr %#x.\n", hr2); + + hr = IMFMediaEvent_GetType(event, &got_met); + ok_(__FILE__, line)(hr == S_OK, "Cannot get type, hr %#x.\n", hr); + ok_(__FILE__, line)(got_met == met, "Unexpected event type %d instead of %d.\n", got_met, met); + + IMFMediaEvent_Release(event); +} + static void test_sample_grabber(void) { IMFMediaType *media_type, *media_type2, *media_type3; @@ -2791,6 +2813,7 @@ static void test_sample_grabber(void) IMFStreamSink *stream, *stream2; IMFRateSupport *rate_support; IMFMediaEventGenerator *eg; + IMFClockStateSink *css; IMFMediaSink *sink, *sink2; DWORD flags, count, id; IMFActivate *activate; @@ -2800,6 +2823,7 @@ static void test_sample_grabber(void) float rate; HRESULT hr; GUID guid; + int i;
hr = MFStartup(MF_VERSION, MFSTARTUP_FULL); ok(hr == S_OK, "Failed to start up, hr %#x.\n", hr); @@ -3080,6 +3104,29 @@ static void test_sample_grabber(void) hr = IMFStreamSink_GetEvent(stream, MF_EVENT_FLAG_NO_WAIT, &event); ok(hr == MF_E_NO_EVENTS_AVAILABLE, "Unexpected hr %#x.\n", hr);
+ hr = IMFMediaSink_QueryInterface(sink, &IID_IMFClockStateSink, (void **)&css); + ok(hr == S_OK, "Failed to get interface, hr %#x.\n", hr); + + hr = IMFClockStateSink_OnClockStart(css, MFGetSystemTime(), 0); + ok(hr == S_OK, "Failed to start clock, hr %#x.\n", hr); + + for (i = 0; i < 4; i++) + expect_event(stream, MEStreamSinkRequestSample); + expect_event(stream, MEStreamSinkStarted); + + hr = IMFClockStateSink_OnClockPause(css, MFGetSystemTime()); + ok(hr == S_OK, "Failed to pause clock, hr %#x.\n", hr); + if (strcmp(winetest_platform, "wine") != 0) + expect_event(stream, MEStreamSinkPaused); + else + todo_wine ok(0, "MEStreamSinkPaused event was not sent.\n"); + + hr = IMFClockStateSink_OnClockStop(css, MFGetSystemTime()); + ok(hr == S_OK, "Failed to stop clock, hr %#x.\n", hr); + expect_event(stream, MEStreamSinkStopped); + + IMFClockStateSink_Release(css); + EXPECT_REF(clock, 3); hr = IMFMediaSink_Shutdown(sink); ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr);