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.
This commit is contained in:
Rob Shearman 2006-01-11 12:12:06 +01:00 committed by Alexandre Julliard
parent ab4438e24d
commit 823ba55aca
1 changed files with 48 additions and 1 deletions

View File

@ -48,6 +48,23 @@ LRESULT CALLBACK ProgressTestWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
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)
{
@ -87,11 +104,12 @@ static void init(void)
hProgressParentWnd = CreateWindowExA(0, progressTestClass, "Progress Bar Test", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, GetModuleHandleA(NULL), 0);
assert(hProgressParentWnd != NULL);
GetClientRect(hProgressParentWnd, &rect);
hProgressWnd = CreateWindowEx(0, PROGRESS_CLASS, "", WS_CHILD | WS_VISIBLE,
0, 0, rect.right, rect.bottom, hProgressParentWnd, NULL, GetModuleHandleA(NULL), 0);
assert(hProgressWnd != NULL);
progress_wndproc = (WNDPROC)SetWindowLongPtr(hProgressWnd, GWLP_WNDPROC, (LPARAM)ProgressSubclassProc);
ShowWindow(hProgressParentWnd, SW_SHOWNORMAL);
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)
*/
static void test_redraw(void)
{
RECT client_rect;
SendMessageA(hProgressWnd, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
SendMessageA(hProgressWnd, PBM_SETPOS, 10, 0);
SendMessageA(hProgressWnd, PBM_SETSTEP, 20, 0);
@ -145,6 +165,33 @@ static void test_redraw(void)
Usually the progress bar doesn't repaint itself immediately. If the
position is not in the new range, it does.
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");
}