From 975a686aa0ef178447216c8ab2e2c945e145832e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Thu, 19 Oct 2017 10:09:20 +0200 Subject: [PATCH] d3d9/tests: Make test_reset more resilient against DPI scaling. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stefan Dösinger Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/d3d9/tests/d3d9ex.c | 53 ++++++++++++++++++++++++++-------------- dlls/d3d9/tests/device.c | 23 +++++++++++------ 2 files changed, 51 insertions(+), 25 deletions(-) diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c index a3cbdbfadff..59a1daf3c94 100644 --- a/dlls/d3d9/tests/d3d9ex.c +++ b/dlls/d3d9/tests/d3d9ex.c @@ -934,7 +934,7 @@ static void test_reset(void) DWORD value; HWND window; HRESULT hr; - RECT rect; + RECT rect, client_rect; LONG ret; struct { @@ -1194,6 +1194,9 @@ static void test_reset(void) ok(SetWindowPos(window, NULL, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER), "Failed to set window position.\n"); + /* Windows 10 gives us a different size than we requested with some DPI scaling settings (e.g. 172%). */ + ok(GetClientRect(window, &client_rect), "Failed to get client rect.\n"); + memset(&d3dpp, 0, sizeof(d3dpp)); d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.Windowed = TRUE; @@ -1205,8 +1208,10 @@ static void test_reset(void) hr = IDirect3DDevice9Ex_TestCooperativeLevel(device); ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr); - ok(d3dpp.BackBufferWidth == 200, "Got unexpected BackBufferWidth %u.\n", d3dpp.BackBufferWidth); - ok(d3dpp.BackBufferHeight == 150, "Got unexpected BackBufferHeight %u.\n", d3dpp.BackBufferHeight); + ok(d3dpp.BackBufferWidth == client_rect.right, + "Got unexpected BackBufferWidth %u, expected %d.\n", d3dpp.BackBufferWidth, client_rect.right); + ok(d3dpp.BackBufferHeight == client_rect.bottom, + "Got unexpected BackBufferHeight %u, expected %d.\n", d3dpp.BackBufferHeight, client_rect.bottom); ok(d3dpp.BackBufferFormat == d3ddm.Format, "Got unexpected BackBufferFormat %#x, expected %#x.\n", d3dpp.BackBufferFormat, d3ddm.Format); ok(d3dpp.BackBufferCount == 1, "Got unexpected BackBufferCount %u.\n", d3dpp.BackBufferCount); @@ -1224,15 +1229,16 @@ static void test_reset(void) hr = IDirect3DDevice9Ex_GetScissorRect(device, &rect); ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#x.\n", hr); - ok(rect.left == 0 && rect.top == 0 && rect.right == 200 && rect.bottom == 150, - "Got unexpected scissor rect %s.\n", wine_dbgstr_rect(&rect)); + ok(EqualRect(&rect, &client_rect), "Got unexpected scissor rect %s.\n", wine_dbgstr_rect(&rect)); hr = IDirect3DDevice9Ex_GetViewport(device, &vp); ok(SUCCEEDED(hr), "Failed to get viewport, hr %#x.\n", hr); ok(vp.X == 0, "Got unexpected vp.X %u.\n", vp.X); ok(vp.Y == 0, "Got unexpected vp.Y %u.\n", vp.Y); - ok(vp.Width == 200, "Got unexpected vp.Width %u.\n", vp.Width); - ok(vp.Height == 150, "Got unexpected vp.Height %u.\n", vp.Height); + ok(vp.Width == client_rect.right, "Got unexpected vp.Width %u, expected %d.\n", + vp.Width, client_rect.right); + ok(vp.Height == client_rect.bottom, "Got unexpected vp.Height %u, expected %d.\n", + vp.Height, client_rect.bottom); ok(vp.MinZ == 2.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ); ok(vp.MaxZ == 3.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ); @@ -1240,8 +1246,10 @@ static void test_reset(void) ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr); hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp); ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x.\n", hr); - ok(d3dpp.BackBufferWidth == 200, "Got unexpected backbuffer width %u.\n", d3dpp.BackBufferWidth); - ok(d3dpp.BackBufferHeight == 150, "Got unexpected backbuffer height %u.\n", d3dpp.BackBufferHeight); + ok(d3dpp.BackBufferWidth == client_rect.right, "Got unexpected backbuffer width %u, expected %d.\n", + d3dpp.BackBufferWidth, client_rect.right); + ok(d3dpp.BackBufferHeight == client_rect.bottom, "Got unexpected backbuffer height %u, expected %d.\n", + d3dpp.BackBufferHeight, client_rect.bottom); ok(d3dpp.BackBufferFormat == d3ddm.Format, "Got unexpected BackBufferFormat %#x, expected %#x.\n", d3dpp.BackBufferFormat, d3ddm.Format); ok(d3dpp.BackBufferCount == 1, "Got unexpected BackBufferCount %u.\n", d3dpp.BackBufferCount); @@ -1403,7 +1411,7 @@ static void test_reset_ex(void) DWORD value; HWND window; HRESULT hr; - RECT rect; + RECT rect, client_rect; LONG ret; window = create_window(); @@ -1728,6 +1736,9 @@ static void test_reset_ex(void) ok(SetWindowPos(window, NULL, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER), "Failed to set window position.\n"); + /* Windows 10 gives us a different size than we requested with some DPI scaling settings (e.g. 172%). */ + ok(GetClientRect(window, &client_rect), "Failed to get client rect.\n"); + memset(&d3dpp, 0, sizeof(d3dpp)); d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.Windowed = TRUE; @@ -1739,8 +1750,10 @@ static void test_reset_ex(void) hr = IDirect3DDevice9Ex_TestCooperativeLevel(device); ok(hr == D3D_OK, "Got unexpected cooperative level %#x.\n", hr); - ok(d3dpp.BackBufferWidth == 200, "Got unexpected BackBufferWidth %u.\n", d3dpp.BackBufferWidth); - ok(d3dpp.BackBufferHeight == 150, "Got unexpected BackBufferHeight %u.\n", d3dpp.BackBufferHeight); + ok(d3dpp.BackBufferWidth == client_rect.right, + "Got unexpected BackBufferWidth %u, expected %d.\n", d3dpp.BackBufferWidth, client_rect.right); + ok(d3dpp.BackBufferHeight == client_rect.bottom, + "Got unexpected BackBufferHeight %u, expected %d.\n", d3dpp.BackBufferHeight, client_rect.bottom); ok(d3dpp.BackBufferFormat == mode.Format, "Got unexpected BackBufferFormat %#x, expected %#x.\n", d3dpp.BackBufferFormat, mode.Format); ok(d3dpp.BackBufferCount == 1, "Got unexpected BackBufferCount %u.\n", d3dpp.BackBufferCount); @@ -1758,15 +1771,17 @@ static void test_reset_ex(void) hr = IDirect3DDevice9Ex_GetScissorRect(device, &rect); ok(SUCCEEDED(hr), "Failed to get scissor rect, hr %#x.\n", hr); - ok(rect.left == 0 && rect.top == 0 && rect.right == 200 && rect.bottom == 150, - "Got unexpected scissor rect %s.\n", wine_dbgstr_rect(&rect)); + ok(EqualRect(&rect, &client_rect), "Got unexpected scissor rect %s, expected %s.\n", + wine_dbgstr_rect(&rect), wine_dbgstr_rect(&client_rect)); hr = IDirect3DDevice9Ex_GetViewport(device, &vp); ok(SUCCEEDED(hr), "Failed to get viewport, hr %#x.\n", hr); ok(vp.X == 0, "Got unexpected vp.X %u.\n", vp.X); ok(vp.Y == 0, "Got unexpected vp.Y %u.\n", vp.Y); - ok(vp.Width == 200, "Got unexpected vp.Width %u.\n", vp.Width); - ok(vp.Height == 150, "Got unexpected vp.Height %u.\n", vp.Height); + ok(vp.Width == client_rect.right, "Got unexpected vp.Width %u, expected %d.\n", + vp.Width, client_rect.right); + ok(vp.Height == client_rect.bottom, "Got unexpected vp.Height %u, expected %d.\n", + vp.Height, client_rect.bottom); ok(vp.MinZ == 2.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ); ok(vp.MaxZ == 3.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ); @@ -1774,8 +1789,10 @@ static void test_reset_ex(void) ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr); hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp); ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x.\n", hr); - ok(d3dpp.BackBufferWidth == 200, "Got unexpected backbuffer width %u.\n", d3dpp.BackBufferWidth); - ok(d3dpp.BackBufferHeight == 150, "Got unexpected backbuffer height %u.\n", d3dpp.BackBufferHeight); + ok(d3dpp.BackBufferWidth == client_rect.right, + "Got unexpected backbuffer width %u, expected %d.\n", d3dpp.BackBufferWidth, client_rect.right); + ok(d3dpp.BackBufferHeight == client_rect.bottom, + "Got unexpected backbuffer height %u, expected %d.\n", d3dpp.BackBufferHeight, client_rect.bottom); ok(d3dpp.BackBufferFormat == mode.Format, "Got unexpected BackBufferFormat %#x, expected %#x.\n", d3dpp.BackBufferFormat, mode.Format); ok(d3dpp.BackBufferCount == 1, "Got unexpected BackBufferCount %u.\n", d3dpp.BackBufferCount); diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index 3580a22c95e..8f9985c2a83 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -1817,7 +1817,7 @@ cleanup: static void test_reset(void) { HRESULT hr; - RECT winrect; + RECT winrect, client_rect; D3DPRESENT_PARAMETERS d3dpp; D3DDISPLAYMODE d3ddm, d3ddm2; D3DVIEWPORT9 vp; @@ -2072,6 +2072,9 @@ static void test_reset(void) SWP_NOMOVE|SWP_NOZORDER), "SetWindowPos failed\n"); + /* Windows 10 gives us a different size than we requested with some DPI scaling settings (e.g. 172%). */ + GetClientRect(hwnd, &client_rect); + ZeroMemory( &d3dpp, sizeof(d3dpp) ); d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.Windowed = TRUE; @@ -2083,8 +2086,10 @@ static void test_reset(void) hr = IDirect3DDevice9_TestCooperativeLevel(device1); ok(hr == D3D_OK, "IDirect3DDevice9_TestCooperativeLevel after a successful reset returned %#x\n", hr); - ok(d3dpp.BackBufferWidth == 200, "Got unexpected BackBufferWidth %u.\n", d3dpp.BackBufferWidth); - ok(d3dpp.BackBufferHeight == 150, "Got unexpected BackBufferHeight %u.\n", d3dpp.BackBufferHeight); + ok(d3dpp.BackBufferWidth == client_rect.right, "Got unexpected BackBufferWidth %u, expected %d.\n", + d3dpp.BackBufferWidth, client_rect.right); + ok(d3dpp.BackBufferHeight == client_rect.bottom, "Got unexpected BackBufferHeight %u, expected %d.\n", + d3dpp.BackBufferHeight, client_rect.bottom); ok(d3dpp.BackBufferFormat == d3ddm.Format, "Got unexpected BackBufferFormat %#x, expected %#x.\n", d3dpp.BackBufferFormat, d3ddm.Format); ok(d3dpp.BackBufferCount == 1, "Got unexpected BackBufferCount %u.\n", d3dpp.BackBufferCount); @@ -2105,8 +2110,10 @@ static void test_reset(void) ok(hr == D3D_OK, "IDirect3DDevice9_GetViewport failed with %08x\n", hr); ok(vp.X == 0, "D3DVIEWPORT->X = %d\n", vp.X); ok(vp.Y == 0, "D3DVIEWPORT->Y = %d\n", vp.Y); - ok(vp.Width == 200, "D3DVIEWPORT->Width = %d\n", vp.Width); - ok(vp.Height == 150, "D3DVIEWPORT->Height = %d\n", vp.Height); + ok(vp.Width == client_rect.right, "D3DVIEWPORT->Width = %d, expected %d\n", + vp.Width, client_rect.right); + ok(vp.Height == client_rect.bottom, "D3DVIEWPORT->Height = %d, expected %d\n", + vp.Height, client_rect.bottom); ok(vp.MinZ == 0, "D3DVIEWPORT->MinZ = %f\n", vp.MinZ); ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %f\n", vp.MaxZ); @@ -2115,8 +2122,10 @@ static void test_reset(void) memset(&d3dpp, 0, sizeof(d3dpp)); hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &d3dpp); ok(SUCCEEDED(hr), "Failed to get present parameters, hr %#x.\n", hr); - ok(d3dpp.BackBufferWidth == 200, "Got unexpected BackBufferWidth %u.\n", d3dpp.BackBufferWidth); - ok(d3dpp.BackBufferHeight == 150, "Got unexpected BackBufferHeight %u.\n", d3dpp.BackBufferHeight); + ok(d3dpp.BackBufferWidth == client_rect.right, + "Got unexpected BackBufferWidth %u, expected %d.\n", d3dpp.BackBufferWidth, client_rect.right); + ok(d3dpp.BackBufferHeight == client_rect.bottom, + "Got unexpected BackBufferHeight %u, expected %d.\n", d3dpp.BackBufferHeight, client_rect.bottom); ok(d3dpp.BackBufferFormat == d3ddm.Format, "Got unexpected BackBufferFormat %#x, expected %#x.\n", d3dpp.BackBufferFormat, d3ddm.Format); ok(d3dpp.BackBufferCount == 1, "Got unexpected BackBufferCount %u.\n", d3dpp.BackBufferCount);