d3d8/tests: Add more get display mode tests.
Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
248b5d7427
commit
6ca5dbf599
|
@ -9881,13 +9881,20 @@ static void test_draw_primitive(void)
|
|||
|
||||
static void test_get_display_mode(void)
|
||||
{
|
||||
static const DWORD creation_flags[] = {0, CREATE_DEVICE_FULLSCREEN};
|
||||
unsigned int adapter_idx, adapter_count, mode_idx, test_idx;
|
||||
RECT previous_monitor_rect;
|
||||
unsigned int width, height;
|
||||
IDirect3DDevice8 *device;
|
||||
MONITORINFO monitor_info;
|
||||
struct device_desc desc;
|
||||
D3DDISPLAYMODE mode;
|
||||
HMONITOR monitor;
|
||||
IDirect3D8 *d3d;
|
||||
ULONG refcount;
|
||||
HWND window;
|
||||
HRESULT hr;
|
||||
BOOL ret;
|
||||
|
||||
window = create_window();
|
||||
d3d = Direct3DCreate8(D3D_SDK_VERSION);
|
||||
|
@ -9937,8 +9944,104 @@ static void test_get_display_mode(void)
|
|||
|
||||
refcount = IDirect3DDevice8_Release(device);
|
||||
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||
IDirect3D8_Release(d3d);
|
||||
DestroyWindow(window);
|
||||
|
||||
/* D3D8 uses adapter indices to determine which adapter to use to get the display mode */
|
||||
adapter_count = IDirect3D8_GetAdapterCount(d3d);
|
||||
for (adapter_idx = 0; adapter_idx < adapter_count; ++adapter_idx)
|
||||
{
|
||||
if (!adapter_idx)
|
||||
{
|
||||
desc.width = 640;
|
||||
desc.height = 480;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Find a mode different than that of the previous adapter, so that tests can be sure
|
||||
* that they are comparing to the current adapter display mode */
|
||||
monitor = IDirect3D8_GetAdapterMonitor(d3d, adapter_idx - 1);
|
||||
ok(!!monitor, "Adapter %u: GetAdapterMonitor failed.\n", adapter_idx - 1);
|
||||
monitor_info.cbSize = sizeof(monitor_info);
|
||||
ret = GetMonitorInfoW(monitor, &monitor_info);
|
||||
ok(ret, "Adapter %u: GetMonitorInfoW failed, error %#x.\n", adapter_idx - 1,
|
||||
GetLastError());
|
||||
previous_monitor_rect = monitor_info.rcMonitor;
|
||||
|
||||
desc.width = monitor_info.rcMonitor.right - monitor_info.rcMonitor.left;
|
||||
desc.height = monitor_info.rcMonitor.bottom - monitor_info.rcMonitor.top;
|
||||
for (mode_idx = 0; SUCCEEDED(IDirect3D8_EnumAdapterModes(d3d, adapter_idx, mode_idx,
|
||||
&mode)); ++mode_idx)
|
||||
{
|
||||
if (mode.Format != D3DFMT_X8R8G8B8)
|
||||
continue;
|
||||
if (mode.Width < 640 || mode.Height < 480)
|
||||
continue;
|
||||
if (mode.Width != desc.width && mode.Height != desc.height)
|
||||
break;
|
||||
}
|
||||
ok(mode.Width != desc.width && mode.Height != desc.height,
|
||||
"Adapter %u: Failed to find a different mode than %ux%u.\n", adapter_idx,
|
||||
desc.width, desc.height);
|
||||
desc.width = mode.Width;
|
||||
desc.height = mode.Height;
|
||||
}
|
||||
|
||||
for (test_idx = 0; test_idx < ARRAY_SIZE(creation_flags); ++test_idx)
|
||||
{
|
||||
window = create_window();
|
||||
desc.adapter_ordinal = adapter_idx;
|
||||
desc.device_window = window;
|
||||
desc.flags = creation_flags[test_idx];
|
||||
if (!(device = create_device(d3d, window, &desc)))
|
||||
{
|
||||
skip("Adapter %u test %u: Failed to create a D3D device.\n", adapter_idx, test_idx);
|
||||
DestroyWindow(window);
|
||||
continue;
|
||||
}
|
||||
|
||||
monitor = IDirect3D8_GetAdapterMonitor(d3d, adapter_idx);
|
||||
ok(!!monitor, "Adapter %u test %u: GetAdapterMonitor failed.\n", adapter_idx, test_idx);
|
||||
monitor_info.cbSize = sizeof(monitor_info);
|
||||
ret = GetMonitorInfoW(monitor, &monitor_info);
|
||||
ok(ret, "Adapter %u test %u: GetMonitorInfoW failed, error %#x.\n", adapter_idx,
|
||||
test_idx, GetLastError());
|
||||
width = monitor_info.rcMonitor.right - monitor_info.rcMonitor.left;
|
||||
height = monitor_info.rcMonitor.bottom - monitor_info.rcMonitor.top;
|
||||
|
||||
if (adapter_idx)
|
||||
{
|
||||
/* Move the device window to the previous monitor to test that the device window
|
||||
* position doesn't affect which adapter to use to get the display mode */
|
||||
ret = SetWindowPos(window, 0, previous_monitor_rect.left, previous_monitor_rect.top,
|
||||
0, 0, SWP_NOZORDER | SWP_NOSIZE);
|
||||
ok(ret, "Adapter %u test %u: SetWindowPos failed, error %#x.\n", adapter_idx,
|
||||
test_idx, GetLastError());
|
||||
}
|
||||
|
||||
hr = IDirect3D8_GetAdapterDisplayMode(d3d, adapter_idx, &mode);
|
||||
ok(hr == D3D_OK, "Adapter %u test %u: GetAdapterDisplayMode failed, hr %#x.\n",
|
||||
adapter_idx, test_idx, hr);
|
||||
ok(mode.Width == width, "Adapter %u test %u: Expect width %u, got %u.\n", adapter_idx,
|
||||
test_idx, width, mode.Width);
|
||||
ok(mode.Height == height, "Adapter %u test %u: Expect height %u, got %u.\n",
|
||||
adapter_idx, test_idx, height, mode.Height);
|
||||
|
||||
hr = IDirect3DDevice8_GetDisplayMode(device, &mode);
|
||||
ok(hr == D3D_OK, "Adapter %u test %u: GetDisplayMode failed, hr %#x.\n", adapter_idx,
|
||||
test_idx, hr);
|
||||
ok(mode.Width == width, "Adapter %u test %u: Expect width %u, got %u.\n", adapter_idx,
|
||||
test_idx, width, mode.Width);
|
||||
ok(mode.Height == height, "Adapter %u test %u: Expect height %u, got %u.\n",
|
||||
adapter_idx, test_idx, height, mode.Height);
|
||||
|
||||
refcount = IDirect3DDevice8_Release(device);
|
||||
ok(!refcount, "Adapter %u test %u: Device has %u references left.\n", adapter_idx,
|
||||
test_idx, refcount);
|
||||
DestroyWindow(window);
|
||||
}
|
||||
}
|
||||
|
||||
IDirect3D8_Release(d3d);
|
||||
}
|
||||
|
||||
static void test_multi_adapter(void)
|
||||
|
|
Loading…
Reference in New Issue