From 0779443518ac363418b5d308e757de447b116370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Tue, 12 Nov 2019 21:42:03 +0100 Subject: [PATCH] user32/tests: Synchronize with other thread between SendMessage calls. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Alexandre Julliard --- 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 ad4ff7d2a75..45c6787c16f 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 )