[1/2] comctl32/tests: Added tests for treeview right mouse click handling (try 3)
Daniel Jelinski
djelinski1 at gmail.com
Fri May 18 13:53:02 CDT 2012
That was a sneaky one... Apparently Windows checks the current mouse
position when it receives WM_MOUSEMOVE, not the one reported in the
event. This caused the previous version of test to hang if the mouse
cursor was located within 4 pixels from the simulated click position.
Fixed.
-------------- next part --------------
From 81ee95b821c9924297193d764bda0c7d2dba03fc Mon Sep 17 00:00:00 2001
From: Daniel Jelinski <djelinski1 at gmail.com>
Date: Sat, 7 Apr 2012 19:49:50 +0200
Subject: [PATCH 1/2] comctl32/tests: Added tests for treeview right mouse
click handling
Current Wine implementation sends incorrect messages on right click. Added a test to reflect that.
---
dlls/comctl32/tests/treeview.c | 130 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 130 insertions(+), 0 deletions(-)
diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c
index 2246c79..0d94ab4 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;
@@ -1114,6 +1171,10 @@ static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam,
break;
}
+ case NM_RCLICK:
+ {
+ return nm_rclick_result;
+ }
}
}
break;
@@ -1829,6 +1890,74 @@ 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);
+
+ 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)", TRUE);
+ ok_sequence(sequences, TREEVIEW_SEQ_INDEX, tree_rclick_seq, "right click (tree)", TRUE);
+
+ 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)", TRUE);
+ ok_sequence(sequences, TREEVIEW_SEQ_INDEX, tree_rclick_seq, "right click (tree)", TRUE);
+
+ /* 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;
@@ -1901,6 +2030,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