Piotr Caban : user32/tests: Add listbox WM_MEASUREITEM tests.

Alexandre Julliard julliard at winehq.org
Mon May 14 06:54:24 CDT 2018


Module: wine
Branch: stable
Commit: 6b862a4c95a0f57eea753582bd2ab4cc8fef92ed
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=6b862a4c95a0f57eea753582bd2ab4cc8fef92ed

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Wed Feb 28 17:37:03 2018 +0100

user32/tests: Add listbox WM_MEASUREITEM tests.

Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 43df3f468f2d3364345a685ca9f236a8502fa3a5)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 dlls/user32/tests/listbox.c | 55 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/dlls/user32/tests/listbox.c b/dlls/user32/tests/listbox.c
index 91d4675..88d3adb 100644
--- a/dlls/user32/tests/listbox.c
+++ b/dlls/user32/tests/listbox.c
@@ -46,6 +46,15 @@ static const char * const strings[4] = {
 
 static const char BAD_EXTENSION[] = "*.badtxt";
 
+static int strcmp_aw(LPCWSTR strw, const char *stra)
+{
+    WCHAR buf[1024];
+
+    if (!stra) return 1;
+    MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, sizeof(buf)/sizeof(WCHAR));
+    return lstrcmpW(strw, buf);
+}
+
 static HWND
 create_listbox (DWORD add_style, HWND parent)
 {
@@ -239,6 +248,31 @@ static LRESULT WINAPI main_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARA
 {
     switch (msg)
     {
+    case WM_MEASUREITEM:
+    {
+        DWORD style = GetWindowLongA(GetWindow(hwnd, GW_CHILD), GWL_STYLE);
+        MEASUREITEMSTRUCT *mi = (void*)lparam;
+
+        ok(wparam == mi->CtlID, "got wParam=%08lx, expected %08x\n", wparam, mi->CtlID);
+        ok(mi->CtlType == ODT_LISTBOX, "mi->CtlType = %u\n", mi->CtlType);
+        ok(mi->CtlID == 1, "mi->CtlID = %u\n", mi->CtlID);
+        ok(mi->itemHeight, "mi->itemHeight = 0\n");
+
+        if (mi->itemID > 4 || style & LBS_OWNERDRAWFIXED)
+            break;
+
+        if (style & LBS_HASSTRINGS)
+        {
+            ok(!strcmp_aw((WCHAR*)mi->itemData, strings[mi->itemID]),
+                    "mi->itemData = %s (%d)\n", wine_dbgstr_w((WCHAR*)mi->itemData), mi->itemID);
+        }
+        else
+        {
+            ok((void*)mi->itemData == strings[mi->itemID],
+                    "mi->itemData = %08lx, expected %p\n", mi->itemData, strings[mi->itemID]);
+        }
+        break;
+    }
     case WM_DRAWITEM:
     {
         RECT rc_item, rc_client, rc_clip;
@@ -1822,6 +1856,26 @@ static void test_extents(void)
     DestroyWindow(parent);
 }
 
+static void test_WM_MEASUREITEM(void)
+{
+    HWND parent, listbox;
+    LRESULT data;
+
+    parent = create_parent();
+    listbox = create_listbox(WS_CHILD | LBS_OWNERDRAWVARIABLE, parent);
+
+    data = SendMessageA(listbox, LB_GETITEMDATA, 0, 0);
+    ok(data == (LRESULT)strings[0], "data = %08lx, expected %p\n", data, strings[0]);
+    DestroyWindow(parent);
+
+    parent = create_parent();
+    listbox = create_listbox(WS_CHILD | LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS, parent);
+
+    data = SendMessageA(listbox, LB_GETITEMDATA, 0, 0);
+    ok(!data, "data = %08lx\n", data);
+    DestroyWindow(parent);
+}
+
 START_TEST(listbox)
 {
   const struct listbox_test SS =
@@ -1905,4 +1959,5 @@ START_TEST(listbox)
   test_GetListBoxInfo();
   test_missing_lbuttonup();
   test_extents();
+  test_WM_MEASUREITEM();
 }




More information about the wine-cvs mailing list