[Gdiplus 1/5] Tests for PrivateFontCollection
Adam Petaccia
adam at tpetaccia.com
Sat Aug 16 22:29:12 CDT 2008
---
dlls/gdiplus/tests/font.c | 81 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 81 insertions(+), 0 deletions(-)
diff --git a/dlls/gdiplus/tests/font.c b/dlls/gdiplus/tests/font.c
index 3d30a86..b19f0aa 100644
--- a/dlls/gdiplus/tests/font.c
+++ b/dlls/gdiplus/tests/font.c
@@ -28,6 +28,7 @@ static const WCHAR arial[] = {'A','r','i','a','l','\0'};
static const WCHAR nonexistent[] = {'T','h','i','s','F','o','n','t','s','h','o','u','l','d','N','o','t','E','x','i','s','t','\0'};
static const WCHAR MSSansSerif[] = {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'};
static const WCHAR MicrosoftSansSerif[] = {'M','i','c','r','o','s','o','f','t',' ','S','a','n','s',' ','S','e','r','i','f','\0'};
+static const WCHAR Tahoma[] = {'T','a','h','o','m','a','\0'};
static const WCHAR TimesNewRoman[] = {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n','\0'};
static const WCHAR CourierNew[] = {'C','o','u','r','i','e','r',' ','N','e','w','\0'};
@@ -333,6 +334,85 @@ monospace:
expect (Ok, stat);
}
+static void test_fontcollections(void)
+{
+ const static WCHAR tahomafilename[] = {'C',':','\\','W','I','N','D','O','W','S','\\','F','o','n','t','s','\\','T','a','h','o','m','a','.','t','t','f','\0'};
+ const static WCHAR timesNRfilename[] = {'C',':','\\','W','I','N','D','O','W','S','\\','F','o','n','t','s','\\','T','i','m','e','s','.','t','t','f','\0'};
+ const static WCHAR badFileName[] = {'C',':','\\','W','I','N','D','O','W','S','\\','F','o','n','t','s','\\','S','h','o','u','l','d','n','o','t','e','x','i','s','t','.','t','t','f','\0'};
+
+ static WCHAR familyName[LF_FACESIZE];
+ GpStatus stat;
+ GpFontCollection* PrivateFontCollection;
+ GpFontFamily** fontFamily;
+ INT expected = 0, count = 0, i;
+ BOOL hastahoma, hastimesnr;
+
+ stat = GdipNewPrivateFontCollection(&PrivateFontCollection);
+todo_wine
+ expect(Ok, stat);
+ stat = GdipPrivateAddFontFile(PrivateFontCollection, NULL);
+ expect(InvalidParameter, stat);
+todo_wine{
+ stat = GdipPrivateAddFontFile(PrivateFontCollection, badFileName);
+ expect(FileNotFound, stat);
+
+ stat = GdipPrivateAddFontFile(PrivateFontCollection, tahomafilename);
+ if (stat == Ok)
+ {
+ expected++;
+ hastahoma = TRUE;
+ }
+
+ stat = GdipPrivateAddFontFile(PrivateFontCollection, timesNRfilename);
+ if (stat == Ok)
+ {
+ expected++;
+ hastimesnr = TRUE;
+ }
+
+ stat = GdipGetFontCollectionFamilyCount(PrivateFontCollection, &count);
+ expect(Ok, stat);
+ expect(expected, count);
+
+ expected = count;
+
+ /* Test retrieving of installed fonts */
+ fontFamily = GdipAlloc(sizeof(GpFontFamily*) * count);
+ stat = GdipGetFontCollectionFamilyList(PrivateFontCollection, count,
+ fontFamily, &count);
+ expect(Ok, stat);
+ expect(expected, count);
+ if (stat == Ok)
+ {
+ i = 0;
+ if (hastahoma)
+ {
+ GdipGetFamilyName(fontFamily[i], familyName, LANG_NEUTRAL);
+ ok(lstrcmpiW(familyName, Tahoma) == 0, "Expected Tahoma, got %s\n",
+ debugstr_w(familyName));
+ i++;
+ }
+
+ if (hastimesnr)
+ {
+ GdipGetFamilyName(fontFamily[i], familyName, LANG_NEUTRAL);
+ ok(lstrcmpiW(familyName, TimesNewRoman) == 0, "Expected Times New "
+ "Roman, got %s\n", debugstr_w(familyName));
+ i++;
+ }
+ }
+
+ for (i = 0; i < count; i++)
+ {
+ stat = GdipDeleteFontFamily(fontFamily[i]);
+ expect(Ok, stat);
+ }
+}
+
+ stat = GdipDeletePrivateFontCollection(&PrivateFontCollection);
+ expect(Ok, stat);
+}
+
START_TEST(font)
{
struct GdiplusStartupInput gdiplusStartupInput;
@@ -350,6 +430,7 @@ START_TEST(font)
test_fontfamily();
test_fontfamily_properties();
test_getgenerics();
+ test_fontcollections();
GdiplusShutdown(gdiplusToken);
}
--
1.5.4.3
More information about the wine-patches
mailing list