gdi32: Add a buch of CreateScalableFontResource() tests. Take 3.

Dmitry Timoshkov dmitry at baikal.ru
Mon Aug 29 21:59:42 CDT 2011


This version of the patch contains both .sfd and .ttf variants of the font.

---
 dlls/gdi32/tests/Makefile.in   |    2 +
 dlls/gdi32/tests/font.c        |  193 ++++++++++++++++++++++++++++++++++++++++
 dlls/gdi32/tests/resource.rc   |   24 +++++
 dlls/gdi32/tests/wine_test.sfd |  180 +++++++++++++++++++++++++++++++++++++
 dlls/gdi32/tests/wine_test.ttf |  Bin 0 -> 1544 bytes
 5 files changed, 399 insertions(+), 0 deletions(-)
 create mode 100644 dlls/gdi32/tests/resource.rc
 create mode 100644 dlls/gdi32/tests/wine_test.sfd
 create mode 100644 dlls/gdi32/tests/wine_test.ttf

diff --git a/dlls/gdi32/tests/Makefile.in b/dlls/gdi32/tests/Makefile.in
index c77f9e2..dee2fa4 100644
--- a/dlls/gdi32/tests/Makefile.in
+++ b/dlls/gdi32/tests/Makefile.in
@@ -17,4 +17,6 @@ C_SRCS = \
 	path.c \
 	pen.c
 
+RC_SRCS = resource.rc
+
 @MAKE_TEST_RULES@
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c
index aa2d518..6ce8282 100644
--- a/dlls/gdi32/tests/font.c
+++ b/dlls/gdi32/tests/font.c
@@ -48,6 +48,8 @@ static BOOL  (WINAPI *pGdiRealizationInfo)(HDC hdc, DWORD *);
 static HFONT (WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDV *);
 static HANDLE (WINAPI *pAddFontMemResourceEx)(PVOID, DWORD, PVOID, DWORD *);
 static BOOL  (WINAPI *pRemoveFontMemResourceEx)(HANDLE);
+static INT   (WINAPI *pAddFontResourceExA)(LPCSTR, DWORD, PVOID);
+static BOOL  (WINAPI *pRemoveFontResourceExA)(LPCSTR, DWORD, PVOID);
 
 static HMODULE hgdi32 = 0;
 static const MAT2 mat = { {0,1}, {0,0}, {0,0}, {0,1} };
@@ -68,6 +70,8 @@ static void init(void)
     pCreateFontIndirectExA = (void *)GetProcAddress(hgdi32, "CreateFontIndirectExA");
     pAddFontMemResourceEx = (void *)GetProcAddress(hgdi32, "AddFontMemResourceEx");
     pRemoveFontMemResourceEx = (void *)GetProcAddress(hgdi32, "RemoveFontMemResourceEx");
+    pAddFontResourceExA = (void *)GetProcAddress(hgdi32, "AddFontResourceExA");
+    pRemoveFontResourceExA = (void *)GetProcAddress(hgdi32, "RemoveFontResourceExA");
 }
 
 static INT CALLBACK is_truetype_font_installed_proc(const LOGFONT *elf, const TEXTMETRIC *ntm, DWORD type, LPARAM lParam)
@@ -3799,6 +3803,190 @@ static void test_fullname(void)
     DeleteDC(hdc);
 }
 
+static BOOL write_ttf_file(char *tmp_name)
+{
+    char tmp_path[MAX_PATH];
+    HRSRC rsrc;
+    void *rsrc_data;
+    DWORD rsrc_size;
+    HANDLE hfile;
+    BOOL ret;
+
+    SetLastError(0xdeadbeef);
+    rsrc = FindResource(GetModuleHandle(0), "wine_test.ttf", RT_RCDATA);
+    ok(rsrc != 0, "FindResource error %d\n", GetLastError());
+    if (!rsrc) return FALSE;
+    SetLastError(0xdeadbeef);
+    rsrc_data = LockResource(LoadResource(GetModuleHandle(0), rsrc));
+    ok(rsrc_data != 0, "LockResource error %d\n", GetLastError());
+    if (!rsrc_data) return FALSE;
+    SetLastError(0xdeadbeef);
+    rsrc_size = SizeofResource(GetModuleHandle(0), rsrc);
+    ok(rsrc_size != 0, "SizeofResource error %d\n", GetLastError());
+    if (!rsrc_size) return FALSE;
+
+    SetLastError(0xdeadbeef);
+    ret = GetTempPath(MAX_PATH, tmp_path);
+    ok(ret, "GetTempPath() error %d\n", GetLastError());
+    SetLastError(0xdeadbeef);
+    ret = GetTempFileName(tmp_path, "ttf", 0, tmp_name);
+    ok(ret, "GetTempFileName() error %d\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    hfile = CreateFile(tmp_name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
+    ok(hfile != INVALID_HANDLE_VALUE, "CreateFile() error %d\n", GetLastError());
+    if (hfile == INVALID_HANDLE_VALUE) return FALSE;
+
+    SetLastError(0xdeadbeef);
+    ret = WriteFile(hfile, rsrc_data, rsrc_size, &rsrc_size, NULL);
+    ok(ret, "WriteFile() error %d\n", GetLastError());
+
+    CloseHandle(hfile);
+    return ret;
+}
+
+static void test_CreateScalableFontResource(void)
+{
+    char ttf_name[MAX_PATH];
+    char tmp_path[MAX_PATH];
+    char fot_name[MAX_PATH];
+    char *file_part;
+    DWORD ret;
+
+    if (!pAddFontResourceExA || !pRemoveFontResourceExA)
+    {
+        win_skip("AddFontResourceExA is not available on this platform\n");
+        return;
+    }
+
+    if (!write_ttf_file(ttf_name))
+    {
+        skip("Failed to create ttf file for testing\n");
+        return;
+    }
+
+    trace("created %s\n", ttf_name);
+
+    ret = is_truetype_font_installed("wine_test");
+    ok(!ret, "font wine_test should not be enumerated\n");
+
+    ret = GetTempPath(MAX_PATH, tmp_path);
+    ok(ret, "GetTempPath() error %d\n", GetLastError());
+    ret = GetTempFileName(tmp_path, "fot", 0, fot_name);
+    ok(ret, "GetTempFileName() error %d\n", GetLastError());
+
+    ret = GetFileAttributes(fot_name);
+    ok(ret != INVALID_FILE_ATTRIBUTES, "file %s does not exist\n", fot_name);
+
+    SetLastError(0xdeadbeef);
+    ret = CreateScalableFontResource(0, fot_name, ttf_name, NULL);
+    ok(!ret, "CreateScalableFontResource() should fail\n");
+    ok(GetLastError() == ERROR_FILE_EXISTS, "not expected error %d\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = CreateScalableFontResource(0, fot_name, ttf_name, "");
+    ok(!ret, "CreateScalableFontResource() should fail\n");
+    ok(GetLastError() == ERROR_FILE_EXISTS, "not expected error %d\n", GetLastError());
+
+    file_part = strrchr(ttf_name, '\\');
+    SetLastError(0xdeadbeef);
+    ret = CreateScalableFontResource(0, fot_name, file_part, tmp_path);
+    ok(!ret, "CreateScalableFontResource() should fail\n");
+    ok(GetLastError() == ERROR_FILE_EXISTS, "not expected error %d\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = CreateScalableFontResource(0, fot_name, "random file name", tmp_path);
+    ok(!ret, "CreateScalableFontResource() should fail\n");
+todo_wine
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "not expected error %d\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = CreateScalableFontResource(0, fot_name, NULL, ttf_name);
+    ok(!ret, "CreateScalableFontResource() should fail\n");
+todo_wine
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "not expected error %d\n", GetLastError());
+
+    ret = DeleteFile(fot_name);
+    ok(ret, "DeleteFile() error %d\n", GetLastError());
+
+    ret = pRemoveFontResourceExA(fot_name, 0, 0);
+todo_wine
+    ok(!ret, "RemoveFontResourceEx() should fail\n");
+
+    /* FIXME: since CreateScalableFontResource is a stub further testing is impossible */
+    if (ret) return;
+
+    /* test public font resource */
+    SetLastError(0xdeadbeef);
+    ret = CreateScalableFontResource(0, fot_name, ttf_name, NULL);
+    ok(ret, "CreateScalableFontResource() error %d\n", GetLastError());
+
+    ret = is_truetype_font_installed("wine_test");
+    ok(!ret, "font wine_test should not be enumerated\n");
+
+    SetLastError(0xdeadbeef);
+    ret = pAddFontResourceExA(fot_name, 0, 0);
+    ok(ret, "AddFontResourceEx() error %d\n", GetLastError());
+
+    ret = is_truetype_font_installed("wine_test");
+    ok(ret, "font wine_test should be enumerated\n");
+
+    ret = pRemoveFontResourceExA(fot_name, FR_PRIVATE, 0);
+    ok(!ret, "RemoveFontResourceEx() with not matching flags should fail\n");
+
+    SetLastError(0xdeadbeef);
+    ret = pRemoveFontResourceExA(fot_name, 0, 0);
+todo_wine
+    ok(ret, "RemoveFontResourceEx() error %d\n", GetLastError());
+
+    ret = is_truetype_font_installed("wine_test");
+todo_wine
+    ok(!ret, "font wine_test should not be enumerated\n");
+
+    /* FIXME: since RemoveFontResource is a stub correct testing is impossible */
+    if (ret)
+    {
+        /* remove once RemoveFontResource is implemented */
+        DeleteFile(fot_name);
+        DeleteFile(ttf_name);
+        return;
+    }
+
+    ret = pRemoveFontResourceExA(fot_name, 0, 0);
+    ok(!ret, "RemoveFontResourceEx() should fail\n");
+
+    DeleteFile(fot_name);
+
+    /* test hidden font resource */
+    SetLastError(0xdeadbeef);
+    ret = CreateScalableFontResource(1, fot_name, ttf_name, NULL);
+    ok(ret, "CreateScalableFontResource() error %d\n", GetLastError());
+
+    ret = is_truetype_font_installed("wine_test");
+    ok(!ret, "font wine_test should not be enumerated\n");
+
+    SetLastError(0xdeadbeef);
+    ret = pAddFontResourceExA(fot_name, 0, 0);
+    ok(ret, "AddFontResourceEx() error %d\n", GetLastError());
+
+    ret = is_truetype_font_installed("wine_test");
+    ok(!ret, "font wine_test should not be enumerated\n");
+
+    /* XP allows removing a private font added with 0 flags */
+    SetLastError(0xdeadbeef);
+    ret = pRemoveFontResourceExA(fot_name, FR_PRIVATE, 0);
+    ok(ret, "RemoveFontResourceEx() error %d\n", GetLastError());
+
+    ret = is_truetype_font_installed("wine_test");
+    ok(!ret, "font wine_test should not be enumerated\n");
+
+    ret = pRemoveFontResourceExA(fot_name, 0, 0);
+    ok(!ret, "RemoveFontResourceEx() should fail\n");
+
+    DeleteFile(fot_name);
+    DeleteFile(ttf_name);
+}
+
 START_TEST(font)
 {
     init();
@@ -3851,4 +4039,9 @@ START_TEST(font)
     test_CreateFontIndirectEx();
     test_oemcharset();
     test_fullname();
+
+    /* CreateScalableFontResource should be last test until RemoveFontResource
+     * is properly implemented.
+     */
+    test_CreateScalableFontResource();
 }
diff --git a/dlls/gdi32/tests/resource.rc b/dlls/gdi32/tests/resource.rc
new file mode 100644
index 0000000..f172b80
--- /dev/null
+++ b/dlls/gdi32/tests/resource.rc
@@ -0,0 +1,24 @@
+/*
+ * Resources for gdi32 test suite.
+ *
+ * Copyright 2010 Dmitry Timoshkov
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "windef.h"
+
+/* @makedep: wine_test.ttf */
+wine_test.ttf RCDATA wine_test.ttf
diff --git a/dlls/gdi32/tests/wine_test.sfd b/dlls/gdi32/tests/wine_test.sfd
new file mode 100644
index 0000000..64c4497
--- /dev/null
+++ b/dlls/gdi32/tests/wine_test.sfd
@@ -0,0 +1,180 @@
+SplineFontDB: 3.0
+FontName: wine_test
+FullName: wine_test
+FamilyName: wine_test
+Weight: Medium
+Copyright: Copyright (c) 2010 Dmitry Timoshkov
+Version: 001.000
+ItalicAngle: 0
+UnderlinePosition: -205
+UnderlineWidth: 102
+Ascent: 1638
+Descent: 410
+sfntRevision: 0x00010000
+LayerCount: 2
+Layer: 0 1 "Back"  1
+Layer: 1 1 "Fore"  0
+XUID: [1021 905 592216984 1247726]
+FSType: 0
+OS2Version: 2
+OS2_WeightWidthSlopeOnly: 0
+OS2_UseTypoMetrics: 1
+CreationTime: 1288336343
+ModificationTime: 1288336873
+PfmFamily: 17
+TTFWeight: 500
+TTFWidth: 5
+LineGap: 184
+VLineGap: 0
+Panose: 2 0 6 3 0 0 0 0 0 0
+OS2TypoAscent: 0
+OS2TypoAOffset: 1
+OS2TypoDescent: 0
+OS2TypoDOffset: 1
+OS2TypoLinegap: 184
+OS2WinAscent: 0
+OS2WinAOffset: 1
+OS2WinDescent: 0
+OS2WinDOffset: 1
+HheadAscent: 0
+HheadAOffset: 1
+HheadDescent: 0
+HheadDOffset: 1
+OS2SubXSize: 1331
+OS2SubYSize: 1433
+OS2SubXOff: 0
+OS2SubYOff: 286
+OS2SupXSize: 1331
+OS2SupYSize: 1433
+OS2SupXOff: 0
+OS2SupYOff: 983
+OS2StrikeYSize: 102
+OS2StrikeYPos: 530
+OS2Vendor: 'Wine'
+OS2CodePages: 00000001.00000000
+OS2UnicodeRanges: 00000001.00000000.00000000.00000000
+MarkAttachClasses: 1
+DEI: 91125
+ShortTable: cvt  2
+  68
+  1297
+EndShort
+ShortTable: maxp 16
+  1
+  0
+  4
+  8
+  2
+  0
+  0
+  2
+  0
+  1
+  1
+  0
+  64
+  46
+  0
+  0
+EndShort
+LangName: 1033 "" "" "" "Wine : wine_test : 4-11-2010" 
+GaspTable: 1 65535 2
+Encoding: UnicodeBmp
+UnicodeInterp: none
+NameList: Adobe Glyph List
+DisplaySize: -24
+AntiAlias: 1
+FitToEm: 1
+WinInfo: 65 65 19
+BeginChars: 65539 4
+
+StartChar: .notdef
+Encoding: 65536 -1 0
+Width: 748
+Flags: W
+TtInstrs:
+PUSHB_2
+ 1
+ 0
+MDAP[rnd]
+ALIGNRP
+PUSHB_3
+ 7
+ 4
+ 0
+MIRP[min,rnd,black]
+SHP[rp2]
+PUSHB_2
+ 6
+ 5
+MDRP[rp0,min,rnd,grey]
+ALIGNRP
+PUSHB_3
+ 3
+ 2
+ 0
+MIRP[min,rnd,black]
+SHP[rp2]
+SVTCA[y-axis]
+PUSHB_2
+ 3
+ 0
+MDAP[rnd]
+ALIGNRP
+PUSHB_3
+ 5
+ 4
+ 0
+MIRP[min,rnd,black]
+SHP[rp2]
+PUSHB_3
+ 7
+ 6
+ 1
+MIRP[rp0,min,rnd,grey]
+ALIGNRP
+PUSHB_3
+ 1
+ 2
+ 0
+MIRP[min,rnd,black]
+SHP[rp2]
+EndTTInstrs
+LayerCount: 2
+Fore
+SplineSet
+68 0 m 1,0,-1
+ 68 1365 l 1,1,-1
+ 612 1365 l 1,2,-1
+ 612 0 l 1,3,-1
+ 68 0 l 1,0,-1
+136 68 m 1,4,-1
+ 544 68 l 1,5,-1
+ 544 1297 l 1,6,-1
+ 136 1297 l 1,7,-1
+ 136 68 l 1,4,-1
+EndSplineSet
+EndChar
+
+StartChar: .null
+Encoding: 65537 -1 1
+Width: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: nonmarkingreturn
+Encoding: 65538 -1 2
+Width: 682
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: exclam
+Encoding: 33 33 3
+Width: 0
+Flags: W
+LayerCount: 2
+EndChar
+EndChars
+EndSplineFont
diff --git a/dlls/gdi32/tests/wine_test.ttf b/dlls/gdi32/tests/wine_test.ttf
new file mode 100644
index 0000000000000000000000000000000000000000..12dfe88dae541c3585231aac6786602817e31e58
GIT binary patch
literal 1544
zcmds1%S%*I82_F77+;~O(MseFnW^}=GfDKAh2*4e#6`ZMg%0y at E;$couI21ngbUk;
zL0~(fAaWMr9}wiCDB4sI8LbtfHx=6N+&MD_F4}i4=YGHM_dU*czjMxo08o$X&@nqS
zG(LLi-LJcVxlOiZIDBCU4QQqQlzQvf#lGOp at 6GQ4k)%EwO+~V3(4SL(&3Qh0)wK{d
z8v(tAc4ID*&+hFpGt9 at -tLNqmi4%8TuF>92eL5MB#6CY-{X{I+JC!6+ogZVoXrtbi
zOu38ZErh9WQa?POiAFHZ2f9VQHWgXSVgzSsAE9ogBdK_CYq_2F8-UiF&E(y^I<QuA
zh4wDUZ{^(l+IMcIA at mh>)g-9@=z39+TuqCa6V$7rNtS~#9<#Bw1gtG-F)vfeR(cyA
zV^m^fr0}=_^m;DZ+LHJJlbKGMw`puGN&OWPS`*iVk9|@@)>#=-PCAYO_~G{@b`#j}
zD)DNnxL6R{w(Jx0+^euMpPVhK+7LCFxdjF+N`sHo{oEt(z4t+RLiqL<5b|5fognmv
zjN7kQk^i0W&N8~yBfC&O9XhJeyDrcdDpncT39kFhx1pl05n^4Jv?=Lgl~4Q*71_d_
z;K at dR<8gnZKdf21ZDM6NX- at pSA2yzOU8~1~a_ at 1BXIl1GZb1#ME6f9e6 at _)~;Twew
z)QDPzO&k`d6!ww7EO*?fVWuI at 5*BE}yuum|VOe1vr?INAL7#65o3O+Yg?(re!x%&c
zSrm|igE`(Vm#3)%QFKxUVI#oF{{T|7yYwnh8z)XNE>Hg}lvjblOtz47=8~?}5$&{s
zcEGm6DaXwftZ^rm$tSO5=yZ*7X~Z$ZOmRlLq<9}@+<2aFlw6D+3(Sqtc+6R#oKhhc
z&T`>{2}*oFdRS<H?{dkI7tK0rRq_+}_XGkxvb29yGRaDEtk2=MrMax_^`Y03vKyF;
z=kiV_ZP|99*S2jk2P^yg)5<rFS2MxAJ2(tdf?iS*@eXTh=jH$WC^=~<{fDGyX?XI<
Q?!zsqZhmZ=D#>=|57Fe#DF6Tf

literal 0
HcmV?d00001

-- 
1.7.5.1




More information about the wine-patches mailing list