[PATCH 5/5] user32/tests: Process messages while waiting in WindowFromPoint tests.

Rémi Bernon wine at gitlab.winehq.org
Wed Jun 1 09:12:11 CDT 2022


From: Rémi Bernon <rbernon at codeweavers.com>

The test is randomly failing, processing messages while waiting for
events and cleaning up child windows in the other process should fix
the issue.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 dlls/user32/tests/win.c | 40 +++++++++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 2f538874496..800cde0c593 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -10206,21 +10206,29 @@ static void window_from_point_proc(HWND parent)
     flush_events(TRUE);
     SetEvent(start_event);
 
-    got_hittest = FALSE;
     got_click = FALSE;
-    while(!got_click && wait_for_message(&msg)) {
-        if(msg.message == WM_LBUTTONUP) {
-            ok(msg.hwnd == win, "msg.hwnd = %p, expected %p\n", msg.hwnd, win);
-            got_click = TRUE;
+    got_hittest = FALSE;
+    while ((ret = MsgWaitForMultipleObjects( 1, &end_event, FALSE, INFINITE, QS_ALLINPUT )) <= 1)
+    {
+        while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ))
+        {
+            if (msg.message == WM_LBUTTONUP)
+            {
+                ok(msg.hwnd == win, "msg.hwnd = %p, expected %p\n", msg.hwnd, win);
+                got_click = TRUE;
+            }
+            TranslateMessage( &msg );
+            DispatchMessageA( &msg );
         }
-        DispatchMessageA(&msg);
+        if (ret == 0) break;
     }
+    ok(ret == 0, "MsgWaitForMultipleObjects returned %#lx\n", ret);
     ok(got_hittest, "transparent window didn't get WM_NCHITTEST message\n");
     ok(got_click, "button under static window didn't get WM_LBUTTONUP\n");
 
-    ret = WaitForSingleObject(end_event, 5000);
-    ok(ret == WAIT_OBJECT_0, "WaitForSingleObject returned %lx\n", ret);
-
+    DestroyWindow(win);
+    DestroyWindow(child_button);
+    DestroyWindow(child_static);
     CloseHandle(start_event);
     CloseHandle(end_event);
 }
@@ -10240,14 +10248,10 @@ static void test_window_from_point(const char *argv0)
 
     pt.x = pt.y = 150;
     win = WindowFromPoint(pt);
+    ok(win == hwnd, "WindowFromPoint returned %p, expected %p\n", win, hwnd);
     pt.x = 250;
-    if(win == hwnd)
-        win = WindowFromPoint(pt);
-    if(win != hwnd) {
-        skip("there's another window covering test window\n");
-        DestroyWindow(hwnd);
-        return;
-    }
+    win = WindowFromPoint(pt);
+    ok(win == hwnd, "WindowFromPoint returned %p, expected %p\n", win, hwnd);
 
     child = CreateWindowExA(0, "static", "static", WS_CHILD | WS_VISIBLE,
             0, 0, 100, 100, hwnd, 0, NULL, NULL);
@@ -10274,7 +10278,7 @@ static void test_window_from_point(const char *argv0)
     startup.cb = sizeof(startup);
     ok(CreateProcessA(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL,
                 &startup, &info), "CreateProcess failed.\n");
-    ok(wait_for_events(1, &start_event, 1000) == 0, "didn't get start_event\n");
+    wait_for_events(1, &start_event, INFINITE);
 
     child = GetWindow(hwnd, GW_CHILD);
     win = WindowFromPoint(pt);
@@ -10289,6 +10293,8 @@ static void test_window_from_point(const char *argv0)
     ok(win == child, "WindowFromPoint returned %p, expected %p\n", win, child);
 
     SetEvent(end_event);
+    wait_for_events(1, &info.hProcess, INFINITE);
+
     wait_child_process(info.hProcess);
     CloseHandle(start_event);
     CloseHandle(end_event);
-- 
GitLab

https://gitlab.winehq.org/wine/wine/-/merge_requests/169



More information about the wine-devel mailing list