[PATCH 2/2] user32/tests: Sleep when sending mouse clicks too fast.

Zhiyi Zhang zzhang at codeweavers.com
Sat Jul 14 07:23:48 CDT 2018


A thread is used to send mouse clicks to test mouse
click handling for menu. If the thread sends mouse clicks
before pop-up menu initialization, it would report send
input failure and skip the tests.

This patch make the message send thread sleeps for a while
when failure and retry. Also the sleep at the start of the
loop is not necessary, thus removed.

Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
---
 dlls/user32/tests/menu.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/dlls/user32/tests/menu.c b/dlls/user32/tests/menu.c
index 54a5ea232a..3f882d83c7 100644
--- a/dlls/user32/tests/menu.c
+++ b/dlls/user32/tests/menu.c
@@ -2253,7 +2253,7 @@ static struct menu_mouse_tests_s {
     { INPUT_MOUSE, {{1, 0}, {2, 0}, {0}}, {0}, TRUE, FALSE },
     { INPUT_MOUSE, {{3, 0}, {0}}, {0}, FALSE, FALSE },
     { INPUT_MOUSE, {{1, 0}, {2, 0}, {0}}, {0}, TRUE, FALSE },
-    { INPUT_MOUSE, {{3, 1}, {0}}, {0}, TRUE, TRUE },
+    { INPUT_MOUSE, {{3, 1}, {0}}, {0}, TRUE, FALSE },
     { INPUT_MOUSE, {{1, 1}, {0}}, {0}, FALSE, FALSE },
     { -1 }
 };
@@ -2302,12 +2302,11 @@ static DWORD WINAPI test_menu_input_thread(LPVOID lpParameter)
     int i, j;
     HANDLE hWnd = lpParameter;
 
-    Sleep(500);
     /* mixed keyboard/mouse test */
     for (i = 0; menu_tests[i].type != -1; i++)
     {
         BOOL ret = TRUE;
-        int elapsed = 0;
+        int elapsed;
 
         got_input = i && menu_tests[i-1].bMenuVisible;
 
@@ -2315,8 +2314,18 @@ static DWORD WINAPI test_menu_input_thread(LPVOID lpParameter)
             for (j = 0; menu_tests[i].wVk[j] != 0; j++)
                 send_key(menu_tests[i].wVk[j]);
         else
+        {
+            elapsed = 0;
             for (j = 0; menu_tests[i].menu_item_pairs[j].uMenu != 0; j++)
-                if (!(ret = click_menu(hWnd, &menu_tests[i].menu_item_pairs[j]))) break;
+                if (!(ret = click_menu(hWnd, &menu_tests[i].menu_item_pairs[j])))
+                {
+                    /* Maybe clicking too fast before menu is initialized. Sleep 100 ms and retry */
+                    if (elapsed > 500) break;
+                    j--;
+                    elapsed += 100;
+                    Sleep(100);
+                }
+        }
 
         if (!ret)
         {
@@ -2324,6 +2333,8 @@ static DWORD WINAPI test_menu_input_thread(LPVOID lpParameter)
             PostMessageA( hWnd, WM_CANCELMODE, 0, 0 );
             return 0;
         }
+
+        elapsed = 0;
         while (menu_tests[i].bMenuVisible != bMenuVisible)
         {
             if (elapsed > 200)
-- 
2.18.0




More information about the wine-devel mailing list