Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/dxgi/tests/dxgi.c | 110 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+)
diff --git a/dlls/dxgi/tests/dxgi.c b/dlls/dxgi/tests/dxgi.c index aaef811364..d52676912d 100644 --- a/dlls/dxgi/tests/dxgi.c +++ b/dlls/dxgi/tests/dxgi.c @@ -4899,6 +4899,115 @@ static void flush_events(void) } }
+struct adapter_info +{ + const WCHAR *name; + HMONITOR monitor; +}; + +static BOOL CALLBACK enum_monitor_proc(HMONITOR monitor, HDC hdc, RECT *rect, LPARAM lparam) +{ + struct adapter_info *adapter_info = (struct adapter_info *)lparam; + MONITORINFOEXW monitor_info; + + monitor_info.cbSize = sizeof(monitor_info); + if (GetMonitorInfoW(monitor, (MONITORINFO *)&monitor_info) + && !lstrcmpiW(adapter_info->name, monitor_info.szDevice)) + { + adapter_info->monitor = monitor; + return FALSE; + } + + return TRUE; +} + +static HMONITOR get_monitor(const WCHAR *adapter_name) +{ + struct adapter_info info = {adapter_name, NULL}; + + EnumDisplayMonitors(NULL, NULL, enum_monitor_proc, (LPARAM)&info); + return info.monitor; +} + +static void test_multi_adapter(void) +{ + UINT output_count = 0, expected_output_count = 0; + UINT adapter_index, output_index, device_index; + DISPLAY_DEVICEW display_device; + DXGI_OUTPUT_DESC output_desc; + MONITORINFO monitor_info; + IDXGIFactory *factory; + IDXGIAdapter *adapter; + IDXGIOutput *output; + HMONITOR monitor; + BOOL found; + HRESULT hr; + + if (FAILED(hr = CreateDXGIFactory(&IID_IDXGIFactory, (void **)&factory))) + { + skip("Failed to create IDXGIFactory, hr %#x.\n", hr); + return; + } + + hr = IDXGIFactory_EnumAdapters(factory, 0, &adapter); + if (hr == DXGI_ERROR_NOT_FOUND) + { + skip("Could not enumerate adapters.\n"); + IDXGIFactory_Release(factory); + return; + } + ok(hr == S_OK, "Failed to enumerate adapter, hr %#x.\n", hr); + + for (adapter_index = 0; SUCCEEDED(IDXGIFactory_EnumAdapters(factory, adapter_index, &adapter)); ++adapter_index) + { + for (output_index = 0; SUCCEEDED(IDXGIAdapter_EnumOutputs(adapter, output_index, &output)); ++output_index) + { + hr = IDXGIOutput_GetDesc(output, &output_desc); + ok(hr == S_OK, "IDXGIOutput_GetDesc failed, hr %#x\n", hr); + + found = FALSE; + display_device.cb = sizeof(display_device); + for (device_index = 0; EnumDisplayDevicesW(NULL, device_index, &display_device, 0); ++device_index) + { + if (!lstrcmpiW(display_device.DeviceName, output_desc.DeviceName)) + { + found = TRUE; + break; + } + } + ok(found, "%s not found\n", wine_dbgstr_w(output_desc.DeviceName)); + ok(display_device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP, "%s is detached\n", + wine_dbgstr_w(output_desc.DeviceName)); + if (adapter_index == 0 && output_index == 0) + ok(display_device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE, "Expect first output is primary\n"); + else + ok(!(display_device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE), "Expect output is non-primary\n"); + + /* Should have the same monitor handle */ + monitor = get_monitor(display_device.DeviceName); + ok(monitor != NULL, "Failed to find monitor %s\n", wine_dbgstr_w(display_device.DeviceName)); + ok(output_desc.Monitor == monitor, "Expect monitor %p, got %p\n", monitor, output_desc.Monitor); + + /* Should have the same monitor rectangle */ + monitor_info.cbSize = sizeof(monitor_info); + ok(GetMonitorInfoA(monitor, &monitor_info), "GetMonitorInfo failed, error %#x\n", GetLastError()); + ok(EqualRect(&monitor_info.rcMonitor, &output_desc.DesktopCoordinates), "Expect output rect %s, got %s\n", + wine_dbgstr_rect(&monitor_info.rcMonitor), wine_dbgstr_rect(&output_desc.DesktopCoordinates)); + + IDXGIOutput_Release(output); + ++output_count; + } + + IDXGIAdapter_Release(adapter); + } + + IDXGIFactory_Release(factory); + + expected_output_count = GetSystemMetrics(SM_CMONITORS); + todo_wine_if(expected_output_count > 1) + ok(output_count == expected_output_count, "Expect output count %d, got %d\n", expected_output_count, output_count); +} + struct message { unsigned int message; @@ -5824,6 +5933,7 @@ START_TEST(dxgi) queue_test(test_maximum_frame_latency); queue_test(test_output_desc); queue_test(test_object_wrapping); + queue_test(test_multi_adapter);
run_queued_tests();