user32/tests: Add a test for WM_MEASUREITEM when inserting an item to an owner-drawn listbox.
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
4e49d7ba42
commit
d92d91473c
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright 1999 Ove Kaaven
|
* Copyright 1999 Ove Kaaven
|
||||||
* Copyright 2003 Dimitrie O. Paun
|
* 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
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -98,6 +98,22 @@ typedef struct
|
||||||
} u;
|
} u;
|
||||||
} DRAW_ITEM_STRUCT;
|
} 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 BOOL test_DestroyWindow_flag;
|
||||||
static HWINEVENTHOOK hEvent_hook;
|
static HWINEVENTHOOK hEvent_hook;
|
||||||
static HHOOK hKBD_hook;
|
static HHOOK hKBD_hook;
|
||||||
|
@ -2099,6 +2115,25 @@ static BOOL ignore_message( UINT message )
|
||||||
message == WM_DWMNCRENDERINGCHANGED);
|
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);
|
#define add_message(msg) add_message_(__LINE__,msg);
|
||||||
static void add_message_(int line, const struct recvd_message *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;
|
seq->lParam = di.u.lp;
|
||||||
break;
|
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:
|
default:
|
||||||
if (msg->message >= 0xc000) return; /* ignore registered messages */
|
if (msg->message >= 0xc000) return; /* ignore registered messages */
|
||||||
sprintf( seq->output, "%s: %p %04x wp %08lx lp %08lx",
|
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_PARENTNOTIFY || message == WM_CANCELMODE ||
|
||||||
message == WM_SETFOCUS || message == WM_KILLFOCUS ||
|
message == WM_SETFOCUS || message == WM_KILLFOCUS ||
|
||||||
message == WM_ENABLE || message == WM_ENTERIDLE ||
|
message == WM_ENABLE || message == WM_ENTERIDLE ||
|
||||||
message == WM_DRAWITEM || message == WM_COMMAND ||
|
message == WM_DRAWITEM || message == WM_MEASUREITEM ||
|
||||||
message == WM_IME_SETCONTEXT)
|
message == WM_COMMAND || message == WM_IME_SETCONTEXT)
|
||||||
{
|
{
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
|
@ -14094,6 +14149,16 @@ static const struct message wm_lb_deletestring_reset[] =
|
||||||
{ WM_DRAWITEM, sent|wparam|parent|optional, ID_LISTBOX },
|
{ WM_DRAWITEM, sent|wparam|parent|optional, ID_LISTBOX },
|
||||||
{ 0 }
|
{ 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__)
|
#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;
|
msg.flags = sent|wparam|lparam;
|
||||||
if (defwndproc_counter) msg.flags |= defwinproc;
|
if (defwndproc_counter) msg.flags |= defwinproc;
|
||||||
msg.wParam = wp;
|
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";
|
msg.descr = "listbox";
|
||||||
add_message(&msg);
|
add_message(&msg);
|
||||||
}
|
}
|
||||||
|
@ -14163,6 +14231,8 @@ static void test_listbox_messages(void)
|
||||||
|
|
||||||
check_lb_state(listbox, 0, LB_ERR, 0, 0);
|
check_lb_state(listbox, 0, LB_ERR, 0, 0);
|
||||||
|
|
||||||
|
flush_sequence();
|
||||||
|
|
||||||
ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 0");
|
ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 0");
|
||||||
ok(ret == 0, "expected 0, got %ld\n", ret);
|
ok(ret == 0, "expected 0, got %ld\n", ret);
|
||||||
ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 1");
|
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");
|
ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2");
|
||||||
ok(ret == 2, "expected 2, got %ld\n", ret);
|
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);
|
check_lb_state(listbox, 3, LB_ERR, 0, 0);
|
||||||
|
|
||||||
flush_sequence();
|
flush_sequence();
|
||||||
|
|
Loading…
Reference in New Issue