[PATCH 6/6] quartz/tests: Add a test for filter graph threading.
Zebediah Figura
z.figura12 at gmail.com
Mon Sep 30 21:19:10 CDT 2019
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
dlls/quartz/tests/filtergraph.c | 105 ++++++++++++++++++++++++++++++++
1 file changed, 105 insertions(+)
diff --git a/dlls/quartz/tests/filtergraph.c b/dlls/quartz/tests/filtergraph.c
index f279950ebe1..8cfa1e2adb3 100644
--- a/dlls/quartz/tests/filtergraph.c
+++ b/dlls/quartz/tests/filtergraph.c
@@ -4037,6 +4037,110 @@ static void test_add_source_filter(void)
ok(!ref, "Got outstanding refcount %d.\n", ref);
}
+static HWND get_renderer_hwnd(IFilterGraph2 *graph)
+{
+ static const WCHAR sink_id[] = {'I','n',0};
+ IEnumFilters *enum_filters;
+ IBaseFilter *filter;
+ IOverlay *overlay;
+ CLSID clsid;
+ HRESULT hr;
+ IPin *pin;
+ HWND hwnd;
+
+ hr = IFilterGraph2_EnumFilters(graph, &enum_filters);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ while (IEnumFilters_Next(enum_filters, 1, &filter, NULL) == S_OK)
+ {
+ hr = IBaseFilter_GetClassID(filter, &clsid);
+ if (hr == S_OK && IsEqualGUID(&clsid, &CLSID_VideoRenderer))
+ {
+ hr = IBaseFilter_FindPin(filter, sink_id, &pin);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IPin_QueryInterface(pin, &IID_IOverlay, (void **)&overlay);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IOverlay_GetWindowHandle(overlay, &hwnd);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ IOverlay_Release(overlay);
+ IPin_Release(pin);
+ }
+ IBaseFilter_Release(filter);
+ }
+
+ IEnumFilters_Release(enum_filters);
+
+ return hwnd;
+}
+
+static void test_window_threading(void)
+{
+ WCHAR *filename = load_resource(avifile);
+ IFilterGraph2 *graph;
+ HRESULT hr;
+ DWORD tid;
+ ULONG ref;
+ HWND hwnd;
+ BOOL ret;
+
+ graph = create_graph();
+ hr = IFilterGraph2_RenderFile(graph, filename, NULL);
+ if (FAILED(hr))
+ {
+ skip("Cannot render test file, hr %#x.\n", hr);
+ IFilterGraph2_Release(graph);
+ DeleteFileW(filename);
+ return;
+ }
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hwnd = get_renderer_hwnd(graph);
+ if (hwnd)
+ {
+ tid = GetWindowThreadProcessId(hwnd, NULL);
+ ok(tid != GetCurrentThreadId(), "Window should have been created on a separate thread.\n");
+
+ /* The thread should be processing messages, or this will hang. */
+ SendMessageA(hwnd, WM_NULL, 0, 0);
+ }
+ else
+ skip("Could not find renderer window.\n");
+
+ ref = IFilterGraph2_Release(graph);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+
+ hr = CoCreateInstance(&CLSID_FilterGraphNoThread, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IFilterGraph2, (void **)&graph);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IFilterGraph2_RenderFile(graph, filename, NULL);
+ if (FAILED(hr))
+ {
+ skip("Cannot render test file, hr %#x.\n", hr);
+ IFilterGraph2_Release(graph);
+ DeleteFileW(filename);
+ return;
+ }
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hwnd = get_renderer_hwnd(graph);
+ if (hwnd)
+ {
+ tid = GetWindowThreadProcessId(hwnd, NULL);
+ todo_wine ok(tid == GetCurrentThreadId(), "Window should be created on main thread.\n");
+ }
+ else
+ skip("Could not find renderer window.\n");
+
+ ref = IFilterGraph2_Release(graph);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ ret = DeleteFileW(filename);
+ ok(ret, "Failed to delete file, error %u.\n", GetLastError());
+}
+
START_TEST(filtergraph)
{
CoInitializeEx(NULL, COINIT_MULTITHREADED);
@@ -4059,6 +4163,7 @@ START_TEST(filtergraph)
test_graph_seeking();
test_default_sync_source();
test_add_source_filter();
+ test_window_threading();
CoUninitialize();
test_render_with_multithread();
--
2.23.0
More information about the wine-devel
mailing list