2 * Unit test suite for rich edit control 1.0
4 * Copyright 2006 Google (Thomas Kho)
5 * Copyright 2007 Matt Finnicum
6 * Copyright 2007 Dmitry Timoshkov
7 * Copyright 2007 Alex VillacĂs Lasso
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
34 #include <wine/test.h>
36 static HMODULE hmoduleRichEdit;
38 static HWND new_window(LPCTSTR lpClassName, DWORD dwStyle, HWND parent) {
40 hwnd = CreateWindow(lpClassName, NULL, dwStyle|WS_POPUP|WS_HSCROLL|WS_VSCROLL
41 |WS_VISIBLE, 0, 0, 200, 60, parent, NULL,
42 hmoduleRichEdit, NULL);
43 ok(hwnd != NULL, "class: %s, error: %d\n", lpClassName, (int) GetLastError());
47 static HWND new_richedit(HWND parent) {
48 return new_window(RICHEDIT_CLASS10A, ES_MULTILINE, parent);
51 static void test_WM_SETTEXT()
53 HWND hwndRichEdit = new_richedit(NULL);
54 const char * TestItem1 = "TestSomeText";
55 const char * TestItem2 = "TestSomeText\r";
56 const char * TestItem3 = "TestSomeText\rSomeMoreText\r";
57 const char * TestItem4 = "TestSomeText\n\nTestSomeText";
58 const char * TestItem5 = "TestSomeText\r\r\nTestSomeText";
59 const char * TestItem6 = "TestSomeText\r\r\n\rTestSomeText";
60 const char * TestItem7 = "TestSomeText\r\n\r\r\n\rTestSomeText";
61 const char * TestItem8 = "TestSomeText\r\n";
62 const char * TestItem9 = "TestSomeText\r\nSomeMoreText\r\n";
63 const char * TestItem10 = "TestSomeText\r\n\r\nTestSomeText";
64 const char * TestItem11 = "TestSomeText TestSomeText";
65 const char * TestItem12 = "TestSomeText \r\nTestSomeText";
66 const char * TestItem13 = "TestSomeText\r\n \r\nTestSomeText";
70 /* This test attempts to show that WM_SETTEXT on a riched32 control does not
71 attempt to modify the text that is pasted into the control, and should
72 return it as is. In particular, \r\r\n is NOT converted, unlike riched20.
73 Currently, builtin riched32 mangles solitary \r or \n when not part of
77 #define TEST_SETTEXT(a, b, is_todo) \
78 result = SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) a); \
79 ok (result == 1, "WM_SETTEXT returned %ld instead of 1\n", result); \
80 result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buf); \
81 ok (result == strlen(buf), \
82 "WM_GETTEXT returned %ld instead of expected %u\n", \
83 result, strlen(buf)); \
84 result = strcmp(b, buf); \
85 if (is_todo) todo_wine { \
87 "WM_SETTEXT round trip: strcmp = %ld\n", result); \
90 "WM_SETTEXT round trip: strcmp = %ld\n", result); \
93 TEST_SETTEXT(TestItem1, TestItem1, 0)
94 TEST_SETTEXT(TestItem2, TestItem2, 1)
95 TEST_SETTEXT(TestItem3, TestItem3, 1)
96 TEST_SETTEXT(TestItem4, TestItem4, 1)
97 TEST_SETTEXT(TestItem5, TestItem5, 1)
98 TEST_SETTEXT(TestItem6, TestItem6, 1)
99 TEST_SETTEXT(TestItem7, TestItem7, 1)
100 TEST_SETTEXT(TestItem8, TestItem8, 0)
101 TEST_SETTEXT(TestItem9, TestItem9, 0)
102 TEST_SETTEXT(TestItem10, TestItem10, 0)
103 TEST_SETTEXT(TestItem11, TestItem11, 0)
104 TEST_SETTEXT(TestItem12, TestItem12, 0)
105 TEST_SETTEXT(TestItem13, TestItem13, 0)
108 DestroyWindow(hwndRichEdit);
116 /* Must explicitly LoadLibrary(). The test has no references to functions in
117 * RICHED32.DLL, so the linker doesn't actually link to it. */
118 hmoduleRichEdit = LoadLibrary("RICHED32.DLL");
119 ok(hmoduleRichEdit != NULL, "error: %d\n", (int) GetLastError());
123 /* Set the environment variable WINETEST_RICHED32 to keep windows
124 * responsive and open for 30 seconds. This is useful for debugging.
126 * The message pump uses PeekMessage() to empty the queue and then sleeps for
127 * 50ms before retrying the queue. */
128 end = time(NULL) + 30;
129 if (getenv( "WINETEST_RICHED32" )) {
130 while (time(NULL) < end) {
131 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
132 TranslateMessage(&msg);
133 DispatchMessage(&msg);
141 ok(FreeLibrary(hmoduleRichEdit) != 0, "error: %d\n", (int) GetLastError());