Skip to content

Commit 9b7d5bc

Browse files
committed
[WineTests|User32]
- Sync Edit to wine head. svn path=/trunk/; revision=62750
1 parent b66792a commit 9b7d5bc

File tree

1 file changed

+106
-4
lines changed
  • rostests/winetests/user32

1 file changed

+106
-4
lines changed

rostests/winetests/user32/edit.c

Lines changed: 106 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,7 @@ static void test_edit_control_5(void)
12991299
len = SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0);
13001300
ok(lstrlenA(str) == len, "text shouldn't have been truncated\n");
13011301
DestroyWindow(hWnd);
1302+
DestroyWindow(parentWnd);
13021303
}
13031304

13041305
/* Test WM_GETTEXT processing
@@ -1423,6 +1424,8 @@ static void test_margins(void)
14231424
RECT old_rect, new_rect;
14241425
INT old_right_margin;
14251426
DWORD old_margins, new_margins;
1427+
LOGFONTA lf;
1428+
HFONT hfont;
14261429

14271430
hwEdit = create_editcontrol(WS_BORDER | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0);
14281431

@@ -1470,6 +1473,46 @@ static void test_margins(void)
14701473
ok(new_rect.bottom == old_rect.bottom, "The bottom border of the rectangle has changed\n");
14711474

14721475
DestroyWindow (hwEdit);
1476+
1477+
memset(&lf, 0, sizeof(lf));
1478+
lf.lfHeight = -11;
1479+
lf.lfWeight = FW_NORMAL;
1480+
lf.lfCharSet = DEFAULT_CHARSET;
1481+
strcpy(lf.lfFaceName, "Tahoma");
1482+
1483+
hfont = CreateFontIndirectA(&lf);
1484+
ok(hfont != NULL, "got %p\n", hfont);
1485+
1486+
/* Empty window rectangle */
1487+
hwEdit = CreateWindowExA(0, "Edit", "A", WS_POPUP, 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, NULL, NULL);
1488+
ok(hwEdit != NULL, "got %p\n", hwEdit);
1489+
GetClientRect(hwEdit, &old_rect);
1490+
ok(IsRectEmpty(&old_rect), "got rect %d,%d-%d,%d\n", old_rect.left, old_rect.top, old_rect.right, old_rect.bottom);
1491+
1492+
old_margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
1493+
ok(old_margins == 0, "got %x\n", old_margins);
1494+
1495+
SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
1496+
old_margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
1497+
ok(HIWORD(old_margins) > 0 && LOWORD(old_margins) > 0, "got %d, %d\n", HIWORD(old_margins), LOWORD(old_margins));
1498+
1499+
DestroyWindow(hwEdit);
1500+
1501+
/* Size is not enough to display a text, but not empty */
1502+
hwEdit = CreateWindowExA(0, "Edit", "A", WS_POPUP, 0, 0, 2, 2, NULL, NULL, NULL, NULL);
1503+
ok(hwEdit != NULL, "got %p\n", hwEdit);
1504+
GetClientRect(hwEdit, &old_rect);
1505+
ok(!IsRectEmpty(&old_rect), "got rect %d,%d-%d,%d\n", old_rect.left, old_rect.top, old_rect.right, old_rect.bottom);
1506+
1507+
old_margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
1508+
ok(old_margins == 0, "got %x\n", old_margins);
1509+
1510+
SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
1511+
old_margins = SendMessageA(hwEdit, EM_GETMARGINS, 0, 0);
1512+
ok(old_margins == 0, "got %d, %d\n", HIWORD(old_margins), LOWORD(old_margins));
1513+
1514+
DeleteObject(hfont);
1515+
DestroyWindow(hwEdit);
14731516
}
14741517

14751518
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)
21322175
destroy_child_editcontrol(hwEdit);
21332176
}
21342177

2135-
static int got_en_setfocus = 0;
2136-
static int got_wm_capturechanged = 0;
2178+
static BOOL got_en_setfocus = FALSE;
2179+
static BOOL got_wm_capturechanged = FALSE;
21372180
static LRESULT (CALLBACK *p_edit_proc)(HWND, UINT, WPARAM, LPARAM);
21382181

21392182
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
21422185
case WM_COMMAND:
21432186
switch (HIWORD(wParam)) {
21442187
case EN_SETFOCUS:
2145-
got_en_setfocus = 1;
2188+
got_en_setfocus = TRUE;
21462189
break;
21472190
}
21482191
break;
21492192
case WM_CAPTURECHANGED:
21502193
if (hWnd != (HWND)lParam)
21512194
{
2152-
got_wm_capturechanged = 1;
2195+
got_wm_capturechanged = TRUE;
21532196
pEndMenu();
21542197
}
21552198
break;
@@ -2200,9 +2243,49 @@ static LRESULT CALLBACK edit_proc_proxy(HWND hWnd, UINT msg, WPARAM wParam, LPAR
22002243
return p_edit_proc(hWnd, msg, wParam, lParam);
22012244
}
22022245

2246+
struct context_menu_messages
2247+
{
2248+
unsigned int wm_command, em_setsel;
2249+
};
2250+
2251+
static struct context_menu_messages menu_messages;
2252+
2253+
static LRESULT CALLBACK child_edit_menu_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
2254+
{
2255+
switch (msg) {
2256+
case WM_ENTERIDLE:
2257+
if (wParam == MSGF_MENU) {
2258+
HWND hwndMenu = (HWND)lParam;
2259+
MENUBARINFO mbi = { sizeof(MENUBARINFO) };
2260+
if (pGetMenuBarInfo(hwndMenu, OBJID_CLIENT, 0, &mbi)) {
2261+
MENUITEMINFOA mii = { sizeof(MENUITEMINFOA), MIIM_STATE };
2262+
if (GetMenuItemInfoA(mbi.hMenu, EM_SETSEL, FALSE, &mii)) {
2263+
if (mii.fState & MFS_HILITE) {
2264+
PostMessageA(hwnd, WM_KEYDOWN, VK_RETURN, 0x1c0001);
2265+
PostMessageA(hwnd, WM_KEYUP, VK_RETURN, 0x1c0001);
2266+
}
2267+
else {
2268+
PostMessageA(hwnd, WM_KEYDOWN, VK_DOWN, 0x500001);
2269+
PostMessageA(hwnd, WM_KEYUP, VK_DOWN, 0x500001);
2270+
}
2271+
}
2272+
}
2273+
}
2274+
break;
2275+
case WM_COMMAND:
2276+
menu_messages.wm_command++;
2277+
break;
2278+
case EM_SETSEL:
2279+
menu_messages.em_setsel++;
2280+
break;
2281+
}
2282+
return CallWindowProcA(p_edit_proc, hwnd, msg, wParam, lParam);
2283+
}
2284+
22032285
static void test_contextmenu(void)
22042286
{
22052287
HWND hwndMain, hwndEdit;
2288+
MSG msg;
22062289

22072290
hwndMain = CreateWindowA(szEditTest4Class, "ET4", WS_OVERLAPPEDWINDOW|WS_VISIBLE,
22082291
0, 0, 200, 200, NULL, NULL, hinst, NULL);
@@ -2226,6 +2309,25 @@ static void test_contextmenu(void)
22262309
SendMessageA(hwndEdit, WM_CONTEXTMENU, (WPARAM)hwndEdit, MAKEWORD(10, 10));
22272310
}
22282311

2312+
DestroyWindow (hwndEdit);
2313+
2314+
hwndEdit = CreateWindowA("EDIT", "Test Text",
2315+
WS_CHILD | WS_BORDER | WS_VISIBLE,
2316+
0, 0, 100, 100,
2317+
hwndMain, NULL, hinst, NULL);
2318+
memset(&menu_messages, 0, sizeof(menu_messages));
2319+
p_edit_proc = (void*)SetWindowLongPtrA(hwndEdit, GWLP_WNDPROC,
2320+
(ULONG_PTR)child_edit_menu_proc);
2321+
2322+
SetFocus(hwndEdit);
2323+
SendMessageA(hwndEdit, WM_SETTEXT, 0, (LPARAM)"foo");
2324+
SendMessageA(hwndEdit, WM_CONTEXTMENU, (WPARAM)hwndEdit, MAKEWORD(-1, -1));
2325+
while (PeekMessageA(&msg, hwndEdit, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
2326+
ok(menu_messages.wm_command == 0,
2327+
"Expected no WM_COMMAND messages, got %d\n", menu_messages.wm_command);
2328+
ok(menu_messages.em_setsel == 1,
2329+
"Expected 1 EM_SETSEL message, got %d\n", menu_messages.em_setsel);
2330+
22292331
DestroyWindow (hwndEdit);
22302332
DestroyWindow (hwndMain);
22312333
}

0 commit comments

Comments
 (0)