From: Jacob Czekalla <jczekalla@codeweavers.com> This test is specifically for testing the expansion of 5 pixels beyond the monitor and work area when an x11 window is maximized. --- dlls/win32u/tests/win32u.c | 127 +++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/dlls/win32u/tests/win32u.c b/dlls/win32u/tests/win32u.c index 4481ffa1b32..ce747b543b8 100644 --- a/dlls/win32u/tests/win32u.c +++ b/dlls/win32u/tests/win32u.c @@ -3004,6 +3004,132 @@ static void test_NtUserRegisterWindowMessage(void) ok( !wcscmp( buf, L"#0xabc" ), "buf = %s\n", debugstr_w(buf) ); } +struct maximize_test +{ + const char *name; + BOOL is_todo; + RECT test_rect; + RECT expected_rect; +}; +static RECT maximize_rect = { 0 }; +static LRESULT WINAPI test_over_maximize_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + switch (msg) + { + case WM_GETMINMAXINFO: + { + MONITORINFO mi; + MINMAXINFO *mmi = (MINMAXINFO *)lparam; + HMONITOR monitor; + RECT rect = maximize_rect; + + if ((rect.left | rect.right | rect.top | rect.bottom) == 0) + break; + + mi.cbSize = sizeof(mi); + + monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST); + if (!monitor || !GetMonitorInfoW(monitor, &mi)) + break; + + InflateRect(&rect, 5, 5); + + mmi->ptMaxPosition.x = rect.left - mi.rcMonitor.left; + mmi->ptMaxPosition.y = rect.top - mi.rcMonitor.top; + + mmi->ptMaxSize.x = rect.right - rect.left; + mmi->ptMaxSize.y = rect.bottom - rect.top; + + mmi->ptMaxTrackSize.x = mmi->ptMaxSize.x; + mmi->ptMaxTrackSize.y = mmi->ptMaxSize.y; + + return 0; + } + default: + break; + } + return DefWindowProcW(hwnd, msg, wparam, lparam); +} + +static void test_no_caption_maximize(void) +{ + HWND hwnd; + WNDCLASSW cls = { 0 }; + MONITORINFO monitor_info = { sizeof ( MONITORINFO ) }; + HMONITOR monitor; + DWORD style, i; + struct maximize_test tests[2]; + HMODULE ntdll; + RECT rc; + + cls.lpfnWndProc = test_over_maximize_proc; + cls.hInstance = GetModuleHandleW(NULL); + cls.lpszClassName = L"maximize_test"; + RegisterClassW(&cls); + + hwnd = CreateWindowW(L"maximize_test", NULL, WS_OVERLAPPEDWINDOW, 50, 50, 100, 100, 0, NULL, GetModuleHandleW(NULL), NULL); + if (!hwnd) + return; + + ntdll = GetModuleHandleA("ntdll.dll"); + if (ntdll && GetProcAddress(ntdll, "wine_get_version") && !GetModuleHandleA("winex11.drv")) + { + skip("Skipping x11 maximize test.\n"); + DestroyWindow(hwnd); + return; + } + + style = GetWindowLongW(hwnd, GWL_STYLE); + style &= ~WS_CAPTION; + SetWindowLongW(hwnd, GWL_STYLE, style); + SetWindowPos(hwnd, NULL, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | + SWP_NOACTIVATE | SWP_FRAMECHANGED); + flush_events(); + + monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST); + if (!monitor || !GetMonitorInfoW(monitor, &monitor_info)) + { + DestroyWindow(hwnd); + return; + } + + /* test cases */ + tests[0].name = "monitor"; + tests[0].test_rect = monitor_info.rcMonitor; + tests[0].expected_rect = monitor_info.rcMonitor; + tests[0].is_todo = FALSE; + InflateRect(&tests[0].expected_rect, 5, 5); + + tests[1].name = "work area"; + tests[1].test_rect = monitor_info.rcWork; + tests[1].expected_rect = monitor_info.rcWork; + tests[1].is_todo = TRUE; + InflateRect(&tests[1].expected_rect, 5, 5); + + for (i = 0; i < ARRAY_SIZE(tests); i++) + { + maximize_rect = tests[i].test_rect; + + if (IsZoomed(hwnd)) + { + ShowWindow(hwnd, SW_RESTORE); + flush_events(); + } + + ShowWindow(hwnd, SW_MAXIMIZE); + flush_events(); + + GetWindowRect(hwnd, &rc); + todo_wine_if(tests[i].is_todo) + ok(EqualRect(&tests[i].expected_rect, &rc), "%s: expected %s got %s\n", tests[i].name, wine_dbgstr_rect(&tests[i].expected_rect), wine_dbgstr_rect(&rc)); + style = GetWindowLongW(hwnd, GWL_STYLE); + ok(style & WS_MAXIMIZE, "%s: style incorrect, missing WS_MAXIMIZE.\n", tests[i].name); + } + + DestroyWindow(hwnd); +} + START_TEST(win32u) { char **argv; @@ -3049,6 +3175,7 @@ START_TEST(win32u) test_timer(); test_inter_process_messages( argv[0] ); test_wndproc_hook(); + test_no_caption_maximize(); test_NtUserCloseWindowStation(); test_NtUserDisplayConfigGetDeviceInfo(); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11099