Just checking if gmail has a 'wrapping' problem or if this will actually go through.

riched20/tests: Beginnings of EM_SETMARGINS test. This patch is released into the Public Domain under the requirements of the LGPL version 2.1 or later. Released by James McKenzie [email protected]
---
dlls/riched20/tests/editor.c | 215 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 215 insertions(+), 0 deletions(-)

diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 7a4e032..31f3bdc 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -7034,6 +7034,220 @@ static void test_dialogmode(void)
     DestroyWindow(hwParent);
 }
+static INT CALLBACK is_truetype_font_installed_proc(const LOGFONT *elf, const TEXTMETRIC *ntm, DWORD type, LPARAM lParam)
+{
+    if (type != TRUETYPE_FONTTYPE) return 1;
+
+    return 0;
+}
+
+static BOOL is_truetype_font_installed(const char *name)
+{
+    HDC hdc = GetDC(0);
+    BOOL ret = FALSE;
+
+    if (!EnumFontFamiliesA(hdc, name, is_truetype_font_installed_proc, 0))
+        ret = TRUE;
+
+    ReleaseDC(0, hdc);
+    return ret;
+}
+
+static INT CALLBACK is_font_installed_proc(const LOGFONT *elf, const TEXTMETRIC *ntm, DWORD type, LPARAM lParam)
+{
+    return 0;
+}
+
+static BOOL is_font_installed(const char *name)
+{
+    HDC hdc = GetDC(0);
+    BOOL ret = FALSE;
+
+    if(!EnumFontFamiliesA(hdc, name, is_font_installed_proc, 0))
+        ret = TRUE;
+
+    ReleaseDC(0, hdc);
+    return ret;
+}
+
+static void test_em_setmargins(void)
+{
+  HWND hwndRichEdit;
+  RECT old_rect, new_rect;
+
+  HDC hDC;
+  LOGFONTA lfA;
+  UINT ret;
+  int ry, i, j, k;
+
+  HFONT testFont1A, hDC_font;
+
+  /* Add various window sizes for USEFONTINFO tests */
+  static const struct rect_parameters
+  {
+    int start_left, start_top, end_right, end_bottom;
+  } rect_param[] =
+  {
+    { 0, 0, 400, 80 },
+  };
+
+  /* data for ANSI font tests */
+  static const struct font_margins_data
+  {
+    const char face_name[LF_FACESIZE];
+    int weight, height, ascent, descent, int_leading, ext_leading;
+    int ave_char_width, max_char_width, dpi;
+  } fmd[] =
+  {
+    { "Courier", FW_NORMAL, 13, 11, 2, 0, 0, 8, 8, 96 },
+    { "System", FW_BOLD, 16, 13, 3, 3, 0, 7, 14, 96 },
+    { "Arial", FW_NORMAL, 16, 13, 3, 3, 0, 6, 35, 96, },
+  };
+
+  /* Test data for margins testing */
+  static const struct margin_test_data
+  {
+    int left_margin, right_margin;
+    DWORD margin_type;
+  } mmt [] =
+  {
+    { 0, 0, EC_LEFTMARGIN }, /*Clear all margin settings */
+    /*Left Margin tests*/
+    { 10, 0, EC_LEFTMARGIN }, /*Set Left Margin to 10 */
+ { EC_USEFONTINFO, 0, EC_LEFTMARGIN }, /*Test EC_USEFONTINFO as lparam with EC_LEFTMARGIN */
+    { 0, 0, EC_LEFTMARGIN },  /*Clear margins for Right Margin tests */
+    /*EC_USEFONTINFO as lpararm tests */
+ { 10, 10, EC_USEFONTINFO }, /*Set margins to 10 with EC_USEFONTINFO, should return zero */ + { 0, EC_USEFONTINFO, EC_USEFONTINFO }, /*Set Right Margin to EC_USEFONTINFO under EC_USEFONTINFO, should + return zero except with TrueType Fonts, this should be the lagging spacing value for large fonts and large
+      edit windows*/
+ { EC_USEFONTINFO, 0, EC_USEFONTINFO }, /*Set Left Margin to EC_USEFONTINFO under EC_USEFONTINFO, should return + zero except with TrueType Fonts, this should be the leading spacing value for large fonts and large edit
+      windows*/
+ { EC_USEFONTINFO, EC_USEFONTINFO, EC_USEFONTINFO }, /*Set both margins to EC_USEFONTINFO under EC_USEFONTINFO,
+      should have same results for both left and right tests above */
+    { 0, 0, EC_USEFONTINFO }, /*Clear Margins, if set */
+  };
+
+  /* Run tests for number of rectangles */
+  for ( k=0; k< (sizeof(rect_param)/sizeof(rect_param[0])); k++)
+  {
+ hwndRichEdit = CreateWindow(RICHEDIT_CLASS, NULL, ES_MULTILINE|WS_POPUP|WS_HSCROLL|WS_VSCROLL|WS_VISIBLE, + rect_param[k].start_left, rect_param[k].start_top, rect_param[k].end_right, + rect_param[k].end_bottom, NULL, NULL, hmoduleRichEdit, NULL); + ok(hwndRichEdit != NULL, "Error creating Richedit Window in EM_SETMARGINS test. error received: %d\n",
+                             (int) GetLastError());
+    if (!hwndRichEdit)
+    {
+      return;
+    }
+
+    hDC = GetDC(hwndRichEdit);
+    ok (hDC != NULL, "Creation of hdc failed.\n");
+    if (!hDC)
+    {
+      DestroyWindow(hwndRichEdit);
+      return;
+    }
+
+    ry = GetDeviceCaps(hDC, LOGPIXELSY);
+
+    ZeroMemory(&lfA, sizeof(lfA));
+    ZeroMemory(&testFont1A, sizeof(HFONT));
+ /*Initialize rect variable to be the size of the entire richedit window */
+    old_rect.left = rect_param[k].start_left;
+    old_rect.right = rect_param[k].end_right;
+    old_rect.top = rect_param[k].start_top;
+    old_rect.bottom = rect_param[k].end_bottom;
+    SendMessageA(hwndRichEdit, EM_SETRECT, 0, (LPARAM)&old_rect);
+    SendMessageA(hwndRichEdit, EM_GETRECT, 0, (LPARAM)&old_rect);
+ ok (rect_param[k].start_left == old_rect.left , "Richedit control window not created correctly. Canceling " + "test for window size of %d by %d\n", rect_param[k].end_right, rect_param[k].end_bottom);
+    if (rect_param[k].start_left != old_rect.left) continue;
+
+    /* Run tests for number of ANSI fonts */
+    for (i = 0; i < sizeof(fmd)/sizeof(fmd[0]); i++)
+    {
+      strcpy(lfA.lfFaceName, fmd[i].face_name);
+      lfA.lfHeight = fmd[i].height;
+      lfA.lfCharSet = DEFAULT_CHARSET;
+      lfA.lfWeight = fmd[i].weight;
+      ret = is_font_installed(lfA.lfFaceName);
+      /* If font cannot cannot be found, skip rest of tests */
+ ok (ret != 0, "Font not found, test results are not predictable. Aborting test for font %s\n",
+         fmd[i].face_name);
+      if (ret) continue;
+      ret = is_truetype_font_installed(lfA.lfFaceName);
+      if (lfA.lfFaceName == "Arial")
+      {
+ ok (ret == 0, "Truetype font emulated, test results will not be consistent with Windows!\n");
+        if (!ret) continue;
+      }
+
+      testFont1A = CreateFontIndirectA (&lfA);
+      hDC_font = SelectObject(hDC, testFont1A);
+      /* looping through the all of the tests */
+      for (j=0; j < sizeof (mmt)/sizeof (mmt[1]); j++)
+      {
+ SendMessageA(hwndRichEdit, EM_SETMARGINS, mmt[j].margin_type, MAKELONG (mmt[j].left_margin,
+                     mmt[j].right_margin));
+        ret=SendMessageA(hwndRichEdit, EM_GETRECT, 0, (LPARAM)&new_rect);
+        ok (ret == 0, "An error occurred getting new margins\n");
+        switch (mmt[j].margin_type)
+        {
+          case EC_USEFONTINFO :
+ /* Per several web sources, using the EC_USEFONTINFO with a TrueType font should result in the + following: The Left Margin should be set to the 'C' value, that is the value used to set white + space after a character and the next printed character. This is also called leading spacing. + The Right Margin should be set to the 'A' value, that is the value use to set white space to the + current position before drawing the next character. This is also called lagging spacing. + During testing could not find a case where this was true for any version of riched20.dll */
+            {
+ ok(new_rect.right == old_rect.right, "The right border moved in EC_USEFONTINFO Left/Right " + "margin change test to %d for font %s(%d)\n", old_rect.right - new_rect.right,
+                 fmd[i].face_name, fmd[i].height);
+ ok(new_rect.left == old_rect.left, "The left border was moved in EC_USEFONTINFO Left/Right Margin " + "change test to %d for font %s(%d).\n", old_rect.left - new_rect.left, fmd[i].face_name,
+                 fmd[i].height);
+            }
+            break;
+          case EC_LEFTMARGIN :
+            if (mmt[j].left_margin == 0 )
+            {
+ ok(new_rect.left == old_rect.left, "The left border moved %d in the Left Margin " + "Zero test for font %s(%d).\n", new_rect.left - old_rect.left, fmd[i].face_name, fmd[i].height);
+            }
+            else
+            {
+              todo_wine {
+ ok(new_rect.left == old_rect.left + mmt[j].left_margin, "The left border moved %d and should be " + "%d in the Left margin change test for font %s(%d).\n", new_rect.left - old_rect.left,
+                   mmt[j].left_margin, fmd[i].face_name, fmd[i].height);
+              }
+            }
+ ok(new_rect.right == old_rect.right, "The right border was moved %d in Left Margin change test for " + "font %s(%d).\n", new_rect.right - old_rect.right, fmd[i].face_name, fmd[i].height);
+            break;
+          case EC_LEFTMARGIN | EC_RIGHTMARGIN :
+          case EC_RIGHTMARGIN :
+ default: /* fall through if there is a data error or new margin type test */ + ok (0 == 1, "Check %s %d %d 0x%x\n", fmd[i].face_name, fmd[i].height, fmd[i].dpi, mmt[j].margin_type);
+        }
+ /* test if top or bottom margin moved. Test should not disturb them */ + ok(new_rect.top == old_rect.top, "The top border moved %d in the test.\n",
+           new_rect.top - old_rect.top);
+ ok(new_rect.bottom == old_rect.bottom, "The bottom border moved %d in the test\n",
+           new_rect.bottom - old_rect.bottom);
+      }
+      SelectObject(hDC, hDC_font);
+      DeleteObject(testFont1A);
+    }
+    DeleteObject(testFont1A);
+    ReleaseDC (hwndRichEdit, hDC);
+    DestroyWindow (hwndRichEdit);
+  }
+}
+
 START_TEST( editor )
 {
   BOOL ret;
@@ -7090,6 +7304,7 @@ START_TEST( editor )
   test_WM_GETDLGCODE();
   test_zoom();
   test_dialogmode();
+  test_em_setmargins();
    /* Set the environment variable WINETEST_RICHED20 to keep windows
    * responsive and open for 30 seconds. This is useful for debugging.
--
1.7.4



Reply via email to