Commit d92d9147 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

user32/tests: Add a test for WM_MEASUREITEM when inserting an item to an owner-drawn listbox.

parent 4e49d7ba
......@@ -3,7 +3,7 @@
*
* Copyright 1999 Ove Kaaven
* Copyright 2003 Dimitrie O. Paun
* Copyright 2004, 2005 Dmitry Timoshkov
* Copyright 2004,2005,2016 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -98,6 +98,22 @@ typedef struct
} u;
} DRAW_ITEM_STRUCT;
/* encoded MEASUREITEMSTRUCT into a WPARAM */
typedef struct
{
union
{
struct
{
UINT CtlType : 4;
UINT CtlID : 4;
UINT itemID : 4;
UINT wParam : 20;
} item;
WPARAM wp;
} u;
} MEASURE_ITEM_STRUCT;
static BOOL test_DestroyWindow_flag;
static HWINEVENTHOOK hEvent_hook;
static HHOOK hKBD_hook;
......@@ -2099,6 +2115,25 @@ static BOOL ignore_message( UINT message )
message == WM_DWMNCRENDERINGCHANGED);
}
static unsigned hash_Ly_W(const WCHAR *str)
{
unsigned hash = 0;
for (; *str; str++)
hash = hash * 1664525u + (unsigned char)(*str) + 1013904223u;
return hash;
}
static unsigned hash_Ly(const char *str)
{
unsigned hash = 0;
for (; *str; str++)
hash = hash * 1664525u + (unsigned char)(*str) + 1013904223u;
return hash;
}
#define add_message(msg) add_message_(__LINE__,msg);
static void add_message_(int line, const struct recvd_message *msg)
......@@ -2203,6 +2238,26 @@ static void add_message_(int line, const struct recvd_message *msg)
seq->lParam = di.u.lp;
break;
}
case WM_MEASUREITEM:
{
MEASURE_ITEM_STRUCT mi;
MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *)msg->lParam;
sprintf( seq->output, "%s: %p WM_MEASUREITEM: CtlType %#x, CtlID %#x, itemID %#x, itemData %#lx",
msg->descr, msg->hwnd, mis->CtlType, mis->CtlID,
mis->itemID, mis->itemData);
mi.u.wp = 0;
mi.u.item.CtlType = mis->CtlType;
mi.u.item.CtlID = mis->CtlID;
mi.u.item.itemID = mis->itemID;
mi.u.item.wParam = msg->wParam;
seq->wParam = mi.u.wp;
seq->lParam = mis->itemData ? hash_Ly_W((const WCHAR *)mis->itemData) : 0;
break;
}
default:
if (msg->message >= 0xc000) return; /* ignore registered messages */
sprintf( seq->output, "%s: %p %04x wp %08lx lp %08lx",
......@@ -8989,8 +9044,8 @@ static LRESULT WINAPI ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam
message == WM_PARENTNOTIFY || message == WM_CANCELMODE ||
message == WM_SETFOCUS || message == WM_KILLFOCUS ||
message == WM_ENABLE || message == WM_ENTERIDLE ||
message == WM_DRAWITEM || message == WM_COMMAND ||
message == WM_IME_SETCONTEXT)
message == WM_DRAWITEM || message == WM_MEASUREITEM ||
message == WM_COMMAND || message == WM_IME_SETCONTEXT)
{
switch (message)
{
......@@ -14094,6 +14149,16 @@ static const struct message wm_lb_deletestring_reset[] =
{ WM_DRAWITEM, sent|wparam|parent|optional, ID_LISTBOX },
{ 0 }
};
static const struct message wm_lb_addstring[] =
{
{ LB_ADDSTRING, sent|wparam|lparam, 0, 0xf30604ed },
{ WM_MEASUREITEM, sent|wparam|lparam|parent, 0xf0f2, 0xf30604ed },
{ LB_ADDSTRING, sent|wparam|lparam, 0, 0xf30604ee },
{ WM_MEASUREITEM, sent|wparam|lparam|parent, 0xf1f2, 0xf30604ee },
{ LB_ADDSTRING, sent|wparam|lparam, 0, 0xf30604ef },
{ WM_MEASUREITEM, sent|wparam|lparam|parent, 0xf2f2, 0xf30604ef },
{ 0 }
};
#define check_lb_state(a1, a2, a3, a4, a5) check_lb_state_dbg(a1, a2, a3, a4, a5, __LINE__)
......@@ -14119,7 +14184,10 @@ static LRESULT WINAPI listbox_hook_proc(HWND hwnd, UINT message, WPARAM wp, LPAR
msg.flags = sent|wparam|lparam;
if (defwndproc_counter) msg.flags |= defwinproc;
msg.wParam = wp;
msg.lParam = lp;
if (message == LB_ADDSTRING)
msg.lParam = lp ? hash_Ly((const char *)lp) : 0;
else
msg.lParam = lp;
msg.descr = "listbox";
add_message(&msg);
}
......@@ -14163,6 +14231,8 @@ static void test_listbox_messages(void)
check_lb_state(listbox, 0, LB_ERR, 0, 0);
flush_sequence();
ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 0");
ok(ret == 0, "expected 0, got %ld\n", ret);
ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 1");
......@@ -14170,6 +14240,7 @@ static void test_listbox_messages(void)
ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2");
ok(ret == 2, "expected 2, got %ld\n", ret);
ok_sequence(wm_lb_addstring, "LB_ADDSTRING", FALSE);
check_lb_state(listbox, 3, LB_ERR, 0, 0);
flush_sequence();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment