Signed-off-by: Waritnan Sookbuntherng lion328@hotmail.co.th --- v2: Add tests. v3: Cover more points. --- dlls/comctl32/tests/status.c | 85 ++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+)
diff --git a/dlls/comctl32/tests/status.c b/dlls/comctl32/tests/status.c index d78bd20262..074e637801 100644 --- a/dlls/comctl32/tests/status.c +++ b/dlls/comctl32/tests/status.c @@ -20,6 +20,7 @@
#include <windows.h> #include <commctrl.h> +#include <uxtheme.h>
#include "wine/test.h"
@@ -586,6 +587,89 @@ static void test_notify(void) ok(g_got_contextmenu, "WM_RBUTTONUP did not activate the context menu!\n"); }
+static void test_sizegrip(void) +{ + HWND hwndStatus; + LONG style; + RECT rcClient, rcGripper; + POINT pt; + int width, r; + + hwndStatus = CreateWindowA(SUBCLASS_NAME, "", WS_CHILD|WS_VISIBLE|SBARS_SIZEGRIP, + 0, 0, 100, 100, g_hMainWnd, NULL, NULL, NULL); + + style = GetWindowLongPtrA(g_hMainWnd, GWL_STYLE); + GetClientRect(hwndStatus, &rcClient); + + width = GetSystemMetrics(SM_CXVSCROLL); + + rcGripper = rcClient; + rcGripper.left = rcClient.right - width; + +#define SETWNDLONG(MAXIMIZE, RTL) \ + do \ + { \ + SetWindowLongA(g_hMainWnd, GWL_STYLE, (MAXIMIZE) ? style|WS_MAXIMIZE : style); \ + SetWindowLongA(hwndStatus, GWL_EXSTYLE, (RTL) ? WS_EX_LAYOUTRTL : 0); \ + } while (0) + +#define TEST_NCHITTEST(X, Y, EXPECT) \ + do \ + { \ + pt.x = (X); \ + pt.y = (Y); \ + ClientToScreen(hwndStatus, &pt); \ + r = SendMessageA(hwndStatus, WM_NCHITTEST, 0, MAKELPARAM(pt.x, pt.y)); \ + ok((EXPECT) == r, "expect WM_NCHITTEST " #EXPECT " got %#x\n", r); \ + } while (0) + + /* check bounds when not maximized */ + SETWNDLONG(FALSE, FALSE); + todo_wine TEST_NCHITTEST(rcGripper.left, rcGripper.top, HTBOTTOMRIGHT); + TEST_NCHITTEST(rcGripper.left - 1, rcGripper.top, HTCLIENT); + todo_wine TEST_NCHITTEST(rcGripper.left, rcGripper.top - 1, HTBOTTOMRIGHT); + todo_wine TEST_NCHITTEST(rcGripper.right, rcGripper.bottom, HTBOTTOMRIGHT); + todo_wine TEST_NCHITTEST(rcGripper.right + 1, rcGripper.bottom, HTBOTTOMRIGHT); + todo_wine TEST_NCHITTEST(rcGripper.right, rcGripper.bottom + 1, HTBOTTOMRIGHT); + TEST_NCHITTEST(rcGripper.right - 1, rcGripper.bottom - 1, HTBOTTOMRIGHT); + + /* maximized */ + SETWNDLONG(TRUE, FALSE); + TEST_NCHITTEST(rcGripper.left, rcGripper.top, HTCLIENT); + TEST_NCHITTEST(rcGripper.left - 1, rcGripper.top, HTCLIENT); + TEST_NCHITTEST(rcGripper.left, rcGripper.top - 1, HTNOWHERE); + TEST_NCHITTEST(rcGripper.right, rcGripper.bottom, HTNOWHERE); + TEST_NCHITTEST(rcGripper.right + 1, rcGripper.bottom, HTNOWHERE); + TEST_NCHITTEST(rcGripper.right, rcGripper.bottom + 1, HTNOWHERE); + todo_wine TEST_NCHITTEST(rcGripper.right - 1, rcGripper.bottom - 1, HTCLIENT); + + /* not maximized and right-to-left */ + SETWNDLONG(FALSE, TRUE); + todo_wine TEST_NCHITTEST(rcGripper.left, rcGripper.top, HTBOTTOMLEFT); + TEST_NCHITTEST(rcGripper.left - 1, rcGripper.top, HTCLIENT); + todo_wine TEST_NCHITTEST(rcGripper.left, rcGripper.top - 1, HTBOTTOMLEFT); + todo_wine TEST_NCHITTEST(rcGripper.right, rcGripper.bottom, HTBOTTOMLEFT); + todo_wine TEST_NCHITTEST(rcGripper.right + 1, rcGripper.bottom, HTBOTTOMLEFT); + todo_wine TEST_NCHITTEST(rcGripper.right, rcGripper.bottom + 1, HTBOTTOMLEFT); + TEST_NCHITTEST(rcGripper.right - 1, rcGripper.bottom - 1, HTBOTTOMLEFT); + + /* maximized with right-to-left */ + SETWNDLONG(TRUE, TRUE); + TEST_NCHITTEST(rcGripper.left, rcGripper.top, HTCLIENT); + TEST_NCHITTEST(rcGripper.left - 1, rcGripper.top, HTCLIENT); + TEST_NCHITTEST(rcGripper.left, rcGripper.top - 1, HTNOWHERE); + TEST_NCHITTEST(rcGripper.right, rcGripper.bottom, HTNOWHERE); + TEST_NCHITTEST(rcGripper.right + 1, rcGripper.bottom, HTNOWHERE); + TEST_NCHITTEST(rcGripper.right, rcGripper.bottom + 1, HTNOWHERE); + todo_wine TEST_NCHITTEST(rcGripper.right - 1, rcGripper.bottom - 1, HTCLIENT); + +#undef TEST_NCHITTEST +#undef SETWNDLONG + + SetWindowLongA(g_hMainWnd, GWL_STYLE, style); + DestroyWindow(hwndStatus); +} + static void init_functions(void) { HMODULE hComCtl32 = LoadLibraryA("comctl32.dll"); @@ -620,4 +704,5 @@ START_TEST(status) test_status_ownerdraw(); test_gettext(); test_notify(); + test_sizegrip(); }