Commit 823ba55a authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

comctl32: Test the painting behaviour of the progress bar control.

Test the painting behaviour of the progress bar control when the PBM_SETPOS message is sent to it, with respect to whether the background is erased and what part of the control is redrawn.
parent ab4438e2
...@@ -48,6 +48,23 @@ LRESULT CALLBACK ProgressTestWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM ...@@ -48,6 +48,23 @@ LRESULT CALLBACK ProgressTestWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
return 0L; return 0L;
} }
static WNDPROC progress_wndproc;
static BOOL erased;
static RECT last_paint_rect;
LRESULT CALLBACK ProgressSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (msg == WM_PAINT)
{
GetUpdateRect(hWnd, &last_paint_rect, FALSE);
}
else if (msg == WM_ERASEBKGND)
{
erased = TRUE;
}
return CallWindowProc(progress_wndproc, hWnd, msg, wParam, lParam);
}
static void update_window(HWND hWnd) static void update_window(HWND hWnd)
{ {
...@@ -92,6 +109,7 @@ static void init(void) ...@@ -92,6 +109,7 @@ static void init(void)
hProgressWnd = CreateWindowEx(0, PROGRESS_CLASS, "", WS_CHILD | WS_VISIBLE, hProgressWnd = CreateWindowEx(0, PROGRESS_CLASS, "", WS_CHILD | WS_VISIBLE,
0, 0, rect.right, rect.bottom, hProgressParentWnd, NULL, GetModuleHandleA(NULL), 0); 0, 0, rect.right, rect.bottom, hProgressParentWnd, NULL, GetModuleHandleA(NULL), 0);
assert(hProgressWnd != NULL); assert(hProgressWnd != NULL);
progress_wndproc = (WNDPROC)SetWindowLongPtr(hProgressWnd, GWLP_WNDPROC, (LPARAM)ProgressSubclassProc);
ShowWindow(hProgressParentWnd, SW_SHOWNORMAL); ShowWindow(hProgressParentWnd, SW_SHOWNORMAL);
ok(GetUpdateRect(hProgressParentWnd, NULL, FALSE), "GetUpdateRect: There should be a region that needs to be updated\n"); ok(GetUpdateRect(hProgressParentWnd, NULL, FALSE), "GetUpdateRect: There should be a region that needs to be updated\n");
...@@ -119,6 +137,8 @@ static void cleanup(void) ...@@ -119,6 +137,8 @@ static void cleanup(void)
*/ */
static void test_redraw(void) static void test_redraw(void)
{ {
RECT client_rect;
SendMessageA(hProgressWnd, PBM_SETRANGE, 0, MAKELPARAM(0, 100)); SendMessageA(hProgressWnd, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
SendMessageA(hProgressWnd, PBM_SETPOS, 10, 0); SendMessageA(hProgressWnd, PBM_SETPOS, 10, 0);
SendMessageA(hProgressWnd, PBM_SETSTEP, 20, 0); SendMessageA(hProgressWnd, PBM_SETSTEP, 20, 0);
...@@ -145,6 +165,33 @@ static void test_redraw(void) ...@@ -145,6 +165,33 @@ static void test_redraw(void)
Usually the progress bar doesn't repaint itself immediately. If the Usually the progress bar doesn't repaint itself immediately. If the
position is not in the new range, it does. position is not in the new range, it does.
Don't test this, it may change in future Windows versions. */ Don't test this, it may change in future Windows versions. */
SendMessage(hProgressWnd, PBM_SETPOS, 0, 0);
update_window(hProgressWnd);
/* increase to 10 - no background erase required */
erased = FALSE;
SetRectEmpty(&last_paint_rect);
SendMessage(hProgressWnd, PBM_SETPOS, 10, 0);
GetClientRect(hProgressWnd, &client_rect);
ok(EqualRect(&last_paint_rect, &client_rect),
"last_paint_rect was { %ld, %ld, %ld, %ld } instead of { %ld, %ld, %ld, %ld }\n",
last_paint_rect.left, last_paint_rect.top, last_paint_rect.right, last_paint_rect.bottom,
client_rect.left, client_rect.top, client_rect.right, client_rect.bottom);
update_window(hProgressWnd);
ok(!erased, "Progress bar shouldn't have erased the background\n");
/* decrease to 0 - background erase will be required */
erased = FALSE;
SetRectEmpty(&last_paint_rect);
SendMessage(hProgressWnd, PBM_SETPOS, 0, 0);
GetClientRect(hProgressWnd, &client_rect);
ok(EqualRect(&last_paint_rect, &client_rect),
"last_paint_rect was { %ld, %ld, %ld, %ld } instead of { %ld, %ld, %ld, %ld }\n",
last_paint_rect.left, last_paint_rect.top, last_paint_rect.right, last_paint_rect.bottom,
client_rect.left, client_rect.top, client_rect.right, client_rect.bottom);
update_window(hProgressWnd);
ok(erased, "Progress bar should have erased the background\n");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment