Commit e7fd0b46 authored by Dylan Smith's avatar Dylan Smith Committed by Alexandre Julliard

richedit: Add more tests for WM_SETTEXT RTF support.

parent 88c2b90a
...@@ -3282,10 +3282,15 @@ static void test_WM_SETTEXT(void) ...@@ -3282,10 +3282,15 @@ static void test_WM_SETTEXT(void)
const char * TestItem7 = "TestSomeText\r\n\r\r\n\rTestSomeText"; const char * TestItem7 = "TestSomeText\r\n\r\r\n\rTestSomeText";
const char * TestItem7_after = "TestSomeText\r\n \r\nTestSomeText"; const char * TestItem7_after = "TestSomeText\r\n \r\nTestSomeText";
const char rtftextA[] = "{\\rtf sometext}";
const char urtftextA[] = "{\\urtf sometext}";
const WCHAR rtftextW[] = {'{','\\','r','t','f',' ','s','o','m','e','t','e','x','t','}',0};
const WCHAR urtftextW[] = {'{','\\','u','r','t','f',' ','s','o','m','e','t','e','x','t','}',0};
const WCHAR sometextW[] = {'s','o','m','e','t','e','x','t',0};
char buf[1024] = {0}; char buf[1024] = {0};
WCHAR bufW[1024] = {0};
LRESULT result; LRESULT result;
EDITSTREAM es;
char * p;
/* This test attempts to show that WM_SETTEXT on a riched20 control causes /* This test attempts to show that WM_SETTEXT on a riched20 control causes
any solitary \r to be converted to \r\n on return. Properly paired any solitary \r to be converted to \r\n on return. Properly paired
...@@ -3302,7 +3307,7 @@ static void test_WM_SETTEXT(void) ...@@ -3302,7 +3307,7 @@ static void test_WM_SETTEXT(void)
result, lstrlen(buf)); \ result, lstrlen(buf)); \
result = strcmp(b, buf); \ result = strcmp(b, buf); \
ok(result == 0, \ ok(result == 0, \
"WM_SETTEXT round trip: strcmp = %ld\n", result); "WM_SETTEXT round trip: strcmp = %ld, text=\"%s\"\n", result, buf);
TEST_SETTEXT(TestItem1, TestItem1) TEST_SETTEXT(TestItem1, TestItem1)
TEST_SETTEXT(TestItem2, TestItem2_after) TEST_SETTEXT(TestItem2, TestItem2_after)
...@@ -3313,20 +3318,39 @@ static void test_WM_SETTEXT(void) ...@@ -3313,20 +3318,39 @@ static void test_WM_SETTEXT(void)
TEST_SETTEXT(TestItem6, TestItem6_after) TEST_SETTEXT(TestItem6, TestItem6_after)
TEST_SETTEXT(TestItem7, TestItem7_after) TEST_SETTEXT(TestItem7, TestItem7_after)
/* The following test demonstrates that WM_SETTEXT supports RTF strings */ /* The following tests demonstrate that WM_SETTEXT supports RTF strings */
SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) TestItem1); TEST_SETTEXT(rtftextA, "sometext") /* interpreted as ascii rtf */
p = buf; TEST_SETTEXT(urtftextA, "sometext") /* interpreted as ascii rtf */
es.dwCookie = (DWORD_PTR)&p; TEST_SETTEXT(rtftextW, "{") /* interpreted as ascii text */
es.dwError = 0; TEST_SETTEXT(urtftextW, "{") /* interpreted as ascii text */
es.pfnCallback = test_WM_SETTEXT_esCallback; DestroyWindow(hwndRichEdit);
memset(buf, 0, sizeof(buf));
SendMessage(hwndRichEdit, EM_STREAMOUT,
(WPARAM)(SF_RTF), (LPARAM)&es);
trace("EM_STREAMOUT produced:\n%s\n", buf);
TEST_SETTEXT(buf, TestItem1)
#undef TEST_SETTEXT #undef TEST_SETTEXT
#define TEST_SETTEXTW(a, b) \
result = SendMessageW(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) a); \
ok (result == 1, "WM_SETTEXT returned %ld instead of 1\n", result); \
result = SendMessageW(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) bufW); \
ok (result == lstrlenW(bufW), \
"WM_GETTEXT returned %ld instead of expected %u\n", \
result, lstrlenW(bufW)); \
result = lstrcmpW(b, bufW); \
ok(result == 0, "WM_SETTEXT round trip: strcmp = %ld\n", result);
if (is_win9x)
{
skip("Cannot perform unicode tests\n");
return;
}
hwndRichEdit = CreateWindowW(RICHEDIT_CLASS20W, NULL,
ES_MULTILINE|WS_POPUP|WS_HSCROLL|WS_VSCROLL|WS_VISIBLE,
0, 0, 200, 60, NULL, NULL, hmoduleRichEdit, NULL);
ok(hwndRichEdit != NULL, "class: RichEdit20W, error: %d\n", (int) GetLastError());
TEST_SETTEXTW(rtftextA, sometextW) /* interpreted as ascii rtf */
TEST_SETTEXTW(urtftextA, sometextW) /* interpreted as ascii rtf */
TEST_SETTEXTW(rtftextW, rtftextW) /* interpreted as ascii text */
TEST_SETTEXTW(urtftextW, urtftextW) /* interpreted as ascii text */
DestroyWindow(hwndRichEdit); DestroyWindow(hwndRichEdit);
#undef TEST_SETTEXTW
} }
static void test_EM_STREAMOUT(void) static void test_EM_STREAMOUT(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment