From 1ba63827f26109ee4592ad39ac248178d516fe15 Mon Sep 17 00:00:00 2001 From: Akihiro Sagawa Date: Tue, 8 Apr 2014 01:43:48 +0900 Subject: [PATCH] user32/tests: Add some tests for edit control context menu messages. --- dlls/user32/tests/edit.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c index c41bbb0f53f..219fb1dc747 100644 --- a/dlls/user32/tests/edit.c +++ b/dlls/user32/tests/edit.c @@ -2243,9 +2243,49 @@ static LRESULT CALLBACK edit_proc_proxy(HWND hWnd, UINT msg, WPARAM wParam, LPAR return p_edit_proc(hWnd, msg, wParam, lParam); } +struct context_menu_messages +{ + unsigned int wm_command, em_setsel; +}; + +static struct context_menu_messages menu_messages; + +static LRESULT CALLBACK child_edit_menu_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) { + case WM_ENTERIDLE: + if (wParam == MSGF_MENU) { + HWND hwndMenu = (HWND)lParam; + MENUBARINFO mbi = { sizeof(MENUBARINFO) }; + if (pGetMenuBarInfo(hwndMenu, OBJID_CLIENT, 0, &mbi)) { + MENUITEMINFOA mii = { sizeof(MENUITEMINFOA), MIIM_STATE }; + if (GetMenuItemInfoA(mbi.hMenu, EM_SETSEL, FALSE, &mii)) { + if (mii.fState & MFS_HILITE) { + PostMessageA(hwnd, WM_KEYDOWN, VK_RETURN, 0x1c0001); + PostMessageA(hwnd, WM_KEYUP, VK_RETURN, 0x1c0001); + } + else { + PostMessageA(hwnd, WM_KEYDOWN, VK_DOWN, 0x500001); + PostMessageA(hwnd, WM_KEYUP, VK_DOWN, 0x500001); + } + } + } + } + break; + case WM_COMMAND: + menu_messages.wm_command++; + break; + case EM_SETSEL: + menu_messages.em_setsel++; + break; + } + return CallWindowProcA(p_edit_proc, hwnd, msg, wParam, lParam); +} + static void test_contextmenu(void) { HWND hwndMain, hwndEdit; + MSG msg; hwndMain = CreateWindowA(szEditTest4Class, "ET4", WS_OVERLAPPEDWINDOW|WS_VISIBLE, 0, 0, 200, 200, NULL, NULL, hinst, NULL); @@ -2270,6 +2310,25 @@ static void test_contextmenu(void) } DestroyWindow (hwndEdit); + + hwndEdit = CreateWindowA("EDIT", "Test Text", + WS_CHILD | WS_BORDER | WS_VISIBLE, + 0, 0, 100, 100, + hwndMain, NULL, hinst, NULL); + memset(&menu_messages, 0, sizeof(menu_messages)); + p_edit_proc = (void*)SetWindowLongPtrA(hwndEdit, GWLP_WNDPROC, + (ULONG_PTR)child_edit_menu_proc); + + SetFocus(hwndEdit); + SendMessageA(hwndEdit, WM_SETTEXT, 0, (LPARAM)"foo"); + SendMessageA(hwndEdit, WM_CONTEXTMENU, (WPARAM)hwndEdit, MAKEWORD(-1, -1)); + while (PeekMessageA(&msg, hwndEdit, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); + todo_wine ok(menu_messages.wm_command == 0, + "Expected no WM_COMMAND messages, got %d\n", menu_messages.wm_command); + todo_wine ok(menu_messages.em_setsel == 1, + "Expected 1 EM_SETSEL message, got %d\n", menu_messages.em_setsel); + + DestroyWindow (hwndEdit); DestroyWindow (hwndMain); } -- 2.11.4.GIT