From 857d8f36759ab8bec8ba97578db0bbc6688fb649 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 2 Jul 2010 13:45:25 +0200 Subject: [PATCH] d3d8/tests: Fix some test failures with the focus messages. --- dlls/d3d8/tests/device.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index b46ec4e6b0a..baf78e1156d 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -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; -- 2.11.4.GIT