Author: tfaber
Date: Wed Feb 18 13:18:30 2015
New Revision: 66347
URL:
http://svn.reactos.org/svn/reactos?rev=66347&view=rev
Log:
[GDI32_APITEST]
- Refactor EnumFontFamilies test to be more generic, and check for some common expected
system fonts. This shows that EnumFontFamilies behaves correctly, but that we're
missing the System font in the enumeration.
CORE-9222
Modified:
trunk/rostests/apitests/gdi32/EnumFontFamilies.c
Modified: trunk/rostests/apitests/gdi32/EnumFontFamilies.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/EnumFontFa…
==============================================================================
--- trunk/rostests/apitests/gdi32/EnumFontFamilies.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32/EnumFontFamilies.c [iso-8859-1] Wed Feb 18 13:18:30
2015
@@ -7,6 +7,7 @@
#include <apitest.h>
+#include <winnls.h>
#include <wingdi.h>
#include <winddi.h>
#include <strsafe.h>
@@ -17,6 +18,67 @@
static int EnumProcCalls;
static ENUMLOGFONTA LastFontA;
static ENUMLOGFONTW LastFontW;
+
+typedef int WRAP_ENUM_FONT_FAMILIES(_In_ HDC, _In_ PCWSTR, _In_ PVOID, _In_ LPARAM);
+typedef WRAP_ENUM_FONT_FAMILIES *PWRAP_ENUM_FONT_FAMILIES;
+
+static
+int
+WrapEnumFontFamiliesA(
+ _In_ HDC hdc,
+ _In_ PCWSTR Family,
+ _In_ PVOID EnumProc,
+ _In_ LPARAM lParam)
+{
+ char FamilyA[100];
+ WideCharToMultiByte(CP_ACP, 0, Family, -1, FamilyA, sizeof(FamilyA), NULL, NULL);
+ return EnumFontFamiliesA(hdc, FamilyA, EnumProc, lParam);
+}
+
+static
+int
+WrapEnumFontFamiliesW(
+ _In_ HDC hdc,
+ _In_ PCWSTR Family,
+ _In_ PVOID EnumProc,
+ _In_ LPARAM lParam)
+{
+ return EnumFontFamiliesW(hdc, Family, EnumProc, lParam);
+}
+
+static
+int
+WrapEnumFontFamiliesExA(
+ _In_ HDC hdc,
+ _In_ PCWSTR Family,
+ _In_ PVOID EnumProc,
+ _In_ LPARAM lParam)
+{
+ LOGFONTA lf;
+
+ ZeroMemory(&lf, sizeof(lf));
+ lf.lfCharSet = DEFAULT_CHARSET;
+ lf.lfPitchAndFamily = 0;
+ WideCharToMultiByte(CP_ACP, 0, Family, -1, lf.lfFaceName, sizeof(lf.lfFaceName),
NULL, NULL);
+ return EnumFontFamiliesExA(hdc, &lf, EnumProc, lParam, 0);
+}
+
+static
+int
+WrapEnumFontFamiliesExW(
+ _In_ HDC hdc,
+ _In_ PCWSTR Family,
+ _In_ PVOID EnumProc,
+ _In_ LPARAM lParam)
+{
+ LOGFONTW lf;
+
+ ZeroMemory(&lf, sizeof(lf));
+ lf.lfCharSet = DEFAULT_CHARSET;
+ lf.lfPitchAndFamily = 0;
+ StringCbCopyW(lf.lfFaceName, sizeof(lf.lfFaceName), Family);
+ return EnumFontFamiliesExW(hdc, &lf, EnumProc, lParam, 0);
+}
static
int
@@ -60,98 +122,71 @@
static
void
-TestEnumFontFamiliesA(
- _In_ HDC hdc,
- _In_ PCSTR FontName)
-{
+TestEnumFontFamilies(
+ _In_ HDC hdc,
+ _In_ PCWSTR FontName,
+ _In_ BOOLEAN ExpectToFind)
+{
+ const struct
+ {
+ PWRAP_ENUM_FONT_FAMILIES Wrapper;
+ PCSTR Name;
+ BOOLEAN Wide;
+ } *fun, functions[] =
+ {
+ { WrapEnumFontFamiliesA, "EnumFontFamiliesA", FALSE },
+ { WrapEnumFontFamiliesW, "EnumFontFamiliesW", TRUE },
+ { WrapEnumFontFamiliesExA, "EnumFontFamiliesExA", FALSE },
+ { WrapEnumFontFamiliesExW, "EnumFontFamiliesExW", TRUE },
+ };
+ const struct
+ {
+ PVOID Context;
+ PCSTR Description;
+ } *ctx, contexts[] =
+ {
+ { &ContextContinue, "Continue" },
+ { &ContextStop, "Stop" },
+ };
int ret;
DWORD error;
-
- EnumProcCalls = 0;
- SetLastError(0xdeadbeef);
- ret = EnumFontFamiliesA(hdc,
- FontName,
- EnumProcA,
- (LPARAM)&ContextContinue);
- error = GetLastError();
- ok(ret == 1, "ret is %d, expected 1\n", ret);
- ok(error == 0xdeadbeef, "error is %lu\n", error);
- ok(EnumProcCalls == 0, "EnumProcCalls is %d\n", EnumProcCalls);
-}
-
-static
-void
-TestEnumFontFamiliesW(
- _In_ HDC hdc,
- _In_ PCWSTR FontName)
-{
- int ret;
- DWORD error;
-
- EnumProcCalls = 0;
- SetLastError(0xdeadbeef);
- ret = EnumFontFamiliesW(hdc,
- FontName,
- EnumProcW,
- (LPARAM)&ContextContinue);
- error = GetLastError();
- ok(ret == 1, "ret is %d, expected 1\n", ret);
- ok(error == 0xdeadbeef, "error is %lu\n", error);
- ok(EnumProcCalls == 0, "EnumProcCalls is %d\n", EnumProcCalls);
-}
-
-static
-void
-TestEnumFontFamiliesExA(
- _In_ HDC hdc,
- _In_ PCSTR FontName)
-{
- int ret;
- DWORD error;
- LOGFONTA lf;
-
- EnumProcCalls = 0;
- ZeroMemory(&lf, sizeof(lf));
- lf.lfCharSet = DEFAULT_CHARSET;
- lf.lfPitchAndFamily = 0;
- StringCbCopyA(lf.lfFaceName, sizeof(lf.lfFaceName), FontName);
- SetLastError(0xdeadbeef);
- ret = EnumFontFamiliesExA(hdc,
- &lf,
- EnumProcA,
- (LPARAM)&ContextContinue,
- 0);
- error = GetLastError();
- ok(ret == 1, "ret is %d, expected 1\n", ret);
- ok(error == 0xdeadbeef, "error is %lu\n", error);
- ok(EnumProcCalls == 0, "EnumProcCalls is %d\n", EnumProcCalls);
-}
-
-static
-void
-TestEnumFontFamiliesExW(
- _In_ HDC hdc,
- _In_ PCWSTR FontName)
-{
- int ret;
- DWORD error;
- LOGFONTW lf;
-
- EnumProcCalls = 0;
- ZeroMemory(&lf, sizeof(lf));
- lf.lfCharSet = DEFAULT_CHARSET;
- lf.lfPitchAndFamily = 0;
- StringCbCopyW(lf.lfFaceName, sizeof(lf.lfFaceName), FontName);
- SetLastError(0xdeadbeef);
- ret = EnumFontFamiliesExW(hdc,
- &lf,
- EnumProcW,
- (LPARAM)&ContextContinue,
- 0);
- error = GetLastError();
- ok(ret == 1, "ret is %d, expected 1\n", ret);
- ok(error == 0xdeadbeef, "error is %lu\n", error);
- ok(EnumProcCalls == 0, "EnumProcCalls is %d\n", EnumProcCalls);
+ unsigned iFunction;
+ unsigned iContext;
+
+ for (iContext = 0; iContext < _countof(contexts); iContext++)
+ {
+ ctx = &contexts[iContext];
+ for (iFunction = 0; iFunction < _countof(functions); iFunction++)
+ {
+ fun = &functions[iFunction];
+ EnumProcCalls = 0;
+ SetLastError(0xdeadbeef);
+ ret = fun->Wrapper(hdc,
+ FontName,
+ fun->Wide ? (PVOID)EnumProcW : (PVOID)EnumProcA,
+ (LPARAM)ctx->Context);
+ error = GetLastError();
+ ok(error == 0xdeadbeef, "[%s, %s, '%ls'] error is %lu\n",
fun->Name, ctx->Description, FontName, error);
+ if (ExpectToFind)
+ {
+ if (ctx->Context == &ContextContinue)
+ {
+ ok(ret == 7, "[%s, %s, '%ls'] ret is %d, expected
7\n", fun->Name, ctx->Description, FontName, ret);
+ ok(EnumProcCalls >= 1, "[%s, %s, '%ls'] EnumProcCalls
is %d\n", fun->Name, ctx->Description, FontName, EnumProcCalls);
+ }
+ else
+ {
+ ok(ret == 0, "[%s, %s, '%ls'] ret is %d, expected
0\n", fun->Name, ctx->Description, FontName, ret);
+ ok(EnumProcCalls == 1, "[%s, %s, '%ls'] EnumProcCalls is
%d\n", fun->Name, ctx->Description, FontName, EnumProcCalls);
+ }
+ }
+ else
+ {
+ ok(ret == 1, "[%s, %s, '%ls'] ret is %d, expected 1\n",
fun->Name, ctx->Description, FontName, ret);
+ ok(EnumProcCalls == 0, "[%s, %s, '%ls'] EnumProcCalls is
%d\n", fun->Name, ctx->Description, FontName, EnumProcCalls);
+ }
+ }
+ }
}
START_TEST(EnumFontFamilies)
@@ -165,10 +200,17 @@
return;
}
- TestEnumFontFamiliesA(hdc, "ThisFontDoesNotExist");
- TestEnumFontFamiliesW(hdc, L"ThisFontDoesNotExist");
- TestEnumFontFamiliesExA(hdc, "ThisFontDoesNotExist");
- TestEnumFontFamiliesExW(hdc, L"ThisFontDoesNotExist");
+ TestEnumFontFamilies(hdc, L"ThisFontDoesNotExist", FALSE);
+ /* Basic fonts that should be installed */
+ TestEnumFontFamilies(hdc, L"MS Sans Serif", TRUE);
+ TestEnumFontFamilies(hdc, L"Tahoma", TRUE);
+ TestEnumFontFamilies(hdc, L"System", TRUE);
+ /* Show case insensitivity */
+ TestEnumFontFamilies(hdc, L"tahOmA", TRUE);
+ /* Special fonts that we have a hack for in win32k ;) */
+ TestEnumFontFamilies(hdc, L"Marlett", TRUE);
+ TestEnumFontFamilies(hdc, L"Symbol", TRUE);
+ TestEnumFontFamilies(hdc, L"VGA", FALSE);
DeleteDC(hdc);
}