[1/2] comctl32/tests: Added tests for treeview right mouse click handling
Daniel Jelinski
djelinski1 at gmail.com
Tue May 15 14:53:32 CDT 2012
-------------- next part --------------
From aca07c83922c25c46305b90ba6115e0306c7000a 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
Current Wine implementation sends incorrect messages on right click. Added a test to reflect that.
---
dlls/comctl32/tests/treeview.c | 122 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 122 insertions(+), 0 deletions(-)
diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c
index 2246c79..7d1371e 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,66 @@ 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(void)
+{
+ HWND hTree;
+ 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, (LPARAM)0x10001);
+ /* this sequence should NOT send WM_CONTEXTMENU */
+ SendMessageA(hTree, WM_RBUTTONDOWN, 2, (LPARAM)0x10001);
+
+ 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, (LPARAM)0x10001);
+ /* this sequence should send WM_CONTEXTMENU */
+ SendMessageA(hTree, WM_RBUTTONDOWN, 2, (LPARAM)0x10001);
+
+ 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);
+
+ flush_sequences(sequences, NUM_MSG_SEQUENCES);
+ /* now test dragging - rbuttondown, mousemove, rbuttonup */
+ PostMessageA(hTree, WM_MOUSEMOVE, 2, (LPARAM)0x10002 + cxDrag);
+ SendMessageA(hTree, WM_RBUTTONDOWN, 2, (LPARAM)0x10001);
+
+ 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, (LPARAM)0x10002 + cxDrag);
+
+ 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 +2022,7 @@ START_TEST(treeview)
test_TVS_CHECKBOXES();
test_TVM_GETNEXTITEM();
test_TVM_HITTEST();
+ test_mouse();
if (!load_v6_module(&ctx_cookie, &hCtx))
{
--
1.7.5.4
More information about the wine-patches
mailing list