Module: wine Branch: master Commit: 43df3f468f2d3364345a685ca9f236a8502fa3a5 URL: https://source.winehq.org/git/wine.git/?a=commit;h=43df3f468f2d3364345a685ca...
Author: Piotr Caban piotr@codeweavers.com Date: Wed Feb 28 17:37:03 2018 +0100
user32/tests: Add listbox WM_MEASUREITEM tests.
Signed-off-by: Piotr Caban piotr@codeweavers.com Signed-off-by: Alexandre Julliard julliard@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(); }