Author: gedmurphy
Date: Tue Dec 8 22:14:48 2015
New Revision: 70311
URL:
http://svn.reactos.org/svn/reactos?rev=70311&view=rev
Log:
[GDI32_APITEST]
- Add some tests for GetGlyphIndices
Added:
trunk/rostests/apitests/gdi32/GetGlyphIndices.c (with props)
trunk/rostests/apitests/gdi32/ReactOSTestTahoma.ttf (with props)
trunk/rostests/apitests/gdi32/resource.rc (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] Tue Dec 8 22:14:48 2015
@@ -44,6 +44,7 @@
GetCurrentObject.c
GetDIBColorTable.c
GetDIBits.c
+ GetGlyphIndices.c
GetObject.c
GetRandomRgn.c
GetPixel.c
@@ -72,7 +73,7 @@
init.c
testlist.c)
-add_executable(gdi32_apitest ${SOURCE})
+add_executable(gdi32_apitest ${SOURCE} resource.rc)
target_link_libraries(gdi32_apitest ${PSEH_LIB} win32ksys)
set_module_type(gdi32_apitest win32cui)
add_importlibs(gdi32_apitest gdi32 user32 msvcrt kernel32 ntdll)
Added: trunk/rostests/apitests/gdi32/GetGlyphIndices.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/GetGlyphIn…
==============================================================================
--- trunk/rostests/apitests/gdi32/GetGlyphIndices.c (added)
+++ trunk/rostests/apitests/gdi32/GetGlyphIndices.c [iso-8859-1] Tue Dec 8 22:14:48 2015
@@ -0,0 +1,170 @@
+/*
+* PROJECT: ReactOS api tests
+* LICENSE: GPL - See COPYING in the top level directory
+* PURPOSE: Test for GetGlyphIndices
+* PROGRAMMERS: Ged Murphy
+*/
+
+#include <apitest.h>
+#include <wingdi.h>
+#include <winuser.h>
+#include <Strsafe.h>
+
+
+#define ok_lasterrornotchanged() \
+ ok_err(0x12345)
+
+#define MAX_BMP_GLYPHS 0xFFFF
+
+static LPVOID GetResource(LPCWSTR FontName, LPDWORD Size)
+{
+ HRSRC hRsrc;
+ LPVOID Data;
+
+ hRsrc = FindResourceW(GetModuleHandleW(NULL), FontName, (LPCWSTR)RT_RCDATA);
+ if (!hRsrc) return NULL;
+
+ Data = LockResource(LoadResource(GetModuleHandleW(NULL), hRsrc));
+ if (!Data) return NULL;
+
+ *Size = SizeofResource(GetModuleHandleW(NULL), hRsrc);
+ if (*Size == 0) return NULL;
+
+ return Data;
+}
+
+static BOOL ExtractTTFFile(LPCWSTR FontName, LPWSTR TempFile)
+{
+ WCHAR TempPath[MAX_PATH];
+ HANDLE hFile;
+ void *Data;
+ DWORD Size;
+ BOOL ret;
+
+ Data = GetResource(FontName, &Size);
+ if (!Data) return FALSE;
+
+ GetTempPathW(MAX_PATH, TempPath);
+ GetTempFileNameW(TempPath, L"ttf", 0, TempFile);
+
+ hFile = CreateFileW(TempFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, 0);
+ if (hFile == INVALID_HANDLE_VALUE) return FALSE;
+
+ ret = WriteFile(hFile, Data, Size, &Size, NULL);
+
+ CloseHandle(hFile);
+ return ret;
+}
+
+static BOOL InstallTempFont(LPWSTR TempFile)
+{
+ if (ExtractTTFFile(L"ReactOSTestTahoma.ttf", TempFile))
+ {
+ if (AddFontResourceExW(TempFile, FR_PRIVATE, 0) > 0)
+ {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+static VOID RemoveTempFont(LPWSTR TempFile)
+{
+ BOOL Success;
+ Success = RemoveFontResourceExW(TempFile, FR_PRIVATE, 0);
+ ok(Success, "RemoveFontResourceEx() failed, we're leaving fonts installed :
%lu\n", GetLastError());
+ DeleteFileW(TempFile);
+}
+
+static HFONT IntCreateFont(LPWSTR FontName)
+{
+ LOGFONTW Font = { 0 };
+ Font.lfCharSet = DEFAULT_CHARSET;
+ wcsncpy(Font.lfFaceName, FontName, sizeof(Font.lfFaceName) /
sizeof(Font.lfFaceName[0]));
+ return CreateFontIndirectW(&Font);
+}
+
+START_TEST(GetGlyphIndices)
+{
+ WCHAR Glyphs[MAX_BMP_GLYPHS];
+ WORD Indices[MAX_BMP_GLYPHS];
+ WCHAR Single[2] = { L' ', UNICODE_NULL };
+ WCHAR TempTTFFile[MAX_PATH];
+ HFONT hFont;
+ HDC hdc;
+ int i;
+
+ if (!InstallTempFont(TempTTFFile))
+ {
+ skip("Failed to create ttf file for testing\n");
+ return;
+ }
+
+ hdc = CreateCompatibleDC(NULL);
+ ok(hdc != 0, "CreateCompatibleDC failed, skipping tests.\n");
+ if (!hdc) return;
+
+ hFont = IntCreateFont(L"ReactOSTestTahoma");
+ ok(hFont != NULL, "Failed to open the test font");
+ SelectObject(hdc, hFont);
+
+ SetLastError(0x12345);
+
+ /* Test NULL DC */
+ ok_int(GetGlyphIndicesW(NULL, Single, 1, Indices, 0), GDI_ERROR);
+ ok_lasterrornotchanged();
+
+ /* Test invalid DC */
+ ok_int(GetGlyphIndicesW((HDC)(ULONG_PTR)0x12345, Single, 1, Indices, 0), GDI_ERROR);
+ ok_lasterrornotchanged();
+
+ /* Test invalid params */
+ ok_int(GetGlyphIndicesW(hdc, NULL, 0, Indices, 0), GDI_ERROR);
+ ok_lasterrornotchanged();
+ ok_int(GetGlyphIndicesW(hdc, NULL, 1, Indices, 0), GDI_ERROR);
+ ok_lasterrornotchanged();
+ ok_int(GetGlyphIndicesW(hdc, Single, 1, NULL, 0), GDI_ERROR);
+ ok_lasterrornotchanged();
+
+ /* Test a single valid char */
+ Single[0] = L'a';
+ ok_int(GetGlyphIndicesW(hdc, Single, 1, Indices, 0), 1);
+ ok_lasterrornotchanged();
+ ok_int(Indices[0], 68);
+
+ /* Setup an array of all possible BMP glyphs */
+ for (i = 0; i < 4; i++)
+ Glyphs[i] = (WCHAR)i;
+
+ /* Test a string of valid chars */
+ StringCchCopyW(Glyphs, MAX_BMP_GLYPHS, L"0123");
+ ok_int(GetGlyphIndicesW(hdc, Glyphs, 4, Indices, 0), 4);
+ ok_lasterrornotchanged();
+ ok_int(Indices[0], 19);
+ ok_int(Indices[1], 20);
+ ok_int(Indices[2], 21);
+ ok_int(Indices[3], 22);
+
+ /* Setup an array of all possible BMP glyphs */
+ for (i = 0; i < MAX_BMP_GLYPHS; i++)
+ Glyphs[i] = (WCHAR)i;
+
+ /* Get all the glyphs */
+ ok_int(GetGlyphIndicesW(hdc,
+ Glyphs,
+ MAX_BMP_GLYPHS,
+ Indices,
+ GGI_MARK_NONEXISTING_GLYPHS), MAX_BMP_GLYPHS);
+
+ /* The first 32 are invalid and should contain 0xffff */
+ for (i = 0; i < 32; i++)
+ ok_int(Indices[i], 0xffff);
+
+ /* These are the first 2 valid chars */
+ ok(Indices[32] != 0xffff, "ascii char ' ' should be a valid
char");
+ ok(Indices[33] != 0xffff, "ascii char '!' should be a valid
char");
+
+ RemoveTempFont(TempTTFFile);
+}
+
Propchange: trunk/rostests/apitests/gdi32/GetGlyphIndices.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/apitests/gdi32/ReactOSTestTahoma.ttf
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/ReactOSTes…
==============================================================================
Binary file - no diff available.
Propchange: trunk/rostests/apitests/gdi32/ReactOSTestTahoma.ttf
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: 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 (added)
+++ trunk/rostests/apitests/gdi32/resource.rc [iso-8859-1] Tue Dec 8 22:14:48 2015
@@ -0,0 +1,3 @@
+#include "windef.h"
+
+ReactOSTestTahoma.ttf RCDATA ReactOSTestTahoma.ttf
Propchange: trunk/rostests/apitests/gdi32/resource.rc
------------------------------------------------------------------------------
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] Tue Dec 8 22:14:48 2015
@@ -45,6 +45,7 @@
extern void func_GetCurrentObject(void);
extern void func_GetDIBColorTable(void);
extern void func_GetDIBits(void);
+extern void func_GetGlyphIndices(void);
extern void func_GetPixel(void);
extern void func_GetObject(void);
extern void func_GetRandomRgn(void);
@@ -115,6 +116,7 @@
{ "GetCurrentObject", func_GetCurrentObject },
{ "GetDIBColorTable", func_GetDIBColorTable },
{ "GetDIBits", func_GetDIBits },
+ { "GetGlyphIndices", func_GetGlyphIndices },
{ "GetPixel", func_GetPixel },
{ "GetObject", func_GetObject },
{ "GetRandomRgn", func_GetRandomRgn },