richedit: EM_STREAMIN tests for richedit 2.0.
This commit is contained in:
parent
54bc660d95
commit
2353e1d280
|
@ -2302,6 +2302,97 @@ static DWORD CALLBACK EditStreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff,
|
||||||
return 1; /* indicates callback failed */
|
return 1; /* indicates callback failed */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DWORD CALLBACK test_EM_STREAMIN_esCallback(DWORD_PTR dwCookie,
|
||||||
|
LPBYTE pbBuff,
|
||||||
|
LONG cb,
|
||||||
|
LONG *pcb)
|
||||||
|
{
|
||||||
|
const char** str = (const char**)dwCookie;
|
||||||
|
int size = strlen(*str);
|
||||||
|
*pcb = cb;
|
||||||
|
if (*pcb > size) {
|
||||||
|
*pcb = size;
|
||||||
|
}
|
||||||
|
if (*pcb > 0) {
|
||||||
|
memcpy(pbBuff, *str, *pcb);
|
||||||
|
*str += *pcb;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void test_EM_STREAMIN(void)
|
||||||
|
{
|
||||||
|
HWND hwndRichEdit = new_richedit(NULL);
|
||||||
|
LRESULT result;
|
||||||
|
EDITSTREAM es;
|
||||||
|
char buffer[1024] = {0};
|
||||||
|
|
||||||
|
const char * streamText1 =
|
||||||
|
"{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang12298{\\fonttbl{\\f0\\fswiss\\fprq2\\fcharset0 System;}}\r\n" \
|
||||||
|
"\\viewkind4\\uc1\\pard\\f0\\fs17 TestSomeText\\par\r\n" \
|
||||||
|
"}\r\n";
|
||||||
|
|
||||||
|
/* In richedit 2.0 mode, this should NOT be accepted, unlike 1.0 */
|
||||||
|
const char * streamText2 =
|
||||||
|
"{{\\colortbl;\\red0\\green255\\blue102;\\red255\\green255\\blue255;" \
|
||||||
|
"\\red170\\green255\\blue255;\\red255\\green238\\blue0;\\red51\\green255" \
|
||||||
|
"\\blue221;\\red238\\green238\\blue238;}\\tx0 \\tx424 \\tx848 \\tx1272 " \
|
||||||
|
"\\tx1696 \\tx2120 \\tx2544 \\tx2968 \\tx3392 \\tx3816 \\tx4240 \\tx4664 " \
|
||||||
|
"\\tx5088 \\tx5512 \\tx5936 \\tx6360 \\tx6784 \\tx7208 \\tx7632 \\tx8056 " \
|
||||||
|
"\\tx8480 \\tx8904 \\tx9328 \\tx9752 \\tx10176 \\tx10600 \\tx11024 " \
|
||||||
|
"\\tx11448 \\tx11872 \\tx12296 \\tx12720 \\tx13144 \\cf2 RichEdit1\\line }";
|
||||||
|
|
||||||
|
const char * streamText3 = "RichEdit1";
|
||||||
|
|
||||||
|
es.dwCookie = (DWORD_PTR)&streamText1;
|
||||||
|
es.dwError = 0;
|
||||||
|
es.pfnCallback = test_EM_STREAMIN_esCallback;
|
||||||
|
SendMessage(hwndRichEdit, EM_STREAMIN,
|
||||||
|
(WPARAM)(SF_RTF), (LPARAM)&es);
|
||||||
|
|
||||||
|
result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
|
||||||
|
todo_wine {
|
||||||
|
ok (result == 12,
|
||||||
|
"EM_STREAMIN: Test 1 returned %ld, expected 12\n", result);
|
||||||
|
}
|
||||||
|
result = strcmp (buffer,"TestSomeText");
|
||||||
|
todo_wine {
|
||||||
|
ok (result == 0,
|
||||||
|
"EM_STREAMIN: Test 1 set wrong text: Result: %s\n",buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
es.dwCookie = (DWORD_PTR)&streamText2;
|
||||||
|
SendMessage(hwndRichEdit, EM_STREAMIN,
|
||||||
|
(WPARAM)(SF_RTF), (LPARAM)&es);
|
||||||
|
|
||||||
|
result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
|
||||||
|
todo_wine {
|
||||||
|
ok (result == 0,
|
||||||
|
"EM_STREAMIN: Test 2 returned %ld, expected 0\n", result);
|
||||||
|
}
|
||||||
|
todo_wine {
|
||||||
|
ok (strlen(buffer) == 0,
|
||||||
|
"EM_STREAMIN: Test 2 set wrong text: Result: %s\n",buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
es.dwCookie = (DWORD_PTR)&streamText3;
|
||||||
|
SendMessage(hwndRichEdit, EM_STREAMIN,
|
||||||
|
(WPARAM)(SF_RTF), (LPARAM)&es);
|
||||||
|
|
||||||
|
result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
|
||||||
|
todo_wine {
|
||||||
|
ok (result == 0,
|
||||||
|
"EM_STREAMIN: Test 3 returned %ld, expected 9\n", result);
|
||||||
|
}
|
||||||
|
todo_wine {
|
||||||
|
ok (strlen(buffer) == 0,
|
||||||
|
"EM_STREAMIN: Test 3 set wrong text: Result: %s\n",buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
DestroyWindow(hwndRichEdit);
|
||||||
|
}
|
||||||
|
|
||||||
static void test_EM_StreamIn_Undo(void)
|
static void test_EM_StreamIn_Undo(void)
|
||||||
{
|
{
|
||||||
/* The purpose of this test is to determine when a EM_StreamIn should be
|
/* The purpose of this test is to determine when a EM_StreamIn should be
|
||||||
|
@ -2820,6 +2911,7 @@ START_TEST( editor )
|
||||||
test_EM_GETMODIFY();
|
test_EM_GETMODIFY();
|
||||||
test_EM_EXSETSEL();
|
test_EM_EXSETSEL();
|
||||||
test_WM_PASTE();
|
test_WM_PASTE();
|
||||||
|
test_EM_STREAMIN();
|
||||||
test_EM_StreamIn_Undo();
|
test_EM_StreamIn_Undo();
|
||||||
test_EM_FORMATRANGE();
|
test_EM_FORMATRANGE();
|
||||||
test_unicode_conversions();
|
test_unicode_conversions();
|
||||||
|
|
Loading…
Reference in New Issue