richedit: EM_STREAMIN tests for richedit 1.0 emulation.

This commit is contained in:
Alex Villacís Lasso 2008-04-21 17:29:29 -05:00 committed by Alexandre Julliard
parent 0739567dac
commit 54bc660d95
1 changed files with 95 additions and 0 deletions

View File

@ -153,6 +153,100 @@ static void test_WM_GETTEXTLENGTH(void)
DestroyWindow(hwndRichEdit);
}
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";
/* This should be accepted in richedit 1.0 emulation. See bug #8326 */
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 == 9,
"EM_STREAMIN: Test 2 returned %ld, expected 9\n", result);
}
result = strcmp (buffer,"RichEdit1");
todo_wine {
ok (result == 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);
}
START_TEST( editor )
{
MSG msg;
@ -165,6 +259,7 @@ START_TEST( editor )
test_WM_SETTEXT();
test_WM_GETTEXTLENGTH();
test_EM_STREAMIN();
/* Set the environment variable WINETEST_RICHED32 to keep windows
* responsive and open for 30 seconds. This is useful for debugging.