Commit 857d8f36 authored by Alexandre Julliard's avatar Alexandre Julliard

d3d8/tests: Fix some test failures with the focus messages.

parent f0e21b0e
......@@ -46,6 +46,22 @@ static int get_refcount(IUnknown *object)
return IUnknown_Release( object );
}
/* try to make sure pending X events have been processed before continuing */
static void flush_events(void)
{
MSG msg;
int diff = 200;
int min_timeout = 100;
DWORD time = GetTickCount() + diff;
while (diff > 0)
{
if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
diff = time - GetTickCount();
}
}
static IDirect3DDevice8 *create_device(IDirect3D8 *d3d8, HWND device_window, HWND focus_window, BOOL windowed)
{
D3DPRESENT_PARAMETERS present_parameters = {0};
......@@ -1505,7 +1521,8 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM
{
if (filter_messages && filter_messages == hwnd)
{
ok(message == WM_DISPLAYCHANGE, "Received unexpected message %#x for window %p.\n", message, hwnd);
if (message != WM_DISPLAYCHANGE && message != WM_IME_NOTIFY)
todo_wine ok(0, "Received unexpected message %#x for window %p.\n", message, hwnd);
}
if (expect_message.window == hwnd && expect_message.message == message) expect_message.message = 0;
......@@ -1555,7 +1572,6 @@ static void test_wndproc(void)
LONG_PTR proc;
ULONG ref;
DWORD res, tid;
MSG msg;
if (!(d3d8 = pDirect3DCreate8(D3D_SDK_VERSION)))
{
......@@ -1601,7 +1617,7 @@ static void test_wndproc(void)
expect_message.window = focus_window;
expect_message.message = WM_SETFOCUS;
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
flush_events();
device = create_device(d3d8, device_window, focus_window, FALSE);
if (!device)
......@@ -1620,6 +1636,7 @@ static void test_wndproc(void)
ok(tmp == focus_window, "Expected foreground window %p, got %p.\n", focus_window, tmp);
}
SetForegroundWindow(focus_window);
flush_events();
filter_messages = focus_window;
......
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