[PATCH] Add test case to user32 winetests for edit control context menu. Try 2

Michael Martin martinmnet at hotmail.com
Thu Oct 15 07:17:01 CDT 2009


This patch adds test for edit control clipboard context menu.
The test passes on Windows XP as the WM_COMMAND message is not sent to the edit control by its context menu.
Fails on wine because wine does incorrectly send that message.
This problem shows up using the edit class context menu on application created with vb6.0, which leads to application crashing.

The code does not use WINE_TODO() because a simple fix for this will be sent when
this problem is accepted.

Mike




---


 dlls/user32/tests/edit.c |   81 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 81 insertions(+), 0 deletions(-)

diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c
index 5ca012e..598b486 100644
--- a/dlls/user32/tests/edit.c
+++ b/dlls/user32/tests/edit.c
@@ -36,6 +36,7 @@ struct edit_notify {
     int en_change, en_maxtext, en_update;
 };
 
+static WNDPROC editWndProc;
 static struct edit_notify notifications;
 
 static INT_PTR CALLBACK multi_edit_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
@@ -533,6 +534,69 @@ static INT_PTR CALLBACK edit_wantreturn_dialog_proc(HWND hdlg, UINT msg, WPARAM
     return FALSE;
 }
 
+static LRESULT CALLBACK edit_control_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+    static int timerCount = 0;
+    HGLOBAL cbData;
+    LPSTR lpStrCopy;
+    LPARAM mousePos;
+    HWND findHwnd;
+    RECT winRect;
+
+    ok(msg != WM_COMMAND, "Should not have received WM_COMMAND\n");
+
+    switch(msg)
+    {
+        case WM_TIMER:
+            /* Using a timer here to move the menu selection down to the paste menu item and then select it.
+               We are trying to show that on windows the clipboard context menu does not
+               send WM_COMMAND messages to the edit class windows procedure. */
+            switch(timerCount)
+            {
+                case 0:
+                    /* Copy some data to clipboard */
+                    cbData = GlobalAlloc(GMEM_MOVEABLE, 5);
+                    lpStrCopy = (LPSTR)GlobalLock(cbData);
+                    memcpy(lpStrCopy, "test\0", 5);
+                    OpenClipboard(hwnd);
+                    SetClipboardData(CF_TEXT, cbData);
+                    CloseClipboard();
+
+                    /* Move mouse to upper left of text control */
+                    GetWindowRect(hwnd, &winRect);
+                    SetCursorPos(winRect.left, winRect.top);
+                    mousePos = MAKELPARAM(winRect.left + 20, winRect.top + 20);
+                    /* Show the Context Menu */
+                    PostMessage(hwnd, WM_CONTEXTMENU, (WPARAM)hwnd, mousePos);
+                    break;
+                case 1:
+                case 2:
+                case 3:
+                case 4:
+                    /* Find the menu window and send keydown.
+                       Do this four times to move menu selection to the paste menu item */
+                    findHwnd = FindWindowEx(NULL, NULL, MAKEINTATOM(0x8000), NULL);
+                    PostMessage(findHwnd, WM_KEYDOWN, VK_DOWN,0);
+                    break;
+                case 5:
+                    /* Find the menu window and send return, selecting the paste menu item */
+                    findHwnd = FindWindowEx(NULL, NULL, MAKEINTATOM(0x8000), NULL);
+                    PostMessage(findHwnd, WM_KEYDOWN, VK_RETURN,0);
+                    break;
+                case 6:
+                    /* Kill the timer as we are done */
+                    KillTimer(hwnd, 1);
+                    PostQuitMessage(0);
+                    break;
+            }
+            timerCount++;
+            break;
+    }
+
+    /* Call the defauly window proc for the edit class */
+    return CallWindowProc(editWndProc, hwnd, msg, wparam, lparam);
+}
+
 static HINSTANCE hinst;
 static HWND hwndET2;
 static const char szEditTest2Class[] = "EditTest2Class";
@@ -2260,6 +2324,22 @@ static void test_dialogmode(void)
     destroy_child_editcontrol(hwEdit);
 }
 
+static void test_contextmenu(void)
+{
+    HWND hwEdit;
+    LONG Timer1;
+    hwEdit = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
+    editWndProc = (WNDPROC)SetWindowLongPtr(hwEdit, GWLP_WNDPROC,(LRESULT)edit_control_wndproc);
+    ShowWindow(hwEdit, SW_SHOW);
+    Timer1 = SetTimer(hwEdit, 1, 100, NULL);
+    MSG msg;
+    while (GetMessage(&msg, 0, 0, 0) > 0)
+    {
+        TranslateMessage(&msg);
+        DispatchMessage(&msg);
+    }
+}
+
 START_TEST(edit)
 {
     hinst = GetModuleHandleA(NULL);
@@ -2285,6 +2365,7 @@ START_TEST(edit)
     test_child_edit_wmkeydown();
     test_fontsize();
     test_dialogmode();
+    test_contextmenu();
 
     UnregisterWindowClasses();
 }
 		 	   		  
_________________________________________________________________
Hotmail: Trusted email with powerful SPAM protection.
http://clk.atdmt.com/GBL/go/177141665/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20091015/1a0a4a0b/attachment.htm>


More information about the wine-patches mailing list