d3d9/tests: Add window proc tests for switching between fullscreen and windowed.

This commit is contained in:
Henri Verbeet 2010-10-06 12:01:31 +02:00 committed by Alexandre Julliard
parent 4fa4ea7335
commit 9b42e7f7e3
1 changed files with 95 additions and 0 deletions

View File

@ -75,6 +75,22 @@ static IDirect3DDevice9 *create_device(IDirect3D9 *d3d9, HWND device_window, HWN
return NULL;
}
static HRESULT reset_device(IDirect3DDevice9 *device, HWND device_window, BOOL windowed)
{
D3DPRESENT_PARAMETERS present_parameters = {0};
present_parameters.Windowed = windowed;
present_parameters.hDeviceWindow = device_window;
present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
present_parameters.BackBufferWidth = 640;
present_parameters.BackBufferHeight = 480;
present_parameters.BackBufferFormat = D3DFMT_A8R8G8B8;
present_parameters.EnableAutoDepthStencil = TRUE;
present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8;
return IDirect3DDevice9_Reset(device, &present_parameters);
}
#define CHECK_CALL(r,c,d,rc) \
if (SUCCEEDED(r)) {\
int tmp1 = get_refcount( (IUnknown *)d ); \
@ -2550,6 +2566,7 @@ static void test_wndproc_windowed(void)
IDirect3D9 *d3d9;
HANDLE thread;
LONG_PTR proc;
HRESULT hr;
ULONG ref;
DWORD res, tid;
@ -2617,6 +2634,32 @@ static void test_wndproc_windowed(void)
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
(LONG_PTR)test_proc, proc);
filter_messages = NULL;
hr = reset_device(device, device_window, FALSE);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
(LONG_PTR)test_proc, proc);
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
(LONG_PTR)test_proc, proc);
hr = reset_device(device, device_window, TRUE);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
(LONG_PTR)test_proc, proc);
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
(LONG_PTR)test_proc, proc);
filter_messages = focus_window;
ref = IDirect3DDevice9_Release(device);
ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
@ -2629,6 +2672,32 @@ static void test_wndproc_windowed(void)
goto done;
}
filter_messages = NULL;
hr = reset_device(device, focus_window, FALSE);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
(LONG_PTR)test_proc, proc);
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
(LONG_PTR)test_proc, proc);
hr = reset_device(device, focus_window, TRUE);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
(LONG_PTR)test_proc, proc);
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
(LONG_PTR)test_proc, proc);
filter_messages = device_window;
ref = IDirect3DDevice9_Release(device);
ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
@ -2639,6 +2708,32 @@ static void test_wndproc_windowed(void)
goto done;
}
filter_messages = NULL;
hr = reset_device(device, device_window, FALSE);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
(LONG_PTR)test_proc, proc);
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
(LONG_PTR)test_proc, proc);
hr = reset_device(device, device_window, TRUE);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
(LONG_PTR)test_proc, proc);
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
(LONG_PTR)test_proc, proc);
filter_messages = device_window;
ref = IDirect3DDevice9_Release(device);
ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);