Akihiro Sagawa : user32/tests: Test pending redraw state with owner-drawn list box.

Alexandre Julliard julliard at winehq.org
Fri Feb 25 07:30:23 CST 2022


Module: wine
Branch: oldstable
Commit: b823fa1a3a5ee2c7dc2343f03ac928a8aec51537
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=b823fa1a3a5ee2c7dc2343f03ac928a8aec51537

Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date:   Thu Aug 12 21:17:40 2021 +0900

user32/tests: Test pending redraw state with owner-drawn list box.

Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit a70ed810d59dbbcaaa65db515ee92b9b985323ff)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 dlls/user32/tests/listbox.c | 51 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 50 insertions(+), 1 deletion(-)

diff --git a/dlls/user32/tests/listbox.c b/dlls/user32/tests/listbox.c
index cd372f8ac59..7d0ae5a2157 100644
--- a/dlls/user32/tests/listbox.c
+++ b/dlls/user32/tests/listbox.c
@@ -238,7 +238,7 @@ static void check_item_height(void)
     DestroyWindow (hLB);
 }
 
-static int got_selchange;
+static unsigned int got_selchange, got_drawitem;
 
 static LRESULT WINAPI main_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 {
@@ -293,6 +293,7 @@ static LRESULT WINAPI main_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARA
         trace("item rect %s\n", wine_dbgstr_rect(&rc_item));
         ok(EqualRect(&dis->rcItem, &rc_item), "item rects are not equal\n");
 
+        got_drawitem++;
         break;
     }
 
@@ -343,6 +344,19 @@ static void test_ownerdraw(void)
         0,
         LBS_NODATA
     };
+    static const struct {
+        UINT message;
+        WPARAM wparam;
+        LPARAM lparam;
+        UINT drawitem;
+    } testcase[] = {
+        { WM_NULL, 0, 0, 0 },
+        { WM_PAINT, 0, 0, 0 },
+        { LB_GETCOUNT, 0, 0, 0 },
+        { LB_SETCOUNT, ARRAY_SIZE(strings), 0, ARRAY_SIZE(strings) },
+        { LB_ADDSTRING, 0, (LPARAM)"foo", ARRAY_SIZE(strings)+1 },
+        { LB_DELETESTRING, 0, 0, ARRAY_SIZE(strings)-1 },
+    };
     HWND parent, hLB;
     INT ret;
     RECT rc;
@@ -405,6 +419,41 @@ static void test_ownerdraw(void)
 
         DestroyWindow (hLB);
     }
+
+    /* test pending redraw state */
+    for (i = 0; i < ARRAY_SIZE(testcase); i++)
+    {
+        winetest_push_context("%d", i);
+        hLB = create_listbox(LBS_OWNERDRAWFIXED | LBS_NODATA | WS_CHILD | WS_VISIBLE, parent);
+        assert(hLB);
+
+        ret = SendMessageA(hLB, WM_SETREDRAW, FALSE, 0);
+        ok(!ret, "got %d\n", ret);
+        ret = SendMessageA(hLB, testcase[i].message, testcase[i].wparam, testcase[i].lparam);
+        if (testcase[i].message >= LB_ADDSTRING && testcase[i].message < LB_MSGMAX &&
+            testcase[i].message != LB_SETCOUNT)
+            ok(ret > 0, "expected > 0, got %d\n", ret);
+        else
+            ok(!ret, "expected 0, got %d\n", ret);
+
+        got_drawitem = 0;
+        ret = RedrawWindow(hLB, NULL, 0, RDW_UPDATENOW);
+        ok(ret, "RedrawWindow failed\n");
+        ok(!got_drawitem, "got %u\n", got_drawitem);
+
+        ret = SendMessageA(hLB, WM_SETREDRAW, TRUE, 0);
+        ok(!ret, "got %d\n", ret);
+
+        got_drawitem = 0;
+        ret = RedrawWindow(hLB, NULL, 0, RDW_UPDATENOW);
+        ok(ret, "RedrawWindow failed\n");
+        todo_wine_if(testcase[i].message == LB_SETCOUNT)
+        ok(got_drawitem == testcase[i].drawitem, "expected %u, got %u\n", testcase[i].drawitem, got_drawitem);
+
+        DestroyWindow(hLB);
+        winetest_pop_context();
+    }
+
     DestroyWindow(parent);
 }
 




More information about the wine-cvs mailing list