Module: wine Branch: master Commit: 0b069106b0e0f141d6925d3e10166be89fc59145 URL: https://gitlab.winehq.org/wine/wine/-/commit/0b069106b0e0f141d6925d3e10166be...
Author: Evan Tang etang@codeweavers.com Date: Fri Nov 4 16:08:46 2022 -0500
riched20: Add test for EN_CHANGE events during window creation.
GenoPro isn't very happy if it receives one
---
dlls/riched20/tests/editor.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index b72c8b89528..226c8eb7eea 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -8913,6 +8913,47 @@ static void fill_reobject_struct(REOBJECT *reobj, LONG cp, LPOLEOBJECT poleobj, reobj->dwUser = user; }
+static BOOL change_received = FALSE; + +static LRESULT WINAPI ChangeWatcherWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + if (message == WM_COMMAND && (wParam >> 16) == EN_CHANGE) change_received = TRUE; + return DefWindowProcA(hwnd, message, wParam, lParam); +} + +static LRESULT WINAPI RichEditWithEventsWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + if (message == WM_CREATE) + SendMessageA(hwnd, EM_SETEVENTMASK, 0, ENM_CHANGE); + return CallWindowProcA(richeditProc, hwnd, message, wParam, lParam); +} + +static void test_init_messages(void) +{ + WNDCLASSA cls; + HWND parent, edit; + + /* register class to capture EN_CHANGE */ + cls = make_simple_class(ChangeWatcherWndProc, "ChangeWatcherClass"); + if (!RegisterClassA(&cls)) assert(0); + + /* and a class that sets ENM_CHANGE during WM_CREATE */ + if (!GetClassInfoA(hmoduleRichEdit, RICHEDIT_CLASS20A, &cls)) return; + richeditProc = cls.lpfnWndProc; + cls.lpfnWndProc = RichEditWithEventsWndProc; + cls.lpszClassName = "RichEditWithEvents"; + if (!RegisterClassA(&cls)) assert(0); + + parent = CreateWindowA("ChangeWatcherClass", NULL, WS_POPUP|WS_VISIBLE, + 0, 0, 200, 60, NULL, NULL, NULL, NULL); + ok(parent != 0, "Failed to create parent window\n"); + change_received = FALSE; + edit = new_window("RichEditWithEvents", 0, parent); + todo_wine ok(change_received == FALSE, "Creating a RichEdit should not make any EN_CHANGE events\n"); + DestroyWindow(edit); + DestroyWindow(parent); +} + static void test_EM_SELECTIONTYPE(void) { HWND hwnd = new_richedit(NULL); @@ -9091,6 +9132,7 @@ START_TEST( editor ) test_background(); test_eop_char_fmt(); test_para_numbering(); + test_init_messages(); test_EM_SELECTIONTYPE();
/* Set the environment variable WINETEST_RICHED20 to keep windows