From: Eric Pouech eric.pouech@gmail.com
The edit control should process all events in queue to be fully initialized (otherwise the WM_PASTE will bypass some pending messages).
Wine-bug: https://bugs.winehq.org/show_bug.cgi?id=53276
Signed-off-by: Eric Pouech eric.pouech@gmail.com --- dlls/user32/tests/edit.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c index 2afbbd5bea4..dd689c80f84 100644 --- a/dlls/user32/tests/edit.c +++ b/dlls/user32/tests/edit.c @@ -38,6 +38,24 @@ struct edit_notify {
static struct edit_notify notifications;
+/* try to make sure pending X events have been processed before continuing */ +static void flush_events(void) +{ + MSG msg; + int diff = 200; + int min_timeout = 100; + DWORD time = GetTickCount() + diff; + + while (diff > 0) + { + if (MsgWaitForMultipleObjects(0, NULL, FALSE, min_timeout, QS_ALLINPUT) == WAIT_TIMEOUT) + break; + while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) + DispatchMessageA(&msg); + diff = time - GetTickCount(); + } +} + static INT_PTR CALLBACK multi_edit_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) { static int num_ok_commands = 0; @@ -3204,6 +3222,8 @@ static void test_paste(void) r = CloseClipboard(); ok(r == TRUE, "expected %d, got %d\n", TRUE, r);
+ flush_events(); + /* Paste single line */ SendMessageA(hEdit, WM_SETTEXT, 0, (LPARAM)""); r = SendMessageA(hEdit, WM_PASTE, 0, 0); @@ -3227,12 +3247,16 @@ static void test_paste(void) r = CloseClipboard(); ok(r == TRUE, "expected %d, got %d\n", TRUE, r);
+ flush_events(); + /* Paste multiline text in singleline edit - should be cut */ SendMessageA(hEdit, WM_SETTEXT, 0, (LPARAM)""); r = SendMessageA(hEdit, WM_PASTE, 0, 0); len = SendMessageA(hEdit, WM_GETTEXTLENGTH, 0, 0); ok(strlen("first line") == len, "got %d\n", len);
+ flush_events(); + /* Paste multiline text in multiline edit */ SendMessageA(hMultilineEdit, WM_SETTEXT, 0, (LPARAM)""); r = SendMessageA(hMultilineEdit, WM_PASTE, 0, 0);