user/tests: Try harder to flush X events before running tests.
diff --git a/dlls/user/tests/msg.c b/dlls/user/tests/msg.c
index 5b3cac5..b11ed2f 100644
--- a/dlls/user/tests/msg.c
+++ b/dlls/user/tests/msg.c
@@ -1282,6 +1282,21 @@
sequence_cnt++;
}
+/* try to make sure pending X events have been processed before continuing */
+static void flush_events(void)
+{
+ MSG msg;
+ int diff = 100;
+ DWORD time = GetTickCount() + diff;
+
+ while (diff > 0)
+ {
+ MsgWaitForMultipleObjects( 0, NULL, FALSE, diff, QS_ALLINPUT );
+ while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
+ diff = time - GetTickCount();
+ }
+}
+
static void flush_sequence(void)
{
HeapFree(GetProcessHeap(), 0, sequence);
@@ -3938,10 +3953,7 @@
ShowWindow( hwnd, SW_SHOW );
UpdateWindow( hwnd );
-
- /* try to flush pending X expose events */
- MsgWaitForMultipleObjects( 0, NULL, FALSE, 100, QS_ALLINPUT );
- while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
+ flush_events();
check_update_rgn( hwnd, 0 );
SetRectRgn( hrgn, 10, 10, 20, 20 );
@@ -4142,10 +4154,7 @@
ShowWindow( hparent, SW_SHOW );
UpdateWindow( hparent );
UpdateWindow( hchild );
- /* try to flush pending X expose events */
- MsgWaitForMultipleObjects( 0, NULL, FALSE, 100, QS_ALLINPUT );
- while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
-
+ flush_events();
flush_sequence();
log_all_parent_messages++;
@@ -4702,6 +4711,7 @@
assert(hwnd != 0);
UpdateWindow(hwnd);
+ flush_events();
SetFocus(hwnd);
ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
@@ -6171,7 +6181,7 @@
10, 10, 150, 150, hwnd, 0, 0, NULL);
ok (hchild != 0, "Failed to create child\n");
UpdateWindow(hwnd);
- while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
+ flush_events();
flush_sequence();
/* scroll without the child window */
@@ -6424,6 +6434,7 @@
if (++count > 10) break;
}
}
+ DestroyWindow(hwnd);
}
diff --git a/dlls/user/tests/win.c b/dlls/user/tests/win.c
index d4045b16..326a279 100644
--- a/dlls/user/tests/win.c
+++ b/dlls/user/tests/win.c
@@ -60,6 +60,21 @@
#define COUNTOF(arr) (sizeof(arr)/sizeof(arr[0]))
+/* try to make sure pending X events have been processed before continuing */
+static void flush_events(void)
+{
+ MSG msg;
+ int diff = 100;
+ DWORD time = GetTickCount() + diff;
+
+ while (diff > 0)
+ {
+ MsgWaitForMultipleObjects( 0, NULL, FALSE, diff, QS_ALLINPUT );
+ while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
+ diff = time - GetTickCount();
+ }
+}
+
/* check the values returned by the various parent/owner functions on a given window */
static void check_parents( HWND hwnd, HWND ga_parent, HWND gwl_parent, HWND get_parent,
HWND gw_owner, HWND ga_root, HWND ga_root_owner )
@@ -3423,6 +3438,7 @@
ShowWindow(hwndMain, SW_SHOW);
ShowWindow(hwnd1, SW_SHOW);
ShowWindow(hwnd2, SW_SHOW);
+ flush_events();
zero_parentdc_test(&test_answer);
InvalidateRect(hwndMain, NULL, TRUE);