Module: wine Branch: refs/heads/master Commit: d8568e90be825d63cf53928db19187592d884050 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=d8568e90be825d63cf53928d...
Author: Alexandre Julliard julliard@winehq.org Date: Wed Mar 15 12:11:02 2006 +0100
user/tests: Try harder to flush X events before running tests.
---
dlls/user/tests/msg.c | 29 ++++++++++++++++++++--------- dlls/user/tests/win.c | 16 ++++++++++++++++ 2 files changed, 36 insertions(+), 9 deletions(-)
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 @@ static void add_message(const struct mes 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 @@ static void test_paint_messages(void)
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 @@ static void test_paint_messages(void) 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 @@ static void test_accelerators(void)
assert(hwnd != 0); UpdateWindow(hwnd); + flush_events(); SetFocus(hwnd); ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
@@ -6171,7 +6181,7 @@ static void test_scrollwindowex(void) 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 @@ static void test_DispatchMessage(void) if (++count > 10) break; } } + DestroyWindow(hwnd); }
diff --git a/dlls/user/tests/win.c b/dlls/user/tests/win.c index d4045b1..326a279 100644 --- a/dlls/user/tests/win.c +++ b/dlls/user/tests/win.c @@ -60,6 +60,21 @@ static HMENU hmenu;
#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 @@ static void test_csparentdc(void) ShowWindow(hwndMain, SW_SHOW); ShowWindow(hwnd1, SW_SHOW); ShowWindow(hwnd2, SW_SHOW); + flush_events();
zero_parentdc_test(&test_answer); InvalidateRect(hwndMain, NULL, TRUE);