[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    RFC:  Final Proposed Riched20 EM_SETMARGINS Test
From:       James McKenzie <jjmckenzie51 () earthlink ! net>
Date:       2011-01-31 2:14:26
Message-ID: 4D461B02.1010507 () earthlink ! net
[Download RAW message or body]

All:

Constructive Criticism requested so that this can be made better.

I've decided to use two loops in the test:  One for fonts.  Second for 
actual tests.  This allows for quick and easy expansion.  The check code 
for font changes might be removed, but does no harm by remaining.  This 
patch is based on git as of Friday, January 28.

I could find no font that changed the Margin from zero for the 
EC_USEFONTINFO lparam test case.  If someone knows of a font that will 
do so, please advise as well so I can include it.

Thank you.

James McKenzie

["richedit.EM_SETMARGINS.test.patch" (application/mbox)]

--- a/dlls/riched20/tests/editor.c	2010-06-20 16:47:44.000000000 -0700
+++ b/dlls/riched20/tests/editor.c	2010-06-20 14:51:01.000000000 -0700
@@ -7093,6 +7093,665 @@
     DestroyWindow(hwParent);
 }
 
+static INT CALLBACK find_font_proc(const LOGFONT *elf, const TEXTMETRIC *ntm, DWORD \
type, LPARAM lParam) +{
+    return 0;
+}
+
+static inline int is_win9xA()
+{
+    static WCHAR arialW[]={'A','r','i','a','l',0};
+    SetLastError(0xdeadbeef);
+    lstrcmpW(arialW, arialW);
+    return (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED);
+}
+
+static void test_em_setmargins(void)
+{
+    HWND hwndRichEdit;
+    RECT old_rect, new_rect;
+
+    HDC hDC;
+    LOGFONTW lfW;
+    LOGFONTA lfA;
+    CHARFORMAT2A CharFont1ANSI;
+    CHARFORMAT2W CharFont1Unicode;
+
+    TEXTMETRICA tma;
+    TEXTMETRICW tmw;
+
+    UINT ret;
+    int ry, i, j;
+
+    HFONT testFont1W, testFont1A, hDC_font;
+    BOOL bRet;
+
+    hwndRichEdit = new_richedit(NULL);
+
+    static const WCHAR smallFonts[] = {'S','m','a','l','l',' \
','F','o','n','t','s',0}; +    static const WCHAR tahoma[] = \
{'T','a','h','o','m','a',0}; +    static const WCHAR fixedSys[] = \
{'F','i','x','e','d','s','y','s',0}; +    static const WCHAR system[] = \
{'S','y','s','t','e','m',0}; +
+    hDC = GetDC(hwndRichEdit);
+    ok (hDC != NULL, "Creation of hdc failed \n");
+    if (!hDC)
+    {
+        DestroyWindow(hwndRichEdit);
+        return;
+    }
+
+    /* Record DPI for tests */
+    ry = GetDeviceCaps(hDC, LOGPIXELSY);
+
+    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[] =
+    {
+        { "MS Sans Serif", FW_NORMAL, 13, 11, 2, 2, 0, 5, 11, 96 },
+
+        { "MS Sans Serif", FW_NORMAL, 16, 13, 3, 3, 0, 7, 14, 120 },
+
+        { "MS Serif", FW_NORMAL, 10, 8, 2, 2, 0, 4, 8, 96 },
+        { "MS Serif", FW_NORMAL, 11, 9, 2, 2, 0, 5, 9, 96 },
+
+        { "MS Serif", FW_NORMAL, 16, 13, 3, 3, 0, 6, 14, 120 },
+        { "MS Serif", FW_NORMAL, 20, 16, 4, 4, 0, 8, 18, 120 },
+
+        { "Courier", FW_NORMAL, 13, 11, 2, 0, 0, 8, 8, 96 },
+
+        { "Courier", FW_NORMAL, 16, 13, 3, 0, 0, 9, 9, 120 },
+        { "Courier", FW_NORMAL, 20, 16, 4, 0, 0, 12, 12, 120 },
+
+        { "System", FW_BOLD, 16, 13, 3, 3, 0, 7, 14, 96 },
+
+        { "System", FW_BOLD, 20, 16, 4, 4, 0, 9, 17, 120 },
+
+        { "Small Fonts", FW_NORMAL, 10, 8, 2, 2, 0, 4, 8, 96 },
+
+        { "Small Fonts", FW_NORMAL, 13, 11, 2, 2, 0, 6, 12, 120 },
+
+        { "Fixedsys", FW_NORMAL, 15, 12, 3, 3, 0, 8, 8, 96 },
+
+        /* The 120dpi version still has its dpi marked as 96 */
+        { "Fixedsys", FW_NORMAL, 20, 16, 4, 2, 0, 10, 10, 96 },
+
+        { "Tahoma", FW_NORMAL, 12, 10, 2, 2, 0, 4, 19, 96 },
+        { "Tahoma", FW_NORMAL, 14, 12, 2, 2, 0, 5, 23, 96 },
+
+        { "Arial", FW_NORMAL, 16, 13, 3, 3, 0, 6, 35, 96, },
+
+        { "Arial", FW_NORMAL, 28, 23, 5, 3, 1, 11, 67, 96 },
+
+    };
+
+    static const struct font_margins_data_unicode
+    {
+        const WCHAR face_name[LF_FACESIZE];
+        int weight, height, ascent, descent, int_leading, ext_leading;
+        int ave_char_width, max_char_width, dpi;
+    } fmdW[] =
+    {
+        { {'M','S',' ','S','a','n','s',' ','S','e','r','i','f',0}, FW_NORMAL, 13, \
11, 2, 2, 0, 5, 11, 96 }, +
+        { {'M','S',' ','S','a','n','s',' ','S','e','r','i','f',0}, FW_NORMAL, 16, \
13, 3, 3, 0, 7, 14, 120 }, +
+        { {'M','S',' ','S','e','r','i','f',0}, FW_NORMAL, 10, 8, 2, 2, 0, 4, 8, 96 \
}, +        { {'M','S',' ','S','e','r','i','f',0}, FW_NORMAL, 11, 9, 2, 2, 0, 5, 9, \
96 }, +
+        { {'M','S',' ','S','e','r','i','f',0}, FW_NORMAL, 16, 13, 3, 3, 0, 6, 14, \
120 }, +        { {'M','S',' ','S','e','r','i','f',0}, FW_NORMAL, 20, 16, 4, 4, 0, 8, \
18, 120 }, +
+        { {'C','o','u','r','i','e','r',0}, FW_NORMAL, 13, 11, 2, 0, 0, 8, 8, 96 },
+
+        { {'C','o','u','r','i','e','r',0}, FW_NORMAL, 16, 13, 3, 0, 0, 9, 9, 120 },
+        { {'C','o','u','r','i','e','r',0}, FW_NORMAL, 20, 16, 4, 0, 0, 12, 12, 120 \
}, +
+        { {'S','y','s','t','e','m',0}, FW_BOLD, 16, 13, 3, 3, 0, 7, 14, 96 },
+
+        { {'S','y','s','t','e','m',0}, FW_BOLD, 20, 16, 4, 4, 0, 9, 17, 120 },
+
+        { {'S','m','a','l','l',' ','F','o','n','t','s',0}, FW_NORMAL, 10, 8, 2, 2, \
0, 4, 8, 96 }, +
+        { {'S','m','a','l','l',' ','F','o','n','t','s',0}, FW_NORMAL, 13, 11, 2, 2, \
0, 6, 12, 120 }, +
+        { {'F','i','x','e','d','s','y','s',0}, FW_NORMAL, 15, 12, 3, 3, 0, 8, 8, 96 \
}, +
+        /* The 120dpi version still has its dpi marked as 96 */
+        { {'F','i','x','e','d','s','y','s',0}, FW_NORMAL, 20, 16, 4, 2, 0, 10, 10, \
96 }, +
+        { {'T','a','h','o','m','a',0}, FW_NORMAL, 12, 10, 2, 2, 0, 4, 19, 96 },
+        { {'T','a','h','o','m','a',0}, FW_NORMAL, 14, 12, 2, 2, 0, 5, 23, 96 },
+
+        { {'A','r','i','a','l',0}, FW_NORMAL, 16, 13, 3, 3, 0, 6, 35, 96, },
+
+        { {'A','r','i','a','l',0}, FW_NORMAL, 28, 23, 5, 3, 1, 11, 67, 96 },
+
+    };
+
+    static const struct margin_test_data
+    {
+        int left_margin, right_margin;
+        DWORD margin_type;
+    } mmt [] =
+    {
+        { 0, 0 ,0 }, /* Clear all settings */
+        { 10, 0, 0 }, /* Attempt to set Left Margin */
+        { 0, 10, 0 }, /* Attempt to set Right Margin */
+        { 10, 10, 0 }, /* Attempt to set both margins */
+        { EC_USEFONTINFO, 0, 0 }, /* Attempt to use Left Margin EC_USEFONTINFO */
+        { 0, 0, 0 }, /*Clear all margin settings */
+        { 0, EC_USEFONTINFO, 0 }, /* Attempt to use Right Margin EC_USEFONTINFO */
+        { 0, 0, 0 }, /*Clear all margin settings */
+        { EC_USEFONTINFO, EC_USEFONTINFO, 0 },  /*Test EC_USEFONTINFO for lparm for \
both margins */ +        { 0, 0, 0 }, /*Clear all margin settings */
+
+        { 10, 0, EC_LEFTMARGIN }, /*Set Left Margin to 10 */
+        { 0, 10,  EC_LEFTMARGIN }, /*Set Left Margin to 0, bogus Right Margin Value \
*/ +        { EC_USEFONTINFO, 0, EC_LEFTMARGIN }, /*Test EC_USEFONTINFO as lparam \
with EC_LEFTMARGIN */ +        { 0, 0, EC_LEFTMARGIN },  /*Clear margins for Right \
Margin tests */ +
+        { 0, 10, EC_RIGHTMARGIN }, /*Set Right Margin to 10 */
+        { 10, 0, EC_RIGHTMARGIN }, /*Set Right Margin to 0.  Left Margin value is \
bogus */ +        { 10, 10, EC_RIGHTMARGIN }, /*Set Right Margin to 10.  Left Margin \
value is bogus */ +        { 0, EC_USEFONTINFO, EC_RIGHTMARGIN }, /*Test \
EC_USEFONTINFO as lparam with EC_RIGHTMARGIN */ +        { 0, 0, EC_RIGHTMARGIN }, \
/*Clear all Margins */ +
+        { 0, 10, EC_LEFTMARGIN | EC_RIGHTMARGIN }, /*Set Right Margin to 10, Left to \
zero */ +        { 10, 0, EC_LEFTMARGIN | EC_RIGHTMARGIN }, /*Set Left Margin to 10, \
Right to zero */ +        { 10, 10, EC_LEFTMARGIN | EC_RIGHTMARGIN }, /*Set both \
margins to 10 */ +        { 20, 20, EC_LEFTMARGIN | EC_RIGHTMARGIN }, /*Set both \
margins to +10 margin value to show that margins will change */ +        { \
EC_USEFONTINFO, EC_USEFONTINFO, EC_LEFTMARGIN | EC_RIGHTMARGIN }, /*Set both margins \
to EC_USEFONTINFO */ +        { 0, 0, EC_LEFTMARGIN | EC_RIGHTMARGIN }, /*Clear \
Margins */ +
+        { 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 */ +        { EC_USEFONTINFO, \
0, EC_USEFONTINFO }, /*Set Left Margin to EC_USEFONTINFO under EC_USEFONTINFO, should \
return zero */ +        { EC_USEFONTINFO, EC_USEFONTINFO, EC_USEFONTINFO }, /*Set \
both margins to EC_USEFONTINFO under EC_USEFONTINFO, should +                         \
return zero */ +        { 0, 0, EC_USEFONTINFO }, /*Clear Margins, if set */
+    };
+
+    ZeroMemory(&CharFont1ANSI, sizeof(CHARFORMAT2A));
+    CharFont1ANSI.cbSize = sizeof(CharFont1ANSI);
+    ZeroMemory(&CharFont1Unicode, sizeof(CHARFORMAT2W));
+    CharFont1Unicode.cbSize = sizeof(CharFont1Unicode);
+    ZeroMemory(&lfA, sizeof(lfA));
+    ZeroMemory(&testFont1A, sizeof(HFONT));
+    /*Initialize rect variable to be the size of the entire richedit window */
+    SendMessageA(hwndRichEdit, EM_SETRECT, 0, (LPARAM)&old_rect);
+    SendMessageA(hwndRichEdit, EM_GETRECT, 0, (LPARAM)&old_rect);
+
+    for (i = 0; i < sizeof(fmd)/sizeof(fmd[0]); i++)
+    {
+        strcpy(lfA.lfFaceName, fmd[i].face_name);
+        lfA.lfHeight = fmd[i].height;
+        lfA.lfCharSet = ANSI_CHARSET;
+        lfA.lfWeight = fmd[i].weight;
+        ret = EnumFontFamiliesEx(hDC, &lfA, find_font_proc, (LPARAM)&lfA, 0);
+        if (ret) continue;
+
+        testFont1A = CreateFontIndirectA (&lfA);
+        hDC_font = SelectObject(hDC, testFont1A);
+        bRet = GetTextMetrics(hDC, &tma);
+        ok(bRet, "GetTextMetrics error %d\n", GetLastError());
+        if(fmd[i].dpi == tma.tmDigitizedAspectX)
+        {
+            trace("found font %s, height %d charset %x dpi %d\n", lfA.lfFaceName, \
lfA.lfHeight, lfA.lfCharSet, fmd[i].dpi); +            if ((strcmp(lfA.lfFaceName, \
"Small Fonts") != 0) && (strcmp(lfA.lfFaceName, "Tahoma") != 0)  && \
(strcmp(lfA.lfFaceName, \ +                "Fixedsys") !=0))
+            /*Small Fonts and Tahoma not represented properly in Wine on MacOSX, \
Fixedsys appears as 96 DPI in 120 dpi systems*/ +            {
+              ok(tma.tmWeight == fmd[i].weight, "%s(%d): tma.tmWeight %d != %d\n", \
fmd[i].face_name, fmd[i].height, tma.tmWeight, \ +                 fmd[i].weight);
+              ok(tma.tmHeight == fmd[i].height, "%s(%d): tma.tmHeight %d != %d\n", \
fmd[i].face_name, fmd[i].height, tma.tmHeight, \ +                 fmd[i].height);
+              ok(tma.tmAscent == fmd[i].ascent, "%s(%d): tma.tmAscent %d != %d\n", \
fmd[i].face_name, fmd[i].height, tma.tmAscent, \ +                 fmd[i].ascent);
+              ok(tma.tmDescent == fmd[i].descent, "%s(%d): tma.tmDescent %d != \
%d\n", fmd[i].face_name, fmd[i].height, tma.tmDescent, \ +                 \
fmd[i].descent); +              ok(tma.tmInternalLeading == fmd[i].int_leading, \
"%s(%d): tma.tmInternalLeading %d != %d\n", fmd[i].face_name, \ +                 \
fmd[i].height, tma.tmInternalLeading, fmd[i].int_leading); +              \
ok(tma.tmExternalLeading == fmd[i].ext_leading, "%s(%d): tma.tmExternalLeading %d != \
%d\n", fmd[i].face_name, \ +                 fmd[i].height, tma.tmExternalLeading, \
fmd[i].ext_leading); +              ok(tma.tmAveCharWidth == fmd[i].ave_char_width, \
"%s(%d): tma.tmAveCharWidth %d != %d\n", fmd[i].face_name, fmd[i].height, \ +         \
tma.tmAveCharWidth, fmd[i].ave_char_width); +
+              /* Don't run the max char width test on System/ANSI_CHARSET.  We have \
extra characters in our font +                 that make the max width bigger */
+              if((strcmp(lfA.lfFaceName, "System")) != 0 && (strcmp(lfA.lfFaceName, \
"Tahoma")) !=0 ) +                  ok(tma.tmMaxCharWidth == fmd[i].max_char_width, \
"%s(%d): tma.tmMaxCharWidth %d != %d\n",\ +                     fmd[i].face_name, \
fmd[i].height, tma.tmMaxCharWidth, fmd[i].max_char_width); +            } /* if \
(fmd[i].lfFaceName */ +        } /* if  (fmd[i].dpi */
+        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) {
+            /* It appears that EC_USEFONTINFO does not do anything with the testing \
fonts */ +            case EC_USEFONTINFO :
+                if (mmt[j].right_margin == 0 && mmt[j].left_margin == 0)
+                {
+                    ok(new_rect.right == old_rect.right, "The right border changed \
in USEFONTINFO Zero Margin change " \ +                       "test when setting \
margin to zero for font %s(%d). The Margin was changed by %d.\n", fmd[i].face_name, \ \
+                       fmd[i].height, old_rect.right - new_rect.right); +            \
ok(new_rect.left == old_rect.left, "The left border changed in USEFONTINFO Zero \
Margin change " \ +                       "test setting margin to zero for font \
%s(%d). The Margin was changed by %d.\n", fmd[i].face_name, +                       \
fmd[i].height, new_rect.left - old_rect.left); +                }
+                else if (mmt[j].right_margin == 0)
+                {
+                    ok(new_rect.right == old_rect.right, "The right border changed \
in USEFONTINFO Left Only Margin change " \ +                       "test setting \
margin to zero for font %s(%d). The Margin was changed to %d.\n", fmd[i].face_name, \ \
+                       fmd[i].height, old_rect.right - new_rect.right); +            \
ok(new_rect.left == old_rect.left, "The left border was changed in USEFONTINFO Left \
Only Margin change test to a " \ +                       "value other than zero for \
font %s(%d). It was set to %d\n", fmd[i].face_name, fmd[i].height, \ +                \
new_rect.left - old_rect.left); +                }
+                else if (mmt[j].left_margin == 0)
+                {
+                    ok(new_rect.right == old_rect.right, "The right border was \
changed in USEFONTINFO Right Only " \ +                       "Margin change test to \
a value other than zero for font %s(%d).  It was set to %d.\n", fmd[i].face_name, \ + \
fmd[i].height, old_rect.right - new_rect.right); +                    \
ok(new_rect.left == old_rect.left, "The left border was changed in USEFONTINFO Right \
Only Margin change " \ +                       "test setting margin to zero for for \
font %s(%d). The Margin was changed to %d.\n", fmd[i].face_name, \ +                  \
fmd[i].height, new_rect.left - old_rect.left); +                }
+                else if (mmt[j].left_margin != EC_USEFONTINFO && mmt[j].right_margin \
!= EC_USEFONTINFO) +                {
+                    ok(new_rect.right == old_rect.right, "The right border was \
changed in EC_USEFONTINFO Left/Right margin " \ +                       "change test \
to a value other than zero for font %s(%d).  It was set to %d.\n", fmd[i].face_name, \
\ +                       fmd[i].height, old_rect.right - new_rect.right);
+                    ok(new_rect.left == old_rect.left, "The left border was changed \
in EC_USEFONTINFO Left/Right Margin" \ +                       "change test to a \
value other than zero for font %s(%d).  It was set to %d.\n", fmd[i].face_name, \ +   \
fmd[i].height, old_rect.left - new_rect.left); +                }
+                else /* both margins are set to EC_USEFONTINFO */
+                {
+                    ok(new_rect.right == old_rect.right, "The right border was \
changed in USEFONTINFO Left/Right " \ +                       "Margin change test to \
a value other than zero for font %s(%d).  It was set to %d\n", fmd[i].face_name, \ +  \
fmd[i].height, old_rect.right - new_rect.right); +                    \
ok(new_rect.left == old_rect.left, "The left border was changed in USEFONTINFO \
Left/Right " \ +                       "Margin change test to a value other than zero \
for font %s(%d).  It was set to %d\n", fmd[i].face_name, \ +                       \
fmd[i].height, old_rect.left - new_rect.left); +                }
+                ok(new_rect.top == old_rect.top, "The top border was changed in \
USEFONTINFO Margin change test by %d\n", \ +                   new_rect.top - \
old_rect.top); +                ok(new_rect.bottom == old_rect.bottom, "The bottom \
border was changed in USEFONTINFO Margin change test by %d\n", \ +                   \
new_rect.bottom - old_rect.bottom); +                break;
+            case EC_LEFTMARGIN | EC_RIGHTMARGIN :
+                /*Set Left and Right Margins for testing purposes to various values. \
Zero should not move the margins, others should +                  move the same \
number of pixels as requested */ +                if (mmt[j].right_margin == 0 && \
mmt[j].left_margin == 0) +                {
+                    ok(new_rect.right == old_rect.right, "The right border of the \
rectangle changed in Left/Right Margin Change " \ +                       "test \
setting margin to zero for font %s(%d). The value of it is %d.\n", fmd[i].face_name, \
fmd[i].height, \ +                       old_rect.right - new_rect.right);
+                    ok(new_rect.left == old_rect.left, "The left border of the \
rectangle changed in Left/Right Margin Change " \ +                       "test \
setting margin to zero for font %s(%d). The value of it is %d.\n", fmd[i].face_name, \
fmd[i].height, \ +                       new_rect.left - old_rect.left);
+                }
+                else if (mmt[j].right_margin == 0)
+                {
+                    ok(new_rect.right == old_rect.right, "The right border changed \
in Left/Right Margin Change " \ +                       "test setting margin to zero \
for font %s(%d). The value of it is %d.\n", fmd[i].face_name, fmd[i].height, \ +      \
old_rect.right - new_rect.right); +                    todo_wine {
+                        ok(new_rect.left == old_rect.left + mmt[j].left_margin, "The \
left border was changed in Left/Right Margin " \ +                           "Change \
test to an incorrect value for font %s(%d) by %d. Should be %d\n", fmd[i].face_name, \
\ +                           fmd[i].height, new_rect.left - old_rect.left, \
mmt[j].left_margin); +                    }
+                }
+                else if (mmt[j].left_margin == 0)
+                {
+                    todo_wine {
+                        ok(new_rect.right == old_rect.right - mmt[j].right_margin, \
"The right border was changed in Left/Right margin " \ +                           \
"change test to an incorrect value for font %s(%d) by %d. Should be %d.\n", \
fmd[i].face_name, \ +                           fmd[i].height, old_rect.right - \
new_rect.right, mmt[j].right_margin); +                     }
+                     ok(new_rect.left == old_rect.left, "The left border of the \
rectangle changed in Left/Right Margin Change " \ +                        "Change \
test setting margin to zero for for font %s(%d). The value of it is %d.\n", \
fmd[i].face_name, \ +                        fmd[i].height, new_rect.left - \
old_rect.left); +                }
+                else
+                {
+                    todo_wine {
+                        ok(new_rect.right == old_rect.right - mmt[j].right_margin, \
"The right border was changed in Left/Right margin " \ +                           \
"change test to an incorrect value for font %s(%d) by %d. Should be %d.\n", \
fmd[i].face_name, \ +                           fmd[i].height, old_rect.right - \
new_rect.right, mmt[j].right_margin); +                        ok(new_rect.left == \
old_rect.left + mmt[j].left_margin, "The left border was changed in Left/Right \
Margin" \ +                           "Change test for font %s(%d) by %d. Should be \
%d\n", fmd[i].face_name, fmd[i].height, \ +                           old_rect.left - \
new_rect.left, mmt[j].left_margin); +                    }
+                }
+                ok(new_rect.top == old_rect.top, "The top border was changed in \
Left/Right Margin Change test by %d\n", \ +                   new_rect.top - \
old_rect.top); +                ok(new_rect.bottom == old_rect.bottom, "The bottom \
border was changed in Left/Right Margin Change test by %d\n", \ +                   \
new_rect.bottom - old_rect.bottom); +                break;
+            case EC_LEFTMARGIN :
+                /*Set Left Margin for testing purposes to various values.  Zero \
should not move the left margin, others should move +                  the same \
number of pixels as requested */ +                if (mmt[j].left_margin == 0 )
+                {
+                    ok(new_rect.left == old_rect.left, "The left border of the \
rectangle was moved for font %s(%d) in zero margin " \ +                       "test. \
The value of the margin change is %d and the change input value was %d and the margin \
message type " \ +                       "was 0x%x\n", fmd[i].face_name, \
fmd[i].height, new_rect.left - old_rect.left, mmt[j].left_margin, \ +                 \
mmt[j].margin_type); +                }
+                else
+                {
+                    todo_wine {
+                        ok(new_rect.left == old_rect.left + mmt[j].left_margin, "The \
left border change is wrong in the Left Margin "\ +                           "Change \
test for font %s(%d). The value of it is %d.\n", fmd[i].face_name, fmd[i].height, \ + \
new_rect.left - old_rect.left); +                    }
+                }
+                ok(new_rect.right == old_rect.right, "The right border was changed \
in Left Margin Change test by %d for font %s(%d). " \ +                   "It should \
have been moved %d.  Margin change type is 0x%x\n", new_rect.right - old_rect.right, \
fmd[i].face_name, \ +                   fmd[i].height, mmt[j].left_margin, \
mmt[j].margin_type); +                ok(new_rect.top == old_rect.top, "The top \
border was changed\n"); +                ok(new_rect.bottom == old_rect.bottom, "The \
bottom border was changed\n"); +                break;
+            case EC_RIGHTMARGIN :
+                /*Set Right Margin for testing purposes to various values.  Zero \
should not move the right margin, others should move +                  the same \
number of pixels as requested */ +                if (mmt[j].right_margin == 0 )
+                {
+                    ok(new_rect.right == old_rect.right, "The right border of the \
rectangle is wrong for font " \ +                       "%s(%d). The value of it is \
%d.\n", fmd[i].face_name, fmd[i].height, old_rect.right - new_rect.right); +          \
} +                else
+                {
+                    todo_wine {
+                        ok(new_rect.right == old_rect.right - mmt[j].right_margin, \
"The right border of the rectangle is wrong for " \ +                           "font \
%s(%d). The value of it is %d. The margin type is 0x%x\n", fmd[i].face_name, \
fmd[i].height, \ +                           old_rect.right - old_rect.right, \
mmt[j].margin_type); +                    }
+                }
+                ok(new_rect.left == old_rect.left, "The left border was changed in \
Right Margin Change test by %d for font %s(%d)." \ +                   "It should \
have been moved %d.\n", new_rect.left - old_rect.left, fmd[i].face_name, \
fmd[i].height, \ +                   mmt[j].left_margin);
+                ok(new_rect.top == old_rect.top, "The top border was changed in \
Right Margin Change test by %d\n", \ +                   new_rect.top - \
old_rect.top); +                ok(new_rect.bottom == old_rect.bottom, "The bottom \
border was changed in Right Margin Change test by %d\n", \ +                   \
new_rect.bottom - old_rect.bottom); +                break;
+            case 0 :
+                ok(new_rect.right == old_rect.right, "The right border was changed \
in Zero Left/Right Margin change test to an "\ +                   "incorrect value \
for font %s(%d) to %d and it should be zero. Value inputted for the test was %d\n", \ \
+                   fmd[i].face_name, fmd[i].height, old_rect.right - new_rect.right, \
mmt[j].right_margin); +                ok(new_rect.left == old_rect.left, "The left \
border was changed in Zero Left/Right " \ +                   "Margin change test to \
an incorrect value for font %s(%d) to %d and should be zero.  The value inputted for \
"\ +                   "the test was %d\n", fmd[i].face_name, fmd[i].height, \
old_rect.left - new_rect.left, mmt[j].left_margin); +                ok(new_rect.top \
== old_rect.top, "The top border was changed in Zero Margin change test by %d\n", \ + \
new_rect.top - old_rect.top); +                ok(new_rect.bottom == old_rect.bottom, \
"The bottom border was changed in Zero Margin change test by %d\n", \ +               \
new_rect.bottom - old_rect.bottom); +                break;
+            default:
+                ok (0 == 1, "Check %s %d %d\n", fmd[i].face_name, fmd[i].height, \
fmd[i].dpi); +            } /* switch (margin_type) */
+        } /*for (j) */
+            SelectObject(hDC, hDC_font);
+            DeleteObject(testFont1A);
+    } /* for (i) */
+    /* Per http://www.piclist.com/techref/os/win/api/win32/mess/src/msg06_7.htm the \
Left Margin +    should be set to the 'C' value, that is the value used to set white \
space after a character +    and 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.  The margin value passed in the lParam variable +    is ignored \
*/ +
+    if (is_win9xA())
+    {
+        win_skip ("Cannot perform EC_USEFONTINFO tests on Windows 95/98/ME (Richedit \
1.0 and 2.0) as lparam\n"); +        ReleaseDC(hwndRichEdit, hDC);
+        DestroyWindow(hwndRichEdit);
+        return;
+    }
+
+    /*Run UNICODE Tests */
+    ZeroMemory(&testFont1W, sizeof(HFONT));
+    ZeroMemory(&lfW, sizeof(lfW));
+    /*Initialize rect variable to be the size of the entire richedit window */
+    SendMessageW(hwndRichEdit, EM_SETRECT, 0, (LPARAM)&old_rect);
+    SendMessageW(hwndRichEdit, EM_GETRECT, 0, (LPARAM)&old_rect);
+
+    for (i = 0; i < sizeof(fmdW)/sizeof(fmdW[0]); i++)
+    {
+        lstrcpyW(lfW.lfFaceName, fmdW[i].face_name);
+        lfW.lfHeight = fmdW[i].height;
+        lfW.lfCharSet = ANSI_CHARSET;
+        lfW.lfWeight = fmdW[i].weight;
+        ret = EnumFontFamiliesExW(hDC, &lfW, find_font_proc, (LPARAM)&lfW, 0);
+        if (ret)
+        {
+            ok (ret, "Font Enumeration failed\n");
+            continue;
+        }
+
+        testFont1W = CreateFontIndirectW (&lfW);
+        hDC_font = SelectObject(hDC, testFont1W);
+        bRet = GetTextMetricsW(hDC, &tmw);
+        ok(bRet, "GetTextMetrics error %d\n", GetLastError());
+        if(fmdW[i].dpi == tmw.tmDigitizedAspectX)
+        {
+            trace("found font %s, height %d charset %x dpi %d\n", \
wine_dbgstr_w(lfW.lfFaceName), lfW.lfHeight, lfW.lfCharSet, fmdW[i].dpi); +           \
if ((lstrcmpW(lfW.lfFaceName, smallFonts) != 0) && (lstrcmpW(lfW.lfFaceName, tahoma) \
!= 0)  && (lstrcmpW(lfW.lfFaceName, \ +                fixedSys ) !=0))
+            /*Small Fonts and Tahoma not represented properly in Wine on MacOSX, \
Fixedsys appears as 96 DPI in 120 dpi systems*/ +            {
+              ok(tmw.tmWeight == fmdW[i].weight, "%s(%d): tmw.tmWeight %d != %d\n", \
wine_dbgstr_w(fmdW[i].face_name), fmdW[i].height, \ +                 tmw.tmWeight, \
fmdW[i].weight); +              ok(tmw.tmHeight == fmdW[i].height, "%s(%d): \
tmw.tmHeight %d != %d\n", wine_dbgstr_w(fmdW[i].face_name), fmdW[i].height, \ +       \
tmw.tmHeight, fmdW[i].height); +              ok(tmw.tmAscent == fmdW[i].ascent, \
"%s(%d): tmw.tmwscent %d != %d\n", wine_dbgstr_w(fmdW[i].face_name), fmdW[i].height, \
tmw.tmAscent, \ +                 fmdW[i].ascent);
+              ok(tmw.tmDescent == fmdW[i].descent, "%s(%d): tmw.tmDescent %d != \
%d\n", wine_dbgstr_w(fmdW[i].face_name), fmdW[i].height, tmw.tmDescent, \ +           \
fmdW[i].descent); +              ok(tmw.tmInternalLeading == fmdW[i].int_leading, \
"%s(%d): tmw.tmInternalLeading %d != %d\n", wine_dbgstr_w(fmdW[i].face_name), \ +     \
fmdW[i].height, tmw.tmInternalLeading, fmdW[i].int_leading); +              \
ok(tmw.tmExternalLeading == fmdW[i].ext_leading, "%s(%d): tmw.tmExternalLeading %d != \
%d\n", wine_dbgstr_w(fmdW[i].face_name), \ +                 fmdW[i].height, \
tmw.tmExternalLeading, fmdW[i].ext_leading); +              ok(tmw.tmAveCharWidth == \
fmdW[i].ave_char_width, "%s(%d): tmw.tmAveCharWidth %d != %d\n", \
wine_dbgstr_w(fmdW[i].face_name), fmdW[i].height, \ +                 \
tmw.tmAveCharWidth, fmdW[i].ave_char_width); +
+              /* Don't run the max char width test on System/ANSI_CHARSET.  We have \
extra characters in our font +                 that make the max width bigger */
+              if((lstrcmpW(lfW.lfFaceName, system )) != 0 && \
(lstrcmpW(lfW.lfFaceName, tahoma)) !=0 ) +                  ok(tmw.tmMaxCharWidth == \
fmdW[i].max_char_width, "%s(%d): tmw.tmMaxCharWidth %d != %d\n",\ +                   \
wine_dbgstr_w(fmdW[i].face_name), fmdW[i].height, tmw.tmMaxCharWidth, \
fmdW[i].max_char_width); +            } /* if (fmdW[i].lfFaceName */
+        } /* if  (fmdW[i].dpi */
+        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) {
+            /* It appears that EC_USEFONTINFO does not do anything with the testing \
fonts */ +            case EC_USEFONTINFO :
+                if (mmt[j].right_margin == 0 && mmt[j].left_margin == 0)
+                {
+                    ok(new_rect.right == old_rect.right, "The right border changed \
in USEFONTINFO Zero Margin change " \ +                       "test when setting \
margin to zero for font %s(%d). The Margin was changed by %d.\n", \
wine_dbgstr_w(fmdW[i].face_name), \ +                       fmdW[i].height, \
old_rect.right - new_rect.right); +                    ok(new_rect.left == \
old_rect.left, "The left border changed in USEFONTINFO Zero Margin change " \ +       \
"test setting margin to zero for font %s(%d). The Margin was changed by %d.\n", \
wine_dbgstr_w(fmdW[i].face_name), +                       fmdW[i].height, \
new_rect.left - old_rect.left); +                }
+                else if (mmt[j].right_margin == 0)
+                {
+                    ok(new_rect.right == old_rect.right, "The right border changed \
in USEFONTINFO Left Only Margin change " \ +                       "test setting \
margin to zero for font %s(%d). The Margin was changed to %d.\n", \
wine_dbgstr_w(fmdW[i].face_name), \ +                       fmdW[i].height, \
old_rect.right - new_rect.right); +                    ok(new_rect.left == \
old_rect.left, "The left border was changed in USEFONTINFO Left Only Margin change \
test to a " \ +                       "value other than zero for font %s(%d). It was \
set to %d\n", wine_dbgstr_w(fmdW[i].face_name), fmdW[i].height, \ +                   \
new_rect.left - old_rect.left); +                }
+                else if (mmt[j].left_margin == 0)
+                {
+                    ok(new_rect.right == old_rect.right, "The right border was \
changed in USEFONTINFO Right Only " \ +                       "Margin change test to \
a value other than zero for font %s(%d).  It was set to %d.\n", \
wine_dbgstr_w(fmdW[i].face_name), \ +                       fmdW[i].height, \
old_rect.right - new_rect.right); +                    ok(new_rect.left == \
old_rect.left, "The left border was changed in USEFONTINFO Right Only Margin change " \
\ +                       "test setting margin to zero for for font %s(%d). The \
Margin was changed to %d.\n", wine_dbgstr_w(fmdW[i].face_name), \ +                   \
fmdW[i].height, new_rect.left - old_rect.left); +                }
+                else if (mmt[j].left_margin != EC_USEFONTINFO && mmt[j].right_margin \
!= EC_USEFONTINFO) +                {
+                    ok(new_rect.right == old_rect.right, "The right border was \
changed in EC_USEFONTINFO Left/Right margin " \ +                       "change test \
to a value other than zero for font %s(%d).  It was set to %d.\n", \
wine_dbgstr_w(fmdW[i].face_name), \ +                       fmdW[i].height, \
old_rect.right - new_rect.right); +                    ok(new_rect.left == \
old_rect.left, "The left border was changed in EC_USEFONTINFO Left/Right Margin" \ +  \
"change test to a value other than zero for font %s(%d).  It was set to %d.\n", \
wine_dbgstr_w(fmdW[i].face_name), \ +                       fmdW[i].height, \
old_rect.left - new_rect.left); +                }
+                else /* both margins are set to EC_USEFONTINFO */
+                {
+                    ok(new_rect.right == old_rect.right, "The right border was \
changed in USEFONTINFO Left/Right " \ +                       "Margin change test to \
a value other than zero for font %s(%d).  It was set to %d\n", \
wine_dbgstr_w(fmdW[i].face_name), \ +                       fmdW[i].height, \
old_rect.right - new_rect.right); +                    ok(new_rect.left == \
old_rect.left, "The left border was changed in USEFONTINFO Left/Right " \ +           \
"Margin change test to a value other than zero for font %s(%d).  It was set to %d\n", \
wine_dbgstr_w(fmdW[i].face_name), \ +                       fmdW[i].height, \
old_rect.left - new_rect.left); +                }
+                ok(new_rect.top == old_rect.top, "The top border was changed in \
USEFONTINFO Margin change test by %d\n", \ +                   new_rect.top - \
old_rect.top); +                ok(new_rect.bottom == old_rect.bottom, "The bottom \
border was changed in USEFONTINFO Margin change test by %d\n", \ +                   \
new_rect.bottom - old_rect.bottom); +                break;
+            case EC_LEFTMARGIN | EC_RIGHTMARGIN :
+                /*Set Left and Right Margins for testing purposes to various values. \
Zero should not move the margins, others should +                  move the same \
number of pixels as requested */ +                if (mmt[j].right_margin == 0 && \
mmt[j].left_margin == 0) +                {
+                    ok(new_rect.right == old_rect.right, "The right border of the \
rectangle changed in Left/Right Margin Change " \ +                       "test \
setting margin to zero for font %s(%d). The value of it is %d.\n", \
wine_dbgstr_w(fmdW[i].face_name), fmdW[i].height, \ +                       \
old_rect.right - new_rect.right); +                    ok(new_rect.left == \
old_rect.left, "The left border of the rectangle changed in Left/Right Margin Change \
" \ +                       "test setting margin to zero for font %s(%d). The value \
of it is %d.\n", wine_dbgstr_w(fmdW[i].face_name), fmdW[i].height, \ +                \
new_rect.left - old_rect.left); +                }
+                else if (mmt[j].right_margin == 0)
+                {
+                    ok(new_rect.right == old_rect.right, "The right border changed \
in Left/Right Margin Change " \ +                       "test setting margin to zero \
for font %s(%d). The value of it is %d.\n", wine_dbgstr_w(fmdW[i].face_name), \
fmdW[i].height, \ +                       old_rect.right - new_rect.right);
+                    todo_wine {
+                        ok(new_rect.left == old_rect.left + mmt[j].left_margin, "The \
left border was changed in Left/Right Margin " \ +                           "Change \
test to an incorrect value for font %s(%d) by %d. Should be %d\n", \
wine_dbgstr_w(fmdW[i].face_name), \ +                           fmdW[i].height, \
new_rect.left - old_rect.left, mmt[j].left_margin); +                    }
+                }
+                else if (mmt[j].left_margin == 0)
+                {
+                    todo_wine {
+                        ok(new_rect.right == old_rect.right - mmt[j].right_margin, \
"The right border was changed in Left/Right margin " \ +                           \
"change test to an incorrect value for font %s(%d) by %d. Should be %d.\n", \
wine_dbgstr_w(fmdW[i].face_name), \ +                           fmdW[i].height, \
old_rect.right - new_rect.right, mmt[j].right_margin); +                     }
+                     ok(new_rect.left == old_rect.left, "The left border of the \
rectangle changed in Left/Right Margin Change " \ +                        "Change \
test setting margin to zero for for font %s(%d). The value of it is %d.\n", \
wine_dbgstr_w(fmdW[i].face_name), \ +                        fmdW[i].height, \
new_rect.left - old_rect.left); +                }
+                else
+                {
+                    todo_wine {
+                        ok(new_rect.right == old_rect.right - mmt[j].right_margin, \
"The right border was changed in Left/Right margin " \ +                           \
"change test to an incorrect value for font %s(%d) by %d. Should be %d.\n", \
wine_dbgstr_w(fmdW[i].face_name), \ +                           fmdW[i].height, \
old_rect.right - new_rect.right, mmt[j].right_margin); +                        \
ok(new_rect.left == old_rect.left + mmt[j].left_margin, "The left border was changed \
in Left/Right Margin" \ +                           "Change test for font %s(%d) by \
%d. Should be %d\n", wine_dbgstr_w(fmdW[i].face_name), fmdW[i].height, \ +            \
old_rect.left - new_rect.left, mmt[j].left_margin); +                    }
+                }
+                ok(new_rect.top == old_rect.top, "The top border was changed in \
Left/Right Margin Change test by %d\n", \ +                   new_rect.top - \
old_rect.top); +                ok(new_rect.bottom == old_rect.bottom, "The bottom \
border was changed in Left/Right Margin Change test by %d\n", \ +                   \
new_rect.bottom - old_rect.bottom); +                break;
+            case EC_LEFTMARGIN :
+                /*Set Left Margin for testing purposes to various values.  Zero \
should not move the left margin, others should move +                  the same \
number of pixels as requested */ +                if (mmt[j].left_margin == 0 )
+                {
+                    ok(new_rect.left == old_rect.left, "The left border of the \
rectangle was moved for font %s(%d) in zero margin " \ +                       "test. \
The value of the margin change is %d and the change input value was %d and the margin \
message type " \ +                       "was 0x%x\n", \
wine_dbgstr_w(fmdW[i].face_name), fmdW[i].height, new_rect.left - old_rect.left, \
mmt[j].left_margin, \ +                       mmt[j].margin_type);
+                }
+                else
+                {
+                    todo_wine {
+                        ok(new_rect.left == old_rect.left + mmt[j].left_margin, "The \
left border change is wrong in the Left Margin "\ +                           "Change \
test for font %s(%d). The value of it is %d.\n", wine_dbgstr_w(fmdW[i].face_name), \
fmdW[i].height, \ +                           new_rect.left - old_rect.left);
+                    }
+                }
+                ok(new_rect.right == old_rect.right, "The right border was changed \
in Left Margin Change test by %d for font %s(%d). " \ +                   "It should \
have been moved %d.  Margin change type is 0x%x\n", new_rect.right - old_rect.right, \
wine_dbgstr_w(fmdW[i].face_name), \ +                   fmdW[i].height, \
mmt[j].left_margin, mmt[j].margin_type); +                ok(new_rect.top == \
old_rect.top, "The top border was changed\n"); +                ok(new_rect.bottom == \
old_rect.bottom, "The bottom border was changed\n"); +                break;
+            case EC_RIGHTMARGIN :
+                /*Set Right Margin for testing purposes to various values.  Zero \
should not move the right margin, others should move +                  the same \
number of pixels as requested */ +                if (mmt[j].right_margin == 0 )
+                {
+                    ok(new_rect.right == old_rect.right, "The right border of the \
rectangle is wrong for font " \ +                       "%s(%d). The value of it is \
%d.\n", wine_dbgstr_w(fmdW[i].face_name), fmdW[i].height, old_rect.right - \
new_rect.right); +                }
+                else
+                {
+                    todo_wine {
+                        ok(new_rect.right == old_rect.right - mmt[j].right_margin, \
"The right border of the rectangle is wrong for " \ +                           "font \
%s(%d). The value of it is %d. The margin type is 0x%x\n", \
wine_dbgstr_w(fmdW[i].face_name), fmdW[i].height, \ +                           \
old_rect.right - old_rect.right, mmt[j].margin_type); +                    }
+                }
+                ok(new_rect.left == old_rect.left, "The left border was changed in \
Right Margin Change test by %d for font %s(%d)." \ +                   "It should \
have been moved %d.\n", new_rect.left - old_rect.left, \
wine_dbgstr_w(fmdW[i].face_name), fmdW[i].height, \ +                   \
mmt[j].left_margin); +                ok(new_rect.top == old_rect.top, "The top \
border was changed in Right Margin Change test by %d\n", \ +                   \
new_rect.top - old_rect.top); +                ok(new_rect.bottom == old_rect.bottom, \
"The bottom border was changed in Right Margin Change test by %d\n", \ +              \
new_rect.bottom - old_rect.bottom); +                break;
+            case 0 :
+                ok(new_rect.right == old_rect.right, "The right border was changed \
in Zero Left/Right Margin change test to an "\ +                   "incorrect value \
for font %s(%d) to %d and it should be zero. Value inputted for the test was %d\n", \ \
+                   wine_dbgstr_w(fmdW[i].face_name), fmdW[i].height, old_rect.right \
- new_rect.right, mmt[j].right_margin); +                ok(new_rect.left == \
old_rect.left, "The left border was changed in Zero Left/Right " \ +                  \
"Margin change test to an incorrect value for font %s(%d) to %d and should be zero.  \
The value inputted for "\ +                   "the test was %d\n", \
wine_dbgstr_w(fmdW[i].face_name), fmdW[i].height, old_rect.left - new_rect.left, \
mmt[j].left_margin); +                ok(new_rect.top == old_rect.top, "The top \
border was changed in Zero Margin change test by %d\n", \ +                   \
new_rect.top - old_rect.top); +                ok(new_rect.bottom == old_rect.bottom, \
"The bottom border was changed in Zero Margin change test by %d\n", \ +               \
new_rect.bottom - old_rect.bottom); +                break;
+            default:
+                ok (0 == 1, "Check %s %d %d\n", wine_dbgstr_w(fmdW[i].face_name), \
fmdW[i].height, fmdW[i].dpi); +            } /* switch (margin_type) */
+        } /*for (j) */
+            SelectObject(hDC, hDC_font);
+            DeleteObject(testFont1A);
+    } /* for (i) */
+    DeleteObject(testFont1A);
+    DeleteObject(testFont1W);
+    ReleaseDC (hwndRichEdit, hDC);
+    DestroyWindow (hwndRichEdit);
+}
+
 START_TEST( editor )
 {
   BOOL ret;
@@ -7103,6 +7762,7 @@ START_TEST( editor )
 
   is_win9x = GetVersion() & 0x80000000;
 
+  if (winetest_debug > 1) {
   test_WM_CHAR();
   test_EM_FINDTEXT();
   test_EM_GETLINE();
@@ -7151,6 +7811,8 @@ 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.





[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic