[2/2] comctl32/tests: Added tests for treeview right mouse click handling
Daniel Jelinski
djelinski1 at gmail.com
Mon Jul 2 12:42:24 CDT 2012
Resend from last month
-------------- next part --------------
From 5c7749b55f4d690e729d06d3358173148c89b604 Mon Sep 17 00:00:00 2001
From: Daniel Jelinski <djelinski1 at gmail.com>
Date: Sat, 7 Apr 2012 19:49:50 +0200
Subject: comctl32/tests: Added tests for treeview right mouse click handling
---
dlls/comctl32/tests/treeview.c | 133 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 133 insertions(+), 0 deletions(-)
diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c
index 5a4fde3..fe20af8 100644
--- a/dlls/comctl32/tests/treeview.c
+++ b/dlls/comctl32/tests/treeview.c
@@ -232,6 +232,61 @@ static const struct message parent_get_dispinfo_seq[] = {
{ 0 }
};
+static const struct message parent_rclick_seq[] = {
+ { WM_CTLCOLOREDIT, sent|optional }, /* comctl32 older than 5.80 only */
+ { WM_NOTIFY, sent|id|optional, 0, 0, NM_CUSTOMDRAW }, /* comctl32 older than 5.80 only */
+ { WM_NOTIFY, sent|id, 0, 0, NM_RCLICK },
+ { WM_CTLCOLOREDIT, sent|optional }, /* comctl32 older than 5.80 only */
+ { WM_NOTIFY, sent|id|optional, 0, 0, NM_CUSTOMDRAW }, /* comctl32 older than 5.80 only */
+ { WM_CONTEXTMENU, sent },
+ { 0 }
+};
+
+static const struct message parent_rclick_nomenu_seq[] = {
+ { WM_CTLCOLOREDIT, sent|optional }, /* comctl32 older than 5.80 only */
+ { WM_NOTIFY, sent|id|optional, 0, 0, NM_CUSTOMDRAW }, /* comctl32 older than 5.80 only */
+ { WM_NOTIFY, sent|id, 0, 0, NM_RCLICK },
+ { WM_CTLCOLOREDIT, sent|optional }, /* comctl32 older than 5.80 only */
+ { WM_NOTIFY, sent|id|optional, 0, 0, NM_CUSTOMDRAW }, /* comctl32 older than 5.80 only */
+ { 0 }
+};
+
+static const struct message tree_rclick_seq[] = {
+ { WM_RBUTTONDOWN, sent },
+ { WM_PAINT, sent|optional|defwinproc }, /* comctl32 older than 5.80 only */
+ { WM_CAPTURECHANGED, sent|defwinproc },
+ { WM_PAINT, sent|optional|defwinproc }, /* comctl32 older than 5.80 only */
+ { 0 }
+};
+
+static const struct message parent_rdrag_seq[] = {
+ { WM_CTLCOLOREDIT, sent|optional }, /* comctl32 older than 5.80 only */
+ { WM_NOTIFY, sent|id|optional, 0, 0, NM_CUSTOMDRAW }, /* comctl32 older than 5.80 only */
+ { WM_NOTIFY, sent|id, 0, 0, TVN_BEGINRDRAG },
+ { WM_CTLCOLOREDIT, sent|optional }, /* comctl32 older than 5.80 only */
+ { WM_NOTIFY, sent|id|optional, 0, 0, NM_CUSTOMDRAW }, /* comctl32 older than 5.80 only */
+ { 0 }
+};
+
+static const struct message tree_rdrag_seq[] = {
+ { WM_RBUTTONDOWN, sent },
+ { WM_PAINT, sent|optional|defwinproc }, /* comctl32 older than 5.80 only */
+ { WM_CAPTURECHANGED, sent|defwinproc },
+ { WM_PAINT, sent|optional|defwinproc }, /* comctl32 older than 5.80 only */
+ { 0 }
+};
+
+static const struct message parent_rdrop_seq[] = {
+ { WM_CONTEXTMENU, sent },
+ { 0 }
+};
+
+static const struct message tree_rdrop_seq[] = {
+ { WM_RBUTTONUP, sent },
+ { WM_CONTEXTMENU, sent|defwinproc },
+ { 0 }
+};
+
static const struct message empty_seq[] = {
{ 0 }
};
@@ -243,6 +298,8 @@ static HTREEITEM hRoot, hChild;
static int pos = 0;
static char sequence[256];
+static int nm_rclick_result;
+
static void Clear(void)
{
pos = 0;
@@ -1125,6 +1182,10 @@ static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam,
break;
}
+ case NM_RCLICK:
+ {
+ return nm_rclick_result;
+ }
}
}
break;
@@ -1889,6 +1950,77 @@ static void test_TVM_HITTEST(void)
DestroyWindow(hTree);
}
+static void flush_message_queue(void)
+{
+ MSG msg;
+
+ while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+}
+
+static void test_mouse_rbutton(void)
+{
+ HWND hTree;
+ POINT pt;
+ INT cxDrag = GetSystemMetrics(SM_CXDRAG);
+ /* test report on Windows machine with cxDrag = 2 (NT4) indicates that 4 pixels are taken anyway.
+ On the other hand, description of SM_CXDRAG suggests that it should be used. */
+ cxDrag = cxDrag >= 4 ? cxDrag : 4;
+
+ hTree = create_treeview_control(0);
+ fill_tree(hTree);
+
+ flush_message_queue();
+ flush_sequences(sequences, NUM_MSG_SEQUENCES);
+
+ /* WM_RBUTTONDOWN does not return until it gets another mouse event.
+ Make sure it gets one by posting WM_RBUTTONUP to message queue.
+ See comctl32/treeview.c TREEVIEW_TrackMouse for details */
+ nm_rclick_result = 1;
+ PostMessageA(hTree, WM_RBUTTONUP, 0, MAKELPARAM(1, 1));
+ /* this sequence should NOT send WM_CONTEXTMENU */
+ SendMessageA(hTree, WM_RBUTTONDOWN, MK_RBUTTON, MAKELPARAM(1, 1));
+
+ ok_sequence(sequences, PARENT_SEQ_INDEX, parent_rclick_nomenu_seq, "right click (parent, prevent WM_CONTEXTMENU)", FALSE);
+ ok_sequence(sequences, TREEVIEW_SEQ_INDEX, tree_rclick_seq, "right click (tree)", FALSE);
+
+ flush_sequences(sequences, NUM_MSG_SEQUENCES);
+
+ nm_rclick_result = 0;
+ PostMessageA(hTree, WM_RBUTTONUP, 0, MAKELPARAM(1, 1));
+ /* this sequence should send WM_CONTEXTMENU */
+ SendMessageA(hTree, WM_RBUTTONDOWN, MK_RBUTTON, MAKELPARAM(1, 1));
+
+ ok_sequence(sequences, PARENT_SEQ_INDEX, parent_rclick_seq, "right click (parent, send WM_CONTEXTMENU)", FALSE);
+ ok_sequence(sequences, TREEVIEW_SEQ_INDEX, tree_rclick_seq, "right click (tree)", FALSE);
+
+ /* apparently Windows determines whether item was dragged by looking at current cursor position,
+ not the one reported by WM_MOUSEMOVE.*/
+ pt.x = 1 + cxDrag;
+ pt.y = 1;
+ ClientToScreen(hTree, &pt);
+ SetCursorPos(pt.x,pt.y);
+
+ flush_sequences(sequences, NUM_MSG_SEQUENCES);
+ /* now test dragging - rbuttondown, mousemove, rbuttonup */
+ PostMessageA(hTree, WM_MOUSEMOVE, MK_RBUTTON, MAKELPARAM(1 + cxDrag, 1));
+ SendMessageA(hTree, WM_RBUTTONDOWN, MK_RBUTTON, MAKELPARAM(1, 1));
+
+ ok_sequence(sequences, PARENT_SEQ_INDEX, parent_rdrag_seq, "right drag (parent)", FALSE);
+ ok_sequence(sequences, TREEVIEW_SEQ_INDEX, tree_rdrag_seq, "right drag (tree)", FALSE);
+
+ flush_sequences(sequences, NUM_MSG_SEQUENCES);
+ SendMessageA(hTree, WM_RBUTTONUP, 0, MAKELPARAM(2 + cxDrag, 1));
+
+ ok_sequence(sequences, PARENT_SEQ_INDEX, parent_rdrop_seq, "right drop (parent)", FALSE);
+ ok_sequence(sequences, TREEVIEW_SEQ_INDEX, tree_rdrop_seq, "right drop (tree)", FALSE);
+
+ DestroyWindow(hTree);
+}
+
START_TEST(treeview)
{
HMODULE hComctl32;
@@ -1962,6 +2094,7 @@ START_TEST(treeview)
test_TVS_CHECKBOXES();
test_TVM_GETNEXTITEM();
test_TVM_HITTEST();
+ test_mouse_rbutton();
if (!load_v6_module(&ctx_cookie, &hCtx))
{
--
1.7.5.4
More information about the wine-patches
mailing list