From: Paul Gofman pgofman@codeweavers.com
--- dlls/user32/tests/win.c | 136 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 166653f0d2c..08a1d0609cc 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -126,6 +126,17 @@ static void flush_events( BOOL remove_messages ) } }
+static void pump_messages(void) +{ + MSG msg; + + while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) + { + TranslateMessage(&msg); + DispatchMessageA(&msg); + } +} + /* 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 ) @@ -10880,6 +10891,8 @@ static void test_update_region(void) const RECT rc = {15, 15, 40, 40}; const POINT wnd_orig = {30, 20}; const POINT child_orig = {10, 5}; + RECT r, expect_rect; + BOOL bret;
parent = CreateWindowExA(0, "MainWindowClass", NULL, WS_VISIBLE | WS_CLIPCHILDREN, @@ -10937,7 +10950,130 @@ static void test_update_region(void)
DeleteObject(rgn1); DeleteObject(rgn2); + + pump_messages(); + /* Test that NULL invalidated region means current full client rect and not the one at the moment of + * invalidation. */ + ValidateRect(parent, NULL); + GetUpdateRect(parent, &r, FALSE); + SetRect(&expect_rect, 0, 0, 0, 0); + ok(EqualRect(&r, &expect_rect), "got %s, expected %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&expect_rect)); + InvalidateRect(parent, NULL, FALSE); + SetRect(&r, 0, 0, 10, 10); + /* Adding a rectangle to NULL one still keeps that as full window. */ + InvalidateRect(parent, &r, FALSE); + GetUpdateRect(parent, &r, FALSE); + GetClientRect(parent, &expect_rect); + ok(EqualRect(&r, &expect_rect), "got %s, expected %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&expect_rect)); + SetWindowPos(parent, NULL, 0, 0, 350, 200, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE); + GetUpdateRect(parent, &r, FALSE); + GetClientRect(parent, &expect_rect); + todo_wine ok(EqualRect(&r, &expect_rect), "got %s, expected %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&expect_rect)); + ValidateRect(parent, NULL); + + SetWindowPos(parent, NULL, 0, 0, 300, 150, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE); + GetUpdateRect(parent, &r, FALSE); + SetRect(&expect_rect, 0, 0, 0, 0); + ok(EqualRect(&r, &expect_rect), "got %s, expected %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&expect_rect)); + RedrawWindow(parent, NULL, 0, RDW_INVALIDATE | RDW_FRAME); + RedrawWindow(parent, NULL, 0, RDW_INVALIDATE); + GetUpdateRect(parent, &r, FALSE); + GetClientRect(parent, &expect_rect); + ok(EqualRect(&r, &expect_rect), "got %s, expected %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&expect_rect)); + SetWindowPos(parent, NULL, 0, 0, 350, 200, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE); + GetUpdateRect(parent, &r, FALSE); + GetClientRect(parent, &expect_rect); + todo_wine ok(EqualRect(&r, &expect_rect), "got %s, expected %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&expect_rect)); + pump_messages(); + RedrawWindow(parent, NULL, 0, RDW_VALIDATE | RDW_FRAME | RDW_ALLCHILDREN); + + ValidateRect(hwnd, NULL); + SetRect(&expect_rect, 0, 0, 0, 0); + GetUpdateRect(hwnd, &r, FALSE); + ok(EqualRect(&r, &expect_rect), "got %s, expected %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&expect_rect)); + GetClientRect(hwnd, &expect_rect); + RedrawWindow(parent, NULL, 0, RDW_INVALIDATE | RDW_ALLCHILDREN); + GetUpdateRect(hwnd, &r, FALSE); + ok(EqualRect(&r, &expect_rect), "got %s, expected %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&expect_rect)); + SetWindowPos(hwnd, NULL, 0, 0, 210, 110, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE); + GetUpdateRect(hwnd, &r, FALSE); + GetClientRect(hwnd, &expect_rect); + todo_wine ok(EqualRect(&r, &expect_rect), "got %s, expected %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&expect_rect)); + ValidateRect(hwnd, NULL); + ValidateRect(parent, NULL); + SetWindowPos(hwnd, NULL, 0, 0, 200, 100, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE); + + SetRect(&expect_rect, 0, 0, 0, 0); + GetUpdateRect(hwnd, &r, FALSE); + ok(EqualRect(&r, &expect_rect), "got %s, expected %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&expect_rect)); + GetClientRect(hwnd, &expect_rect); + InvalidateRect(hwnd, NULL, FALSE); + GetUpdateRect(hwnd, &r, FALSE); + ok(EqualRect(&r, &expect_rect), "got %s, expected %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&expect_rect)); + SetWindowPos(hwnd, NULL, 0, 0, 210, 110, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE); + GetUpdateRect(hwnd, &r, FALSE); + GetClientRect(hwnd, &expect_rect); + todo_wine ok(EqualRect(&r, &expect_rect), "got %s, expected %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&expect_rect)); + ValidateRect(hwnd, NULL); + ValidateRect(parent, NULL); + SetWindowPos(hwnd, NULL, 0, 0, 200, 100, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE); + + SetRect(&expect_rect, 0, 0, 0, 0); + GetUpdateRect(hwnd, &r, FALSE); + ok(EqualRect(&r, &expect_rect), "got %s, expected %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&expect_rect)); + GetClientRect(hwnd, &expect_rect); + InvalidateRect(hwnd, NULL, FALSE); + GetUpdateRect(hwnd, &r, FALSE); + ok(EqualRect(&r, &expect_rect), "got %s, expected %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&expect_rect)); + /* Child window bottom is outside parent window. Invalidated area is still new child window extents + * coordinates cropped to visible part. */ + SetWindowPos(hwnd, NULL, 0, 150, 210, 100, SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE); + GetClientRect(hwnd, &expect_rect); + GetClientRect(parent, &r); + expect_rect.bottom = r.bottom - 150; + GetUpdateRect(hwnd, &r, FALSE); + todo_wine ok(EqualRect(&r, &expect_rect), "got %s, expected %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&expect_rect)); + ValidateRect(hwnd, NULL); + ValidateRect(parent, NULL); + SetWindowPos(hwnd, NULL, 0, 0, 200, 100, SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE); + + SetWindowPos(parent, NULL, 0, 0, 300, 150, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE); + GetUpdateRect(parent, &r, FALSE); + SetRect(&expect_rect, 0, 0, 0, 0); + ok(EqualRect(&r, &expect_rect), "got %s, expected %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&expect_rect)); + + GetClientRect(parent, &r); + InvalidateRect(parent, &r, FALSE); + expect_rect = r; + GetUpdateRect(parent, &r, FALSE); + ok(EqualRect(&r, &expect_rect), "got %s, expected %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&expect_rect)); + SetWindowPos(parent, NULL, 0, 0, 350, 200, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE); + GetUpdateRect(parent, &r, FALSE); + ok(EqualRect(&r, &expect_rect), "got %s, expected %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&expect_rect)); + GetClientRect(parent, &r); + ok(!EqualRect(&r, &expect_rect), "got %s, expected %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&expect_rect)); + + ValidateRect(parent, NULL); + SetWindowPos(parent, NULL, 0, 0, 300, 150, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE); + GetUpdateRect(parent, &r, FALSE); + SetRect(&expect_rect, 0, 0, 0, 0); + ok(EqualRect(&r, &expect_rect), "got %s, expected %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&expect_rect)); + InvalidateRect(parent, NULL, FALSE); + SetRect(&r, 0, 0, 0, 0); + /* Subtracting empty rectangle from update region turns 'full client rect' into the specific coordinates + * region (unlike adding rectangle). */ + bret = ValidateRect(parent, &r); + ok(bret, "got error %lu.\n", GetLastError()); + GetClientRect(parent, &expect_rect); + GetUpdateRect(parent, &r, FALSE); + ok(EqualRect(&r, &expect_rect), "got %s, expected %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&expect_rect)); + SetWindowPos(parent, NULL, 0, 0, 350, 200, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE); + GetUpdateRect(parent, &r, FALSE); + ok(EqualRect(&r, &expect_rect), "got %s, expected %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&expect_rect)); + + ValidateRect(parent, NULL); DestroyWindow(parent); + pump_messages(); }
static void test_window_without_child_style(void)