Author: tfaber
Date: Sat Apr 25 10:41:32 2015
New Revision: 67391
URL:
http://svn.reactos.org/svn/reactos?rev=67391&view=rev
Log:
[GDI32_APITEST]
- Add a test for NtGdiAddFontResourceW. This goes in gdi32_apitest until we fix w32knapi
to be Testman-compatible (ROSTESTS-167). Patch by Víctor Martínez Calvo.
ROSTESTS-166 #resolve
Added:
trunk/rostests/apitests/gdi32/NtGdiAddFontResource.c (with props)
Modified:
trunk/rostests/apitests/gdi32/CMakeLists.txt
trunk/rostests/apitests/gdi32/testlist.c
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 25 10:41:32 2015
@@ -51,6 +51,7 @@
GetTextExtentExPoint.c
GetTextFace.c
MaskBlt.c
+ NtGdiAddFontResource.c
OffsetClipRgn.c
OffsetRgn.c
PaintRgn.c
@@ -71,7 +72,7 @@
testlist.c)
add_executable(gdi32_apitest ${SOURCE})
-target_link_libraries(gdi32_apitest ${PSEH_LIB})
+target_link_libraries(gdi32_apitest ${PSEH_LIB} win32ksys)
set_module_type(gdi32_apitest win32cui)
-add_importlibs(gdi32_apitest gdi32 user32 msvcrt kernel32)
+add_importlibs(gdi32_apitest gdi32 user32 msvcrt kernel32 ntdll)
add_cd_file(TARGET gdi32_apitest DESTINATION reactos/bin FOR all)
Added: trunk/rostests/apitests/gdi32/NtGdiAddFontResource.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/NtGdiAddFo…
==============================================================================
--- trunk/rostests/apitests/gdi32/NtGdiAddFontResource.c (added)
+++ trunk/rostests/apitests/gdi32/NtGdiAddFontResource.c [iso-8859-1] Sat Apr 25 10:41:32
2015
@@ -0,0 +1,101 @@
+/*
+ * PROJECT: ReactOS API tests
+ * LICENSE: GPL - See COPYING in the top level directory
+ * PURPOSE: Test for NtGdiAddFontResourceW
+ * PROGRAMMERS: VÃctor MartÃnez Calvo ( victor.martinez(a)reactos.org )
+ */
+
+#include <apitest.h>
+#include <wingdi.h>
+#include <ndk/rtlfuncs.h>
+#include <strsafe.h>
+
+
+INT
+APIENTRY
+NtGdiAddFontResourceW(
+ _In_reads_(cwc) WCHAR *pwszFiles,
+ _In_ ULONG cwc,
+ _In_ ULONG cFiles,
+ _In_ FLONG f,
+ _In_ DWORD dwPidTid,
+ _In_opt_ DESIGNVECTOR *pdv);
+
+void Test_NtGdiAddFontResourceW()
+{
+ WCHAR lpszFontPath[MAX_PATH];
+ WCHAR lpszFontSearch[MAX_PATH];
+
+ INT ret;
+ UNICODE_STRING NtAbsPath;
+ WIN32_FIND_DATAW FindFileData;
+ HANDLE hFind;
+ ULONG cwc;
+
+ // Create "Font" folder Path
+ GetWindowsDirectoryW(lpszFontPath, MAX_PATH);
+ StringCbCatW(lpszFontPath, sizeof(lpszFontPath), L"\\Fonts\\");
+
+ // Search first .ttf file in Fonts Path
+ StringCbCopyW(lpszFontSearch, sizeof(lpszFontSearch), lpszFontPath);
+ StringCbCatW(lpszFontSearch, sizeof(lpszFontSearch), L"*.ttf");
+
+ hFind = FindFirstFileW(lpszFontSearch, &FindFileData);
+
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ skip("Unable to find fonts in Font directory!\n");
+ return;
+ }
+
+ // File found. Create FontPath to File.
+ StringCbCatW(lpszFontPath, sizeof(lpszFontPath), FindFileData.cFileName);
+
+ // Fail due "cwc" being zero.
+ SetLastError(0xdeaddead);
+ RtlInitUnicodeString(&NtAbsPath, NULL);
+ RtlDosPathNameToNtPathName_U(lpszFontPath, &NtAbsPath, NULL, NULL);
+ cwc = 0;
+ ret = NtGdiAddFontResourceW(NtAbsPath.Buffer, cwc, 1, 0, 0, 0);
+
+ ok(ret == 0, "Expected 0 files added. Added: %d\n", ret);
+ ok(GetLastError() == 0xdeaddead, "Expected 0xdeaddead. Obtained: 0x%lx\n",
GetLastError());
+
+ RtlFreeUnicodeString(&NtAbsPath);
+
+ // "cwc" must count the null terminator. Otherwise fails.
+ SetLastError(0xdeaddead);
+ RtlInitUnicodeString(&NtAbsPath, NULL);
+ RtlDosPathNameToNtPathName_U(lpszFontPath, &NtAbsPath, NULL, NULL);
+ cwc = NtAbsPath.Length / sizeof(WCHAR);
+ ret = NtGdiAddFontResourceW(NtAbsPath.Buffer, cwc, 1, 0, 0, 0);
+
+ ok(ret == 0, "Expected 0 files added. Added: %d\n", ret);
+ ok(GetLastError() == 0xdeaddead, "Expected 0xdeaddead. Obtained: 0x%lx\n",
GetLastError());
+
+ RtlFreeUnicodeString(&NtAbsPath);
+
+ // Correct "cwc" value.
+ SetLastError(0xdeaddead);
+ RtlInitUnicodeString(&NtAbsPath, NULL);
+ RtlDosPathNameToNtPathName_U(lpszFontPath, &NtAbsPath, NULL, NULL);
+ cwc = NtAbsPath.Length / sizeof(WCHAR) + 1;
+ ret = NtGdiAddFontResourceW(NtAbsPath.Buffer, cwc, 1, 0, 0, 0);
+
+ ok(ret == 1, "Expected 1 files added. Added: %d\n", ret);
+ ok(GetLastError() == 0xdeaddead, "Expected 0xdeaddead. Obtained: 0x%lx\n",
GetLastError());
+
+ RtlFreeUnicodeString(&NtAbsPath);
+
+ // Test an invalid pointer.
+ SetLastError(0xdeadbeef);
+ ret = NtGdiAddFontResourceW((PVOID)-4, 123, 1, 0, 0, NULL);
+
+ ok(ret == 0, "Expected 0 files added. Added: %d\n", ret);
+ ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef. Obtained: 0x%lx\n",
GetLastError());
+}
+
+START_TEST(NtGdiAddFontResource)
+{
+ Test_NtGdiAddFontResourceW();
+}
Propchange: trunk/rostests/apitests/gdi32/NtGdiAddFontResource.c
------------------------------------------------------------------------------
svn:eol-style = native
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 25 10:41:32 2015
@@ -52,6 +52,7 @@
extern void func_GetTextExtentExPoint(void);
extern void func_GetTextFace(void);
extern void func_MaskBlt(void);
+extern void func_NtGdiAddFontResource(void);
extern void func_OffsetClipRgn(void);
extern void func_OffsetRgn(void);
extern void func_PaintRgn(void);
@@ -120,6 +121,7 @@
{ "GetTextExtentExPoint", func_GetTextExtentExPoint },
{ "GetTextFace", func_GetTextFace },
{ "MaskBlt", func_MaskBlt },
+ { "NtGdiAddFontResource", func_NtGdiAddFontResource},
{ "OffsetClipRgn", func_OffsetClipRgn },
{ "OffsetRgn", func_OffsetRgn },
{ "PaintRgn", func_PaintRgn },