[13/18] comctl32: TaskDialog - Flush evens before testing

Fabian Maurer dark.shadow4 at web.de
Fri Feb 24 14:04:07 CST 2017


Signed-off-by: Fabian Maurer <dark.shadow4 at web.de>
---
 dlls/comctl32/tests/taskdialog.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/dlls/comctl32/tests/taskdialog.c b/dlls/comctl32/tests/taskdialog.c
index 6dc4c2a5ee..548c197e22 100644
--- a/dlls/comctl32/tests/taskdialog.c
+++ b/dlls/comctl32/tests/taskdialog.c
@@ -223,6 +223,22 @@ static HRESULT CALLBACK TaskDialogCallbackProc(HWND hwnd, UINT uNotification, WP
     return S_OK; /* Fallback in case we got a message mismatch */
 }
 
+/* try to make sure pending X events have been processed before continuing - from user32 tests msg.c*/
+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 (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
+        diff = time - GetTickCount();
+    }
+}
+
 #define run_test( info, expect_button, expect_radio, expect_checkbox, expect_messages, send_messages ) \
         run_test_( (info), (expect_button), (expect_radio), (expect_checkbox), \
                    (expect_messages), (send_messages), __FILE__, __LINE__)
@@ -237,6 +253,8 @@ static void run_test_(TASKDIALOGCONFIG *info, int expect_button, int expect_radi
     int ret_radio = 0;
     BOOL ret_checkbox = 0;
 
+    flush_events();
+
     message_list = expect_messages;
     message_send_list = send_messages;
 
-- 
2.11.1




More information about the wine-patches mailing list