Commit 2b31cac6 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

d3d8/tests: Allow passing a resolution to reset_device.

parent bc47d492
......@@ -136,19 +136,27 @@ static IDirect3DDevice8 *create_device(IDirect3D8 *d3d8, HWND focus_window, cons
return NULL;
}
static HRESULT reset_device(IDirect3DDevice8 *device, HWND device_window, BOOL windowed)
static HRESULT reset_device(IDirect3DDevice8 *device, const struct device_desc *desc)
{
D3DPRESENT_PARAMETERS present_parameters = {0};
present_parameters.Windowed = windowed;
present_parameters.hDeviceWindow = device_window;
present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
present_parameters.BackBufferWidth = registry_mode.dmPelsWidth;
present_parameters.BackBufferHeight = registry_mode.dmPelsHeight;
present_parameters.BackBufferWidth = 640;
present_parameters.BackBufferHeight = 480;
present_parameters.BackBufferFormat = D3DFMT_A8R8G8B8;
present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
present_parameters.hDeviceWindow = NULL;
present_parameters.Windowed = TRUE;
present_parameters.EnableAutoDepthStencil = TRUE;
present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8;
if (desc)
{
present_parameters.BackBufferWidth = desc->width;
present_parameters.BackBufferHeight = desc->height;
present_parameters.hDeviceWindow = desc->device_window;
present_parameters.Windowed = !(desc->flags & CREATE_DEVICE_FULLSCREEN);
}
return IDirect3DDevice8_Reset(device, &present_parameters);
}
......@@ -2424,8 +2432,8 @@ static void test_wndproc_windowed(void)
filter_messages = focus_window;
device_desc.device_window = device_window;
device_desc.width = 640;
device_desc.height = 480;
device_desc.width = registry_mode.dmPelsWidth;
device_desc.height = registry_mode.dmPelsHeight;
device_desc.flags = 0;
if (!(device = create_device(d3d8, focus_window, &device_desc)))
{
......@@ -2449,7 +2457,8 @@ static void test_wndproc_windowed(void)
filter_messages = NULL;
hr = reset_device(device, device_window, FALSE);
device_desc.flags = CREATE_DEVICE_FULLSCREEN;
hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
......@@ -2459,7 +2468,8 @@ static void test_wndproc_windowed(void)
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
hr = reset_device(device, device_window, TRUE);
device_desc.flags = 0;
hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
......@@ -2486,7 +2496,8 @@ static void test_wndproc_windowed(void)
filter_messages = NULL;
hr = reset_device(device, focus_window, FALSE);
device_desc.flags = CREATE_DEVICE_FULLSCREEN;
hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
......@@ -2496,7 +2507,8 @@ static void test_wndproc_windowed(void)
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
hr = reset_device(device, focus_window, TRUE);
device_desc.flags = 0;
hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
......@@ -2521,7 +2533,8 @@ static void test_wndproc_windowed(void)
filter_messages = NULL;
hr = reset_device(device, device_window, FALSE);
device_desc.flags = CREATE_DEVICE_FULLSCREEN;
hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
......@@ -2531,7 +2544,8 @@ static void test_wndproc_windowed(void)
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
hr = reset_device(device, device_window, TRUE);
device_desc.flags = 0;
hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
......@@ -2830,7 +2844,8 @@ static void test_window_style(void)
focus_rect.left, focus_rect.top, focus_rect.right, focus_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = reset_device(device, device_window, TRUE);
device_desc.flags = 0;
hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
style = GetWindowLongA(device_window, GWL_STYLE);
......@@ -3205,7 +3220,8 @@ static void test_device_window_reset(void)
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
hr = reset_device(device, device_window, FALSE);
device_desc.device_window = device_window;
hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device.\n");
GetWindowRect(focus_window, &r);
......@@ -3340,7 +3356,7 @@ static void test_reset_resources(void)
IDirect3DSurface8_Release(rt);
IDirect3DSurface8_Release(surface);
hr = reset_device(device, device_window, TRUE);
hr = reset_device(device, NULL);
ok(SUCCEEDED(hr), "Failed to reset device.\n");
hr = IDirect3DDevice8_GetBackBuffer(device, 0, D3DBACKBUFFER_TYPE_MONO, &rt);
......@@ -6506,14 +6522,15 @@ static void test_lost_device(void)
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
hr = reset_device(device, window, FALSE);
hr = reset_device(device, &device_desc);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice8_TestCooperativeLevel(device);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = reset_device(device, window, TRUE);
device_desc.flags = 0;
hr = reset_device(device, &device_desc);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice8_TestCooperativeLevel(device);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
......@@ -6534,7 +6551,8 @@ static void test_lost_device(void)
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = reset_device(device, window, FALSE);
device_desc.flags = CREATE_DEVICE_FULLSCREEN;
hr = reset_device(device, &device_desc);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice8_TestCooperativeLevel(device);
todo_wine ok(hr == D3DERR_DEVICELOST, "Got unexpected 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