user32: Add more tests for ES_WANTRETURN.

This commit is contained in:
Lei Zhang 2008-04-07 13:32:20 -07:00 committed by Alexandre Julliard
parent df2b1bea63
commit 8cf7eef073
2 changed files with 169 additions and 0 deletions

View File

@ -284,6 +284,135 @@ static INT_PTR CALLBACK edit_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPA
return FALSE;
}
static INT_PTR CALLBACK edit_wantreturn_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch (msg)
{
case WM_INITDIALOG:
{
HWND hedit = GetDlgItem(hdlg, 1000);
SetFocus(hedit);
switch (lparam)
{
/* test cases for WM_KEYDOWN */
case 0:
PostMessage(hedit, WM_KEYDOWN, VK_ESCAPE, 0x10001);
break;
case 1:
PostMessage(hedit, WM_KEYDOWN, VK_RETURN, 0x1c0001);
PostMessage(hdlg, WM_USER, 0xdeadbeef, 0);
break;
case 2:
PostMessage(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
PostMessage(hdlg, WM_USER, 0xdeadbeef, 1);
break;
/* test cases for WM_CHAR */
case 3:
PostMessage(hedit, WM_CHAR, VK_ESCAPE, 0x10001);
PostMessage(hdlg, WM_USER, 0xdeadbeef, 0);
break;
case 4:
PostMessage(hedit, WM_CHAR, VK_RETURN, 0x1c0001);
PostMessage(hdlg, WM_USER, 0xdeadbeef, 2);
break;
case 5:
PostMessage(hedit, WM_CHAR, VK_TAB, 0xf0001);
PostMessage(hdlg, WM_USER, 0xdeadbeef, 0);
break;
/* test cases for WM_KEYDOWN + WM_CHAR */
case 6:
PostMessage(hedit, WM_KEYDOWN, VK_ESCAPE, 0x10001);
PostMessage(hedit, WM_CHAR, VK_ESCAPE, 0x10001);
PostMessage(hdlg, WM_USER, 0xdeadbeef, 0);
break;
case 7:
PostMessage(hedit, WM_KEYDOWN, VK_RETURN, 0x1c0001);
PostMessage(hedit, WM_CHAR, VK_RETURN, 0x1c0001);
PostMessage(hdlg, WM_USER, 0xdeadbeef, 2);
break;
case 8:
PostMessage(hedit, WM_KEYDOWN, VK_TAB, 0xf0001);
PostMessage(hedit, WM_CHAR, VK_TAB, 0xf0001);
PostMessage(hdlg, WM_USER, 0xdeadbeef, 1);
break;
default:
break;
}
break;
}
case WM_COMMAND:
if (HIWORD(wparam) != BN_CLICKED)
break;
switch (LOWORD(wparam))
{
case IDOK:
EndDialog(hdlg, 111);
break;
case IDCANCEL:
EndDialog(hdlg, 222);
break;
default:
break;
}
break;
case WM_USER:
{
HWND hok = GetDlgItem(hdlg, IDOK);
HWND hedit = GetDlgItem(hdlg, 1000);
HWND hfocus = GetFocus();
int len = SendMessage(hedit, WM_GETTEXTLENGTH, 0, 0);
if (wparam != 0xdeadbeef)
break;
switch (lparam)
{
case 0:
if ((hfocus == hedit) && len == 0)
EndDialog(hdlg, 444);
else
EndDialog(hdlg, 555);
break;
case 1:
if ((hfocus == hok) && len == 0)
EndDialog(hdlg, 444);
else
EndDialog(hdlg, 555);
break;
case 2:
if ((hfocus == hedit) && len == 2)
EndDialog(hdlg, 444);
else
EndDialog(hdlg, 555);
break;
default:
EndDialog(hdlg, 55);
}
break;
}
case WM_CLOSE:
EndDialog(hdlg, 333);
break;
default:
break;
}
return FALSE;
}
static HINSTANCE hinst;
static HWND hwndET2;
static const char szEditTest2Class[] = "EditTest2Class";
@ -1455,6 +1584,35 @@ static void test_multi_edit_dialog(void)
ok(11 == r, "Expected %d, got %d\n", 11, r);
}
static void test_wantreturn_edit_dialog(void)
{
int r;
/* tests for WM_KEYDOWN */
r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 0);
ok(333 == r, "Expected %d, got %d\n", 333, r);
r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 1);
ok(444 == r, "Expected %d, got %d\n", 444, r);
r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 2);
ok(444 == r, "Expected %d, got %d\n", 444, r);
/* tests for WM_CHAR */
r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 3);
ok(444 == r, "Expected %d, got %d\n", 444, r);
r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 4);
todo_wine ok(444 == r, "Expected %d, got %d\n", 444, r);
r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 5);
ok(444 == r, "Expected %d, got %d\n", 444, r);
/* tests for WM_KEYDOWN + WM_CHAR */
r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 6);
todo_wine ok(444 == r, "Expected %d, got %d\n", 444, r);
r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 7);
todo_wine ok(444 == r, "Expected %d, got %d\n", 444, r);
r = DialogBoxParam(hinst, "EDIT_WANTRETURN_DIALOG", NULL, (DLGPROC)edit_wantreturn_dialog_proc, 8);
ok(444 == r, "Expected %d, got %d\n", 444, r);
}
static BOOL RegisterWindowClasses (void)
{
WNDCLASSA test2;
@ -1525,6 +1683,7 @@ START_TEST(edit)
test_undo();
test_edit_dialog();
test_multi_edit_dialog();
test_wantreturn_edit_dialog();
UnregisterWindowClasses();
}

View File

@ -118,6 +118,16 @@ FONT 8, "MS Shell Dlg"
EDITTEXT 1000, 5, 5, 150, 50, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_MULTILINE | WS_VSCROLL | ES_AUTOVSCROLL
}
EDIT_WANTRETURN_DIALOG DIALOG DISCARDABLE 0, 0, 160, 80
STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | DS_CENTER
CAPTION "Edit Test"
FONT 8, "MS Shell Dlg"
{
PUSHBUTTON "Ok", IDOK, 20, 60, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
PUSHBUTTON "Cancel", IDCANCEL, 100, 60, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
EDITTEXT 1000, 5, 5, 150, 50, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_MULTILINE | WS_VSCROLL | ES_AUTOVSCROLL | ES_WANTRETURN
}
EDIT_READONLY_DIALOG DIALOG DISCARDABLE 0, 0, 160, 80
STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | DS_CENTER
CAPTION "Edit Readonly Test"