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

Alexandre Julliard julliard at wine.codeweavers.com
Wed Jan 11 05:35:26 CST 2006


Module: wine
Branch: refs/heads/master
Commit: 823ba55acaf5a466f78aecdead8bc1fdadc8abf6
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=823ba55acaf5a466f78aecdead8bc1fdadc8abf6

Author: Rob Shearman <rob at codeweavers.com>
Date:   Wed Jan 11 12:12:06 2006 +0100

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.

---

 dlls/comctl32/tests/progress.c |   49 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 48 insertions(+), 1 deletions(-)

diff --git a/dlls/comctl32/tests/progress.c b/dlls/comctl32/tests/progress.c
index 01b60c5..803055f 100644
--- a/dlls/comctl32/tests/progress.c
+++ b/dlls/comctl32/tests/progress.c
@@ -48,6 +48,23 @@ LRESULT CALLBACK ProgressTestWndProc(HWN
     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");
 }
 
 




More information about the wine-cvs mailing list