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(void)
59 { "TestSomeText\r", 1},
60 { "TestSomeText\rSomeMoreText\r", 2, 1}, /* NT4 and below */
61 { "TestSomeText\n\nTestSomeText", 3},
62 { "TestSomeText\r\r\nTestSomeText", 2},
63 { "TestSomeText\r\r\n\rTestSomeText", 3, 2}, /* NT4 and below */
64 { "TestSomeText\r\n\r\r\n\rTestSomeText", 4, 3}, /* NT4 and below */
65 { "TestSomeText\r\n" ,2},
66 { "TestSomeText\r\nSomeMoreText\r\n", 3},
67 { "TestSomeText\r\n\r\nTestSomeText", 3},
68 { "TestSomeText TestSomeText" ,1},
69 { "TestSomeText \r\nTestSomeText", 2},
70 { "TestSomeText\r\n \r\nTestSomeText", 3},
71 { "TestSomeText\n", 2},
72 { "TestSomeText\r\r\r", 3, 1}, /* NT4 and below */
73 { "TestSomeText\r\r\rSomeMoreText", 4, 2} /* NT4 and below */
75 HWND hwndRichEdit
= new_richedit(NULL
);
78 /* This test attempts to show that WM_SETTEXT on a riched32 control does not
79 * attempt to modify the text that is pasted into the control, and should
80 * return it as is. In particular, \r\r\n is NOT converted, unlike riched20.
82 * For riched32, the rules for breaking lines seem to be the following:
83 * - \r\n is one line break. This is the normal case.
84 * - \r{0,2}\n is one line break. In particular, \n by itself is a line break.
85 * - \r{0,N-1}\r\r\n is N line breaks.
86 * - \n{1,N} are that many line breaks.
87 * - \r with text or other characters (except \n) past it, is a line break. That
88 * is, a run of \r{N} without a terminating \n is considered N line breaks
89 * - \r at the end of the text is NOT a line break. This differs from riched20,
90 * where \r at the end of the text is a proper line break.
93 for (i
= 0; i
< sizeof(testitems
)/sizeof(testitems
[0]); i
++) {
98 result
= SendMessage(hwndRichEdit
, WM_SETTEXT
, 0, (LPARAM
) testitems
[i
].itemtext
);
99 ok (result
== 1, "[%d] WM_SETTEXT returned %ld instead of 1\n", i
, result
);
100 result
= SendMessage(hwndRichEdit
, WM_GETTEXT
, 1024, (LPARAM
) buf
);
101 ok (result
== lstrlen(buf
),
102 "[%d] WM_GETTEXT returned %ld instead of expected %u\n",
103 i
, result
, lstrlen(buf
));
104 result
= strcmp(testitems
[i
].itemtext
, buf
);
106 "[%d] WM_SETTEXT round trip: strcmp = %ld\n", i
, result
);
107 result
= SendMessage(hwndRichEdit
, EM_GETLINECOUNT
, 0, 0);
108 ok (result
== testitems
[i
].lines
||
109 broken(testitems
[i
].lines_broken
&& result
== testitems
[i
].lines_broken
),
110 "[%d] EM_GETLINECOUNT returned %ld, expected %d\n", i
, result
, testitems
[i
].lines
);
113 DestroyWindow(hwndRichEdit
);
116 static void test_WM_GETTEXTLENGTH(void)
118 HWND hwndRichEdit
= new_richedit(NULL
);
119 static const char text3
[] = "aaa\r\nbbb\r\nccc\r\nddd\r\neee";
120 static const char text4
[] = "aaa\r\nbbb\r\nccc\r\nddd\r\neee\r\n";
123 /* Test for WM_GETTEXTLENGTH */
124 SendMessage(hwndRichEdit
, WM_SETTEXT
, 0, (LPARAM
) text3
);
125 result
= SendMessage(hwndRichEdit
, WM_GETTEXTLENGTH
, 0, 0);
126 ok(result
== lstrlen(text3
),
127 "WM_GETTEXTLENGTH reports incorrect length %d, expected %d\n",
128 result
, lstrlen(text3
));
130 SendMessage(hwndRichEdit
, WM_SETTEXT
, 0, (LPARAM
) text4
);
131 result
= SendMessage(hwndRichEdit
, WM_GETTEXTLENGTH
, 0, 0);
132 ok(result
== lstrlen(text4
),
133 "WM_GETTEXTLENGTH reports incorrect length %d, expected %d\n",
134 result
, lstrlen(text4
));
136 DestroyWindow(hwndRichEdit
);
139 static DWORD CALLBACK
test_EM_STREAMIN_esCallback(DWORD_PTR dwCookie
,
144 const char** str
= (const char**)dwCookie
;
145 int size
= strlen(*str
);
151 memcpy(pbBuff
, *str
, *pcb
);
158 static void test_EM_STREAMIN(void)
160 HWND hwndRichEdit
= new_richedit(NULL
);
163 char buffer
[1024] = {0};
165 const char * streamText0
= "{\\rtf1 TestSomeText}";
166 const char * streamText0a
= "{\\rtf1 TestSomeText\\par}";
167 const char * streamText0b
= "{\\rtf1 TestSomeText\\par\\par}";
169 const char * streamText1
=
170 "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang12298{\\fonttbl{\\f0\\fswiss\\fprq2\\fcharset0 System;}}\r\n"
171 "\\viewkind4\\uc1\\pard\\f0\\fs17 TestSomeText\\par\r\n"
174 /* This should be accepted in richedit 1.0 emulation. See bug #8326 */
175 const char * streamText2
=
176 "{{\\colortbl;\\red0\\green255\\blue102;\\red255\\green255\\blue255;"
177 "\\red170\\green255\\blue255;\\red255\\green238\\blue0;\\red51\\green255"
178 "\\blue221;\\red238\\green238\\blue238;}\\tx0 \\tx424 \\tx848 \\tx1272 "
179 "\\tx1696 \\tx2120 \\tx2544 \\tx2968 \\tx3392 \\tx3816 \\tx4240 \\tx4664 "
180 "\\tx5088 \\tx5512 \\tx5936 \\tx6360 \\tx6784 \\tx7208 \\tx7632 \\tx8056 "
181 "\\tx8480 \\tx8904 \\tx9328 \\tx9752 \\tx10176 \\tx10600 \\tx11024 "
182 "\\tx11448 \\tx11872 \\tx12296 \\tx12720 \\tx13144 \\cf2 RichEdit1\\line }";
184 const char * streamText3
= "RichEdit1";
186 /* Minimal test without \par at the end */
187 es
.dwCookie
= (DWORD_PTR
)&streamText0
;
189 es
.pfnCallback
= test_EM_STREAMIN_esCallback
;
190 SendMessage(hwndRichEdit
, EM_STREAMIN
,
191 (WPARAM
)(SF_RTF
), (LPARAM
)&es
);
193 result
= SendMessage(hwndRichEdit
, WM_GETTEXT
, 1024, (LPARAM
) buffer
);
195 "EM_STREAMIN: Test 0 returned %ld, expected 12\n", result
);
196 result
= strcmp (buffer
,"TestSomeText");
198 "EM_STREAMIN: Test 0 set wrong text: Result: %s\n",buffer
);
199 ok(es
.dwError
== 0, "EM_STREAMIN: Test 0 set error %d, expected %d\n", es
.dwError
, 0);
201 /* Native richedit 2.0 ignores last \par */
202 es
.dwCookie
= (DWORD_PTR
)&streamText0a
;
204 es
.pfnCallback
= test_EM_STREAMIN_esCallback
;
205 SendMessage(hwndRichEdit
, EM_STREAMIN
,
206 (WPARAM
)(SF_RTF
), (LPARAM
)&es
);
208 result
= SendMessage(hwndRichEdit
, WM_GETTEXT
, 1024, (LPARAM
) buffer
);
210 "EM_STREAMIN: Test 0-a returned %ld, expected 12\n", result
);
211 result
= strcmp (buffer
,"TestSomeText");
213 "EM_STREAMIN: Test 0-a set wrong text: Result: %s\n",buffer
);
214 ok(es
.dwError
== 0, "EM_STREAMIN: Test 0 set error %d, expected %d\n", es
.dwError
, 0);
216 /* Native richedit 2.0 ignores last \par, next-to-last \par appears */
217 es
.dwCookie
= (DWORD_PTR
)&streamText0b
;
219 es
.pfnCallback
= test_EM_STREAMIN_esCallback
;
220 SendMessage(hwndRichEdit
, EM_STREAMIN
,
221 (WPARAM
)(SF_RTF
), (LPARAM
)&es
);
223 result
= SendMessage(hwndRichEdit
, WM_GETTEXT
, 1024, (LPARAM
) buffer
);
225 "EM_STREAMIN: Test 0-b returned %ld, expected 14\n", result
);
226 result
= strcmp (buffer
,"TestSomeText\r\n");
228 "EM_STREAMIN: Test 0-b set wrong text: Result: %s\n",buffer
);
229 ok(es
.dwError
== 0, "EM_STREAMIN: Test 0 set error %d, expected %d\n", es
.dwError
, 0);
231 es
.dwCookie
= (DWORD_PTR
)&streamText1
;
233 es
.pfnCallback
= test_EM_STREAMIN_esCallback
;
234 SendMessage(hwndRichEdit
, EM_STREAMIN
,
235 (WPARAM
)(SF_RTF
), (LPARAM
)&es
);
237 result
= SendMessage(hwndRichEdit
, WM_GETTEXT
, 1024, (LPARAM
) buffer
);
239 "EM_STREAMIN: Test 1 returned %ld, expected 12\n", result
);
240 result
= strcmp (buffer
,"TestSomeText");
242 "EM_STREAMIN: Test 1 set wrong text: Result: %s\n",buffer
);
243 ok(es
.dwError
== 0, "EM_STREAMIN: Test 0 set error %d, expected %d\n", es
.dwError
, 0);
246 es
.dwCookie
= (DWORD_PTR
)&streamText2
;
248 SendMessage(hwndRichEdit
, EM_STREAMIN
,
249 (WPARAM
)(SF_RTF
), (LPARAM
)&es
);
251 result
= SendMessage(hwndRichEdit
, WM_GETTEXT
, 1024, (LPARAM
) buffer
);
254 "EM_STREAMIN: Test 2 returned %ld, expected 9\n", result
);
256 result
= strcmp (buffer
,"RichEdit1");
259 "EM_STREAMIN: Test 2 set wrong text: Result: %s\n",buffer
);
261 ok(es
.dwError
== 0, "EM_STREAMIN: Test 0 set error %d, expected %d\n", es
.dwError
, 0);
263 es
.dwCookie
= (DWORD_PTR
)&streamText3
;
265 SendMessage(hwndRichEdit
, EM_STREAMIN
,
266 (WPARAM
)(SF_RTF
), (LPARAM
)&es
);
268 result
= SendMessage(hwndRichEdit
, WM_GETTEXT
, 1024, (LPARAM
) buffer
);
270 "EM_STREAMIN: Test 3 returned %ld, expected 0\n", result
);
271 ok (strlen(buffer
) == 0,
272 "EM_STREAMIN: Test 3 set wrong text: Result: %s\n",buffer
);
273 ok(es
.dwError
== -16, "EM_STREAMIN: Test 0 set error %d, expected %d\n", es
.dwError
, -16);
275 DestroyWindow(hwndRichEdit
);
278 static DWORD CALLBACK
test_WM_SETTEXT_esCallback(DWORD_PTR dwCookie
,
283 char** str
= (char**)dwCookie
;
286 memcpy(*str
, pbBuff
, *pcb
);
292 static void test_EM_STREAMOUT(void)
294 HWND hwndRichEdit
= new_richedit(NULL
);
297 char buf
[1024] = {0};
300 const char * TestItem1
= "TestSomeText";
301 const char * TestItem2
= "TestSomeText\r";
302 const char * TestItem3
= "TestSomeText\r\n";
304 SendMessage(hwndRichEdit
, WM_SETTEXT
, 0, (LPARAM
) TestItem1
);
306 es
.dwCookie
= (DWORD_PTR
)&p
;
308 es
.pfnCallback
= test_WM_SETTEXT_esCallback
;
309 memset(buf
, 0, sizeof(buf
));
310 SendMessage(hwndRichEdit
, EM_STREAMOUT
,
311 (WPARAM
)(SF_TEXT
), (LPARAM
)&es
);
313 ok(r
== 12, "streamed text length is %d, expecting 12\n", r
);
314 ok(strcmp(buf
, TestItem1
) == 0,
315 "streamed text different, got %s\n", buf
);
317 SendMessage(hwndRichEdit
, WM_SETTEXT
, 0, (LPARAM
) TestItem2
);
319 es
.dwCookie
= (DWORD_PTR
)&p
;
321 es
.pfnCallback
= test_WM_SETTEXT_esCallback
;
322 memset(buf
, 0, sizeof(buf
));
323 SendMessage(hwndRichEdit
, EM_STREAMOUT
,
324 (WPARAM
)(SF_TEXT
), (LPARAM
)&es
);
327 ok(r
== 13, "streamed text length is %d, expecting 13\n", r
);
328 ok(strcmp(buf
, TestItem2
) == 0,
329 "streamed text different, got %s\n", buf
);
331 SendMessage(hwndRichEdit
, WM_SETTEXT
, 0, (LPARAM
) TestItem3
);
333 es
.dwCookie
= (DWORD_PTR
)&p
;
335 es
.pfnCallback
= test_WM_SETTEXT_esCallback
;
336 memset(buf
, 0, sizeof(buf
));
337 SendMessage(hwndRichEdit
, EM_STREAMOUT
,
338 (WPARAM
)(SF_TEXT
), (LPARAM
)&es
);
340 ok(r
== 14, "streamed text length is %d, expecting 14\n", r
);
341 ok(strcmp(buf
, TestItem3
) == 0,
342 "streamed text different, got %s\n", buf
);
344 DestroyWindow(hwndRichEdit
);
347 static const struct getline_s
{
352 {0, 10, "foo bar\r\n"},
358 /* Buffer smaller than line length */
364 static void test_EM_GETLINE(void)
367 HWND hwndRichEdit
= new_richedit(NULL
);
368 static const int nBuf
= 1024;
369 char dest
[1024], origdest
[1024];
370 const char text
[] = "foo bar\r\n"
375 SendMessage(hwndRichEdit
, WM_SETTEXT
, 0, (LPARAM
) text
);
377 memset(origdest
, 0xBB, nBuf
);
378 for (i
= 0; i
< sizeof(gl
)/sizeof(struct getline_s
); i
++)
381 int expected_nCopied
= min(gl
[i
].buffer_len
, strlen(gl
[i
].text
));
382 int expected_bytes_written
= min(gl
[i
].buffer_len
, strlen(gl
[i
].text
) + 1);
383 memset(dest
, 0xBB, nBuf
);
384 *(WORD
*) dest
= gl
[i
].buffer_len
;
386 /* EM_GETLINE appends a "\r\0" to the end of the line
387 * nCopied counts up to and including the '\r' */
388 nCopied
= SendMessage(hwndRichEdit
, EM_GETLINE
, gl
[i
].line
, (LPARAM
) dest
);
389 ok(nCopied
== expected_nCopied
, "%d: %d!=%d\n", i
, nCopied
,
391 /* two special cases since a parameter is passed via dest */
392 if (gl
[i
].buffer_len
== 0)
393 ok(!dest
[0] && !dest
[1] && !strncmp(dest
+2, origdest
+2, nBuf
-2),
395 else if (gl
[i
].buffer_len
== 1)
396 ok(dest
[0] == gl
[i
].text
[0] && !dest
[1] &&
397 !strncmp(dest
+2, origdest
+2, nBuf
-2), "buffer_len=1\n");
400 ok(!strncmp(dest
, gl
[i
].text
, expected_bytes_written
),
401 "%d: expected_bytes_written=%d\n", i
, expected_bytes_written
);
402 ok(!strncmp(dest
+ expected_bytes_written
, origdest
403 + expected_bytes_written
, nBuf
- expected_bytes_written
),
404 "%d: expected_bytes_written=%d\n", i
, expected_bytes_written
);
408 DestroyWindow(hwndRichEdit
);
411 static void test_EM_LINELENGTH(void)
413 HWND hwndRichEdit
= new_richedit(NULL
);
423 int offset_test
[16][2] = {
424 {0, 9}, /* Line 1: |richedit1\r */
425 {5, 9}, /* Line 1: riche|dit1\r */
426 {10, 9}, /* Line 2: |richedit1\n */
427 {15, 9}, /* Line 2: riche|dit1\n */
428 {20, 9}, /* Line 3: |richedit1\r\n */
429 {25, 9}, /* Line 3: riche|dit1\r\n */
430 {30, 9}, /* Line 3: richedit1\r|\n */
431 {31, 5}, /* Line 4: |short\r */
432 {42, 9}, /* Line 5: riche|dit1\r */
433 {46, 9}, /* Line 5: richedit1|\r */
434 {47, 0}, /* Line 6: |\r */
435 {48, 0}, /* Line 7: |\r */
436 {49, 0}, /* Line 8: |\r\r\n */
437 {50, 0}, /* Line 8: \r|\r\n */
438 {51, 0}, /* Line 8: \r\r|\n */
439 {52, 0}, /* Line 9: \r\r\n| */
444 SendMessage(hwndRichEdit
, WM_SETTEXT
, 0, (LPARAM
) text
);
446 result
= SendMessage(hwndRichEdit
, EM_GETLINECOUNT
, 0, 0);
448 win_skip("Win9x, WinME and NT4 don't handle '\\r only' correctly\n");
451 ok(result
== 9, "Incorrect line count of %ld\n", result
);
453 for (i
= 0; i
< sizeof(offset_test
)/sizeof(offset_test
[0]); i
++) {
454 result
= SendMessage(hwndRichEdit
, EM_LINELENGTH
, offset_test
[i
][0], 0);
455 ok(result
== offset_test
[i
][1], "Length of line at offset %d is %ld, expected %d\n",
456 offset_test
[i
][0], result
, offset_test
[i
][1]);
459 DestroyWindow(hwndRichEdit
);
462 static void test_EM_GETTEXTRANGE(void)
464 HWND hwndRichEdit
= new_richedit(NULL
);
465 const char * text1
= "foo bar\r\nfoo bar";
466 const char * text3
= "foo bar\rfoo bar";
467 const char * expect1
= "bar\r\nfoo";
468 const char * expect2
= "\nfoo";
469 const char * expect3
= "bar\rfoo";
470 char buffer
[1024] = {0};
472 TEXTRANGEA textRange
;
474 SendMessage(hwndRichEdit
, WM_SETTEXT
, 0, (LPARAM
)text1
);
476 textRange
.lpstrText
= buffer
;
477 textRange
.chrg
.cpMin
= 4;
478 textRange
.chrg
.cpMax
= 12;
479 result
= SendMessage(hwndRichEdit
, EM_GETTEXTRANGE
, 0, (LPARAM
)&textRange
);
480 ok(result
== 8, "EM_GETTEXTRANGE returned %ld\n", result
);
481 ok(!strcmp(expect1
, buffer
), "EM_GETTEXTRANGE filled %s\n", buffer
);
483 textRange
.lpstrText
= buffer
;
484 textRange
.chrg
.cpMin
= 8;
485 textRange
.chrg
.cpMax
= 12;
486 result
= SendMessage(hwndRichEdit
, EM_GETTEXTRANGE
, 0, (LPARAM
)&textRange
);
487 ok(result
== 4, "EM_GETTEXTRANGE returned %ld\n", result
);
488 ok(!strcmp(expect2
, buffer
), "EM_GETTEXTRANGE filled %s\n", buffer
);
490 SendMessage(hwndRichEdit
, WM_SETTEXT
, 0, (LPARAM
)text3
);
492 textRange
.lpstrText
= buffer
;
493 textRange
.chrg
.cpMin
= 4;
494 textRange
.chrg
.cpMax
= 11;
495 result
= SendMessage(hwndRichEdit
, EM_GETTEXTRANGE
, 0, (LPARAM
)&textRange
);
496 ok(result
== 7, "EM_GETTEXTRANGE returned %ld\n", result
);
498 ok(!strcmp(expect3
, buffer
), "EM_GETTEXTRANGE filled %s\n", buffer
);
501 DestroyWindow(hwndRichEdit
);
504 static void test_EM_GETSELTEXT(void)
506 HWND hwndRichEdit
= new_richedit(NULL
);
507 const char * text1
= "foo bar\r\nfoo bar";
508 const char * text2
= "foo bar\rfoo bar";
509 const char * expect1
= "bar\r\nfoo";
510 const char * expect2
= "bar\rfoo";
511 char buffer
[1024] = {0};
514 SendMessage(hwndRichEdit
, WM_SETTEXT
, 0, (LPARAM
)text1
);
516 SendMessage(hwndRichEdit
, EM_SETSEL
, 4, 12);
517 result
= SendMessage(hwndRichEdit
, EM_GETSELTEXT
, 0, (LPARAM
)buffer
);
518 ok(result
== 8, "EM_GETTEXTRANGE returned %ld\n", result
);
519 ok(!strcmp(expect1
, buffer
), "EM_GETTEXTRANGE filled %s\n", buffer
);
521 SendMessage(hwndRichEdit
, WM_SETTEXT
, 0, (LPARAM
)text2
);
523 SendMessage(hwndRichEdit
, EM_SETSEL
, 4, 11);
524 result
= SendMessage(hwndRichEdit
, EM_GETSELTEXT
, 0, (LPARAM
)buffer
);
525 ok(result
== 7, "EM_GETTEXTRANGE returned %ld\n", result
);
527 ok(!strcmp(expect2
, buffer
), "EM_GETTEXTRANGE filled %s\n", buffer
);
530 DestroyWindow(hwndRichEdit
);
533 static const char haystack
[] = "WINEWine wineWine wine WineWine";
536 static const char haystack2
[] = "first\r\r\nsecond";
547 struct find_s find_tests
[] = {
548 /* Find in empty text */
549 {0, -1, "foo", FR_DOWN
, -1},
550 {0, -1, "foo", 0, -1},
551 {0, -1, "", FR_DOWN
, -1},
552 {20, 5, "foo", FR_DOWN
, -1},
553 {5, 20, "foo", FR_DOWN
, -1}
556 struct find_s find_tests2
[] = {
558 {0, -1, "foo", FR_DOWN
| FR_MATCHCASE
, -1},
559 {5, 20, "WINE", FR_DOWN
| FR_MATCHCASE
, -1},
561 /* Subsequent finds */
562 {0, -1, "Wine", FR_DOWN
| FR_MATCHCASE
, 4},
563 {5, 31, "Wine", FR_DOWN
| FR_MATCHCASE
, 13},
564 {14, 31, "Wine", FR_DOWN
| FR_MATCHCASE
, 23},
565 {24, 31, "Wine", FR_DOWN
| FR_MATCHCASE
, 27},
568 {19, 20, "Wine", FR_MATCHCASE
, -1},
569 {10, 20, "Wine", FR_MATCHCASE
, 13},
570 {20, 10, "Wine", FR_MATCHCASE
, -1},
572 /* Case-insensitive */
573 {1, 31, "wInE", FR_DOWN
, 4},
574 {1, 31, "Wine", FR_DOWN
, 4},
576 /* High-to-low ranges */
577 {20, 5, "Wine", FR_DOWN
, -1},
578 {2, 1, "Wine", FR_DOWN
, -1},
579 {30, 29, "Wine", FR_DOWN
, -1},
580 {20, 5, "Wine", 0, /*13*/ -1},
583 {5, 10, "", FR_DOWN
, -1},
584 {10, 5, "", FR_DOWN
, -1},
585 {0, -1, "", FR_DOWN
, -1},
588 /* Whole-word search */
589 {0, -1, "wine", FR_DOWN
| FR_WHOLEWORD
, 18},
590 {0, -1, "win", FR_DOWN
| FR_WHOLEWORD
, -1},
591 {13, -1, "wine", FR_DOWN
| FR_WHOLEWORD
, 18},
592 {0, -1, "winewine", FR_DOWN
| FR_WHOLEWORD
, 0},
593 {10, -1, "winewine", FR_DOWN
| FR_WHOLEWORD
, 23},
594 {11, -1, "winewine", FR_WHOLEWORD
, 23},
595 {31, -1, "winewine", FR_WHOLEWORD
, -1},
598 {5, 200, "XXX", FR_DOWN
, -1},
599 {-20, 20, "Wine", FR_DOWN
, -1},
600 {-20, 20, "Wine", FR_DOWN
, -1},
601 {-15, -20, "Wine", FR_DOWN
, -1},
602 {1<<12, 1<<13, "Wine", FR_DOWN
, -1},
604 /* Check the case noted in bug 4479 where matches at end aren't recognized */
605 {23, 31, "Wine", FR_DOWN
| FR_MATCHCASE
, 23},
606 {27, 31, "Wine", FR_DOWN
| FR_MATCHCASE
, 27},
607 {27, 32, "Wine", FR_DOWN
| FR_MATCHCASE
, 27},
608 {13, 31, "WineWine", FR_DOWN
| FR_MATCHCASE
, 23},
609 {13, 32, "WineWine", FR_DOWN
| FR_MATCHCASE
, 23},
611 /* The backwards case of bug 4479; bounds look right
612 * Fails because backward find is wrong */
613 {19, 20, "WINE", FR_MATCHCASE
, -1},
614 {0, 20, "WINE", FR_MATCHCASE
, 0},
616 {0, -1, "wineWine wine", FR_DOWN
, 0},
617 {0, -1, "wineWine wine", 0, 0},
618 {0, -1, "INEW", 0, 1},
619 {0, 31, "INEW", 0, 1},
620 {4, -1, "INEW", 0, 10},
623 struct find_s find_tests3
[] = {
624 /* Searching for end of line characters */
625 {0, -1, "t\r\r\ns", FR_DOWN
| FR_MATCHCASE
, 4},
626 {6, -1, "\r\n", FR_DOWN
| FR_MATCHCASE
, 6},
627 {7, -1, "\n", FR_DOWN
| FR_MATCHCASE
, 7},
630 static void check_EM_FINDTEXT(HWND hwnd
, const char *name
, struct find_s
*f
, int id
) {
633 memset(&ft
, 0, sizeof(ft
));
634 ft
.chrg
.cpMin
= f
->start
;
635 ft
.chrg
.cpMax
= f
->end
;
636 ft
.lpstrText
= f
->needle
;
637 findloc
= SendMessage(hwnd
, EM_FINDTEXT
, f
->flags
, (LPARAM
) &ft
);
638 ok(findloc
== f
->expected_loc
,
639 "EM_FINDTEXT(%s,%d) '%s' in range(%d,%d), flags %08x, got start at %d, expected %d\n",
640 name
, id
, f
->needle
, f
->start
, f
->end
, f
->flags
, findloc
, f
->expected_loc
);
643 static void check_EM_FINDTEXTEX(HWND hwnd
, const char *name
, struct find_s
*f
,
647 int expected_end_loc
;
649 memset(&ft
, 0, sizeof(ft
));
650 ft
.chrg
.cpMin
= f
->start
;
651 ft
.chrg
.cpMax
= f
->end
;
652 ft
.lpstrText
= f
->needle
;
653 ft
.chrgText
.cpMax
= 0xdeadbeef;
654 findloc
= SendMessage(hwnd
, EM_FINDTEXTEX
, f
->flags
, (LPARAM
) &ft
);
655 ok(findloc
== f
->expected_loc
,
656 "EM_FINDTEXTEX(%s,%d) '%s' in range(%d,%d), flags %08x, start at %d\n",
657 name
, id
, f
->needle
, f
->start
, f
->end
, f
->flags
, findloc
);
658 ok(ft
.chrgText
.cpMin
== f
->expected_loc
,
659 "EM_FINDTEXTEX(%s,%d) '%s' in range(%d,%d), flags %08x, start at %d, expected %d\n",
660 name
, id
, f
->needle
, f
->start
, f
->end
, f
->flags
, ft
.chrgText
.cpMin
, f
->expected_loc
);
661 expected_end_loc
= ((f
->expected_loc
== -1) ? -1
662 : f
->expected_loc
+ strlen(f
->needle
));
663 ok(ft
.chrgText
.cpMax
== expected_end_loc
||
664 broken(ft
.chrgText
.cpMin
== -1 && ft
.chrgText
.cpMax
== 0xdeadbeef), /* Win9x, WinME and NT4 */
665 "EM_FINDTEXTEX(%s,%d) '%s' in range(%d,%d), flags %08x, end at %d, expected %d\n",
666 name
, id
, f
->needle
, f
->start
, f
->end
, f
->flags
, ft
.chrgText
.cpMax
, expected_end_loc
);
669 static void run_tests_EM_FINDTEXT(HWND hwnd
, const char *name
, struct find_s
*find
,
674 for (i
= 0; i
< num_tests
; i
++) {
675 check_EM_FINDTEXT(hwnd
, name
, &find
[i
], i
);
676 check_EM_FINDTEXTEX(hwnd
, name
, &find
[i
], i
);
680 static void test_EM_FINDTEXT(void)
682 HWND hwndRichEdit
= new_richedit(NULL
);
684 /* Empty rich edit control */
685 run_tests_EM_FINDTEXT(hwndRichEdit
, "1", find_tests
,
686 sizeof(find_tests
)/sizeof(struct find_s
));
688 SendMessage(hwndRichEdit
, WM_SETTEXT
, 0, (LPARAM
) haystack
);
691 run_tests_EM_FINDTEXT(hwndRichEdit
, "2", find_tests2
,
692 sizeof(find_tests2
)/sizeof(struct find_s
));
694 SendMessage(hwndRichEdit
, WM_SETTEXT
, 0, (LPARAM
) haystack2
);
696 /* Haystack text 2 (with EOL characters) */
697 run_tests_EM_FINDTEXT(hwndRichEdit
, "3", find_tests3
,
698 sizeof(find_tests3
)/sizeof(struct find_s
));
700 DestroyWindow(hwndRichEdit
);
703 static void test_EM_POSFROMCHAR(void)
705 HWND hwndRichEdit
= new_richedit(NULL
);
709 unsigned int height
= 0;
711 static const char text
[] = "aa\n"
712 "this is a long line of text that should be longer than the "
721 /* Fill the control to lines to ensure that most of them are offscreen */
722 for (i
= 0; i
< 50; i
++)
724 /* Do not modify the string; it is exactly 16 characters long. */
725 SendMessage(hwndRichEdit
, EM_SETSEL
, 0, 0);
726 SendMessage(hwndRichEdit
, EM_REPLACESEL
, 0, (LPARAM
)"0123456789ABCD\r\n");
730 Richedit 1.0 receives a POINTL* on wParam and character offset on lParam, returns void.
731 Richedit 2.0 receives character offset on wParam, ignores lParam, returns MAKELONG(x,y)
732 Richedit 3.0 accepts either of the above API conventions.
735 /* Testing Richedit 1.0 API format */
737 /* Testing start of lines. X-offset should be constant on all cases (native is 1).
738 Since all lines are identical and drawn with the same font,
739 they should have the same height... right?
741 for (i
= 0; i
< 50; i
++)
743 /* All the lines are 16 characters long */
744 result
= SendMessage(hwndRichEdit
, EM_POSFROMCHAR
, (WPARAM
)&pl
, i
* 16);
745 ok(result
== 0, "EM_POSFROMCHAR returned %ld, expected 0\n", result
);
748 ok(pl
.y
== 0, "EM_POSFROMCHAR reports y=%d, expected 0\n", pl
.y
);
749 ok(pl
.x
== 1, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl
.x
);
754 ok(pl
.y
> 0, "EM_POSFROMCHAR reports y=%d, expected > 0\n", pl
.y
);
755 ok(pl
.x
== xpos
, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl
.x
);
760 ok(pl
.y
== i
* height
, "EM_POSFROMCHAR reports y=%d, expected %d\n", pl
.y
, i
* height
);
761 ok(pl
.x
== xpos
, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl
.x
);
765 /* Testing position at end of text */
766 result
= SendMessage(hwndRichEdit
, EM_POSFROMCHAR
, (WPARAM
)&pl
, 50 * 16);
767 ok(result
== 0, "EM_POSFROMCHAR returned %ld, expected 0\n", result
);
768 ok(pl
.y
== 50 * height
, "EM_POSFROMCHAR reports y=%d, expected %d\n", pl
.y
, 50 * height
);
769 ok(pl
.x
== xpos
, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl
.x
);
771 /* Testing position way past end of text */
772 result
= SendMessage(hwndRichEdit
, EM_POSFROMCHAR
, (WPARAM
)&pl
, 55 * 16);
773 ok(result
== 0, "EM_POSFROMCHAR returned %ld, expected 0\n", result
);
774 ok(pl
.y
== 50 * height
, "EM_POSFROMCHAR reports y=%d, expected %d\n", pl
.y
, 50 * height
);
775 ok(pl
.x
== xpos
, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl
.x
);
778 /* Testing that vertical scrolling does, in fact, have an effect on EM_POSFROMCHAR */
779 SendMessage(hwndRichEdit
, EM_SCROLL
, SB_LINEDOWN
, 0); /* line down */
780 for (i
= 0; i
< 50; i
++)
782 /* All the lines are 16 characters long */
783 result
= SendMessage(hwndRichEdit
, EM_POSFROMCHAR
, (WPARAM
)&pl
, i
* 16);
784 ok(result
== 0, "EM_POSFROMCHAR returned %ld, expected 0\n", result
);
785 ok(pl
.y
== (i
- 1) * height
,
786 "EM_POSFROMCHAR reports y=%d, expected %d\n",
787 pl
.y
, (i
- 1) * height
);
788 ok(pl
.x
== xpos
, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl
.x
);
791 /* Testing position at end of text */
792 result
= SendMessage(hwndRichEdit
, EM_POSFROMCHAR
, (WPARAM
)&pl
, 50 * 16);
793 ok(result
== 0, "EM_POSFROMCHAR returned %ld, expected 0\n", result
);
794 ok(pl
.y
== (50 - 1) * height
, "EM_POSFROMCHAR reports y=%d, expected %d\n", pl
.y
, (50 - 1) * height
);
795 ok(pl
.x
== xpos
, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl
.x
);
797 /* Testing position way past end of text */
798 result
= SendMessage(hwndRichEdit
, EM_POSFROMCHAR
, (WPARAM
)&pl
, 55 * 16);
799 ok(result
== 0, "EM_POSFROMCHAR returned %ld, expected 0\n", result
);
800 ok(pl
.y
== (50 - 1) * height
, "EM_POSFROMCHAR reports y=%d, expected %d\n", pl
.y
, (50 - 1) * height
);
801 ok(pl
.x
== xpos
, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl
.x
);
803 /* Testing that horizontal scrolling does, in fact, have an effect on EM_POSFROMCHAR */
804 SendMessage(hwndRichEdit
, WM_SETTEXT
, 0, (LPARAM
) text
);
805 SendMessage(hwndRichEdit
, EM_SCROLL
, SB_LINEUP
, 0); /* line up */
807 result
= SendMessage(hwndRichEdit
, EM_POSFROMCHAR
, (WPARAM
)&pl
, 0);
808 ok(result
== 0, "EM_POSFROMCHAR returned %ld, expected 0\n", result
);
809 ok(pl
.y
== 0, "EM_POSFROMCHAR reports y=%d, expected 0\n", pl
.y
);
810 ok(pl
.x
== 1, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl
.x
);
813 SendMessage(hwndRichEdit
, WM_HSCROLL
, SB_LINERIGHT
, 0);
814 result
= SendMessage(hwndRichEdit
, EM_POSFROMCHAR
, (WPARAM
)&pl
, 0);
815 ok(result
== 0, "EM_POSFROMCHAR returned %ld, expected 0\n", result
);
816 ok(pl
.y
== 0, "EM_POSFROMCHAR reports y=%d, expected 0\n", pl
.y
);
818 /* Fails on builtin because horizontal scrollbar is not being shown */
819 ok(pl
.x
< xpos
, "EM_POSFROMCHAR reports x=%hd, expected value less than %d\n", pl
.x
, xpos
);
821 DestroyWindow(hwndRichEdit
);
824 static void test_word_wrap(void)
827 POINTL point
= {0, 60}; /* This point must be below the first line */
828 const char *text
= "Must be long enough to test line wrapping";
829 DWORD dwCommonStyle
= WS_VISIBLE
|WS_POPUP
|WS_VSCROLL
|ES_MULTILINE
;
832 /* Test the effect of WS_HSCROLL and ES_AUTOHSCROLL styles on wrapping
833 * when specified on window creation and set later. */
834 hwnd
= CreateWindow(RICHEDIT_CLASS10A
, NULL
, dwCommonStyle
,
835 0, 0, 200, 80, NULL
, NULL
, hmoduleRichEdit
, NULL
);
836 ok(hwnd
!= NULL
, "error: %d\n", (int) GetLastError());
837 res
= SendMessage(hwnd
, WM_SETTEXT
, 0, (LPARAM
) text
);
838 ok(res
, "WM_SETTEXT failed.\n");
839 pos
= SendMessage(hwnd
, EM_CHARFROMPOS
, 0, (LPARAM
) &point
);
840 ok(pos
, "pos=%d indicating no word wrap when it is expected.\n", pos
);
841 lines
= SendMessage(hwnd
, EM_GETLINECOUNT
, 0, 0);
842 ok(lines
> 1, "Line was expected to wrap (lines=%d).\n", lines
);
844 SetWindowLong(hwnd
, GWL_STYLE
, dwCommonStyle
|WS_HSCROLL
|ES_AUTOHSCROLL
);
845 pos
= SendMessage(hwnd
, EM_CHARFROMPOS
, 0, (LPARAM
) &point
);
846 ok(pos
, "pos=%d indicating no word wrap when it is expected.\n", pos
);
849 hwnd
= CreateWindow(RICHEDIT_CLASS10A
, NULL
, dwCommonStyle
|WS_HSCROLL
,
850 0, 0, 200, 80, NULL
, NULL
, hmoduleRichEdit
, NULL
);
851 ok(hwnd
!= NULL
, "error: %d\n", (int) GetLastError());
853 res
= SendMessage(hwnd
, WM_SETTEXT
, 0, (LPARAM
) text
);
854 ok(res
, "WM_SETTEXT failed.\n");
855 pos
= SendMessage(hwnd
, EM_CHARFROMPOS
, 0, (LPARAM
) &point
);
856 ok(pos
, "pos=%d indicating no word wrap when it is expected.\n", pos
);
857 lines
= SendMessage(hwnd
, EM_GETLINECOUNT
, 0, 0);
858 ok(lines
> 1, "Line was expected to wrap (lines=%d).\n", lines
);
860 SetWindowLong(hwnd
, GWL_STYLE
, dwCommonStyle
|WS_HSCROLL
|ES_AUTOHSCROLL
);
861 pos
= SendMessage(hwnd
, EM_CHARFROMPOS
, 0, (LPARAM
) &point
);
862 ok(pos
, "pos=%d indicating no word wrap when it is expected.\n", pos
);
865 hwnd
= CreateWindow(RICHEDIT_CLASS10A
, NULL
, dwCommonStyle
|ES_AUTOHSCROLL
,
866 0, 0, 200, 80, NULL
, NULL
, hmoduleRichEdit
, NULL
);
867 ok(hwnd
!= NULL
, "error: %d\n", (int) GetLastError());
868 res
= SendMessage(hwnd
, WM_SETTEXT
, 0, (LPARAM
) text
);
869 ok(res
, "WM_SETTEXT failed.\n");
870 pos
= SendMessage(hwnd
, EM_CHARFROMPOS
, 0, (LPARAM
) &point
);
872 broken(pos
== lstrlen(text
)), /* Win9x, WinME and NT4 */
873 "pos=%d indicating word wrap when none is expected.\n", pos
);
874 lines
= SendMessage(hwnd
, EM_GETLINECOUNT
, 0, 0);
875 ok(lines
== 1, "Line was not expected to wrap (lines=%d).\n", lines
);
877 SetWindowLong(hwnd
, GWL_STYLE
, dwCommonStyle
);
878 pos
= SendMessage(hwnd
, EM_CHARFROMPOS
, 0, (LPARAM
) &point
);
880 broken(pos
== lstrlen(text
)), /* Win9x, WinME and NT4 */
881 "pos=%d indicating word wrap when none is expected.\n", pos
);
882 lines
= SendMessage(hwnd
, EM_GETLINECOUNT
, 0, 0);
883 ok(lines
== 1, "Line was not expected to wrap (lines=%d).\n", lines
);
886 hwnd
= CreateWindow(RICHEDIT_CLASS10A
, NULL
,
887 dwCommonStyle
|WS_HSCROLL
|ES_AUTOHSCROLL
,
888 0, 0, 200, 80, NULL
, NULL
, hmoduleRichEdit
, NULL
);
889 ok(hwnd
!= NULL
, "error: %d\n", (int) GetLastError());
890 res
= SendMessage(hwnd
, WM_SETTEXT
, 0, (LPARAM
) text
);
891 ok(res
, "WM_SETTEXT failed.\n");
892 pos
= SendMessage(hwnd
, EM_CHARFROMPOS
, 0, (LPARAM
) &point
);
894 broken(pos
== lstrlen(text
)), /* Win9x, WinME and NT4 */
895 "pos=%d indicating word wrap when none is expected.\n", pos
);
896 lines
= SendMessage(hwnd
, EM_GETLINECOUNT
, 0, 0);
897 ok(lines
== 1, "Line was not expected to wrap (lines=%d).\n", lines
);
899 SetWindowLong(hwnd
, GWL_STYLE
, dwCommonStyle
);
900 pos
= SendMessage(hwnd
, EM_CHARFROMPOS
, 0, (LPARAM
) &point
);
902 broken(pos
== lstrlen(text
)), /* Win9x, WinME and NT4 */
903 "pos=%d indicating word wrap when none is expected.\n", pos
);
904 lines
= SendMessage(hwnd
, EM_GETLINECOUNT
, 0, 0);
905 ok(lines
== 1, "Line was not expected to wrap (lines=%d).\n", lines
);
907 /* Test the effect of EM_SETTARGETDEVICE on word wrap. */
908 res
= SendMessage(hwnd
, EM_SETTARGETDEVICE
, 0, 1);
909 ok(res
, "EM_SETTARGETDEVICE failed (returned %d).\n", res
);
910 pos
= SendMessage(hwnd
, EM_CHARFROMPOS
, 0, (LPARAM
) &point
);
912 broken(pos
== lstrlen(text
)), /* Win9x, WinME and NT4 */
913 "pos=%d indicating word wrap when none is expected.\n", pos
);
914 lines
= SendMessage(hwnd
, EM_GETLINECOUNT
, 0, 0);
915 ok(lines
== 1, "Line was not expected to wrap (lines=%d).\n", lines
);
917 res
= SendMessage(hwnd
, EM_SETTARGETDEVICE
, 0, 0);
918 ok(res
, "EM_SETTARGETDEVICE failed (returned %d).\n", res
);
919 pos
= SendMessage(hwnd
, EM_CHARFROMPOS
, 0, (LPARAM
) &point
);
920 ok(pos
, "pos=%d indicating no word wrap when it is expected.\n", pos
);
923 /* Test to see if wrapping happens with redraw disabled. */
924 hwnd
= CreateWindow(RICHEDIT_CLASS10A
, NULL
, dwCommonStyle
,
925 0, 0, 400, 80, NULL
, NULL
, hmoduleRichEdit
, NULL
);
926 ok(hwnd
!= NULL
, "error: %d\n", (int) GetLastError());
927 ok(IsWindowVisible(hwnd
), "Window should be visible.\n");
928 SendMessage(hwnd
, WM_SETREDRAW
, FALSE
, 0);
929 /* redraw is disabled by making the window invisible. */
930 ok(!IsWindowVisible(hwnd
), "Window shouldn't be visible.\n");
931 res
= SendMessage(hwnd
, EM_REPLACESEL
, FALSE
, (LPARAM
) text
);
932 ok(res
, "EM_REPLACESEL failed.\n");
933 MoveWindow(hwnd
, 0, 0, 100, 80, TRUE
);
934 SendMessage(hwnd
, WM_SETREDRAW
, TRUE
, 0);
935 /* Wrapping didn't happen while redraw was disabled. */
936 lines
= SendMessage(hwnd
, EM_GETLINECOUNT
, 0, 0);
937 todo_wine
ok(lines
== 1, "Line wasn't expected to wrap (lines=%d).\n", lines
);
938 /* There isn't even a rewrap from resizing the window. */
939 lines
= SendMessage(hwnd
, EM_GETLINECOUNT
, 0, 0);
940 todo_wine
ok(lines
== 1, "Line wasn't expected to wrap (lines=%d).\n", lines
);
941 res
= SendMessage(hwnd
, EM_REPLACESEL
, FALSE
, (LPARAM
) text
);
942 ok(res
, "EM_REPLACESEL failed.\n");
943 lines
= SendMessage(hwnd
, EM_GETLINECOUNT
, 0, 0);
944 ok(lines
> 1, "Line was expected to wrap (lines=%d).\n", lines
);
949 static void test_EM_GETOPTIONS(void)
954 hwnd
= CreateWindow(RICHEDIT_CLASS10A
, NULL
,
956 0, 0, 200, 60, NULL
, NULL
, hmoduleRichEdit
, NULL
);
957 options
= SendMessage(hwnd
, EM_GETOPTIONS
, 0, 0);
958 ok(options
== 0, "Incorrect options %x\n", options
);
961 hwnd
= CreateWindow(RICHEDIT_CLASS10A
, NULL
,
962 WS_POPUP
|WS_VSCROLL
|WS_HSCROLL
,
963 0, 0, 200, 60, NULL
, NULL
, hmoduleRichEdit
, NULL
);
964 options
= SendMessage(hwnd
, EM_GETOPTIONS
, 0, 0);
965 ok(options
== ECO_AUTOVSCROLL
,
966 "Incorrect initial options %x\n", options
);
970 static void test_autoscroll(void)
975 /* The WS_VSCROLL and WS_HSCROLL styles implicitly set
976 * auto vertical/horizontal scrolling options. */
977 hwnd
= CreateWindowEx(0, RICHEDIT_CLASS10A
, NULL
,
978 WS_POPUP
|ES_MULTILINE
|WS_VSCROLL
|WS_HSCROLL
,
979 0, 0, 200, 60, NULL
, NULL
, hmoduleRichEdit
, NULL
);
980 ok(hwnd
!= NULL
, "class: %s, error: %d\n", RICHEDIT_CLASS10A
, (int) GetLastError());
981 ret
= SendMessage(hwnd
, EM_GETOPTIONS
, 0, 0);
982 ok(ret
& ECO_AUTOVSCROLL
, "ECO_AUTOVSCROLL isn't set.\n");
983 ok(!(ret
& ECO_AUTOHSCROLL
), "ECO_AUTOHSCROLL is set.\n");
984 ret
= GetWindowLong(hwnd
, GWL_STYLE
);
985 todo_wine
ok(ret
& ES_AUTOVSCROLL
, "ES_AUTOVSCROLL isn't set.\n");
986 ok(!(ret
& ES_AUTOHSCROLL
), "ES_AUTOHSCROLL is set.\n");
989 hwnd
= CreateWindowEx(0, RICHEDIT_CLASS10A
, NULL
,
990 WS_POPUP
|ES_MULTILINE
,
991 0, 0, 200, 60, NULL
, NULL
, hmoduleRichEdit
, NULL
);
992 ok(hwnd
!= NULL
, "class: %s, error: %d\n", RICHEDIT_CLASS10A
, (int) GetLastError());
993 ret
= SendMessage(hwnd
, EM_GETOPTIONS
, 0, 0);
994 ok(!(ret
& ECO_AUTOVSCROLL
), "ECO_AUTOVSCROLL is set.\n");
995 ok(!(ret
& ECO_AUTOHSCROLL
), "ECO_AUTOHSCROLL is set.\n");
996 ret
= GetWindowLong(hwnd
, GWL_STYLE
);
997 ok(!(ret
& ES_AUTOVSCROLL
), "ES_AUTOVSCROLL is set.\n");
998 ok(!(ret
& ES_AUTOHSCROLL
), "ES_AUTOHSCROLL is set.\n");
1002 START_TEST( editor
)
1007 /* Must explicitly LoadLibrary(). The test has no references to functions in
1008 * RICHED32.DLL, so the linker doesn't actually link to it. */
1009 hmoduleRichEdit
= LoadLibrary("RICHED32.DLL");
1010 ok(hmoduleRichEdit
!= NULL
, "error: %d\n", (int) GetLastError());
1013 test_EM_GETTEXTRANGE();
1014 test_EM_GETSELTEXT();
1015 test_WM_GETTEXTLENGTH();
1017 test_EM_STREAMOUT();
1019 test_EM_LINELENGTH();
1021 test_EM_POSFROMCHAR();
1023 test_EM_GETOPTIONS();
1026 /* Set the environment variable WINETEST_RICHED32 to keep windows
1027 * responsive and open for 30 seconds. This is useful for debugging.
1029 * The message pump uses PeekMessage() to empty the queue and then sleeps for
1030 * 50ms before retrying the queue. */
1031 end
= time(NULL
) + 30;
1032 if (getenv( "WINETEST_RICHED32" )) {
1033 while (time(NULL
) < end
) {
1034 if (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
)) {
1035 TranslateMessage(&msg
);
1036 DispatchMessage(&msg
);
1043 OleFlushClipboard();
1044 ok(FreeLibrary(hmoduleRichEdit
) != 0, "error: %d\n", (int) GetLastError());