2 * PROJECT: ReactOS API tests
3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Test for EnumFontFamilies[Ex]
5 * PROGRAMMERS: Thomas Faber <thomas.faber@reactos.org>
15 static BYTE ContextContinue
;
16 static BYTE ContextStop
;
18 static int EnumProcCalls
;
19 static ENUMLOGFONTA LastFontA
;
20 static ENUMLOGFONTW LastFontW
;
22 typedef int WRAP_ENUM_FONT_FAMILIES(_In_ HDC
, _In_ PCWSTR
, _In_ PVOID
, _In_ LPARAM
);
23 typedef WRAP_ENUM_FONT_FAMILIES
*PWRAP_ENUM_FONT_FAMILIES
;
27 WrapEnumFontFamiliesA(
34 WideCharToMultiByte(CP_ACP
, 0, Family
, -1, FamilyA
, sizeof(FamilyA
), NULL
, NULL
);
35 return EnumFontFamiliesA(hdc
, FamilyA
, EnumProc
, lParam
);
40 WrapEnumFontFamiliesW(
46 return EnumFontFamiliesW(hdc
, Family
, EnumProc
, lParam
);
51 WrapEnumFontFamiliesExA(
59 ZeroMemory(&lf
, sizeof(lf
));
60 lf
.lfCharSet
= DEFAULT_CHARSET
;
61 lf
.lfPitchAndFamily
= 0;
62 WideCharToMultiByte(CP_ACP
, 0, Family
, -1, lf
.lfFaceName
, sizeof(lf
.lfFaceName
), NULL
, NULL
);
63 return EnumFontFamiliesExA(hdc
, &lf
, EnumProc
, lParam
, 0);
68 WrapEnumFontFamiliesExW(
76 ZeroMemory(&lf
, sizeof(lf
));
77 lf
.lfCharSet
= DEFAULT_CHARSET
;
78 lf
.lfPitchAndFamily
= 0;
79 StringCbCopyW(lf
.lfFaceName
, sizeof(lf
.lfFaceName
), Family
);
80 return EnumFontFamiliesExW(hdc
, &lf
, EnumProc
, lParam
, 0);
87 _In_
const LOGFONTA
*elf
,
88 _In_
const TEXTMETRICA
*ntm
,
94 ok(lParam
== (LPARAM
)&ContextContinue
||
95 lParam
== (LPARAM
)&ContextStop
,
96 "Context is %p, expected %p or %p\n",
97 (PVOID
)lParam
, &ContextContinue
, &ContextStop
);
99 LastFontA
= *(ENUMLOGFONTA
*)elf
;
100 return lParam
== (LPARAM
)&ContextContinue
? 7 : 0;
107 _In_
const LOGFONTW
*elf
,
108 _In_
const TEXTMETRICW
*ntm
,
114 ok(lParam
== (LPARAM
)&ContextContinue
||
115 lParam
== (LPARAM
)&ContextStop
,
116 "Context is %p, expected %p or %p\n",
117 (PVOID
)lParam
, &ContextContinue
, &ContextStop
);
119 LastFontW
= *(ENUMLOGFONTW
*)elf
;
120 return lParam
== (LPARAM
)&ContextContinue
? 7 : 0;
125 TestEnumFontFamilies(
127 _In_ PCWSTR FontName
,
128 _In_ BOOLEAN ExpectToFind
)
132 PWRAP_ENUM_FONT_FAMILIES Wrapper
;
135 } *fun
, functions
[] =
137 { WrapEnumFontFamiliesA
, "EnumFontFamiliesA", FALSE
},
138 { WrapEnumFontFamiliesW
, "EnumFontFamiliesW", TRUE
},
139 { WrapEnumFontFamiliesExA
, "EnumFontFamiliesExA", FALSE
},
140 { WrapEnumFontFamiliesExW
, "EnumFontFamiliesExW", TRUE
},
148 { &ContextContinue
, "Continue" },
149 { &ContextStop
, "Stop" },
156 for (iContext
= 0; iContext
< _countof(contexts
); iContext
++)
158 ctx
= &contexts
[iContext
];
159 for (iFunction
= 0; iFunction
< _countof(functions
); iFunction
++)
161 fun
= &functions
[iFunction
];
163 SetLastError(0xdeadbeef);
164 ret
= fun
->Wrapper(hdc
,
166 fun
->Wide
? (PVOID
)EnumProcW
: (PVOID
)EnumProcA
,
167 (LPARAM
)ctx
->Context
);
168 error
= GetLastError();
169 ok(error
== 0xdeadbeef, "[%s, %s, '%ls'] error is %lu\n", fun
->Name
, ctx
->Description
, FontName
, error
);
172 if (ctx
->Context
== &ContextContinue
)
174 ok(ret
== 7, "[%s, %s, '%ls'] ret is %d, expected 7\n", fun
->Name
, ctx
->Description
, FontName
, ret
);
175 ok(EnumProcCalls
>= 1, "[%s, %s, '%ls'] EnumProcCalls is %d\n", fun
->Name
, ctx
->Description
, FontName
, EnumProcCalls
);
179 ok(ret
== 0, "[%s, %s, '%ls'] ret is %d, expected 0\n", fun
->Name
, ctx
->Description
, FontName
, ret
);
180 ok(EnumProcCalls
== 1, "[%s, %s, '%ls'] EnumProcCalls is %d\n", fun
->Name
, ctx
->Description
, FontName
, EnumProcCalls
);
185 ok(ret
== 1, "[%s, %s, '%ls'] ret is %d, expected 1\n", fun
->Name
, ctx
->Description
, FontName
, ret
);
186 ok(EnumProcCalls
== 0, "[%s, %s, '%ls'] EnumProcCalls is %d\n", fun
->Name
, ctx
->Description
, FontName
, EnumProcCalls
);
192 START_TEST(EnumFontFamilies
)
196 hdc
= CreateCompatibleDC(NULL
);
203 TestEnumFontFamilies(hdc
, L
"ThisFontDoesNotExist", FALSE
);
204 /* Basic fonts that should be installed */
205 TestEnumFontFamilies(hdc
, L
"MS Sans Serif", TRUE
);
206 TestEnumFontFamilies(hdc
, L
"Tahoma", TRUE
);
207 TestEnumFontFamilies(hdc
, L
"System", TRUE
);
208 /* Show case insensitivity */
209 TestEnumFontFamilies(hdc
, L
"tahOmA", TRUE
);
210 /* Special fonts that we have a hack for in win32k ;) */
211 TestEnumFontFamilies(hdc
, L
"Marlett", TRUE
);
212 TestEnumFontFamilies(hdc
, L
"Symbol", TRUE
);
213 TestEnumFontFamilies(hdc
, L
"VGA", FALSE
);