Module: wine Branch: master Commit: 2353e1d2808b186b7469e4077d55002d4b4efdf3 URL: http://source.winehq.org/git/wine.git/?a=commit;h=2353e1d2808b186b7469e4077d...
Author: Alex Villacís Lasso a_villacis@palosanto.com Date: Mon Apr 21 17:31:28 2008 -0500
richedit: EM_STREAMIN tests for richedit 2.0.
---
dlls/riched20/tests/editor.c | 92 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 92 insertions(+), 0 deletions(-)
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index dd7640c..69d9ac3 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -2302,6 +2302,97 @@ static DWORD CALLBACK EditStreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, 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) { /* 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_EXSETSEL(); test_WM_PASTE(); + test_EM_STREAMIN(); test_EM_StreamIn_Undo(); test_EM_FORMATRANGE(); test_unicode_conversions();