Module: wine Branch: master Commit: 0779443518ac363418b5d308e757de447b116370 URL: https://source.winehq.org/git/wine.git/?a=commit;h=0779443518ac363418b5d308e...
Author: Rémi Bernon rbernon@codeweavers.com Date: Tue Nov 12 21:42:03 2019 +0100
user32/tests: Synchronize with other thread between SendMessage calls.
This sometimes fails on Windows because we check the queue status before the other thread second call to SendMessage has been made (or received).
Signed-off-by: Rémi Bernon rbernon@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/user32/tests/msg.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index ad4ff7d2a7..45c6787c16 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -17466,6 +17466,7 @@ static DWORD WINAPI SendMessage_thread_1(void *param)
trace("thread: call SendMessage\n"); SendMessageA(wnd_event->hwnd, WM_USER+2, 0, 0); + SetEvent(wnd_event->stop_event);
trace("thread: call SendMessage\n"); SendMessageA(wnd_event->hwnd, WM_USER+3, 0, 0); @@ -17492,6 +17493,7 @@ static DWORD WINAPI SendMessage_thread_2(void *param)
trace("thread: call SendMessage\n"); SendMessageA(wnd_event->hwnd, WM_USER+2, 0, 0); + SetEvent(wnd_event->stop_event);
trace("thread: call SendMessage\n"); SendMessageA(wnd_event->hwnd, WM_USER+3, 0, 0); @@ -17508,6 +17510,7 @@ static void test_SendMessage_other_thread(int thread_n) MSG msg;
wnd_event.start_event = CreateEventA(NULL, 0, 0, NULL); + wnd_event.stop_event = CreateEventA(NULL, 0, 0, NULL);
wnd_event.hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW, 100, 100, 200, 200, 0, 0, 0, NULL); @@ -17542,6 +17545,10 @@ static void test_SendMessage_other_thread(int thread_n) DispatchMessageA(&msg); ok_sequence(send_message_1, "SendMessage from other thread 1", thread_n == 2);
+ ret = WaitForSingleObject(wnd_event.stop_event, 100); + todo_wine_if (thread_n == 2) + ok(ret == WAIT_OBJECT_0, "WaitForSingleObject failed, ret:%x\n", ret); + /* intentionally yield */ MsgWaitForMultipleObjects(0, NULL, FALSE, 100, qs_all_input);
@@ -17578,6 +17585,9 @@ todo_wine_if (thread_n == 2)
flush_events(); flush_sequence(); + + CloseHandle(wnd_event.start_event); + CloseHandle(wnd_event.stop_event); }
static LRESULT CALLBACK insendmessage_wnd_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )