Fix these failures:
win.c:2445: Test failed: style 0x200000: expected !100 win.c:2445: Test failed: style 0x300000: expected !100
Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
v2: Drop the pre-existing window removal patch, add a new patch to reduce msg test verbosity.
dlls/user32/tests/win.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index cb6b61e59c0..e48d7bea513 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -2249,7 +2249,7 @@ static void test_mdi(void) mdi_hwndMain = CreateWindowExA(0, "MDI_parent_Class", "MDI parent window", WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX /*| WS_VISIBLE*/, - 100, 100, CW_USEDEFAULT, CW_USEDEFAULT, + 200, 100, CW_USEDEFAULT, CW_USEDEFAULT, GetDesktopWindow(), 0, GetModuleHandleA(NULL), NULL); assert(mdi_hwndMain);
Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=48815 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/tests/win.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index e48d7bea513..c9d9509eacc 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -170,8 +170,14 @@ static void check_active_state_(const char *file, int line, ok_(file, line)(focus == GetFocus(), "GetFocus() = %p\n", GetFocus()); }
-static BOOL ignore_message( UINT message ) +static BOOL ignore_message( UINT message, HWND hwnd ) { + WCHAR buffer[256]; + + if (GetClassNameW( hwnd, buffer, ARRAY_SIZE(buffer) ) == 22 && + !wcscmp( buffer, L"UserAdapterWindowClass" )) + return TRUE; + /* these are always ignored */ return (message >= 0xc000 || message == WM_GETICON || @@ -179,8 +185,7 @@ static BOOL ignore_message( UINT message ) message == WM_TIMER || message == WM_SYSTIMER || message == WM_TIMECHANGE || - message == WM_DEVICECHANGE || - message == 0x0060 /* undocumented, used by Win10 1709+ */); + message == WM_DEVICECHANGE); }
static BOOL CALLBACK EnumChildProc( HWND hwndChild, LPARAM lParam) @@ -3953,7 +3958,7 @@ static BOOL peek_message( MSG *msg ) do { ret = PeekMessageA(msg, 0, 0, 0, PM_REMOVE); - } while (ret && ignore_message(msg->message)); + } while (ret && ignore_message(msg->message, msg->hwnd)); return ret; }
@@ -4113,7 +4118,7 @@ static void test_mouse_input(HWND hwnd) /* FIXME: SetCursorPos in Wine generates additional WM_MOUSEMOVE message */ while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) { - if (ignore_message(msg.message)) continue; + if (ignore_message(msg.message, msg.hwnd)) continue; ok(msg.hwnd == popup && msg.message == WM_MOUSEMOVE, "hwnd %p message %04x\n", msg.hwnd, msg.message); DispatchMessageA(&msg);
Shows that it switches focus to some other process window and back, and only on some older Windows versions. Win10 simply returns 0 and does nothing.
Stop calling it elsewhere, as it makes focus go to an unpredictable window, which may very well not be ours.
Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=51391 Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=51130 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/tests/win.c | 209 ++++++++++++++++++++++++++++++---------- 1 file changed, 156 insertions(+), 53 deletions(-)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index c9d9509eacc..e83e4bcb39e 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -106,22 +106,6 @@ static void flush_events( BOOL remove_messages ) } }
-static BOOL wait_for_event(HANDLE event, int timeout) -{ - DWORD end_time = GetTickCount() + timeout; - MSG msg; - - do { - if(MsgWaitForMultipleObjects(1, &event, FALSE, timeout, QS_ALLINPUT) == WAIT_OBJECT_0) - return TRUE; - while(PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) - DispatchMessageA(&msg); - timeout = end_time - GetTickCount(); - }while(timeout > 0); - - return FALSE; -} - /* check the values returned by the various parent/owner functions on a given window */ static void check_parents( HWND hwnd, HWND ga_parent, HWND gwl_parent, HWND get_parent, HWND gw_owner, HWND ga_root, HWND ga_root_owner ) @@ -188,6 +172,28 @@ static BOOL ignore_message( UINT message, HWND hwnd ) message == WM_DEVICECHANGE); }
+static DWORD wait_for_events( DWORD count, HANDLE *events, DWORD timeout ) +{ + DWORD ret, end = GetTickCount() + timeout; + MSG msg; + + while ((ret = MsgWaitForMultipleObjects( count, events, FALSE, timeout, QS_ALLINPUT )) <= count) + { + while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) + { + TranslateMessage( &msg ); + DispatchMessageA( &msg ); + } + if (ret < count) return ret; + if (timeout == INFINITE) continue; + if (end <= GetTickCount()) timeout = 0; + else timeout = end - GetTickCount(); + } + + ok( ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %#x\n", ret ); + return ret; +} + static BOOL CALLBACK EnumChildProc( HWND hwndChild, LPARAM lParam) { (*(LPINT)lParam)++; @@ -3437,31 +3443,142 @@ todo_wine DestroyWindow( child ); }
+static void test_SetActiveWindow_0_proc( char **argv ) +{ + HANDLE start_event, stop_event; + HWND hwnd, other, tmp; + BOOL ret; + + sscanf( argv[3], "%p", &other ); + start_event = CreateEventW( NULL, FALSE, FALSE, L"test_SetActiveWindow_0_start" ); + ok( start_event != 0, "CreateEventW failed, error %u\n", GetLastError() ); + stop_event = CreateEventW( NULL, FALSE, FALSE, L"test_SetActiveWindow_0_stop" ); + ok( stop_event != 0, "CreateEventW failed, error %u\n", GetLastError() ); + + hwnd = CreateWindowExA( 0, "static", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 200, 200, 0, 0, NULL, NULL ); + ok( !!hwnd, "CreateWindowExA failed, error %u\n", GetLastError() ); + flush_events( TRUE ); + + ret = SetForegroundWindow( hwnd ); + ok( ret, "SetForegroundWindow failed, error %u\n", GetLastError() ); + + tmp = GetForegroundWindow(); + ok( tmp == hwnd, "GetForegroundWindow returned %p\n", tmp ); + tmp = GetActiveWindow(); + ok( tmp == hwnd, "GetActiveWindow returned %p\n", tmp ); + tmp = GetFocus(); + ok( tmp == hwnd, "GetFocus returned %p\n", tmp ); + + SetLastError( 0xdeadbeef ); + tmp = SetActiveWindow( 0 ); + if (!tmp) ok( GetLastError() == 0xdeadbeef, "got error %u\n", GetLastError() ); + else /* < Win10 */ + { + ok( tmp == hwnd, "SetActiveWindow returned %p\n", tmp ); + todo_wine + ok( GetLastError() == 0, "got error %u\n", GetLastError() ); + + tmp = GetForegroundWindow(); + ok( tmp == other || tmp == 0, "GetForegroundWindow returned %p\n", tmp ); + tmp = GetActiveWindow(); + ok( tmp == 0, "GetActiveWindow returned %p\n", tmp ); + tmp = GetFocus(); + ok( tmp == 0, "GetFocus returned %p\n", tmp ); + + SetEvent( start_event ); + wait_for_events( 1, &stop_event, INFINITE ); + + tmp = GetForegroundWindow(); + todo_wine + ok( tmp == other, "GetForegroundWindow returned %p\n", tmp ); + tmp = GetActiveWindow(); + ok( tmp == 0, "GetActiveWindow returned %p\n", tmp ); + tmp = GetFocus(); + ok( tmp == 0, "GetFocus returned %p\n", tmp ); + } + + tmp = SetActiveWindow( 0 ); + ok( tmp == 0, "SetActiveWindow returned %p\n", tmp ); + tmp = GetForegroundWindow(); + todo_wine + ok( tmp == hwnd, "GetForegroundWindow returned %p\n", tmp ); + tmp = GetActiveWindow(); + todo_wine + ok( tmp == hwnd, "GetActiveWindow returned %p\n", tmp ); + tmp = GetFocus(); + todo_wine + ok( tmp == hwnd, "GetFocus returned %p\n", tmp ); + + CloseHandle( start_event ); + CloseHandle( stop_event ); + DestroyWindow( hwnd ); +} + +static void test_SetActiveWindow_0( char **argv ) +{ + STARTUPINFOA startup = {.cb = sizeof(STARTUPINFOA)}; + PROCESS_INFORMATION info; + char cmdline[MAX_PATH]; + HANDLE events[3]; + HWND hwnd, tmp; + BOOL ret; + + hwnd = CreateWindowExA( 0, "static", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 200, 200, 0, 0, NULL, NULL ); + ok( !!hwnd, "CreateWindowExA failed, error %u\n", GetLastError() ); + SetWindowPos( hwnd, HWND_TOPMOST, 150, 150, 300, 300, SWP_FRAMECHANGED | SWP_SHOWWINDOW ); + flush_events( TRUE ); + + tmp = GetForegroundWindow(); + ok( tmp == hwnd, "GetForegroundWindow returned %p\n", tmp ); + tmp = GetActiveWindow(); + ok( tmp == hwnd, "GetActiveWindow returned %p\n", tmp ); + tmp = GetFocus(); + ok( tmp == hwnd, "GetFocus returned %p\n", tmp ); + + events[1] = CreateEventW( NULL, FALSE, FALSE, L"test_SetActiveWindow_0_start" ); + ok( events[1] != 0, "CreateEventW failed, error %u\n", GetLastError() ); + events[2] = CreateEventW( NULL, FALSE, FALSE, L"test_SetActiveWindow_0_stop" ); + ok( events[2] != 0, "CreateEventW failed, error %u\n", GetLastError() ); + + sprintf( cmdline, "%s %s SetActiveWindow_0 %p", argv[0], argv[1], hwnd ); + ret = CreateProcessA( NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info ); + ok( ret, "CreateProcessA failed, error %u\n", GetLastError() ); + + events[0] = info.hProcess; + if (wait_for_events( 2, events, INFINITE ) == 1) + { + tmp = GetForegroundWindow(); + todo_wine + ok( tmp == hwnd, "GetForegroundWindow returned %p\n", tmp ); + tmp = GetActiveWindow(); + todo_wine + ok( tmp == hwnd, "GetActiveWindow returned %p\n", tmp ); + tmp = GetFocus(); + todo_wine + ok( tmp == hwnd, "GetFocus returned %p\n", tmp ); + SetEvent( events[2] ); + } + + wait_child_process( info.hProcess ); + CloseHandle( info.hProcess ); + CloseHandle( info.hThread ); + CloseHandle( events[1] ); + CloseHandle( events[2] ); + + DestroyWindow( hwnd ); +} + static void test_SetActiveWindow(HWND hwnd) { HWND hwnd2, ret;
flush_events( TRUE ); ShowWindow(hwnd, SW_HIDE); - SetFocus(0); - SetActiveWindow(0); check_wnd_state(0, 0, 0, 0);
ShowWindow(hwnd, SW_SHOW); check_wnd_state(hwnd, hwnd, hwnd, 0);
- SetLastError(0xdeadbeef); - ret = SetActiveWindow(0); - ok(ret == hwnd || broken(!ret) /* Win10 1809 */, "expected %p, got %p\n", hwnd, ret); - if (!ret) ok(GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError()); - if (!GetActiveWindow()) /* doesn't always work on vista */ - { - check_wnd_state(0, 0, 0, 0); - ret = SetActiveWindow(hwnd); - ok(ret == 0, "SetActiveWindow returned %p instead of 0\n", ret); - } - check_wnd_state(hwnd, hwnd, hwnd, 0); - SetWindowPos(hwnd,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_HIDEWINDOW); check_wnd_state(hwnd, hwnd, hwnd, 0);
@@ -3510,17 +3627,7 @@ static void test_SetActiveWindow(HWND hwnd) ret = SetActiveWindow(hwnd2); ok(ret == hwnd, "expected %p, got %p\n", hwnd, ret); check_wnd_state(hwnd, hwnd, hwnd, 0); - SetLastError(0xdeadbeef); - ret = SetActiveWindow(0); - ok(ret == hwnd || broken(!ret) /* Win10 1809 */, "expected %p, got %p\n", hwnd, ret); - if (!ret) ok(GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError()); - if (!GetActiveWindow()) - { - ret = SetActiveWindow(hwnd2); - ok(ret == NULL, "expected NULL, got %p\n", ret); - todo_wine - check_active_state(hwnd, hwnd, hwnd); - } + DestroyWindow(hwnd2); }
@@ -3561,22 +3668,11 @@ static void test_SetForegroundWindow(HWND hwnd)
flush_events( TRUE ); ShowWindow(hwnd, SW_HIDE); - SetFocus(0); - SetActiveWindow(0); check_wnd_state(0, 0, 0, 0);
ShowWindow(hwnd, SW_SHOW); check_wnd_state(hwnd, hwnd, hwnd, 0);
- SetLastError(0xdeadbeef); - hwnd2 = SetActiveWindow(0); - ok(hwnd2 == hwnd || broken(!hwnd2) /* Win10 1809 */, "expected %p, got %p\n", hwnd, hwnd2); - if (!hwnd2) ok(GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError()); - if (GetActiveWindow() == hwnd) /* doesn't always work on vista */ - check_wnd_state(hwnd, hwnd, hwnd, 0); - else - check_wnd_state(0, 0, 0, 0); - ret = SetForegroundWindow(hwnd); if (!ret) { @@ -9876,7 +9972,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_event(start_event, 1000), "didn't get start_event\n"); + ok(wait_for_events(1, &start_event, 1000) == 0, "didn't get start_event\n");
child = GetWindow(hwnd, GW_CHILD); win = WindowFromPoint(pt); @@ -12502,6 +12598,12 @@ START_TEST(win) return; }
+ if (argc == 4 && !strcmp( argv[2], "SetActiveWindow_0" )) + { + test_SetActiveWindow_0_proc( argv ); + return; + } + if (!RegisterWindowClasses()) assert(0);
hwndMain = CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window", @@ -12563,6 +12665,7 @@ START_TEST(win) test_SetWindowPos(hwndMain, hwndMain2); test_SetMenu(hwndMain); test_SetFocus(hwndMain); + test_SetActiveWindow_0( argv ); test_SetActiveWindow(hwndMain); test_NCRedraw();
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=106628
Your paranoid android.
=== w10pro64_zh_CN (64 bit report) ===
user32: win.c:10486: Test failed: pos = 00fa00fa win.c:10490: Test failed: pos = 00fa00fa win.c:10494: Test failed: pos = 00fa00fa
Can be reproduced randomly even without user32:monitor, for instance running user32:win in a fresh Win7 VM.
Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=51392 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/tests/win.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index e83e4bcb39e..289b2c5a276 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -7127,7 +7127,7 @@ static void test_ShowWindow(void) { HWND hwnd; DWORD style; - RECT rcMain, rc, rcMinimized, rcClient, rcEmpty, rcMaximized, rcResized, rcNonClient; + RECT rcMain, rc, rcMinimized, rcClient, rcEmpty, rcMaximized, rcResized, rcNonClient, rcBroken; LPARAM ret; MONITORINFO mon_info; unsigned int i; @@ -7430,8 +7430,17 @@ static void test_ShowWindow(void) style = GetWindowLongA(hwnd, GWL_STYLE); ok(style & WS_MAXIMIZE, "Test %u: window should be maximized\n", i); GetWindowRect(hwnd, &rc); - ok(EqualRect(&rcMaximized, &rc), "Test %u: expected %s, got %s\n", - i, wine_dbgstr_rect(&rcMaximized), wine_dbgstr_rect(&rc)); + + rcBroken = rcMaximized; + if (test_style[i] & WS_THICKFRAME) + { + InflateRect(&rcBroken, -2, -2); + OffsetRect(&rcBroken, -2, -2); + } + + ok(EqualRect(&rcMaximized, &rc) || broken(EqualRect(&rcBroken, &rc)), + "Test %u: expected %s, got %s\n", i, wine_dbgstr_rect(&rcMaximized), + wine_dbgstr_rect(&rc));
ret = ShowWindow(hwnd, SW_RESTORE); ok(ret, "unexpected ret: %lu\n", ret);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=106629
Your paranoid android.
=== w10pro64_zh_CN (64 bit report) ===
user32: win.c:10495: Test failed: pos = 00fa00fa win.c:10499: Test failed: pos = 00fa00fa win.c:10503: Test failed: pos = 00fa00fa
At WINETEST_DEBUG <= 1, only sequence mismatches will be checked and reported.
At WINETEST_DEBUG == 2, individual message mismatches will be checked and reported, expected / received sequences will be traced on mismatch.
At WINETEST_DEBUG > 2, individual message will be checked or traced, all expected / received sequences will be traced.
Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=51780 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/tests/msg.c | 378 +++++++++++++--------------------------- 1 file changed, 122 insertions(+), 256 deletions(-)
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 90816a9df52..03b2fc3870d 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -2619,294 +2619,157 @@ static void flush_sequence(void) LeaveCriticalSection( &sequence_cs ); }
-static void dump_sequence(const struct message *expected, const char *context, const char *file, int line) +static int try_compare_message( const struct message *expected, const struct recvd_message *received ) { - const struct recvd_message *actual = sequence; - unsigned int count = 0; + static DWORD type_flags = hook | winevent_hook | kbd_hook; + int ret;
- trace_(file, line)("Failed sequence %s:\n", context ); - while (expected->message && actual->message) + if ((ret = (expected->flags & type_flags) - (received->flags & type_flags))) return ret; + if ((ret = expected->message - received->message)) return ret; + + /* validate parent and defwinproc flags for optional messages */ + if (!(expected->flags & optional)) return 0; + if ((ret = (expected->flags & defwinproc) - (received->flags & defwinproc))) return ret; + if ((ret = (expected->flags & parent) - (received->flags & parent))) return ret; + + return 0; +} + +static int compare_message( const struct message *expected, const struct recvd_message *received, + BOOL todo, const char *file, int line ) +{ + static DWORD type_flags = hook | winevent_hook | kbd_hook; + static DWORD msg_flags = sent | posted; + int ret; + + if ((ret = (expected->flags & type_flags) - (received->flags & type_flags))) goto done; + if ((ret = expected->message - received->message)) goto done; + if ((ret = (expected->flags & defwinproc) - (received->flags & defwinproc))) goto done; + if ((ret = (expected->flags & parent) - (received->flags & parent))) goto done; + if ((ret = (expected->flags & msg_flags) - (received->flags & msg_flags))) goto done; + if ((ret = (expected->flags & beginpaint) - (received->flags & beginpaint))) goto done; + if ((expected->flags & wparam) && (ret = (expected->wParam & ~expected->wp_mask) - (received->wParam & ~expected->wp_mask))) goto done; + if ((expected->flags & lparam) && (ret = (expected->lParam & ~expected->lp_mask) - (received->lParam & ~expected->lp_mask))) goto done; + +done: + if (ret && winetest_debug > 1) { - if (actual->output[0]) + todo_wine_if(todo) + ok_(file, line)( 0, "mismatch %#x, %#x, %#lx, %#lx\n", received->message, + received->flags, received->wParam, received->lParam ); + } + if (!ret && winetest_debug > 2) + trace_(file, line)( "match %#x, %#x, %#lx, %#lx\n", received->message, + received->flags, received->wParam, received->lParam ); + return ret; +} + +static BOOL find_next_message( const struct message **expected, const struct recvd_message **received, + BOOL *matches, BOOL todo, const char *file, int line ) +{ + const struct recvd_message *first_received = *received, *tmp_received, *next_received; + const struct message *first_expected = *expected, *tmp_expected, *next_expected; + BOOL winhook_todo; + + /* try matching messages in expected list with first received message */ + for (next_expected = first_expected; next_expected->message; next_expected++) + if (!try_compare_message( next_expected, first_received )) break; + + /* if current message doesn't match anything in the received list, match a non-optional message */ + if (!next_expected->message) while (first_expected->flags & optional) first_expected++; + + /* try matching messages in received list with first non-optional message */ + for (next_received = first_received; next_received->message; next_received++) + if (!try_compare_message( first_expected, next_received ) && + !(first_expected->flags & optional)) break; + + /* couldn't find a match but there's more messages to try */ + if (!next_expected->message && next_expected - first_expected > 1 && + !next_received->message && next_received - first_received > 1) + return TRUE; + + /* report the smallest mismatch which doesn't end the sequence */ + if ((next_expected->message && next_expected - first_expected < next_received - first_received) || + !next_received->message) + { + for (tmp_expected = first_expected; tmp_expected != next_expected; ++tmp_expected) { - if (expected->flags & hook) + if (tmp_expected->flags & optional) continue; + if ((tmp_expected->flags & winevent_hook) && !hEvent_hook) continue; + winhook_todo = (tmp_expected->flags & winevent_hook) && (tmp_expected->flags & winevent_hook_todo); + if (!winhook_todo) *matches = FALSE; + if (winetest_debug > 1) { - trace_(file, line)( " %u: expected: hook %04x - actual: %s\n", - count, expected->message, actual->output ); - } - else if (expected->flags & winevent_hook) - { - trace_(file, line)( " %u: expected: winevent %04x - actual: %s\n", - count, expected->message, actual->output ); - } - else if (expected->flags & kbd_hook) - { - trace_(file, line)( " %u: expected: kbd %04x - actual: %s\n", - count, expected->message, actual->output ); - } - else - { - trace_(file, line)( " %u: expected: msg %04x - actual: %s\n", - count, expected->message, actual->output ); + todo_wine_if(todo || winhook_todo) + ok_(file, line)( 0, "missing %#x, %#x, %#lx, %#lx\n", tmp_expected->message, + tmp_expected->flags, tmp_expected->wParam, tmp_expected->lParam ); } } + *expected = next_expected; + }
- if (expected->message == actual->message) - { - if ((expected->flags & defwinproc) != (actual->flags & defwinproc) && - (expected->flags & optional)) - { - /* don't match messages if their defwinproc status differs */ - expected++; - } - else - { - expected++; - actual++; - } - } - /* silently drop winevent messages if there is no support for them */ - else if ((expected->flags & optional) || ((expected->flags & winevent_hook) && !hEvent_hook) || - ((expected->flags & winevent_hook_todo) && !strcmp(winetest_platform, "wine"))) - expected++; - else + if ((next_received->message && next_received - first_received < next_expected - first_expected) || + !next_expected->message) + { + for (tmp_received = first_received; tmp_received != next_received; ++tmp_received) { - expected++; - actual++; + *matches = FALSE; + if (winetest_debug > 1) + { + todo_wine_if(todo) + ok_(file, line)( 0, "spurious %#x, %#x, %#lx, %#lx\n", tmp_received->message, + tmp_received->flags, tmp_received->wParam, tmp_received->lParam ); + } } - count++; + *received = next_received; }
- /* optional trailing messages */ - while (expected->message && ((expected->flags & optional) || - ((expected->flags & winevent_hook) && !hEvent_hook))) - { - trace_(file, line)( " %u: expected: msg %04x - actual: nothing\n", count, expected->message ); - expected++; - count++; - } - - if (expected->message) - { - trace_(file, line)( " %u: expected: msg %04x - actual: nothing\n", count, expected->message ); - return; - } - - while (actual->message && actual->output[0]) - { - trace_(file, line)( " %u: expected: nothing - actual: %s\n", count, actual->output ); - actual++; - count++; - } + return (*expected)->message && (*received)->message; }
#define ok_sequence( exp, contx, todo) \ ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
- -static void ok_sequence_(const struct message *expected_list, const char *context, BOOL todo, +static void ok_sequence_(const struct message *expected, const char *context, BOOL todo, const char *file, int line) { static const struct recvd_message end_of_sequence; - const struct message *expected = expected_list; - const struct recvd_message *actual; - int failcount = 0, dump = 0; - unsigned int count = 0; + const struct message *tmp_expected, *first_expected = expected; + const struct recvd_message *tmp_received, *received; + BOOL matches = TRUE;
add_message(&end_of_sequence); + received = sequence;
- actual = sequence; - - while (expected->message && actual->message) + while (expected->message || received->message) { - if (expected->message == actual->message && - !((expected->flags ^ actual->flags) & (hook|winevent_hook|kbd_hook))) - { - if (expected->flags & wparam) - { - if (((expected->wParam ^ actual->wParam) & ~expected->wp_mask) && todo) - { - todo_wine { - failcount ++; - if (strcmp(winetest_platform, "wine")) dump++; - ok_( file, line) (FALSE, - "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n", - context, count, expected->message, expected->wParam, actual->wParam); - } - } - else - { - ok_( file, line)( ((expected->wParam ^ actual->wParam) & ~expected->wp_mask) == 0, - "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n", - context, count, expected->message, expected->wParam, actual->wParam); - if ((expected->wParam ^ actual->wParam) & ~expected->wp_mask) dump++; - } - - } - if (expected->flags & lparam) - { - if (((expected->lParam ^ actual->lParam) & ~expected->lp_mask) && todo) - { - todo_wine { - failcount ++; - if (strcmp(winetest_platform, "wine")) dump++; - ok_( file, line) (FALSE, - "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n", - context, count, expected->message, expected->lParam, actual->lParam); - } - } - else - { - ok_( file, line)(((expected->lParam ^ actual->lParam) & ~expected->lp_mask) == 0, - "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n", - context, count, expected->message, expected->lParam, actual->lParam); - if ((expected->lParam ^ actual->lParam) & ~expected->lp_mask) dump++; - } - } - if ((expected->flags & optional) && - ((expected->flags ^ actual->flags) & (defwinproc|parent))) - { - /* don't match optional messages if their defwinproc or parent status differs */ - expected++; - count++; - continue; - } - if ((expected->flags & defwinproc) != (actual->flags & defwinproc) && todo) - { - todo_wine { - failcount ++; - if (strcmp(winetest_platform, "wine")) dump++; - ok_( file, line) (FALSE, - "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n", - context, count, expected->message, (expected->flags & defwinproc) ? "" : "NOT "); - } - } - else - { - ok_( file, line) ((expected->flags & defwinproc) == (actual->flags & defwinproc), - "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n", - context, count, expected->message, (expected->flags & defwinproc) ? "" : "NOT "); - if ((expected->flags & defwinproc) != (actual->flags & defwinproc)) dump++; - } - - ok_( file, line) ((expected->flags & beginpaint) == (actual->flags & beginpaint), - "%s: %u: the msg 0x%04x should %shave been sent by BeginPaint\n", - context, count, expected->message, (expected->flags & beginpaint) ? "" : "NOT "); - if ((expected->flags & beginpaint) != (actual->flags & beginpaint)) dump++; - - ok_( file, line) ((expected->flags & (sent|posted)) == (actual->flags & (sent|posted)), - "%s: %u: the msg 0x%04x should have been %s\n", - context, count, expected->message, (expected->flags & posted) ? "posted" : "sent"); - if ((expected->flags & (sent|posted)) != (actual->flags & (sent|posted))) dump++; - - ok_( file, line) ((expected->flags & parent) == (actual->flags & parent), - "%s: %u: the msg 0x%04x was expected in %s\n", - context, count, expected->message, (expected->flags & parent) ? "parent" : "child"); - if ((expected->flags & parent) != (actual->flags & parent)) dump++; - - ok_( file, line) ((expected->flags & hook) == (actual->flags & hook), - "%s: %u: the msg 0x%04x should have been sent by a hook\n", - context, count, expected->message); - if ((expected->flags & hook) != (actual->flags & hook)) dump++; - - ok_( file, line) ((expected->flags & winevent_hook) == (actual->flags & winevent_hook), - "%s: %u: the msg 0x%04x should have been sent by a winevent hook\n", - context, count, expected->message); - if ((expected->flags & winevent_hook) != (actual->flags & winevent_hook)) dump++; - - ok_( file, line) ((expected->flags & kbd_hook) == (actual->flags & kbd_hook), - "%s: %u: the msg 0x%04x should have been sent by a keyboard hook\n", - context, count, expected->message); - if ((expected->flags & kbd_hook) != (actual->flags & kbd_hook)) dump++; - - expected++; - actual++; - } - /* - * silently drop hook messages if there is no support for them, mark - * winevent todo's. - */ - else if ((expected->flags & optional) || - ((expected->flags & hook) && !hCBT_hook) || - ((expected->flags & winevent_hook) && !hEvent_hook) || - ((expected->flags & kbd_hook) && !hKBD_hook) || - ((expected->flags & winevent_hook_todo) && !strcmp(winetest_platform, "wine"))) + winetest_push_context( "%u", expected - first_expected ); + if (find_next_message( &expected, &received, &matches, todo, file, line )) { - if ((expected->flags & winevent_hook_todo) && hEvent_hook) - { - todo_wine { - ok_( file, line) (FALSE, - "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n", - context, count, expected->message, actual->message); - } - } - expected++; - } - else if (todo) - { - failcount++; - todo_wine { - if (strcmp(winetest_platform, "wine")) dump++; - ok_( file, line) (FALSE, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n", - context, count, expected->message, actual->message); - } - goto done; - } - else - { - ok_( file, line) (FALSE, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n", - context, count, expected->message, actual->message); - dump++; + if (compare_message( expected, received, todo, file, line )) matches = FALSE; expected++; - actual++; + received++; } - count++; + winetest_pop_context(); }
- /* skip all optional trailing messages, check for winevent todo's. */ - while (expected->message && ((expected->flags & optional) || - ((expected->flags & hook) && !hCBT_hook) || - ((expected->flags & winevent_hook) && !hEvent_hook) || - ((expected->flags & winevent_hook_todo) && !strcmp(winetest_platform, "wine")))) + todo_wine_if(todo) + ok_(file, line)( matches, "%s mismatches\n", context ); + + if (winetest_debug > (matches ? 2 : 1)) { - if ((expected->flags & winevent_hook_todo) && hEvent_hook) - { - todo_wine { - ok_( file, line) (FALSE, "%s: %u: the msg sequence is not complete: expected 0x%04x - actual 0x%04x\n", - context, count, expected->message, actual->message); - } - } - expected++; + trace_(file, line)( "expected:\n" ); + for (tmp_expected = expected; tmp_expected->message; ++tmp_expected) + trace_(file, line)( " %u: %#x, %#x, %#lx, %#lx\n", tmp_expected - expected, + tmp_expected->message, tmp_expected->flags, tmp_expected->wParam, + tmp_expected->lParam ); + trace_(file, line)( "received:\n" ); + for (tmp_received = received; tmp_received->message; ++tmp_received) + trace_(file, line)( " %u: %#x, %#x, %#lx, %#lx\n", tmp_received - received, + tmp_received->message, tmp_received->flags, tmp_received->wParam, + tmp_received->lParam ); }
- if (todo) - { - todo_wine { - if (expected->message || actual->message) { - failcount++; - if (strcmp(winetest_platform, "wine")) dump++; - ok_( file, line) (FALSE, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n", - context, count, expected->message, actual->message); - } - } - } - else - { - if (expected->message || actual->message) - { - dump++; - ok_( file, line) (FALSE, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n", - context, count, expected->message, actual->message); - } - } - if( todo && !failcount) /* succeeded yet marked todo */ - todo_wine { - if (!strcmp(winetest_platform, "wine")) dump++; - ok_( file, line)( TRUE, "%s: marked "todo_wine" but succeeds\n", context); - } - -done: - if (dump) dump_sequence(expected_list, context, file, line); flush_sequence(); }
@@ -13997,6 +13860,7 @@ static void test_ShowWindow(void) }; char comment[64]; INT idx; /* index into the above array of names */ + winetest_push_context("%u", i);
idx = (sw[i].cmd == SW_NORMALNA) ? 12 : sw[i].cmd;
@@ -14038,6 +13902,8 @@ static void test_ShowWindow(void) if (0) /* FIXME: Wine behaves completely different here */ ok(EqualRect(&win_rc, &wp.rcNormalPosition), "expected %s got %s\n", wine_dbgstr_rect(&win_rc), wine_dbgstr_rect(&wp.rcNormalPosition)); + + winetest_pop_context(); } DestroyWindow(hwnd); flush_events();
Please ignore that last patch, I think I borked it as I decided late to move the sequence traces after they have been compared (and so the sequence pointers have been modified and sequences are empty).
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=106630
Your paranoid android.
=== debian11 (32 bit report) ===
user32: msg.c:5437: Test succeeded inside todo block: ShowWindow(SW_SHOWMINIMIZED):overlapped mismatches
=== debian11 (32 bit Arabic:Morocco report) ===
user32: msg.c:5437: Test succeeded inside todo block: ShowWindow(SW_SHOWMINIMIZED):overlapped mismatches
=== debian11 (32 bit German report) ===
user32: msg.c:5437: Test succeeded inside todo block: ShowWindow(SW_SHOWMINIMIZED):overlapped mismatches
=== debian11 (32 bit French report) ===
user32: msg.c:5437: Test succeeded inside todo block: ShowWindow(SW_SHOWMINIMIZED):overlapped mismatches
=== debian11 (32 bit Hebrew:Israel report) ===
user32: msg.c:5437: Test succeeded inside todo block: ShowWindow(SW_SHOWMINIMIZED):overlapped mismatches
=== debian11 (32 bit Hindi:India report) ===
user32: msg.c:5437: Test succeeded inside todo block: ShowWindow(SW_SHOWMINIMIZED):overlapped mismatches
=== debian11 (32 bit Japanese:Japan report) ===
user32: msg.c:5437: Test succeeded inside todo block: ShowWindow(SW_SHOWMINIMIZED):overlapped mismatches
=== debian11 (32 bit Chinese:China report) ===
user32: msg.c:5437: Test succeeded inside todo block: ShowWindow(SW_SHOWMINIMIZED):overlapped mismatches
=== debian11 (32 bit WoW report) ===
user32: msg.c:5437: Test succeeded inside todo block: ShowWindow(SW_SHOWMINIMIZED):overlapped mismatches
=== debian11 (64 bit WoW report) ===
user32: msg.c:5437: Test succeeded inside todo block: ShowWindow(SW_SHOWMINIMIZED):overlapped mismatches
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=106626
Your paranoid android.
=== w1064_2qxl (64 bit report) ===
user32: win.c:4207: Test failed: hwnd 000000000041019E/000000000041019E message 0200 win.c:4210: Test failed: hwnd 000000000041019E/000000000041019E message 0201
=== w10pro64_zh_CN (64 bit report) ===
user32: win.c:10385: Test failed: pos = 00fa00fa win.c:10389: Test failed: pos = 00fa00fa win.c:10393: Test failed: pos = 00fa00fa