comctl32/tests: Add tests for mouse right-click in a treeview control.

Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hugh McMaster 2017-05-18 03:02:10 +00:00 committed by Alexandre Julliard
parent 5fe449307f
commit febdb101e6
1 changed files with 79 additions and 0 deletions

View File

@ -54,6 +54,21 @@ static BOOL g_v6;
static struct msg_sequence *sequences[NUM_MSG_SEQUENCES];
static struct msg_sequence *item_sequence[1];
static void flush_events(void)
{
MSG msg;
int diff = 200;
int min_timeout = 100;
DWORD time = GetTickCount() + diff;
while (diff > 0)
{
if (MsgWaitForMultipleObjects(0, NULL, FALSE, min_timeout, QS_ALLINPUT) == WAIT_TIMEOUT) break;
while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
diff = time - GetTickCount();
}
}
static const struct message FillRootSeq[] = {
{ TVM_INSERTITEMA, sent },
{ TVM_INSERTITEMA, sent },
@ -201,6 +216,13 @@ static const struct message test_get_set_unicodeformat_seq[] = {
{ 0 }
};
static const struct message test_right_click_seq[] = {
{ WM_RBUTTONDOWN, sent|wparam, MK_RBUTTON },
{ WM_CAPTURECHANGED, sent|defwinproc },
{ TVM_GETNEXTITEM, sent|wparam|lparam|defwinproc, TVGN_CARET, 0 },
{ 0 }
};
static const struct message parent_expand_seq[] = {
{ WM_NOTIFY, sent|id, 0, 0, TVN_ITEMEXPANDINGA },
{ WM_NOTIFY, sent|id, 0, 0, TVN_ITEMEXPANDEDA },
@ -342,6 +364,12 @@ static const struct message parent_vk_return_seq[] = {
{ 0 }
};
static const struct message parent_right_click_seq[] = {
{ WM_NOTIFY, sent|id, 0, 0, NM_RCLICK },
{ WM_CONTEXTMENU, sent },
{ 0 }
};
static HWND hMainWnd;
static HTREEITEM hRoot, hChild;
@ -1296,6 +1324,13 @@ static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam,
}
break;
}
case NM_RCLICK:
{
HTREEITEM selected = (HTREEITEM)SendMessageA(((NMHDR *)lParam)->hwndFrom,
TVM_GETNEXTITEM, TVGN_CARET, 0);
ok(selected == hChild, "child item should still be selected\n");
break;
}
}
}
break;
@ -2583,6 +2618,49 @@ todo_wine
DestroyWindow(hwnd);
}
static void test_right_click(void)
{
HWND hTree;
HTREEITEM selected;
RECT rc;
LRESULT result;
POINT pt;
hTree = create_treeview_control(0);
fill_tree(hTree);
SendMessageA(hTree, TVM_ENSUREVISIBLE, 0, (LPARAM)hChild);
SendMessageA(hTree, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hChild);
selected = (HTREEITEM)SendMessageA(hTree, TVM_GETNEXTITEM, TVGN_CARET, 0);
ok(selected == hChild, "child item not selected\n");
*(HTREEITEM *)&rc = hRoot;
result = SendMessageA(hTree, TVM_GETITEMRECT, TRUE, (LPARAM)&rc);
ok(result, "TVM_GETITEMRECT failed\n");
flush_events();
pt.x = (rc.left + rc.right) / 2;
pt.y = (rc.top + rc.bottom) / 2;
ClientToScreen(hMainWnd, &pt);
flush_events();
flush_sequences(sequences, NUM_MSG_SEQUENCES);
PostMessageA(hTree, WM_RBUTTONDOWN, MK_RBUTTON, MAKELPARAM(pt.x, pt.y));
PostMessageA(hTree, WM_RBUTTONUP, 0, MAKELPARAM(pt.x, pt.y));
flush_events();
ok_sequence(sequences, TREEVIEW_SEQ_INDEX, test_right_click_seq, "right click sequence", FALSE);
ok_sequence(sequences, PARENT_SEQ_INDEX, parent_right_click_seq, "parent right click sequence", FALSE);
selected = (HTREEITEM)SendMessageA(hTree, TVM_GETNEXTITEM, TVGN_CARET, 0);
ok(selected == hChild, "child item should still be selected\n");
DestroyWindow(hTree);
}
START_TEST(treeview)
{
HMODULE hComctl32;
@ -2660,6 +2738,7 @@ START_TEST(treeview)
test_WM_KEYDOWN();
test_TVS_FULLROWSELECT();
test_TVM_SORTCHILDREN();
test_right_click();
if (!load_v6_module(&ctx_cookie, &hCtx))
{