From 078989d4639a399e226ce6047f84cbb3f3fba8d4 Mon Sep 17 00:00:00 2001 From: Massimo Del Fedele Date: Sat, 25 Apr 2009 21:22:24 +0200 Subject: [PATCH] richedit20: Test for fonttbl streamout. --- dlls/riched20/tests/editor.c | 56 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index 1b9e2446ea0..bbad7481bfc 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -3383,6 +3383,61 @@ static void test_EM_STREAMOUT(void) DestroyWindow(hwndRichEdit); } +static void test_EM_STREAMOUT_FONTTBL(void) +{ + HWND hwndRichEdit = new_richedit(NULL); + EDITSTREAM es; + char buf[1024] = {0}; + char * p; + char * fontTbl; + int brackCount; + + const char * TestItem = "TestSomeText"; + + /* fills in the richedit control with some text */ + SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) TestItem); + + /* streams out the text in rtf format */ + p = buf; + es.dwCookie = (DWORD_PTR)&p; + es.dwError = 0; + es.pfnCallback = test_WM_SETTEXT_esCallback; + memset(buf, 0, sizeof(buf)); + SendMessage(hwndRichEdit, EM_STREAMOUT, + (WPARAM)(SF_RTF), (LPARAM)&es); + + /* scans for \fonttbl, error if not found */ + fontTbl = strstr(buf, "\\fonttbl"); + ok(fontTbl != NULL, "missing \\fonttbl section\n"); + if(fontTbl) + { + /* scans for terminating closing bracket */ + brackCount = 1; + while(*fontTbl && brackCount) + { + if(*fontTbl == '{') + brackCount++; + else if(*fontTbl == '}') + brackCount--; + fontTbl++; + } + /* checks wether closing bracket is ok */ + ok(brackCount == 0, "missing closing bracket in \\fonttbl block\n"); + if(!brackCount) + { + /* char before closing fonttbl block should be a closed bracket */ + fontTbl -= 2; + ok(*fontTbl == '}', "spurious character '%02x' before \\fonttbl closing bracket\n", *fontTbl); + + /* char after fonttbl block should be a crlf */ + fontTbl += 2; + ok(*fontTbl == 0x0d && *(fontTbl+1) == 0x0a, "missing crlf after \\fonttbl block\n"); + } + } + DestroyWindow(hwndRichEdit); +} + + static void test_EM_SETTEXTEX(void) { HWND hwndRichEdit, parent; @@ -6631,6 +6686,7 @@ START_TEST( editor ) test_WM_PASTE(); test_EM_STREAMIN(); test_EM_STREAMOUT(); + test_EM_STREAMOUT_FONTTBL(); test_EM_StreamIn_Undo(); test_EM_FORMATRANGE(); test_unicode_conversions(); -- 2.11.4.GIT