Author: mjansen
Date: Sat Apr 8 22:25:54 2017
New Revision: 74287
URL:
http://svn.reactos.org/svn/reactos?rev=74287&view=rev
Log:
[GDI32_APITEST] Add test for AddFontMemResourceEx. Uses PanosePitchTest.ttf from Katayama
Hirofumi MZ. CORE-13046 CORE-13038 CORE-13053
Added:
trunk/rostests/apitests/gdi32/AddFontMemResourceEx.c (with props)
trunk/rostests/apitests/gdi32/PanosePitchTest.ttf (with props)
Modified:
trunk/rostests/apitests/gdi32/CMakeLists.txt
trunk/rostests/apitests/gdi32/resource.rc
trunk/rostests/apitests/gdi32/testlist.c
Added: trunk/rostests/apitests/gdi32/AddFontMemResourceEx.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/AddFontMem…
==============================================================================
--- trunk/rostests/apitests/gdi32/AddFontMemResourceEx.c (added)
+++ trunk/rostests/apitests/gdi32/AddFontMemResourceEx.c [iso-8859-1] Sat Apr 8 22:25:54
2017
@@ -0,0 +1,191 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: GPL - See COPYING in the top level directory
+ * PURPOSE: Test for AddFontMemResourceEx
+ * PROGRAMMERS: Mark Jansen
+ *
+ * PanosePitchTest by Katayama Hirofumi MZ, licensed under CC BY
+ */
+
+
+#include <apitest.h>
+#include <wingdi.h>
+#include <winuser.h>
+
+
+static void test_font_caps(HDC hdc)
+{
+ HGDIOBJ old;
+ TEXTMETRICA tm = { 0 };
+ char name[64];
+ BOOL ret;
+ HFONT font = CreateFont(0, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE,
DEFAULT_CHARSET,
+ OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH, TEXT("PanosePitchTest"));
+
+ if (font)
+ {
+ old = SelectObject(hdc, font);
+
+ memset(&tm, 0xaa, sizeof(tm));
+ ret = GetTextMetricsA(hdc, &tm);
+ ok_int(ret, TRUE);
+
+ SetLastError(0xdeadbeef);
+ ret = GetTextFaceA(hdc, sizeof(name), name);
+ ok(ret, "GetTextFaceA error %lu\n", GetLastError());
+ if (ret)
+ {
+ ok_str(name, "PanosePitchTest");
+ }
+
+ ok_int(tm.tmHeight, 11);
+ ok_int(tm.tmAscent, 11);
+ ok_int(tm.tmDescent, 0);
+ ok_int(tm.tmInternalLeading, -5);
+ ok_int(tm.tmExternalLeading, 1);
+ ok_int(tm.tmAveCharWidth, 8);
+ ok_int(tm.tmMaxCharWidth, 11);
+ ok_int(tm.tmWeight, FW_NORMAL);
+ ok_int(tm.tmOverhang, 0);
+ ok_int(tm.tmDigitizedAspectX, 96);
+ ok_int(tm.tmDigitizedAspectY, 96);
+ ok_int(tm.tmFirstChar, 63);
+ ok_int(tm.tmLastChar, 65);
+ ok_int(tm.tmDefaultChar, 165);
+ ok_int(tm.tmBreakChar, 65);
+ ok_int(tm.tmItalic, 0);
+ ok_int(tm.tmUnderlined, 0);
+ ok_int(tm.tmStruckOut, 0);
+ ok_hex(tm.tmPitchAndFamily, TMPF_TRUETYPE | TMPF_VECTOR);
+ ok_int(tm.tmCharSet, SHIFTJIS_CHARSET);
+
+ SelectObject(hdc, old);
+ DeleteObject(font);
+ }
+
+ font = CreateFont(0, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
+ OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH, TEXT("@PanosePitchTest"));
+
+ if (font)
+ {
+ old = SelectObject(hdc, font);
+
+ memset(&tm, 0xaa, sizeof(tm));
+ ret = GetTextMetricsA(hdc, &tm);
+ ok_int(ret, TRUE);
+
+ SetLastError(0xdeadbeef);
+ ret = GetTextFaceA(hdc, sizeof(name), name);
+ ok(ret, "GetTextFaceA error %lu\n", GetLastError());
+ if (ret)
+ {
+ ok_str(name, "@PanosePitchTest");
+ }
+
+ ok_int(tm.tmHeight, 11);
+ ok_int(tm.tmAscent, 11);
+ ok_int(tm.tmDescent, 0);
+ ok_int(tm.tmInternalLeading, -5);
+ ok_int(tm.tmExternalLeading, 1);
+ ok_int(tm.tmAveCharWidth, 8);
+ ok_int(tm.tmMaxCharWidth, 11);
+ ok_int(tm.tmWeight, FW_NORMAL);
+ ok_int(tm.tmOverhang, 0);
+ ok_int(tm.tmDigitizedAspectX, 96);
+ ok_int(tm.tmDigitizedAspectY, 96);
+ ok_int(tm.tmFirstChar, 63);
+ ok_int(tm.tmLastChar, 65);
+ ok_int(tm.tmDefaultChar, 165);
+ ok_int(tm.tmBreakChar, 65);
+ ok_int(tm.tmItalic, 0);
+ ok_int(tm.tmUnderlined, 0);
+ ok_int(tm.tmStruckOut, 0);
+ ok_hex(tm.tmPitchAndFamily, TMPF_TRUETYPE | TMPF_VECTOR);
+ ok_int(tm.tmCharSet, SHIFTJIS_CHARSET);
+
+ SelectObject(hdc, old);
+ DeleteObject(font);
+ }
+}
+
+/* Not working as of 2017-04-08 on ReactOS */
+static BOOL is_font_available(HDC hdc, const char* fontName)
+{
+ char name[64];
+ BOOL ret;
+
+ HFONT font = CreateFontA(0, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE,
DEFAULT_CHARSET,
+ OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH, fontName);
+ HGDIOBJ old = SelectObject(hdc, font);
+
+
+ SetLastError(0xdeadbeef);
+
+ ret = GetTextFaceA(hdc, sizeof(name), name);
+ ok(ret, "GetTextFaceA error %lu\n", GetLastError());
+ SelectObject(hdc, old);
+ DeleteObject(font);
+
+ if (ret)
+ {
+ return !_strcmpi(name, fontName);
+ }
+ return FALSE;
+}
+
+
+
+START_TEST(AddFontMemResourceEx)
+{
+ HMODULE mod;
+ HRSRC hRsrc;
+
+ HGLOBAL hTemplate;
+ DWORD dwSize, dwNumFonts;
+ LPVOID pFont;
+
+ HANDLE hFont;
+
+ HDC hdc = CreateCompatibleDC(NULL);
+ BOOL is_font_available_broken = is_font_available(hdc, "Nonexisting font name
here");
+
+ ok(!is_font_available_broken, "Validating font is broken! (CORE-13053)
!\n");
+
+ if (is_font_available_broken || !is_font_available(hdc,
"PanosePitchTest"))
+ {
+ mod = GetModuleHandle(NULL);
+ hRsrc = FindResource(mod, TEXT("PanosePitchTest.ttf"),
MAKEINTRESOURCE(RT_RCDATA));
+
+ hTemplate = LoadResource(mod, hRsrc);
+ dwSize = SizeofResource(mod, hRsrc);
+ pFont = LockResource(hTemplate);
+
+ dwNumFonts = 0;
+ hFont = AddFontMemResourceEx(pFont, dwSize, NULL, &dwNumFonts);
+ ok_int(dwNumFonts, 2);
+ ok(hFont != NULL, "Expected valid handle\n");
+
+ if (hFont)
+ {
+ test_font_caps(hdc);
+ RemoveFontMemResourceEx(hFont);
+ if (!is_font_available_broken)
+ {
+ ok (!is_font_available(hdc, "PanosePitchTest"), "Expected
font to be unregistered again\n");
+ }
+ else
+ {
+ skip("Font unregister test\n");
+ }
+ }
+
+ UnlockResource(hTemplate);
+ FreeResource(hTemplate);
+ }
+ else
+ {
+ skip("Font PanosePitchTest already available\n");
+ }
+ DeleteDC(hdc);
+}
+
Propchange: trunk/rostests/apitests/gdi32/AddFontMemResourceEx.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/rostests/apitests/gdi32/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/CMakeLists…
==============================================================================
--- trunk/rostests/apitests/gdi32/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32/CMakeLists.txt [iso-8859-1] Sat Apr 8 22:25:54 2017
@@ -2,6 +2,7 @@
include_directories(${REACTOS_SOURCE_DIR}/win32ss)
list(APPEND SOURCE
+ AddFontMemResourceEx.c
AddFontResource.c
AddFontResourceEx.c
BeginPath.c
Added: trunk/rostests/apitests/gdi32/PanosePitchTest.ttf
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/PanosePitc…
==============================================================================
Binary file - no diff available.
Propchange: trunk/rostests/apitests/gdi32/PanosePitchTest.ttf
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: trunk/rostests/apitests/gdi32/resource.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/resource.r…
==============================================================================
--- trunk/rostests/apitests/gdi32/resource.rc [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32/resource.rc [iso-8859-1] Sat Apr 8 22:25:54 2017
@@ -1,3 +1,4 @@
#include "windef.h"
ReactOSTestTahoma.ttf RCDATA ReactOSTestTahoma.ttf
+PanosePitchTest.ttf RCDATA PanosePitchTest.ttf
Modified: trunk/rostests/apitests/gdi32/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/testlist.c…
==============================================================================
--- trunk/rostests/apitests/gdi32/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32/testlist.c [iso-8859-1] Sat Apr 8 22:25:54 2017
@@ -3,6 +3,7 @@
#define STANDALONE
#include <apitest.h>
+extern void func_AddFontMemResourceEx(void);
extern void func_AddFontResource(void);
extern void func_AddFontResourceEx(void);
extern void func_BeginPath(void);
@@ -75,6 +76,7 @@
const struct test winetest_testlist[] =
{
+ { "AddFontMemResourceEx", func_AddFontMemResourceEx },
{ "AddFontResource", func_AddFontResource },
{ "AddFontResourceEx", func_AddFontResourceEx },
{ "BeginPath", func_BeginPath },