From 54b49016a41baad7490b54370455b406479aa151 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 27 Mar 2008 12:17:23 -0700 Subject: [PATCH 2/3] user32: add more dialog with edit control tests. --- dlls/user32/tests/edit.c | 109 ++++++++++++++++++++++++++++++++++++++-- dlls/user32/tests/resource.rc | 10 ++++ 2 files changed, 113 insertions(+), 6 deletions(-) diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c index c8ae56c..0d15641 100644 --- a/dlls/user32/tests/edit.c +++ b/dlls/user32/tests/edit.c @@ -47,6 +47,7 @@ static INT_PTR CALLBACK edit_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPA SetFocus(hedit); switch (lparam) { + /* from bug 11841 */ case 0: PostMessage(hedit, WM_KEYDOWN, VK_ESCAPE, 0x10001); break; @@ -55,8 +56,40 @@ static INT_PTR CALLBACK edit_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPA break; case 2: PostMessage(hedit, WM_KEYDOWN, VK_TAB, 0xf0001); - PostMessage(hdlg, WM_USER, 0xdeadbeef, 0xdeadbeef); + PostMessage(hdlg, WM_USER, 0xdeadbeef, 1); break; + + /* more 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, 0); + break; + case 5: + PostMessage(hedit, WM_CHAR, VK_TAB, 0xf0001); + PostMessage(hdlg, WM_USER, 0xdeadbeef, 0); + break; + + /* more 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, 1); + 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; } @@ -83,13 +116,37 @@ static INT_PTR CALLBACK edit_dialog_proc(HWND hdlg, UINT msg, WPARAM wparam, LPA break; case WM_USER: - if (wparam != 0xdeadbeef || lparam != 0xdeadbeef) + { + int len; + HWND hok = GetDlgItem(hdlg, IDOK); + HWND hedit = GetDlgItem(hdlg, 1000); + + if (wparam != 0xdeadbeef) break; - if (GetFocus() == GetDlgItem(hdlg, IDOK)) - EndDialog(hdlg, 444); - else - EndDialog(hdlg, 555); + + switch (lparam) + { + case 0: + len = SendMessage(hedit, WM_GETTEXTLENGTH, 0, 0); + if (len == 0) + EndDialog(hdlg, 444); + else + EndDialog(hdlg, 555); + break; + + case 1: + len = SendMessage(hedit, WM_GETTEXTLENGTH, 0, 0); + if ((GetFocus() == hok) && len == 0) + EndDialog(hdlg, 444); + else + EndDialog(hdlg, 555); + break; + + default: + EndDialog(hdlg, 555); + } break; + } case WM_CLOSE: EndDialog(hdlg, 333); @@ -1210,6 +1267,46 @@ static void test_edit_dialog(void) ok(111 == r, "Expected %d, got %d\n", 111, r); r = DialogBoxParam(hinst, "EDIT_READONLY_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 2); ok(444 == r, "Expected %d, got %d\n", 444, r); + + /* more tests for WM_CHAR */ + r = DialogBoxParam(hinst, "EDIT_READONLY_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 3); + ok(444 == r, "Expected %d, got %d\n", 444, r); + r = DialogBoxParam(hinst, "EDIT_READONLY_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 4); + ok(444 == r, "Expected %d, got %d\n", 444, r); + r = DialogBoxParam(hinst, "EDIT_READONLY_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 5); + ok(444 == r, "Expected %d, got %d\n", 444, r); + + /* more tests for WM_KEYDOWN + WM_CHAR */ + r = DialogBoxParam(hinst, "EDIT_READONLY_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 6); + todo_wine ok(444 == r, "Expected %d, got %d\n", 444, r); + r = DialogBoxParam(hinst, "EDIT_READONLY_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 7); + todo_wine ok(444 == r, "Expected %d, got %d\n", 444, r); + r = DialogBoxParam(hinst, "EDIT_READONLY_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 8); + ok(444 == r, "Expected %d, got %d\n", 444, r); + + /* tests with an editable edit control */ + r = DialogBoxParam(hinst, "EDIT_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 0); + ok(333 == r, "Expected %d, got %d\n", 333, r); + r = DialogBoxParam(hinst, "EDIT_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 1); + ok(111 == r, "Expected %d, got %d\n", 111, r); + r = DialogBoxParam(hinst, "EDIT_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 2); + ok(444 == r, "Expected %d, got %d\n", 444, r); + + /* tests for WM_CHAR */ + r = DialogBoxParam(hinst, "EDIT_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 3); + ok(444 == r, "Expected %d, got %d\n", 444, r); + r = DialogBoxParam(hinst, "EDIT_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 4); + todo_wine ok(444 == r, "Expected %d, got %d\n", 444, r); + r = DialogBoxParam(hinst, "EDIT_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 5); + todo_wine ok(444 == r, "Expected %d, got %d\n", 444, r); + + /* tests for WM_KEYDOWN + WM_CHAR */ + r = DialogBoxParam(hinst, "EDIT_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 6); + todo_wine ok(444 == r, "Expected %d, got %d\n", 444, r); + r = DialogBoxParam(hinst, "EDIT_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 7); + todo_wine ok(444 == r, "Expected %d, got %d\n", 444, r); + r = DialogBoxParam(hinst, "EDIT_DIALOG", NULL, (DLGPROC)edit_dialog_proc, 8); + todo_wine ok(444 == r, "Expected %d, got %d\n", 444, r); } static BOOL RegisterWindowClasses (void) diff --git a/dlls/user32/tests/resource.rc b/dlls/user32/tests/resource.rc index 2945466..b0c4967 100644 --- a/dlls/user32/tests/resource.rc +++ b/dlls/user32/tests/resource.rc @@ -98,6 +98,16 @@ BEGIN PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14 END +EDIT_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 +} + EDIT_READONLY_DIALOG DIALOG DISCARDABLE 0, 0, 160, 80 STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | DS_CENTER CAPTION "Edit Readonly Test" -- 1.5.2.5