Commit 7d836b3f authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

d3d9/tests: Add test for regression in IDirect3DDevice9_Reset().

This adds a test for regression introduced in cad27944. Signed-off-by: 's avatarJózef Kucia <jkucia@codeweavers.com> Signed-off-by: 's avatarHenri Verbeet <hverbeet@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 51021faa
......@@ -920,6 +920,7 @@ static void test_reset(void)
IDirect3DDevice9Ex *device;
IDirect3DSurface9 *surface;
UINT i, adapter_mode_count;
DEVMODEW devmode;
IDirect3D9 *d3d9;
D3DVIEWPORT9 vp;
D3DCAPS9 caps;
......@@ -928,6 +929,7 @@ static void test_reset(void)
HWND window;
HRESULT hr;
RECT rect;
LONG ret;
struct
{
UINT w;
......@@ -1020,7 +1022,7 @@ static void test_reset(void)
ok(vp.Width == modes[i].w, "Got vp.Width %u, expected %u.\n", vp.Width, modes[i].w);
ok(vp.Height == modes[i].h, "Got vp.Height %u, expected %u.\n", vp.Height, modes[i].h);
ok(vp.MinZ == 0.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ);
ok(vp.MaxZ == 1.0f, "Got unexpected vp,MaxZ %.8e.\n", vp.MaxZ);
ok(vp.MaxZ == 1.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ);
i = 1;
vp.X = 10;
......@@ -1068,7 +1070,7 @@ static void test_reset(void)
ok(vp.Width == modes[i].w, "Got vp.Width %u, expected %u.\n", vp.Width, modes[i].w);
ok(vp.Height == modes[i].h, "Got vp.Height %u, expected %u.\n", vp.Height, modes[i].h);
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);
ok(vp.MaxZ == 3.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ);
width = GetSystemMetrics(SM_CXSCREEN);
height = GetSystemMetrics(SM_CYSCREEN);
......@@ -1113,7 +1115,7 @@ static void test_reset(void)
ok(vp.Width == 400, "Got unexpected vp.Width %u.\n", vp.Width);
ok(vp.Height == 300, "Got unexpected vp.Height %u.\n", vp.Height);
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);
ok(vp.MaxZ == 3.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ);
hr = IDirect3DDevice9Ex_GetSwapChain(device, 0, &swapchain);
ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr);
......@@ -1123,6 +1125,64 @@ static void test_reset(void)
ok(d3dpp.BackBufferHeight == 300, "Got unexpected backbuffer height %u.\n", d3dpp.BackBufferHeight);
IDirect3DSwapChain9_Release(swapchain);
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 = IDirect3DDevice9Ex_Reset(device, &d3dpp);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
ok(hr == D3D_OK, "Got unexpected cooperative level %#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);
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 == 500 && rect.bottom == 400,
"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 == 500, "Got unexpected vp.Width %u.\n", vp.Width);
ok(vp.Height == 400, "Got unexpected vp.Height %u.\n", vp.Height);
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);
hr = IDirect3DDevice9Ex_GetSwapChain(device, 0, &swapchain);
ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr);
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 == 500, "Got unexpected BackBufferWidth %u.\n", d3dpp.BackBufferWidth);
ok(d3dpp.BackBufferHeight == 400, "Got unexpected BackBufferHeight %u.\n", d3dpp.BackBufferHeight);
IDirect3DSwapChain9_Release(swapchain);
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);
SetRect(&rect, 0, 0, 200, 150);
ok(AdjustWindowRect(&rect, GetWindowLongW(window, GWL_STYLE), FALSE), "Failed to adjust window rect.\n");
ok(SetWindowPos(window, NULL, 0, 0, rect.right - rect.left, rect.bottom - rect.top,
......@@ -1168,7 +1228,7 @@ static void test_reset(void)
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.MinZ == 2.0f, "Got unexpected vp.MinZ %.8e.\n", vp.MinZ);
ok(vp.MaxZ == 3.0f, "Got unexpected vp,MaxZ %.8e.\n", vp.MaxZ);
ok(vp.MaxZ == 3.0f, "Got unexpected vp.MaxZ %.8e.\n", vp.MaxZ);
hr = IDirect3DDevice9Ex_GetSwapChain(device, 0, &swapchain);
ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr);
......
......@@ -1805,10 +1805,12 @@ static void test_reset(void)
IDirect3DDevice9 *device2 = NULL;
IDirect3DSwapChain9 *swapchain;
struct device_desc device_desc;
DEVMODEW devmode;
IDirect3D9 *d3d;
D3DCAPS9 caps;
DWORD value;
HWND hwnd;
LONG ret;
struct
{
UINT w;
......@@ -1884,15 +1886,12 @@ static void test_reset(void)
hr = IDirect3DDevice9_GetViewport(device1, &vp);
ok(hr == D3D_OK, "IDirect3DDevice9_GetViewport failed with %08x\n", hr);
if(SUCCEEDED(hr))
{
ok(vp.X == 0, "D3DVIEWPORT->X = %d\n", vp.X);
ok(vp.Y == 0, "D3DVIEWPORT->Y = %d\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 = %f\n", vp.MinZ);
ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %f\n", vp.MaxZ);
}
ok(vp.X == 0, "D3DVIEWPORT->X = %d\n", vp.X);
ok(vp.Y == 0, "D3DVIEWPORT->Y = %d\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 = %f\n", vp.MinZ);
ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %f\n", vp.MaxZ);
i = 1;
vp.X = 10;
......@@ -1926,15 +1925,12 @@ static void test_reset(void)
ZeroMemory(&vp, sizeof(vp));
hr = IDirect3DDevice9_GetViewport(device1, &vp);
ok(hr == D3D_OK, "IDirect3DDevice9_GetViewport failed with %08x\n", hr);
if(SUCCEEDED(hr))
{
ok(vp.X == 0, "D3DVIEWPORT->X = %d\n", vp.X);
ok(vp.Y == 0, "D3DVIEWPORT->Y = %d\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 = %f\n", vp.MinZ);
ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %f\n", vp.MaxZ);
}
ok(vp.X == 0, "D3DVIEWPORT->X = %d\n", vp.X);
ok(vp.Y == 0, "D3DVIEWPORT->Y = %d\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 = %f\n", vp.MinZ);
ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %f\n", vp.MaxZ);
width = GetSystemMetrics(SM_CXSCREEN);
height = GetSystemMetrics(SM_CYSCREEN);
......@@ -1971,15 +1967,12 @@ static void test_reset(void)
ZeroMemory(&vp, sizeof(vp));
hr = IDirect3DDevice9_GetViewport(device1, &vp);
ok(hr == D3D_OK, "IDirect3DDevice9_GetViewport failed with %08x\n", hr);
if(SUCCEEDED(hr))
{
ok(vp.X == 0, "D3DVIEWPORT->X = %d\n", vp.X);
ok(vp.Y == 0, "D3DVIEWPORT->Y = %d\n", vp.Y);
ok(vp.Width == 400, "D3DVIEWPORT->Width = %d\n", vp.Width);
ok(vp.Height == 300, "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);
}
ok(vp.X == 0, "D3DVIEWPORT->X = %d\n", vp.X);
ok(vp.Y == 0, "D3DVIEWPORT->Y = %d\n", vp.Y);
ok(vp.Width == 400, "D3DVIEWPORT->Width = %d\n", vp.Width);
ok(vp.Height == 300, "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 = IDirect3DDevice9_GetSwapChain(device1, 0, &swapchain);
ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr);
......@@ -1990,6 +1983,60 @@ static void test_reset(void)
ok(d3dpp.BackBufferHeight == 300, "Got unexpected BackBufferHeight %u.\n", d3dpp.BackBufferHeight);
IDirect3DSwapChain9_Release(swapchain);
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 = IDirect3DDevice9_Reset(device1, &d3dpp);
ok(hr == D3D_OK, "IDirect3DDevice9_Reset failed, hr %#x.\n", hr);
hr = IDirect3DDevice9_TestCooperativeLevel(device1);
ok(hr == D3D_OK, "IDirect3DDevice9_TestCooperativeLevel after a successful reset returned %#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 = IDirect3DDevice9_GetViewport(device1, &vp);
ok(hr == D3D_OK, "IDirect3DDevice9_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 = IDirect3DDevice9_GetSwapChain(device1, 0, &swapchain);
ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr);
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 == 500, "Got unexpected BackBufferWidth %u.\n", d3dpp.BackBufferWidth);
ok(d3dpp.BackBufferHeight == 400, "Got unexpected BackBufferHeight %u.\n", d3dpp.BackBufferHeight);
IDirect3DSwapChain9_Release(swapchain);
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);
SetRect(&winrect, 0, 0, 200, 150);
ok(AdjustWindowRect(&winrect, WS_OVERLAPPEDWINDOW, FALSE), "AdjustWindowRect failed\n");
ok(SetWindowPos(hwnd, NULL, 0, 0,
......@@ -2029,15 +2076,12 @@ static void test_reset(void)
ZeroMemory(&vp, sizeof(vp));
hr = IDirect3DDevice9_GetViewport(device1, &vp);
ok(hr == D3D_OK, "IDirect3DDevice9_GetViewport failed with %08x\n", hr);
if(SUCCEEDED(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.MinZ == 0, "D3DVIEWPORT->MinZ = %f\n", vp.MinZ);
ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %f\n", vp.MaxZ);
}
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.MinZ == 0, "D3DVIEWPORT->MinZ = %f\n", vp.MinZ);
ok(vp.MaxZ == 1, "D3DVIEWPORT->MaxZ = %f\n", vp.MaxZ);
hr = IDirect3DDevice9_GetSwapChain(device1, 0, &swapchain);
ok(SUCCEEDED(hr), "Failed to get swapchain, hr %#x.\n", hr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment