user32/tests: Sleep when sending mouse clicks too fast.

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

Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zhiyi Zhang 2018-07-16 23:05:14 +08:00 committed by Alexandre Julliard
parent a205401b38
commit 0b69359a24
1 changed files with 14 additions and 3 deletions

View File

@ -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 }
};
@ -2307,7 +2307,7 @@ static DWORD WINAPI test_menu_input_thread(LPVOID lpParameter)
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;
@ -2316,7 +2316,16 @@ static DWORD WINAPI test_menu_input_thread(LPVOID lpParameter)
send_key(menu_tests[i].wVk[j]);
else
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;
{
/* Maybe clicking too fast before menu is initialized. Sleep 100 ms and retry */
elapsed = 0;
while (!(ret = click_menu(hWnd, &menu_tests[i].menu_item_pairs[j])))
{
if (elapsed > 1000) break;
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)