[PATCH] 4/4 Add tests for FontFamily functions

Adam Petaccia adam at tpetaccia.com
Tue Jun 17 09:56:35 CDT 2008


---
 dlls/gdiplus/tests/font.c |   52 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 51 insertions(+), 1 deletions(-)

diff --git a/dlls/gdiplus/tests/font.c b/dlls/gdiplus/tests/font.c
index 71e6f9a..cad0993 100644
--- a/dlls/gdiplus/tests/font.c
+++ b/dlls/gdiplus/tests/font.c
@@ -20,11 +20,13 @@
 
 #include "windows.h"
 #include "gdiplus.h"
+
 #include "wine/test.h"
 
 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
 
-static WCHAR arial[] = {'A','r','i','a','l','\0'};
+static const WCHAR arial[] = {'A','r','i','a','l','\0'};
+static const WCHAR nonexistant[] = {'T','h','i','s','F','o','n','t','s','h','o','u','l','d','N','o','t','E','x','i','s','t','\0'};
 
 static void test_logfont(void)
 {
@@ -94,6 +96,53 @@ static void test_logfont(void)
     ReleaseDC(0, hdc);
 }
 
+static void test_fontfamily (void)
+{
+    GpFontFamily** family = NULL;
+    WCHAR itsName[LF_FACESIZE];
+    GpStatus stat;
+
+    /* FontFamily can not be NULL */
+    stat = GdipCreateFontFamilyFromName (arial , NULL, family);
+    expect (InvalidParameter, stat);
+
+    family = GdipAlloc (sizeof (GpFontFamily*));
+
+    /* FontFamily must be able to actually find the family.
+     * If it can't, any subsequent calls should fail
+     *
+     * We currently fail (meaning we don't) because we don't actually
+     * test to see if we can successfully get a family
+     */
+    stat = GdipCreateFontFamilyFromName (nonexistant, NULL, family);
+    expect (FontFamilyNotFound, stat);
+    stat = GdipGetFamilyName (*family,itsName, LANG_NEUTRAL);
+    expect (InvalidParameter, stat);
+    ok ((lstrcmpiW(itsName,nonexistant) != 0),
+        "Expected a non-zero value for nonexistant font!\n");
+    stat = GdipDeleteFontFamily(*family);
+    expect (InvalidParameter, stat);
+
+    stat = GdipCreateFontFamilyFromName (arial, NULL, family);
+    expect (Ok, stat);
+
+    stat = GdipGetFamilyName (*family, itsName, LANG_NEUTRAL);
+    expect (Ok, stat);
+    expect (0, lstrcmpiW(itsName,arial));
+
+    if (0)
+    {
+        /* Crashes on Windows XP SP2, Vista, and so Wine as well */
+        stat = GdipGetFamilyName (*family, NULL, LANG_NEUTRAL);
+        expect (Ok, stat);
+    }
+
+    stat = GdipDeleteFontFamily(*family);
+    expect (Ok, stat);
+
+    if (family) GdipFree (family);
+}
+
 START_TEST(font)
 {
     struct GdiplusStartupInput gdiplusStartupInput;
@@ -107,6 +156,7 @@ START_TEST(font)
     GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
 
     test_logfont();
+    test_fontfamily ();
 
     GdiplusShutdown(gdiplusToken);
 }
-- 
1.5.4.3




More information about the wine-patches mailing list