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

Alexandre Julliard julliard at winehq.org
Fri Jul 2 10:21:57 CDT 2010


Module: wine
Branch: master
Commit: 857d8f36759ab8bec8ba97578db0bbc6688fb649
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=857d8f36759ab8bec8ba97578db0bbc6688fb649

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Jul  2 13:45:25 2010 +0200

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

---

 dlls/d3d8/tests/device.c |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index b46ec4e..baf78e1 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;
 




More information about the wine-cvs mailing list