From 458ddd59b247a52fc4463a1a8b90d4744f154142 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 12 Dec 2016 22:03:20 +0300 Subject: [PATCH] comctl32/tests: Trackbar test to show that thumb is updated on TBM_SETTICFREQ. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/comctl32/tests/trackbar.c | 47 +++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/dlls/comctl32/tests/trackbar.c b/dlls/comctl32/tests/trackbar.c index 28af8c58a0d..a6f146250f9 100644 --- a/dlls/comctl32/tests/trackbar.c +++ b/dlls/comctl32/tests/trackbar.c @@ -890,7 +890,7 @@ static void test_thumb_length(void) static void test_tic_settings(void) { HWND hWndTrackbar; - int r; + int r, i; hWndTrackbar = create_trackbar(defaultstyle, hWndParent); ok(hWndTrackbar != NULL, "Expected non NULL value\n"); @@ -955,6 +955,51 @@ static void test_tic_settings(void) SendMessageA(hWndTrackbar, TBM_SETTICFREQ, 1, 0); r = SendMessageA(hWndTrackbar, TBM_GETNUMTICS, 0, 0); expect(3, r); + + DestroyWindow(hWndTrackbar); + + /* Test to show that TBM_SETTICFREQ updates thumb */ + for (i = 0; i < 2; i++) + { + DWORD style = i ? defaultstyle : defaultstyle & ~TBS_AUTOTICKS; + RECT rect, rect1; + WNDPROC oldproc; + + hWndTrackbar = create_trackbar2(style, hWndParent); + ok(hWndTrackbar != NULL, "Expected non NULL value\n"); + + oldproc = (WNDPROC)SetWindowLongPtrA(hWndTrackbar, GWLP_WNDPROC, (LONG_PTR)trackbar_no_wmpaint_proc); + SetWindowLongPtrA(hWndTrackbar, GWLP_USERDATA, (LONG_PTR)oldproc); + + SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect); + SendMessageA(hWndTrackbar, TBM_SETPOS, FALSE, 0); + SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect1); + ok(EqualRect(&rect, &rect1), "Unexpected thumb rectangle %s, previous %s\n", + wine_dbgstr_rect(&rect1), wine_dbgstr_rect(&rect)); + + SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect); + SendMessageA(hWndTrackbar, TBM_SETRANGE, FALSE, MAKELONG(-100, 100)); + SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect1); + ok(EqualRect(&rect, &rect1), "Unexpected thumb rectangle %s, previous %s\n", + wine_dbgstr_rect(&rect1), wine_dbgstr_rect(&rect)); + /* Old position is also 0, but thumb position will be different after range change */ + SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect); + SendMessageA(hWndTrackbar, TBM_SETPOS, TRUE, 0); + SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect1); + ok(EqualRect(&rect, &rect1), "Unexpected thumb rectangle %s, previous %s\n", + wine_dbgstr_rect(&rect1), wine_dbgstr_rect(&rect)); + /* Previous frequency is also 1, yet thumb is updated */ + SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect); + SendMessageA(hWndTrackbar, TBM_SETTICFREQ, 1, 0); + SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect1); + todo_wine + ok(!EqualRect(&rect, &rect1), "Unexpected thumb rectangle %s, previous %s\n", + wine_dbgstr_rect(&rect1), wine_dbgstr_rect(&rect)); + + SetWindowLongPtrA(hWndTrackbar, GWLP_WNDPROC, (LONG_PTR)oldproc); + + DestroyWindow(hWndTrackbar); + } } static void test_tic_placement(void)