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

Michael Martin martinmnet at hotmail.com
Sun Oct 4 08:37:03 CDT 2009



This edit control change passes on XP and fails in WINE.
---

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

diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c
index 5ca012e..45f579d 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;
 };
 
+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,63 @@ static INT_PTR CALLBACK edit_wantreturn_dialog_proc(HWND hdlg, UINT msg, WPARAM
     return FALSE;
 }
 
+static INT_PTR CALLBACK edit_control_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+    static int timerCount = 0;
+    HGLOBAL cbData;
+    LPTSTR lptStrCopy;
+    LPARAM mousePos;
+    HWND findHwnd;
+    RECT winRect;
+
+    ok(msg != WM_COMMAND, "Should not have received WM_COMMAND\n");
+
+    switch(msg)
+    {
+        case WM_TIMER:
+            switch(timerCount)
+            {
+                case 0:
+                    /* Copy some data to clipboard */
+                    cbData = GlobalAlloc(GMEM_MOVEABLE, 5);
+                    lptStrCopy = (TCHAR*)GlobalLock(cbData);
+                    memcpy(lptStrCopy, "test", 4);
+                    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 */
+                    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 menu item */
+                    findHwnd = FindWindowEx(NULL, NULL, MAKEINTATOM(0x8000), NULL);
+                    PostMessage(findHwnd, WM_KEYDOWN, VK_RETURN,0);
+                    break;
+                case 6:
+                    KillTimer(hwnd, 1);
+                    PostQuitMessage(0);
+                    break;
+            }
+            timerCount++;
+            break;
+    }
+
+    return CallWindowProc(editWndProc, hwnd, msg, wparam, lparam);
+}
+
 static HINSTANCE hinst;
 static HWND hwndET2;
 static const char szEditTest2Class[] = "EditTest2Class";
@@ -2260,6 +2318,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)SetWindowLong(hwEdit, GWL_WNDPROC,(LONG)edit_control_wndproc);
+    ShowWindow(hwEdit, 1);
+    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 +2359,7 @@ START_TEST(edit)
     test_child_edit_wmkeydown();
     test_fontsize();
     test_dialogmode();
+    test_contextmenu();
 
     UnregisterWindowClasses();
 }
 		 	   		  
_________________________________________________________________
Hotmail: Powerful Free email with security by Microsoft.
http://clk.atdmt.com/GBL/go/171222986/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20091004/3e545fea/attachment-0001.htm>


More information about the wine-patches mailing list