Signed-off-by: Anton Baskanov baskanov@gmail.com --- dlls/quartz/tests/filtergraph.c | 129 ++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+)
diff --git a/dlls/quartz/tests/filtergraph.c b/dlls/quartz/tests/filtergraph.c index 835a735667a..7d4cfce2628 100644 --- a/dlls/quartz/tests/filtergraph.c +++ b/dlls/quartz/tests/filtergraph.c @@ -5277,6 +5277,134 @@ static void test_set_notify_flags(void) DestroyWindow(window); }
+#define check_events(a, b, c, d) check_events_(__LINE__, a, b, c, d) +static void check_events_(unsigned int line, IMediaEventEx *media_event, + int expected_ec_complete_count, int expected_ec_status_count, BOOL todo) +{ + int ec_complete_count = 0; + int ec_status_count = 0; + LONG_PTR param1, param2; + HRESULT hr; + LONG code; + for (;;) + { + hr = IMediaEventEx_GetEvent(media_event, &code, ¶m1, ¶m2, 50); + if (hr != S_OK) + break; + if (code == EC_COMPLETE) + ++ec_complete_count; + if (code == EC_STATUS) + ++ec_status_count; + } + ok(hr == E_ABORT, "Got hr %#x.\n", hr); + todo_wine_if(todo) ok_(__FILE__, line)(ec_complete_count == expected_ec_complete_count, + "Expected %d EC_COMPLETE events.\n", expected_ec_complete_count); + ok_(__FILE__, line)(ec_status_count == expected_ec_status_count, + "Expected %d EC_STATUS events.\n", expected_ec_status_count); +} + +static void test_events(void) +{ + IFilterGraph2 *graph = create_graph(); + IMediaEventSink *media_event_sink; + IMediaControl *media_control; + IMediaEventEx *media_event; + struct testfilter filter; + LONG_PTR param1, param2; + HANDLE event; + BSTR status; + HRESULT hr; + ULONG ref; + LONG code; + + status = SysAllocString(L"status"); + + hr = IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&media_control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IFilterGraph2_QueryInterface(graph, &IID_IMediaEventEx, (void **)&media_event); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IFilterGraph2_QueryInterface(graph, &IID_IMediaEventSink, (void **)&media_event_sink); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + testfilter_init(&filter, NULL, 0); + filter.IAMFilterMiscFlags_iface.lpVtbl = &testmiscflags_vtbl; + filter.misc_flags = AM_FILTER_MISC_FLAGS_IS_RENDERER; + + hr = IFilterGraph2_AddFilter(graph, &filter.IBaseFilter_iface, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaEventEx_GetEventHandle(media_event, (OAEVENT *)&event); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaControl_Run(media_control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaEventSink_Notify(media_event_sink, EC_STATUS, (LONG_PTR)status, (LONG_PTR)status); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaEventSink_Notify(media_event_sink, EC_COMPLETE, S_OK, + (LONG_PTR)&filter.IBaseFilter_iface); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaEventSink_Notify(media_event_sink, EC_STATUS, (LONG_PTR)status, (LONG_PTR)status); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaControl_Stop(media_control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + check_events(media_event, 1, 2, FALSE); + + hr = IMediaControl_Run(media_control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaEventSink_Notify(media_event_sink, EC_STATUS, (LONG_PTR)status, (LONG_PTR)status); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaEventSink_Notify(media_event_sink, EC_COMPLETE, S_OK, + (LONG_PTR)&filter.IBaseFilter_iface); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaEventSink_Notify(media_event_sink, EC_STATUS, (LONG_PTR)status, (LONG_PTR)status); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaControl_Stop(media_control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaControl_Run(media_control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + check_events(media_event, 0, 2, TRUE); + + hr = IMediaEventSink_Notify(media_event_sink, EC_STATUS, (LONG_PTR)status, (LONG_PTR)status); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaEventSink_Notify(media_event_sink, EC_COMPLETE, S_OK, + (LONG_PTR)&filter.IBaseFilter_iface); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaEventSink_Notify(media_event_sink, EC_STATUS, (LONG_PTR)status, (LONG_PTR)status); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaControl_Stop(media_control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaControl_Pause(media_control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + check_events(media_event, 1, 2, FALSE); + + SetEvent(event); + + hr = IMediaEventEx_GetEvent(media_event, &code, ¶m1, ¶m2, 50); + ok(hr == E_ABORT, "Got hr %#x.\n", hr); + + todo_wine ok(WaitForSingleObject(event, 0) == WAIT_TIMEOUT, "Event should not be signaled.\n"); + + hr = IMediaControl_Stop(media_control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + IMediaControl_Release(media_control); + IMediaEventEx_Release(media_event); + IMediaEventSink_Release(media_event_sink); + ref = IFilterGraph2_Release(graph); + ok(!ref, "Got outstanding refcount %d.\n", ref); + ok(filter.ref == 1, "Got outstanding refcount %d.\n", filter.ref); + + SysFreeString(status); +} + START_TEST(filtergraph) { CoInitializeEx(NULL, COINIT_MULTITHREADED); @@ -5302,6 +5430,7 @@ START_TEST(filtergraph) test_window_threading(); test_autoplug_uyvy(); test_set_notify_flags(); + test_events();
CoUninitialize(); test_render_with_multithread();