Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/user32/tests/win.c | 192 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 192 insertions(+)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 385432575e..34ec39bec0 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -10766,6 +10766,197 @@ static void test_IsWindowEnabled(void) DestroyWindow(hwnd); }
+static void test_window_placement(void) +{ + RECT orig = {100, 200, 300, 400}, orig2 = {200, 300, 400, 500}, rect; + WINDOWPLACEMENT wp = {sizeof(wp)}; + HWND hwnd; + BOOL ret; + + hwnd = CreateWindowA("MainWindowClass", "wp", WS_OVERLAPPEDWINDOW, + orig.left, orig.top, orig.right - orig.left, orig.bottom - orig.top, 0, 0, 0, 0); + ok(!!hwnd, "failed to create window, error %u\n", GetLastError()); + + ret = GetWindowPlacement(hwnd, &wp); + ok(ret, "failed to get window placement, error %u\n", GetLastError()); + ok(wp.showCmd == SW_SHOWNORMAL, "got show cmd %u\n", wp.showCmd); + ok(wp.ptMinPosition.x == -1 && wp.ptMinPosition.y == -1, + "got minimized pos (%d,%d)\n", wp.ptMinPosition.x, wp.ptMinPosition.y); + ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1, + "got maximized pos (%d,%d)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y); + ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n", + wine_dbgstr_rect(&wp.rcNormalPosition)); + + ShowWindow(hwnd, SW_MINIMIZE); + + ret = GetWindowPlacement(hwnd, &wp); + ok(ret, "failed to get window placement, error %u\n", GetLastError()); + ok(!wp.flags, "got flags %#x\n", wp.flags); + ok(wp.showCmd == SW_SHOWMINIMIZED, "got show cmd %u\n", wp.showCmd); + ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000, + "got minimized pos (%d,%d)\n", wp.ptMinPosition.x, wp.ptMinPosition.y); + ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1, + "got maximized pos (%d,%d)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y); + ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n", + wine_dbgstr_rect(&wp.rcNormalPosition)); + + ShowWindow(hwnd, SW_RESTORE); + + ret = GetWindowPlacement(hwnd, &wp); + ok(ret, "failed to get window placement, error %u\n", GetLastError()); + ok(wp.showCmd == SW_SHOWNORMAL, "got show cmd %u\n", wp.showCmd); + ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000, + "got minimized pos (%d,%d)\n", wp.ptMinPosition.x, wp.ptMinPosition.y); + ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1, + "got maximized pos (%d,%d)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y); + ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n", + wine_dbgstr_rect(&wp.rcNormalPosition)); + + ShowWindow(hwnd, SW_MAXIMIZE); + + ret = GetWindowPlacement(hwnd, &wp); + ok(ret, "failed to get window placement, error %u\n", GetLastError()); + ok(wp.showCmd == SW_SHOWMAXIMIZED, "got show cmd %u\n", wp.showCmd); + ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000, + "got minimized pos (%d,%d)\n", wp.ptMinPosition.x, wp.ptMinPosition.y); +todo_wine + ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1, + "got maximized pos (%d,%d)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y); + ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n", + wine_dbgstr_rect(&wp.rcNormalPosition)); + + SetWindowPos(hwnd, 0, 100, 100, 100, 100, SWP_NOZORDER | SWP_NOACTIVATE); + + ret = GetWindowPlacement(hwnd, &wp); + ok(ret, "failed to get window placement, error %u\n", GetLastError()); + ok(wp.showCmd == SW_SHOWMAXIMIZED, "got show cmd %u\n", wp.showCmd); + ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000, + "got minimized pos (%d,%d)\n", wp.ptMinPosition.x, wp.ptMinPosition.y); + ok(wp.ptMaxPosition.x == 100 && wp.ptMaxPosition.y == 100, + "got maximized pos (%d,%d)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y); + ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n", + wine_dbgstr_rect(&wp.rcNormalPosition)); + + ShowWindow(hwnd, SW_MINIMIZE); + + ret = GetWindowPlacement(hwnd, &wp); + ok(ret, "failed to get window placement, error %u\n", GetLastError()); + ok(wp.flags == WPF_RESTORETOMAXIMIZED, "got flags %#x\n", wp.flags); + ok(wp.showCmd == SW_SHOWMINIMIZED, "got show cmd %u\n", wp.showCmd); + ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000, + "got minimized pos (%d,%d)\n", wp.ptMinPosition.x, wp.ptMinPosition.y); +todo_wine + ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1, + "got maximized pos (%d,%d)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y); + ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n", + wine_dbgstr_rect(&wp.rcNormalPosition)); + + ShowWindow(hwnd, SW_RESTORE); + + ret = GetWindowPlacement(hwnd, &wp); + ok(ret, "failed to get window placement, error %u\n", GetLastError()); + ok(wp.showCmd == SW_SHOWMAXIMIZED, "got show cmd %u\n", wp.showCmd); + ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000, + "got minimized pos (%d,%d)\n", wp.ptMinPosition.x, wp.ptMinPosition.y); +todo_wine + ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1, + "got maximized pos (%d,%d)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y); + ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n", + wine_dbgstr_rect(&wp.rcNormalPosition)); + + ShowWindow(hwnd, SW_RESTORE); + + ret = GetWindowPlacement(hwnd, &wp); + ok(ret, "failed to get window placement, error %u\n", GetLastError()); + ok(wp.showCmd == SW_SHOWNORMAL, "got show cmd %u\n", wp.showCmd); + ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000, + "got minimized pos (%d,%d)\n", wp.ptMinPosition.x, wp.ptMinPosition.y); +todo_wine + ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1, + "got maximized pos (%d,%d)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y); + ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n", + wine_dbgstr_rect(&wp.rcNormalPosition)); + + wp.flags = WPF_SETMINPOSITION; + wp.ptMinPosition.x = wp.ptMinPosition.y = 100; + wp.ptMaxPosition.x = wp.ptMaxPosition.y = 100; + wp.rcNormalPosition = orig2; + ret = SetWindowPlacement(hwnd, &wp); + ok(ret, "failed to set window placement, error %u\n", GetLastError()); + + ret = GetWindowPlacement(hwnd, &wp); + ok(ret, "failed to get window placement, error %u\n", GetLastError()); + ok(wp.showCmd == SW_SHOWNORMAL, "got show cmd %u\n", wp.showCmd); + ok(wp.ptMinPosition.x == 100 && wp.ptMinPosition.y == 100, + "got minimized pos (%d,%d)\n", wp.ptMinPosition.x, wp.ptMinPosition.y); +todo_wine + ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1, + "got maximized pos (%d,%d)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y); + ok(EqualRect(&wp.rcNormalPosition, &orig2), "got normal pos %s\n", + wine_dbgstr_rect(&wp.rcNormalPosition)); + GetWindowRect(hwnd, &rect); + ok(EqualRect(&rect, &orig2), "got window rect %s\n", wine_dbgstr_rect(&rect)); + + ShowWindow(hwnd, SW_MINIMIZE); + + ret = GetWindowPlacement(hwnd, &wp); + ok(ret, "failed to get window placement, error %u\n", GetLastError()); + ok(!wp.flags, "got flags %#x\n", wp.flags); + ok(wp.showCmd == SW_SHOWMINIMIZED, "got show cmd %u\n", wp.showCmd); + ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000, + "got minimized pos (%d,%d)\n", wp.ptMinPosition.x, wp.ptMinPosition.y); +todo_wine + ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1, + "got maximized pos (%d,%d)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y); + ok(EqualRect(&wp.rcNormalPosition, &orig2), "got normal pos %s\n", + wine_dbgstr_rect(&wp.rcNormalPosition)); + + ShowWindow(hwnd, SW_RESTORE); + + wp.flags = WPF_SETMINPOSITION; + wp.showCmd = SW_MINIMIZE; + wp.ptMinPosition.x = wp.ptMinPosition.y = 100; + wp.ptMaxPosition.x = wp.ptMaxPosition.y = 100; + wp.rcNormalPosition = orig; + ret = SetWindowPlacement(hwnd, &wp); + ok(ret, "failed to set window placement, error %u\n", GetLastError()); + + ret = GetWindowPlacement(hwnd, &wp); + ok(ret, "failed to get window placement, error %u\n", GetLastError()); + ok(!wp.flags, "got flags %#x\n", wp.flags); + ok(wp.showCmd == SW_SHOWMINIMIZED, "got show cmd %u\n", wp.showCmd); + ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000, + "got minimized pos (%d,%d)\n", wp.ptMinPosition.x, wp.ptMinPosition.y); +todo_wine + ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1, + "got maximized pos (%d,%d)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y); + ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n", + wine_dbgstr_rect(&wp.rcNormalPosition)); + + ShowWindow(hwnd, SW_RESTORE); + + wp.flags = WPF_SETMINPOSITION; + wp.showCmd = SW_MAXIMIZE; + wp.ptMinPosition.x = wp.ptMinPosition.y = 100; + wp.ptMaxPosition.x = wp.ptMaxPosition.y = 100; + wp.rcNormalPosition = orig; + ret = SetWindowPlacement(hwnd, &wp); + ok(ret, "failed to set window placement, error %u\n", GetLastError()); + + ret = GetWindowPlacement(hwnd, &wp); + ok(ret, "failed to get window placement, error %u\n", GetLastError()); + ok(wp.showCmd == SW_SHOWMAXIMIZED, "got show cmd %u\n", wp.showCmd); + ok(wp.ptMinPosition.x == 100 && wp.ptMinPosition.y == 100, + "got minimized pos (%d,%d)\n", wp.ptMinPosition.x, wp.ptMinPosition.y); +todo_wine + ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1, + "got maximized pos (%d,%d)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y); + ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n", + wine_dbgstr_rect(&wp.rcNormalPosition)); + + DestroyWindow(hwnd); +} + START_TEST(win) { char **argv; @@ -10922,6 +11113,7 @@ START_TEST(win) test_minimize_window(hwndMain); test_destroy_quit(); test_IsWindowEnabled(); + test_window_placement();
/* add the tests above this line */ if (hhook) UnhookWindowsHookEx(hhook);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/user32/tests/win.c | 125 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 34ec39bec0..96815707b8 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -6725,6 +6725,130 @@ static void test_ShowWindow(void) flush_events(TRUE); }
+static void test_ShowWindow_owned(HWND hwndMain) +{ + MONITORINFO mon_info = {sizeof(mon_info)}; + RECT rect, orig, expect; + BOOL ret; + HWND hwnd, hwnd2; + LONG style; + + GetMonitorInfoW(MonitorFromWindow(hwndMain, MONITOR_DEFAULTTOPRIMARY), &mon_info); + SetRect(&orig, 20, 20, 210, 110); + hwnd = CreateWindowA("MainWindowClass", "owned", WS_CAPTION | WS_SYSMENU | + WS_MINIMIZEBOX | WS_MAXIMIZEBOX, + orig.left, orig.top, orig.right - orig.left, + orig.bottom - orig.top, hwndMain, 0, 0, NULL); + ok(!!hwnd, "failed to create window, error %u\n", GetLastError()); + hwnd2 = CreateWindowA("MainWindowClass", "owned2", WS_CAPTION | WS_SYSMENU | + WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_VISIBLE, + orig.left, orig.top, orig.right - orig.left, + orig.bottom - orig.top, hwndMain, 0, 0, NULL); + ok(!!hwnd2, "failed to create window, error %u\n", GetLastError()); + + style = GetWindowLongA(hwnd, GWL_STYLE); + ok(!(style & WS_DISABLED), "window should not be disabled\n"); + ok(!(style & WS_VISIBLE), "window should not be visible\n"); + ok(!(style & WS_MINIMIZE), "window should not be minimized\n"); + ok(!(style & WS_MAXIMIZE), "window should not be maximized\n"); + GetWindowRect(hwnd, &rect); + ok(EqualRect(&orig, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&orig), wine_dbgstr_rect(&rect)); + + ret = ShowWindow(hwnd, SW_SHOW); + ok(!ret, "wrong ret %d\n", ret); + style = GetWindowLongA(hwnd, GWL_STYLE); + ok(!(style & WS_DISABLED), "window should not be disabled\n"); + ok(style & WS_VISIBLE, "window should be visible\n"); + ok(!(style & WS_MINIMIZE), "window should not be minimized\n"); + ok(!(style & WS_MAXIMIZE), "window should not be maximized\n"); + GetWindowRect(hwnd, &rect); + ok(EqualRect(&orig, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&orig), wine_dbgstr_rect(&rect)); + + ret = ShowWindow(hwnd, SW_MINIMIZE); + ok(ret, "wrong ret %d\n", ret); + style = GetWindowLongA(hwnd, GWL_STYLE); + ok(!(style & WS_DISABLED), "window should not be disabled\n"); + ok(style & WS_VISIBLE, "window should be visible\n"); + ok(style & WS_MINIMIZE, "window should be minimized\n"); + ok(!(style & WS_MAXIMIZE), "window should not be maximized\n"); + GetWindowRect(hwnd, &rect); + SetRect(&expect, 0, mon_info.rcWork.bottom - GetSystemMetrics(SM_CYMINIMIZED), + GetSystemMetrics(SM_CXMINIMIZED), mon_info.rcWork.bottom); + todo_wine + ok(EqualRect(&expect, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect)); + /* shouldn't be able to resize minimized windows */ + ret = SetWindowPos(hwnd, 0, 0, 0, 200, 200, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); + ok(ret, "wrong ret %d\n", ret); + GetWindowRect(hwnd, &rect); + todo_wine + ok(EqualRect(&expect, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect)); + + /* multiple minimized owned windows stack next to each other (and eventually + * on top of each other) */ + OffsetRect(&expect, GetSystemMetrics(SM_CXMINIMIZED), 0); + ret = ShowWindow(hwnd2, SW_MINIMIZE); + ok(ret, "wrong ret %d\n", ret); + style = GetWindowLongA(hwnd2, GWL_STYLE); + ok(!(style & WS_DISABLED), "window should not be disabled\n"); + ok(style & WS_VISIBLE, "window should be visible\n"); + ok(style & WS_MINIMIZE, "window should be minimized\n"); + ok(!(style & WS_MAXIMIZE), "window should not be maximized\n"); + GetWindowRect(hwnd2, &rect); + todo_wine + ok(EqualRect(&expect, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect)); + + ShowWindow(hwnd, SW_RESTORE); + ok(ret, "wrong ret %d\n", ret); + style = GetWindowLongA(hwnd, GWL_STYLE); + ok(!(style & WS_DISABLED), "window should not be disabled\n"); + ok(style & WS_VISIBLE, "window should be visible\n"); + ok(!(style & WS_MINIMIZE), "window should not be minimized\n"); + ok(!(style & WS_MAXIMIZE), "window should not be maximized\n"); + GetWindowRect(hwnd, &rect); + ok(EqualRect(&orig, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&orig), wine_dbgstr_rect(&rect)); + + ShowWindow(hwnd, SW_MAXIMIZE); + ok(ret, "wrong ret %d\n", ret); + style = GetWindowLongA(hwnd, GWL_STYLE); + ok(!(style & WS_DISABLED), "window should not be disabled\n"); + ok(style & WS_VISIBLE, "window should be visible\n"); + ok(!(style & WS_MINIMIZE), "window should be minimized\n"); + ok(style & WS_MAXIMIZE, "window should not be maximized\n"); + GetWindowRect(hwnd, &rect); + expect = mon_info.rcWork; + AdjustWindowRectEx(&expect, GetWindowLongA(hwnd, GWL_STYLE) & ~WS_BORDER, + 0, GetWindowLongA(hwnd, GWL_EXSTYLE)); + ok(EqualRect(&expect, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect)); + /* maximized windows can be resized */ + ret = SetWindowPos(hwnd, 0, 300, 300, 200, 200, SWP_NOACTIVATE | SWP_NOZORDER); + ok(ret, "wrong ret %d\n", ret); + GetWindowRect(hwnd, &rect); + SetRect(&expect, 300, 300, 500, 500); + ok(EqualRect(&expect, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect)); + + ShowWindow(hwnd, SW_RESTORE); + ok(ret, "wrong ret %d\n", ret); + style = GetWindowLongA(hwnd, GWL_STYLE); + ok(!(style & WS_DISABLED), "window should not be disabled\n"); + ok(style & WS_VISIBLE, "window should be visible\n"); + ok(!(style & WS_MINIMIZE), "window should not be minimized\n"); + ok(!(style & WS_MAXIMIZE), "window should not be maximized\n"); + GetWindowRect(hwnd, &rect); + ok(EqualRect(&orig, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&orig), wine_dbgstr_rect(&rect)); + + DestroyWindow(hwnd2); + DestroyWindow(hwnd); +} + static DWORD CALLBACK enablewindow_thread(LPVOID arg) { HWND hwnd = arg; @@ -11089,6 +11213,7 @@ START_TEST(win) test_SetWindowLong(); test_set_window_style(); test_ShowWindow(); + test_ShowWindow_owned(hwndMain); test_EnableWindow(); test_gettext(); test_GetUpdateRect();
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/user32/tests/win.c | 131 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 96815707b8..88d95d7c0b 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -6849,6 +6849,136 @@ static void test_ShowWindow_owned(HWND hwndMain) DestroyWindow(hwnd); }
+static void test_ShowWindow_child(HWND hwndMain) +{ + RECT rect, orig, expect; + BOOL ret; + HWND hwnd, hwnd2; + LONG style; + POINT pt = {0}; + + SetRect(&orig, 20, 20, 210, 110); + hwnd = CreateWindowA("MainWindowClass", "child", WS_CAPTION | WS_SYSMENU | + WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CHILD, + orig.left, orig.top, orig.right - orig.left, + orig.bottom - orig.top, hwndMain, 0, 0, NULL); + ok(!!hwnd, "failed to create window, error %u\n", GetLastError()); + hwnd2 = CreateWindowA("MainWindowClass", "child2", WS_CAPTION | WS_SYSMENU | + WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CHILD | WS_VISIBLE, + orig.left, orig.top, orig.right - orig.left, + orig.bottom - orig.top, hwndMain, 0, 0, NULL); + ok(!!hwnd2, "failed to create window, error %u\n", GetLastError()); + + ClientToScreen(hwndMain, &pt); + OffsetRect(&orig, pt.x, pt.y); + + style = GetWindowLongA(hwnd, GWL_STYLE); + ok(!(style & WS_DISABLED), "window should not be disabled\n"); + ok(!(style & WS_VISIBLE), "window should not be visible\n"); + ok(!(style & WS_MINIMIZE), "window should not be minimized\n"); + ok(!(style & WS_MAXIMIZE), "window should not be maximized\n"); + GetWindowRect(hwnd, &rect); + ok(EqualRect(&orig, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&orig), wine_dbgstr_rect(&rect)); + + ret = ShowWindow(hwnd, SW_SHOW); + ok(!ret, "wrong ret %d\n", ret); + style = GetWindowLongA(hwnd, GWL_STYLE); + ok(!(style & WS_DISABLED), "window should not be disabled\n"); + ok(style & WS_VISIBLE, "window should be visible\n"); + ok(!(style & WS_MINIMIZE), "window should not be minimized\n"); + ok(!(style & WS_MAXIMIZE), "window should not be maximized\n"); + GetWindowRect(hwnd, &rect); + ok(EqualRect(&orig, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&orig), wine_dbgstr_rect(&rect)); + + ret = ShowWindow(hwnd, SW_MINIMIZE); + ok(ret, "wrong ret %d\n", ret); + style = GetWindowLongA(hwnd, GWL_STYLE); + ok(!(style & WS_DISABLED), "window should not be disabled\n"); + ok(style & WS_VISIBLE, "window should be visible\n"); + ok(style & WS_MINIMIZE, "window should be minimized\n"); + ok(!(style & WS_MAXIMIZE), "window should not be maximized\n"); + GetWindowRect(hwnd, &rect); + GetClientRect(hwndMain, &expect); + SetRect(&expect, 0, expect.bottom - GetSystemMetrics(SM_CYMINIMIZED), + GetSystemMetrics(SM_CXMINIMIZED), expect.bottom); + OffsetRect(&expect, pt.x, pt.y); + todo_wine + ok(EqualRect(&expect, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect)); + /* shouldn't be able to resize minimized windows */ + ret = SetWindowPos(hwnd, 0, 0, 0, 200, 200, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); + ok(ret, "wrong ret %d\n", ret); + GetWindowRect(hwnd, &rect); + todo_wine + ok(EqualRect(&expect, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect)); + + /* multiple minimized children also stack; here the parent is too small to + * fit more than one per row */ + OffsetRect(&expect, 0, -GetSystemMetrics(SM_CYMINIMIZED)); + ret = ShowWindow(hwnd2, SW_MINIMIZE); + ok(ret, "wrong ret %d\n", ret); + style = GetWindowLongA(hwnd2, GWL_STYLE); + ok(!(style & WS_DISABLED), "window should not be disabled\n"); + ok(style & WS_VISIBLE, "window should be visible\n"); + ok(style & WS_MINIMIZE, "window should be minimized\n"); + ok(!(style & WS_MAXIMIZE), "window should not be maximized\n"); + GetWindowRect(hwnd2, &rect); + todo_wine + ok(EqualRect(&expect, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect)); + + ShowWindow(hwnd, SW_RESTORE); + ok(ret, "wrong ret %d\n", ret); + style = GetWindowLongA(hwnd, GWL_STYLE); + ok(!(style & WS_DISABLED), "window should not be disabled\n"); + ok(style & WS_VISIBLE, "window should be visible\n"); + ok(!(style & WS_MINIMIZE), "window should not be minimized\n"); + ok(!(style & WS_MAXIMIZE), "window should not be maximized\n"); + GetWindowRect(hwnd, &rect); + ok(EqualRect(&orig, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&orig), wine_dbgstr_rect(&rect)); + + ShowWindow(hwnd, SW_MAXIMIZE); + ok(ret, "wrong ret %d\n", ret); + style = GetWindowLongA(hwnd, GWL_STYLE); + ok(!(style & WS_DISABLED), "window should not be disabled\n"); + ok(style & WS_VISIBLE, "window should be visible\n"); + ok(!(style & WS_MINIMIZE), "window should be minimized\n"); + ok(style & WS_MAXIMIZE, "window should not be maximized\n"); + GetWindowRect(hwnd, &rect); + GetClientRect(hwndMain, &expect); + AdjustWindowRectEx(&expect, GetWindowLongA(hwnd, GWL_STYLE) & ~WS_BORDER, + 0, GetWindowLongA(hwnd, GWL_EXSTYLE)); + OffsetRect(&expect, pt.x, pt.y); + ok(EqualRect(&expect, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect)); + /* maximized windows can be resized */ + ret = SetWindowPos(hwnd, 0, 300, 300, 200, 200, SWP_NOACTIVATE | SWP_NOZORDER); + ok(ret, "wrong ret %d\n", ret); + GetWindowRect(hwnd, &rect); + SetRect(&expect, 300, 300, 500, 500); + OffsetRect(&expect, pt.x, pt.y); + ok(EqualRect(&expect, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect)); + + ShowWindow(hwnd, SW_RESTORE); + ok(ret, "wrong ret %d\n", ret); + style = GetWindowLongA(hwnd, GWL_STYLE); + ok(!(style & WS_DISABLED), "window should not be disabled\n"); + ok(style & WS_VISIBLE, "window should be visible\n"); + ok(!(style & WS_MINIMIZE), "window should not be minimized\n"); + ok(!(style & WS_MAXIMIZE), "window should not be maximized\n"); + GetWindowRect(hwnd, &rect); + ok(EqualRect(&orig, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&orig), wine_dbgstr_rect(&rect)); + + DestroyWindow(hwnd2); + DestroyWindow(hwnd); +} + static DWORD CALLBACK enablewindow_thread(LPVOID arg) { HWND hwnd = arg; @@ -11214,6 +11344,7 @@ START_TEST(win) test_set_window_style(); test_ShowWindow(); test_ShowWindow_owned(hwndMain); + test_ShowWindow_child(hwndMain); test_EnableWindow(); test_gettext(); test_GetUpdateRect();
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/user32/tests/win.c | 127 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 88d95d7c0b..65e4b14696 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -6979,6 +6979,132 @@ static void test_ShowWindow_child(HWND hwndMain) DestroyWindow(hwnd); }
+static void test_ShowWindow_mdichild(HWND hwndMain) +{ + RECT rect, orig, expect; + BOOL ret; + HWND mdiclient, hwnd, hwnd2; + LONG style; + POINT pt = {0}; + CLIENTCREATESTRUCT mdi_client_cs = {0,1}; + + SetRect(&orig, 20, 20, 210, 110); + GetClientRect(hwndMain, &rect); + mdiclient = CreateWindowA("mdiclient", "MDI client", WS_CHILD, + rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, + hwndMain, 0, 0, &mdi_client_cs); + ok(!!mdiclient, "failed to create window, error %u\n", GetLastError()); + hwnd = CreateWindowExA(WS_EX_MDICHILD, "MainWindowClass", "MDI child", + WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX, + orig.left, orig.top, orig.right - orig.left, + orig.bottom - orig.top, mdiclient, 0, 0, NULL); + ok(!!hwnd, "failed to create window, error %u\n", GetLastError()); + hwnd2 = CreateWindowExA(WS_EX_MDICHILD, "MainWindowClass", "MDI child 2", + WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX, + orig.left, orig.top, orig.right - orig.left, + orig.bottom - orig.top, mdiclient, 0, 0, NULL); + ok(!!hwnd2, "failed to create window, error %u\n", GetLastError()); + + ClientToScreen(hwndMain, &pt); + OffsetRect(&orig, pt.x, pt.y); + + style = GetWindowLongA(hwnd, GWL_STYLE); + ok(!(style & WS_DISABLED), "window should not be disabled\n"); + ok(style & WS_VISIBLE, "window should not be visible\n"); + ok(!(style & WS_MINIMIZE), "window should not be minimized\n"); + ok(!(style & WS_MAXIMIZE), "window should not be maximized\n"); + GetWindowRect(hwnd, &rect); + ok(EqualRect(&orig, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&orig), wine_dbgstr_rect(&rect)); + + ret = ShowWindow(hwnd, SW_MINIMIZE); + ok(ret, "wrong ret %d\n", ret); + style = GetWindowLongA(hwnd, GWL_STYLE); + ok(!(style & WS_DISABLED), "window should not be disabled\n"); + ok(style & WS_VISIBLE, "window should be visible\n"); + ok(style & WS_MINIMIZE, "window should be minimized\n"); + ok(!(style & WS_MAXIMIZE), "window should not be maximized\n"); + GetWindowRect(hwnd, &rect); + GetClientRect(hwndMain, &expect); + SetRect(&expect, 0, expect.bottom - GetSystemMetrics(SM_CYMINIMIZED), + GetSystemMetrics(SM_CXMINIMIZED), expect.bottom); + OffsetRect(&expect, pt.x, pt.y); + todo_wine + ok(EqualRect(&expect, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect)); + /* shouldn't be able to resize minimized windows */ + ret = SetWindowPos(hwnd, 0, 0, 0, 200, 200, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); + ok(ret, "wrong ret %d\n", ret); + GetWindowRect(hwnd, &rect); + todo_wine + ok(EqualRect(&expect, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect)); + + /* multiple minimized children also stack; here the parent is too small to + * fit more than one per row */ + OffsetRect(&expect, 0, -GetSystemMetrics(SM_CYMINIMIZED)); + ret = ShowWindow(hwnd2, SW_MINIMIZE); + ok(ret, "wrong ret %d\n", ret); + style = GetWindowLongA(hwnd2, GWL_STYLE); + ok(!(style & WS_DISABLED), "window should not be disabled\n"); + ok(style & WS_VISIBLE, "window should be visible\n"); + ok(style & WS_MINIMIZE, "window should be minimized\n"); + ok(!(style & WS_MAXIMIZE), "window should not be maximized\n"); + GetWindowRect(hwnd2, &rect); + todo_wine + ok(EqualRect(&expect, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect)); + + ShowWindow(hwnd, SW_RESTORE); + ok(ret, "wrong ret %d\n", ret); + style = GetWindowLongA(hwnd, GWL_STYLE); + ok(!(style & WS_DISABLED), "window should not be disabled\n"); + ok(style & WS_VISIBLE, "window should be visible\n"); + ok(!(style & WS_MINIMIZE), "window should not be minimized\n"); + ok(!(style & WS_MAXIMIZE), "window should not be maximized\n"); + GetWindowRect(hwnd, &rect); + ok(EqualRect(&orig, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&orig), wine_dbgstr_rect(&rect)); + + ShowWindow(hwnd, SW_MAXIMIZE); + ok(ret, "wrong ret %d\n", ret); + style = GetWindowLongA(hwnd, GWL_STYLE); + ok(!(style & WS_DISABLED), "window should not be disabled\n"); + ok(style & WS_VISIBLE, "window should be visible\n"); + ok(!(style & WS_MINIMIZE), "window should be minimized\n"); + ok(style & WS_MAXIMIZE, "window should not be maximized\n"); + GetWindowRect(hwnd, &rect); + GetClientRect(hwndMain, &expect); + AdjustWindowRectEx(&expect, GetWindowLongA(hwnd, GWL_STYLE) & ~WS_BORDER, + 0, GetWindowLongA(hwnd, GWL_EXSTYLE)); + OffsetRect(&expect, pt.x, pt.y); + ok(EqualRect(&expect, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect)); + /* maximized windows can be resized */ + ret = SetWindowPos(hwnd, 0, 300, 300, 200, 200, SWP_NOACTIVATE | SWP_NOZORDER); + ok(ret, "wrong ret %d\n", ret); + GetWindowRect(hwnd, &rect); + SetRect(&expect, 300, 300, 500, 500); + OffsetRect(&expect, pt.x, pt.y); + ok(EqualRect(&expect, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect)); + + ShowWindow(hwnd, SW_RESTORE); + ok(ret, "wrong ret %d\n", ret); + style = GetWindowLongA(hwnd, GWL_STYLE); + ok(!(style & WS_DISABLED), "window should not be disabled\n"); + ok(style & WS_VISIBLE, "window should be visible\n"); + ok(!(style & WS_MINIMIZE), "window should not be minimized\n"); + ok(!(style & WS_MAXIMIZE), "window should not be maximized\n"); + GetWindowRect(hwnd, &rect); + ok(EqualRect(&orig, &rect), "expected %s, got %s\n", + wine_dbgstr_rect(&orig), wine_dbgstr_rect(&rect)); + + DestroyWindow(hwnd2); + DestroyWindow(hwnd); + DestroyWindow(mdiclient); +} + static DWORD CALLBACK enablewindow_thread(LPVOID arg) { HWND hwnd = arg; @@ -11345,6 +11471,7 @@ START_TEST(win) test_ShowWindow(); test_ShowWindow_owned(hwndMain); test_ShowWindow_child(hwndMain); + test_ShowWindow_mdichild(hwndMain); test_EnableWindow(); test_gettext(); test_GetUpdateRect();
Hi,
While running your changed tests on Windows, 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=47684
Your paranoid android.
=== w7u (32 bit report) ===
user32: win.c:3697: Test failed: message 0200 available
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/user32/tests/win.c | 162 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 162 insertions(+)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 65e4b14696..50dbf49e19 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -11337,6 +11337,167 @@ todo_wine DestroyWindow(hwnd); }
+static void test_arrange_iconic_windows(void) +{ + MINIMIZEDMETRICS mm = {sizeof(mm)}, oldmm = {sizeof(oldmm)}; + RECT orig = {100, 200, 300, 400}, rect, expect, parent_rect; + POINT pt = {0}; + HWND parent, hwnds[10]; + UINT ret; + int i, row, col; + + parent = CreateWindowA("MainWindowClass", "parent", WS_OVERLAPPEDWINDOW, + 100, 200, 500, 300, NULL, 0, 0, NULL); + ok(!!parent, "failed to create window, error %u\n", GetLastError()); + + GetClientRect(parent, &parent_rect); + ClientToScreen(parent, &pt); + SystemParametersInfoA(SPI_GETMINIMIZEDMETRICS, sizeof(oldmm), &oldmm, 0); + + mm.iWidth = 100; + mm.iHorzGap = 40; + mm.iVertGap = 3; + mm.iArrange = ARW_TOPLEFT | ARW_RIGHT; + ret = SystemParametersInfoA(SPI_SETMINIMIZEDMETRICS, sizeof(mm), &mm, 0); + ok(ret, "failed to set minimized metrics, error %u\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = ArrangeIconicWindows(parent); +todo_wine + ok(!ret, "wrong ret %u\n", ret); + ok(GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError()); + + for (i = 0; i < ARRAY_SIZE(hwnds); ++i) + { + hwnds[i] = CreateWindowA("MainWindowClass", "child", WS_CHILD | + WS_OVERLAPPEDWINDOW, orig.left, orig.top, orig.right - orig.left, + orig.bottom - orig.top, parent, 0, 0, NULL); + ok(!!hwnds[i], "failed to create window %u, error %u\n", i, GetLastError()); + } + + SetLastError(0xdeadbeef); + ret = ArrangeIconicWindows(parent); +todo_wine + ok(!ret, "wrong ret %u\n", ret); + ok(GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError()); + + for (i = 0; i < ARRAY_SIZE(hwnds); ++i) + { + GetWindowRect(hwnds[i], &rect); + expect = orig; + OffsetRect(&expect, pt.x, pt.y); + ok(EqualRect(&rect, &expect), "hwnd %u: expected rect %s, got %s\n", i, + wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect)); + } + + ShowWindow(hwnds[0], SW_MINIMIZE); + + for (i = 0; i < ARRAY_SIZE(hwnds); ++i) + { + ret = SetWindowPos(hwnds[i], 0, orig.left, orig.top, 0, 0, + SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); + ok(ret, "hwnd %u: failed to move window, error %u\n", i, GetLastError()); + } + + ret = ArrangeIconicWindows(parent); +todo_wine + ok(ret == 1, "wrong ret %u\n", ret); + + GetWindowRect(hwnds[0], &rect); + SetRect(&expect, 0, 0, GetSystemMetrics(SM_CXMINIMIZED), GetSystemMetrics(SM_CYMINIMIZED)); + OffsetRect(&expect, mm.iHorzGap, mm.iVertGap); + OffsetRect(&expect, pt.x, pt.y); +todo_wine + ok(EqualRect(&rect, &expect), "expected rect %s, got %s\n", + wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect)); + + for (i = 1; i < ARRAY_SIZE(hwnds); ++i) + { + GetWindowRect(hwnds[i], &rect); + expect = orig; + OffsetRect(&expect, pt.x, pt.y); + ok(EqualRect(&rect, &expect), "hwnd %u: expected rect %s, got %s\n", i, + wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect)); + } + + for (i = 0; i < ARRAY_SIZE(hwnds); ++i) + { + ShowWindow(hwnds[i], SW_MINIMIZE); + ret = SetWindowPos(hwnds[i], 0, orig.left, orig.top, 0, 0, + SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); + ok(ret, "hwnd %u: failed to move window, error %u\n", i, GetLastError()); + } + + ret = ArrangeIconicWindows(parent); +todo_wine + ok(ret == 10, "wrong ret %u\n", ret); + + col = mm.iHorzGap; + row = mm.iVertGap; + for (i = 0; i < ARRAY_SIZE(hwnds); ++i) + { + if (col + GetSystemMetrics(SM_CXMINIMIZED) > parent_rect.right - parent_rect.left) + { + col = mm.iHorzGap; + row += GetSystemMetrics(SM_CYMINIMIZED) + mm.iVertGap; + } + + GetWindowRect(hwnds[i], &rect); + SetRect(&expect, col, row, col + GetSystemMetrics(SM_CXMINIMIZED), + row + GetSystemMetrics(SM_CYMINIMIZED)); + OffsetRect(&expect, pt.x, pt.y); +todo_wine + ok(EqualRect(&rect, &expect), "hwnd %u: expected rect %s, got %s\n", i, + wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect)); + + col += GetSystemMetrics(SM_CXMINIMIZED) + mm.iHorzGap; + } + + mm.iArrange = ARW_BOTTOMRIGHT | ARW_UP; + mm.iVertGap = 10; + ret = SystemParametersInfoA(SPI_SETMINIMIZEDMETRICS, sizeof(mm), &mm, 0); + ok(ret, "failed to set minimized metrics, error %u\n", GetLastError()); + + for (i = 0; i < ARRAY_SIZE(hwnds); ++i) + { + ret = SetWindowPos(hwnds[i], 0, orig.left, orig.top, 0, 0, + SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); + ok(ret, "hwnd %u: failed to move window, error %u\n", i, GetLastError()); + } + + ret = ArrangeIconicWindows(parent); +todo_wine + ok(ret == 10, "wrong ret %u\n", ret); + + col = parent_rect.right - mm.iHorzGap; + row = parent_rect.bottom - mm.iVertGap; + for (i = 0; i < ARRAY_SIZE(hwnds); ++i) + { + if (row - GetSystemMetrics(SM_CYMINIMIZED) < parent_rect.top) + { + row = parent_rect.bottom - mm.iVertGap; + col -= GetSystemMetrics(SM_CXMINIMIZED) + mm.iHorzGap; + } + + GetWindowRect(hwnds[i], &rect); + SetRect(&expect, col - GetSystemMetrics(SM_CXMINIMIZED), + row - GetSystemMetrics(SM_CYMINIMIZED), col, row); + OffsetRect(&expect, pt.x, pt.y); +todo_wine + ok(EqualRect(&rect, &expect), "hwnd %u: expected rect %s, got %s\n", i, + wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect)); + + row -= GetSystemMetrics(SM_CYMINIMIZED) + mm.iVertGap; + } + + for (i = 0; i < ARRAY_SIZE(hwnds); ++i) + DestroyWindow(hwnds[i]); + DestroyWindow(parent); + + ret = SystemParametersInfoA(SPI_SETMINIMIZEDMETRICS, sizeof(oldmm), &oldmm, 0); + ok(ret, "failed to restore minimized metrics, error %u\n", GetLastError()); +} + START_TEST(win) { char **argv; @@ -11497,6 +11658,7 @@ START_TEST(win) test_destroy_quit(); test_IsWindowEnabled(); test_window_placement(); + test_arrange_iconic_windows();
/* add the tests above this line */ if (hhook) UnhookWindowsHookEx(hhook);
Hi,
While running your changed tests on Windows, 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=47685
Your paranoid android.
=== debian9 (32 bit French report) ===
user32: win.c:9884: Test failed: Expected foreground window 0, got 0xc400ce win.c:9890: Test failed: Expected foreground window 0x20052, got 0xc400ce
On 2/14/19 10:41 PM, Marvin wrote:
Hi,
While running your changed tests on Windows, 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=47685
Your paranoid android.
=== debian9 (32 bit French report) ===
user32: win.c:9884: Test failed: Expected foreground window 0, got 0xc400ce win.c:9890: Test failed: Expected foreground window 0x20052, got 0xc400ce
As usual, this can't result from this patch, and this test is well-known to be finnicky.
Same for the failure in 4/5.