d3d8/tests: Extend the window proc / focus window tests.
This commit is contained in:
parent
d9381b97aa
commit
7aa5e90914
|
@ -1494,6 +1494,13 @@ struct
|
||||||
UINT message;
|
UINT message;
|
||||||
} expect_message;
|
} expect_message;
|
||||||
|
|
||||||
|
struct wndproc_thread_param
|
||||||
|
{
|
||||||
|
HWND dummy_window;
|
||||||
|
HANDLE window_created;
|
||||||
|
HANDLE test_finished;
|
||||||
|
};
|
||||||
|
|
||||||
static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
|
static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
if (filter_messages && filter_messages == hwnd)
|
if (filter_messages && filter_messages == hwnd)
|
||||||
|
@ -1506,14 +1513,37 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM
|
||||||
return DefWindowProcA(hwnd, message, wparam, lparam);
|
return DefWindowProcA(hwnd, message, wparam, lparam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DWORD WINAPI wndproc_thread(void *param)
|
||||||
|
{
|
||||||
|
struct wndproc_thread_param *p = param;
|
||||||
|
DWORD res;
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
|
p->dummy_window = CreateWindowA("d3d8_test_wndproc_wc", "d3d8_test",
|
||||||
|
WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, 640, 480, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
ret = SetEvent(p->window_created);
|
||||||
|
ok(ret, "SetEvent failed, last error %#x.\n", GetLastError());
|
||||||
|
|
||||||
|
res = WaitForSingleObject(p->test_finished, INFINITE);
|
||||||
|
ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
|
||||||
|
|
||||||
|
DestroyWindow(p->dummy_window);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void test_wndproc(void)
|
static void test_wndproc(void)
|
||||||
{
|
{
|
||||||
HWND device_window, focus_window, dummy_window, tmp;
|
struct wndproc_thread_param thread_params;
|
||||||
|
HWND device_window, focus_window, tmp;
|
||||||
IDirect3DDevice8 *device;
|
IDirect3DDevice8 *device;
|
||||||
WNDCLASSA wc = {0};
|
WNDCLASSA wc = {0};
|
||||||
IDirect3D8 *d3d8;
|
IDirect3D8 *d3d8;
|
||||||
|
HANDLE thread;
|
||||||
LONG_PTR proc;
|
LONG_PTR proc;
|
||||||
ULONG ref;
|
ULONG ref;
|
||||||
|
DWORD res;
|
||||||
|
|
||||||
if (!(d3d8 = pDirect3DCreate8(D3D_SDK_VERSION)))
|
if (!(d3d8 = pDirect3DCreate8(D3D_SDK_VERSION)))
|
||||||
{
|
{
|
||||||
|
@ -1525,12 +1555,20 @@ static void test_wndproc(void)
|
||||||
wc.lpszClassName = "d3d8_test_wndproc_wc";
|
wc.lpszClassName = "d3d8_test_wndproc_wc";
|
||||||
ok(RegisterClassA(&wc), "Failed to register window class.\n");
|
ok(RegisterClassA(&wc), "Failed to register window class.\n");
|
||||||
|
|
||||||
|
thread_params.window_created = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||||
|
ok(!!thread_params.window_created, "CreateEvent failed, last error %#x.\n", GetLastError());
|
||||||
|
thread_params.test_finished = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||||
|
ok(!!thread_params.test_finished, "CreateEvent failed, last error %#x.\n", GetLastError());
|
||||||
|
|
||||||
focus_window = CreateWindowA("d3d8_test_wndproc_wc", "d3d8_test",
|
focus_window = CreateWindowA("d3d8_test_wndproc_wc", "d3d8_test",
|
||||||
WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION , 0, 0, 640, 480, 0, 0, 0, 0);
|
WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION , 0, 0, 640, 480, 0, 0, 0, 0);
|
||||||
device_window = CreateWindowA("d3d8_test_wndproc_wc", "d3d8_test",
|
device_window = CreateWindowA("d3d8_test_wndproc_wc", "d3d8_test",
|
||||||
WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION , 0, 0, 640, 480, 0, 0, 0, 0);
|
WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION , 0, 0, 640, 480, 0, 0, 0, 0);
|
||||||
dummy_window = CreateWindowA("d3d8_test_wndproc_wc", "d3d8_test",
|
thread = CreateThread(NULL, 0, wndproc_thread, &thread_params, 0, NULL);
|
||||||
WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION , 0, 0, 640, 480, 0, 0, 0, 0);
|
ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError());
|
||||||
|
|
||||||
|
res = WaitForSingleObject(thread_params.window_created, INFINITE);
|
||||||
|
ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
|
||||||
|
|
||||||
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
|
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
|
||||||
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
|
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
|
||||||
|
@ -1539,10 +1577,14 @@ static void test_wndproc(void)
|
||||||
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
|
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
|
||||||
(LONG_PTR)test_proc, proc);
|
(LONG_PTR)test_proc, proc);
|
||||||
|
|
||||||
trace("device_window %p, focus_window %p, dummy_window %p.\n", device_window, focus_window, dummy_window);
|
trace("device_window %p, focus_window %p, dummy_window %p.\n",
|
||||||
|
device_window, focus_window, thread_params.dummy_window);
|
||||||
|
|
||||||
tmp = GetFocus();
|
tmp = GetFocus();
|
||||||
ok(tmp == dummy_window, "Expected focus %p, got %p.\n", dummy_window, tmp);
|
ok(tmp == device_window, "Expected focus %p, got %p.\n", device_window, tmp);
|
||||||
|
tmp = GetForegroundWindow();
|
||||||
|
ok(tmp == thread_params.dummy_window, "Expected foreground window %p, got %p.\n",
|
||||||
|
thread_params.dummy_window, tmp);
|
||||||
|
|
||||||
expect_message.window = focus_window;
|
expect_message.window = focus_window;
|
||||||
expect_message.message = WM_SETFOCUS;
|
expect_message.message = WM_SETFOCUS;
|
||||||
|
@ -1557,7 +1599,10 @@ static void test_wndproc(void)
|
||||||
ok(!expect_message.message, "Expected message %#x for window %p, but didn't receive it.\n",
|
ok(!expect_message.message, "Expected message %#x for window %p, but didn't receive it.\n",
|
||||||
expect_message.message, expect_message.window);
|
expect_message.message, expect_message.window);
|
||||||
tmp = GetFocus();
|
tmp = GetFocus();
|
||||||
ok(tmp == focus_window, "Expected focus %p, got %p.\n", focus_window, tmp);
|
todo_wine ok(tmp == focus_window, "Expected focus %p, got %p.\n", focus_window, tmp);
|
||||||
|
tmp = GetForegroundWindow();
|
||||||
|
todo_wine ok(tmp == focus_window, "Expected foreground window %p, got %p.\n", focus_window, tmp);
|
||||||
|
SetForegroundWindow(focus_window);
|
||||||
|
|
||||||
filter_messages = focus_window;
|
filter_messages = focus_window;
|
||||||
|
|
||||||
|
@ -1607,7 +1652,13 @@ static void test_wndproc(void)
|
||||||
done:
|
done:
|
||||||
filter_messages = NULL;
|
filter_messages = NULL;
|
||||||
IDirect3D8_Release(d3d8);
|
IDirect3D8_Release(d3d8);
|
||||||
DestroyWindow(dummy_window);
|
|
||||||
|
SetEvent(thread_params.test_finished);
|
||||||
|
WaitForSingleObject(thread, INFINITE);
|
||||||
|
CloseHandle(thread_params.test_finished);
|
||||||
|
CloseHandle(thread_params.window_created);
|
||||||
|
CloseHandle(thread);
|
||||||
|
|
||||||
DestroyWindow(device_window);
|
DestroyWindow(device_window);
|
||||||
DestroyWindow(focus_window);
|
DestroyWindow(focus_window);
|
||||||
UnregisterClassA("d3d8_test_wndproc_wc", GetModuleHandleA(NULL));
|
UnregisterClassA("d3d8_test_wndproc_wc", GetModuleHandleA(NULL));
|
||||||
|
@ -1615,12 +1666,15 @@ done:
|
||||||
|
|
||||||
static void test_wndproc_windowed(void)
|
static void test_wndproc_windowed(void)
|
||||||
{
|
{
|
||||||
HWND device_window, focus_window, dummy_window, tmp;
|
struct wndproc_thread_param thread_params;
|
||||||
|
HWND device_window, focus_window, tmp;
|
||||||
IDirect3DDevice8 *device;
|
IDirect3DDevice8 *device;
|
||||||
WNDCLASSA wc = {0};
|
WNDCLASSA wc = {0};
|
||||||
IDirect3D8 *d3d8;
|
IDirect3D8 *d3d8;
|
||||||
|
HANDLE thread;
|
||||||
LONG_PTR proc;
|
LONG_PTR proc;
|
||||||
ULONG ref;
|
ULONG ref;
|
||||||
|
DWORD res;
|
||||||
|
|
||||||
if (!(d3d8 = pDirect3DCreate8(D3D_SDK_VERSION)))
|
if (!(d3d8 = pDirect3DCreate8(D3D_SDK_VERSION)))
|
||||||
{
|
{
|
||||||
|
@ -1632,12 +1686,20 @@ static void test_wndproc_windowed(void)
|
||||||
wc.lpszClassName = "d3d8_test_wndproc_wc";
|
wc.lpszClassName = "d3d8_test_wndproc_wc";
|
||||||
ok(RegisterClassA(&wc), "Failed to register window class.\n");
|
ok(RegisterClassA(&wc), "Failed to register window class.\n");
|
||||||
|
|
||||||
|
thread_params.window_created = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||||
|
ok(!!thread_params.window_created, "CreateEvent failed, last error %#x.\n", GetLastError());
|
||||||
|
thread_params.test_finished = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||||
|
ok(!!thread_params.test_finished, "CreateEvent failed, last error %#x.\n", GetLastError());
|
||||||
|
|
||||||
focus_window = CreateWindowA("d3d8_test_wndproc_wc", "d3d8_test",
|
focus_window = CreateWindowA("d3d8_test_wndproc_wc", "d3d8_test",
|
||||||
WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, 640, 480, 0, 0, 0, 0);
|
WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, 640, 480, 0, 0, 0, 0);
|
||||||
device_window = CreateWindowA("d3d8_test_wndproc_wc", "d3d8_test",
|
device_window = CreateWindowA("d3d8_test_wndproc_wc", "d3d8_test",
|
||||||
WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, 640, 480, 0, 0, 0, 0);
|
WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, 640, 480, 0, 0, 0, 0);
|
||||||
dummy_window = CreateWindowA("d3d8_test_wndproc_wc", "d3d8_test",
|
thread = CreateThread(NULL, 0, wndproc_thread, &thread_params, 0, NULL);
|
||||||
WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, 640, 480, 0, 0, 0, 0);
|
ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError());
|
||||||
|
|
||||||
|
res = WaitForSingleObject(thread_params.window_created, INFINITE);
|
||||||
|
ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
|
||||||
|
|
||||||
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
|
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
|
||||||
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
|
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
|
||||||
|
@ -1646,10 +1708,14 @@ static void test_wndproc_windowed(void)
|
||||||
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
|
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
|
||||||
(LONG_PTR)test_proc, proc);
|
(LONG_PTR)test_proc, proc);
|
||||||
|
|
||||||
trace("device_window %p, focus_window %p, dummy_window %p.\n", device_window, focus_window, dummy_window);
|
trace("device_window %p, focus_window %p, dummy_window %p.\n",
|
||||||
|
device_window, focus_window, thread_params.dummy_window);
|
||||||
|
|
||||||
tmp = GetFocus();
|
tmp = GetFocus();
|
||||||
ok(tmp == dummy_window, "Expected focus %p, got %p.\n", dummy_window, tmp);
|
ok(tmp == device_window, "Expected focus %p, got %p.\n", device_window, tmp);
|
||||||
|
tmp = GetForegroundWindow();
|
||||||
|
ok(tmp == thread_params.dummy_window, "Expected foreground window %p, got %p.\n",
|
||||||
|
thread_params.dummy_window, tmp);
|
||||||
|
|
||||||
filter_messages = focus_window;
|
filter_messages = focus_window;
|
||||||
|
|
||||||
|
@ -1661,7 +1727,10 @@ static void test_wndproc_windowed(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = GetFocus();
|
tmp = GetFocus();
|
||||||
ok(tmp == dummy_window, "Expected focus %p, got %p.\n", dummy_window, tmp);
|
ok(tmp == device_window, "Expected focus %p, got %p.\n", device_window, tmp);
|
||||||
|
tmp = GetForegroundWindow();
|
||||||
|
ok(tmp == thread_params.dummy_window, "Expected foreground window %p, got %p.\n",
|
||||||
|
thread_params.dummy_window, tmp);
|
||||||
|
|
||||||
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
|
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
|
||||||
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
|
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
|
||||||
|
@ -1699,7 +1768,13 @@ static void test_wndproc_windowed(void)
|
||||||
done:
|
done:
|
||||||
filter_messages = NULL;
|
filter_messages = NULL;
|
||||||
IDirect3D8_Release(d3d8);
|
IDirect3D8_Release(d3d8);
|
||||||
DestroyWindow(dummy_window);
|
|
||||||
|
SetEvent(thread_params.test_finished);
|
||||||
|
WaitForSingleObject(thread, INFINITE);
|
||||||
|
CloseHandle(thread_params.test_finished);
|
||||||
|
CloseHandle(thread_params.window_created);
|
||||||
|
CloseHandle(thread);
|
||||||
|
|
||||||
DestroyWindow(device_window);
|
DestroyWindow(device_window);
|
||||||
DestroyWindow(focus_window);
|
DestroyWindow(focus_window);
|
||||||
UnregisterClassA("d3d8_test_wndproc_wc", GetModuleHandleA(NULL));
|
UnregisterClassA("d3d8_test_wndproc_wc", GetModuleHandleA(NULL));
|
||||||
|
|
Loading…
Reference in New Issue