[WineTests|User32]

- Sync Edit to wine head.

svn path=/trunk/; revision=62750
This commit is contained in:
James Tabor 2014-04-14 20:26:59 +00:00
parent b66792a4bb
commit 9b7d5bcdff

View file

@ -1299,6 +1299,7 @@ static void test_edit_control_5(void)
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
ok(lstrlenA(str) == len, "text shouldn't have been truncated\n");
DestroyWindow(hWnd);
DestroyWindow(parentWnd);
}
/* Test WM_GETTEXT processing
@ -1423,6 +1424,8 @@ static void test_margins(void)
RECT old_rect, new_rect;
INT old_right_margin;
DWORD old_margins, new_margins;
LOGFONTA lf;
HFONT hfont;
hwEdit = create_editcontrol(WS_BORDER | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
@ -1470,6 +1473,46 @@ static void test_margins(void)
ok(new_rect.bottom == old_rect.bottom, "The bottom border of the rectangle has changed\n");
DestroyWindow (hwEdit);
memset(&lf, 0, sizeof(lf));
lf.lfHeight = -11;
lf.lfWeight = FW_NORMAL;
lf.lfCharSet = DEFAULT_CHARSET;
strcpy(lf.lfFaceName, "Tahoma");
hfont = CreateFontIndirectA(&lf);
ok(hfont != NULL, "got %p\n", hfont);
/* Empty window rectangle */
hwEdit = CreateWindowExA(0, "Edit", "A", WS_POPUP, 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, NULL, NULL);
ok(hwEdit != NULL, "got %p\n", hwEdit);
GetClientRect(hwEdit, &old_rect);
ok(IsRectEmpty(&old_rect), "got rect %d,%d-%d,%d\n", old_rect.left, old_rect.top, old_rect.right, old_rect.bottom);
old_margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
ok(old_margins == 0, "got %x\n", old_margins);
SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
old_margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
ok(HIWORD(old_margins) > 0 && LOWORD(old_margins) > 0, "got %d, %d\n", HIWORD(old_margins), LOWORD(old_margins));
DestroyWindow(hwEdit);
/* Size is not enough to display a text, but not empty */
hwEdit = CreateWindowExA(0, "Edit", "A", WS_POPUP, 0, 0, 2, 2, NULL, NULL, NULL, NULL);
ok(hwEdit != NULL, "got %p\n", hwEdit);
GetClientRect(hwEdit, &old_rect);
ok(!IsRectEmpty(&old_rect), "got rect %d,%d-%d,%d\n", old_rect.left, old_rect.top, old_rect.right, old_rect.bottom);
old_margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
ok(old_margins == 0, "got %x\n", old_margins);
SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
old_margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
ok(old_margins == 0, "got %d, %d\n", HIWORD(old_margins), LOWORD(old_margins));
DeleteObject(hfont);
DestroyWindow(hwEdit);
}
static INT CALLBACK find_font_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
@ -2132,8 +2175,8 @@ static void test_child_edit_wmkeydown(void)
destroy_child_editcontrol(hwEdit);
}
static int got_en_setfocus = 0;
static int got_wm_capturechanged = 0;
static BOOL got_en_setfocus = FALSE;
static BOOL got_wm_capturechanged = FALSE;
static LRESULT (CALLBACK *p_edit_proc)(HWND, UINT, WPARAM, LPARAM);
static LRESULT CALLBACK edit4_wnd_procA(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
@ -2142,14 +2185,14 @@ static LRESULT CALLBACK edit4_wnd_procA(HWND hWnd, UINT msg, WPARAM wParam, LPAR
case WM_COMMAND:
switch (HIWORD(wParam)) {
case EN_SETFOCUS:
got_en_setfocus = 1;
got_en_setfocus = TRUE;
break;
}
break;
case WM_CAPTURECHANGED:
if (hWnd != (HWND)lParam)
{
got_wm_capturechanged = 1;
got_wm_capturechanged = TRUE;
pEndMenu();
}
break;
@ -2200,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);
@ -2226,6 +2309,25 @@ static void test_contextmenu(void)
SendMessageA(hwndEdit, WM_CONTEXTMENU, (WPARAM)hwndEdit, MAKEWORD(10, 10));
}
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);
ok(menu_messages.wm_command == 0,
"Expected no WM_COMMAND messages, got %d\n", menu_messages.wm_command);
ok(menu_messages.em_setsel == 1,
"Expected 1 EM_SETSEL message, got %d\n", menu_messages.em_setsel);
DestroyWindow (hwndEdit);
DestroyWindow (hwndMain);
}