Module: wine Branch: master Commit: b2e8ca902b987688ad26acee56f95599622ead72 URL: http://source.winehq.org/git/wine.git/?a=commit;h=b2e8ca902b987688ad26acee56...
Author: Józef Kucia jkucia@codeweavers.com Date: Mon Aug 22 14:53:46 2016 +0200
d3d8/tests: Add test for regression in IDirect3DDevice8_Reset().
This adds a test for regression introduced in cad279449c62a965a70a712a91b11ba52c4ff4f7.
Signed-off-by: Józef Kucia jkucia@codeweavers.com Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/d3d8/tests/device.c | 102 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 75 insertions(+), 27 deletions(-)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index 711c357..2f9c267 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -1284,6 +1284,7 @@ static void test_reset(void) UINT adapter_mode_count; D3DLOCKED_RECT lockrect; UINT mode_count = 0; + DEVMODEW devmode; IDirect3D8 *d3d8; RECT winrect; D3DVIEWPORT8 vp; @@ -1292,6 +1293,7 @@ static void test_reset(void) DWORD value; HWND window; HRESULT hr; + LONG ret; UINT i;
static const DWORD decl[] = @@ -1387,15 +1389,12 @@ static void test_reset(void)
hr = IDirect3DDevice8_GetViewport(device1, &vp); ok(SUCCEEDED(hr), "GetViewport failed, hr %#x.\n", hr); - if (SUCCEEDED(hr)) - { - ok(vp.X == 0, "D3DVIEWPORT->X = %u, expected 0.\n", vp.X); - ok(vp.Y == 0, "D3DVIEWPORT->Y = %u, expected 0.\n", vp.Y); - ok(vp.Width == modes[i].w, "D3DVIEWPORT->Width = %u, expected %u.\n", vp.Width, modes[i].w); - ok(vp.Height == modes[i].h, "D3DVIEWPORT->Height = %u, expected %u.\n", vp.Height, modes[i].h); - ok(vp.MinZ == 0, "D3DVIEWPORT->MinZ = %.8e, expected 0.\n", vp.MinZ); - ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %.8e, expected 1.\n", vp.MaxZ); - } + ok(vp.X == 0, "D3DVIEWPORT->X = %u, expected 0.\n", vp.X); + ok(vp.Y == 0, "D3DVIEWPORT->Y = %u, expected 0.\n", vp.Y); + ok(vp.Width == modes[i].w, "D3DVIEWPORT->Width = %u, expected %u.\n", vp.Width, modes[i].w); + ok(vp.Height == modes[i].h, "D3DVIEWPORT->Height = %u, expected %u.\n", vp.Height, modes[i].h); + ok(vp.MinZ == 0, "D3DVIEWPORT->MinZ = %.8e, expected 0.\n", vp.MinZ); + ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %.8e, expected 1.\n", vp.MaxZ);
i = 1; vp.X = 10; @@ -1431,15 +1430,12 @@ static void test_reset(void) memset(&vp, 0, sizeof(vp)); hr = IDirect3DDevice8_GetViewport(device1, &vp); ok(SUCCEEDED(hr), "GetViewport failed, hr %#x.\n", hr); - if (SUCCEEDED(hr)) - { - ok(vp.X == 0, "D3DVIEWPORT->X = %u, expected 0.\n", vp.X); - ok(vp.Y == 0, "D3DVIEWPORT->Y = %u, expected 0.\n", vp.Y); - ok(vp.Width == modes[i].w, "D3DVIEWPORT->Width = %u, expected %u.\n", vp.Width, modes[i].w); - ok(vp.Height == modes[i].h, "D3DVIEWPORT->Height = %u, expected %u.\n", vp.Height, modes[i].h); - ok(vp.MinZ == 0, "D3DVIEWPORT->MinZ = %.8e, expected 0.\n", vp.MinZ); - ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %.8e, expected 1.\n", vp.MaxZ); - } + ok(vp.X == 0, "D3DVIEWPORT->X = %u, expected 0.\n", vp.X); + ok(vp.Y == 0, "D3DVIEWPORT->Y = %u, expected 0.\n", vp.Y); + ok(vp.Width == modes[i].w, "D3DVIEWPORT->Width = %u, expected %u.\n", vp.Width, modes[i].w); + ok(vp.Height == modes[i].h, "D3DVIEWPORT->Height = %u, expected %u.\n", vp.Height, modes[i].h); + ok(vp.MinZ == 0, "D3DVIEWPORT->MinZ = %.8e, expected 0.\n", vp.MinZ); + ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %.8e, expected 1.\n", vp.MaxZ);
width = GetSystemMetrics(SM_CXSCREEN); height = GetSystemMetrics(SM_CYSCREEN); @@ -1470,15 +1466,12 @@ static void test_reset(void) memset(&vp, 0, sizeof(vp)); hr = IDirect3DDevice8_GetViewport(device1, &vp); ok(SUCCEEDED(hr), "GetViewport failed, hr %#x.\n", hr); - if (SUCCEEDED(hr)) - { - ok(vp.X == 0, "D3DVIEWPORT->X = %u, expected 0.\n", vp.X); - ok(vp.Y == 0, "D3DVIEWPORT->Y = %u, expected 0.\n", vp.Y); - ok(vp.Width == 400, "D3DVIEWPORT->Width = %u, expected 400.\n", vp.Width); - ok(vp.Height == 300, "D3DVIEWPORT->Height = %u, expected 300.\n", vp.Height); - ok(vp.MinZ == 0, "D3DVIEWPORT->MinZ = %.8e, expected 0.\n", vp.MinZ); - ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %.8e, expected 1.\n", vp.MaxZ); - } + ok(vp.X == 0, "D3DVIEWPORT->X = %u, expected 0.\n", vp.X); + ok(vp.Y == 0, "D3DVIEWPORT->Y = %u, expected 0.\n", vp.Y); + ok(vp.Width == 400, "D3DVIEWPORT->Width = %u, expected 400.\n", vp.Width); + ok(vp.Height == 300, "D3DVIEWPORT->Height = %u, expected 300.\n", vp.Height); + ok(vp.MinZ == 0, "D3DVIEWPORT->MinZ = %.8e, expected 0.\n", vp.MinZ); + ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %.8e, expected 1.\n", vp.MaxZ);
width = GetSystemMetrics(SM_CXSCREEN); height = GetSystemMetrics(SM_CYSCREEN); @@ -1495,6 +1488,61 @@ static void test_reset(void) surface_desc.Height); IDirect3DSurface8_Release(surface);
+ memset(&devmode, 0, sizeof(devmode)); + devmode.dmSize = sizeof(devmode); + devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; + devmode.dmPelsWidth = modes[1].w; + devmode.dmPelsHeight = modes[1].h; + ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN); + ok(ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", ret); + width = GetSystemMetrics(SM_CXSCREEN); + height = GetSystemMetrics(SM_CYSCREEN); + ok(width == modes[1].w, "Screen width is %u, expected %u.\n", width, modes[1].w); + ok(height == modes[1].h, "Screen height is %u, expected %u.\n", height, modes[1].h); + + d3dpp.BackBufferWidth = 500; + d3dpp.BackBufferHeight = 400; + d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8; + hr = IDirect3DDevice8_Reset(device1, &d3dpp); + ok(SUCCEEDED(hr), "Reset failed, hr %#x.\n", hr); + hr = IDirect3DDevice8_TestCooperativeLevel(device1); + ok(SUCCEEDED(hr), "TestCooperativeLevel failed, hr %#x.\n", hr); + + width = GetSystemMetrics(SM_CXSCREEN); + height = GetSystemMetrics(SM_CYSCREEN); + ok(width == modes[1].w, "Screen width is %u, expected %u.\n", width, modes[1].w); + ok(height == modes[1].h, "Screen height is %u, expected %u.\n", height, modes[1].h); + + ZeroMemory(&vp, sizeof(vp)); + hr = IDirect3DDevice8_GetViewport(device1, &vp); + ok(SUCCEEDED(hr), "GetViewport failed, hr %#x.\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 == 500, "D3DVIEWPORT->Width = %d.\n", vp.Width); + ok(vp.Height == 400, "D3DVIEWPORT->Height = %d.\n", vp.Height); + ok(vp.MinZ == 0, "D3DVIEWPORT->MinZ = %f.\n", vp.MinZ); + ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %f.\n", vp.MaxZ); + + hr = IDirect3DDevice8_GetRenderTarget(device1, &surface); + ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr); + hr = IDirect3DSurface8_GetDesc(surface, &surface_desc); + ok(hr == D3D_OK, "GetDesc failed, hr %#x.\n", hr); + ok(surface_desc.Width == 500, "Back buffer width is %u, expected 500.\n", + surface_desc.Width); + ok(surface_desc.Height == 400, "Back buffer height is %u, expected 400.\n", + surface_desc.Height); + IDirect3DSurface8_Release(surface); + + devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; + devmode.dmPelsWidth = orig_width; + devmode.dmPelsHeight = orig_height; + ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN); + ok(ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", ret); + width = GetSystemMetrics(SM_CXSCREEN); + height = GetSystemMetrics(SM_CYSCREEN); + ok(width == orig_width, "Got screen width %u, expected %u.\n", width, orig_width); + ok(height == orig_height, "Got screen height %u, expected %u.\n", height, orig_height); + winrect.left = 0; winrect.top = 0; winrect.right = 200;