Massimo Del Fedele : richedit20: Test for fonttbl streamout.

Alexandre Julliard julliard at winehq.org
Mon Apr 27 08:04:07 CDT 2009


Module: wine
Branch: master
Commit: 078989d4639a399e226ce6047f84cbb3f3fba8d4
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=078989d4639a399e226ce6047f84cbb3f3fba8d4

Author: Massimo Del Fedele <max at veneto.com>
Date:   Sat Apr 25 21:22:24 2009 +0200

richedit20: Test for fonttbl streamout.

---

 dlls/riched20/tests/editor.c |   56 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 1b9e244..bbad748 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();




More information about the wine-cvs mailing list