ReactOS 0.4.16-dev-197-g92996da
AddFontResource.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for AddFontResource
5 * PROGRAMMERS: Timo Kreuzer
6 */
7
8#include "precomp.h"
9
10#define COUNT 26
11
13{
14 CHAR szCurrentDir[MAX_PATH];
15 CHAR szFileNameFont1[MAX_PATH];
16 CHAR szFileNameFont2[MAX_PATH];
17 CHAR szFileName[MAX_PATH*2 + 3];
18 int result;
19
20 GetCurrentDirectoryA(MAX_PATH, szCurrentDir);
21
22 snprintf(szFileNameFont1, MAX_PATH, "%s\\testdata\\test.ttf", szCurrentDir);
23 snprintf(szFileNameFont2, MAX_PATH, "%s\\testdata\\test.otf", szCurrentDir);
24
25 //RtlZeroMemory(szFileNameA, sizeof(szFileNameA));
26
27 /* Testing NULL pointer */
30 ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
31 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
32
33 /* Testing -1 pointer */
36 ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
37 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
38
39 /* Testing address 1 pointer */
42 ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
43 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
44
45 /* Testing address empty string */
48 ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
49 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%ld\n", GetLastError());
50
51 /* Testing one ttf font */
53 result = AddFontResourceA(szFileNameFont1);
54 ok(result == 1, "AddFontResourceA(\"%s\") failed, result=%d\n", szFileNameFont1, result);
55 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
56 RemoveFontResourceA(szFileNameFont1);
57
58 /* Testing one otf font */
60 result = AddFontResourceA(szFileNameFont2);
61 ok(result == 1, "AddFontResourceA failed, result=%d\n", result);
62 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
63 RemoveFontResourceA(szFileNameFont2);
64
65 /* Testing two fonts */
67 sprintf(szFileName,"%s|%s",szFileNameFont1, szFileNameFont2);
68 result = AddFontResourceA(szFileName);
69 ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
70 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
71
73 sprintf(szFileName,"%s |%s",szFileNameFont1, szFileNameFont2);
74 result = AddFontResourceA(szFileName);
75 ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
76 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
77
79 sprintf(szFileName,"%s | %s",szFileNameFont1, szFileNameFont2);
80 result = AddFontResourceA(szFileName);
81 ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
82 ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError()=%ld\n", GetLastError());
83
84 snprintf(szFileNameFont1, MAX_PATH, "%s\\testdata\\test.pfm", szCurrentDir);
85 snprintf(szFileNameFont2, MAX_PATH, "%s\\testdata\\test.pfb", szCurrentDir);
86
88
89 sprintf(szFileName,"%s|%s", szFileNameFont1, szFileNameFont2);
90 result = AddFontResourceA(szFileName);
91 ok(result == 1, "AddFontResourceA(\"%s|%s\") failed, result=%d\n",
92 szFileNameFont1, szFileNameFont2, result);
93 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
94 RemoveFontResourceA(szFileName);
95
96 sprintf(szFileName,"%s | %s", szFileNameFont1, szFileNameFont2);
97 result = AddFontResourceA(szFileName);
98 ok(result == 0, "AddFontResourceA(\"%s | %s\") succeeded, result=%d\n",
99 szFileNameFont1, szFileNameFont2, result);
100 ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError()=%ld\n", GetLastError());
101 RemoveFontResourceA(szFileName);
102
103 sprintf(szFileName,"%s|%s", szFileNameFont2, szFileNameFont1);
104 result = AddFontResourceA(szFileName);
105 ok(result == 0, "AddFontResourceA(\"%s|%s\") succeeded, result=%d\n",
106 szFileNameFont2, szFileNameFont1, result);
107 ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError()=%ld\n", GetLastError());
108}
109
111{
113}
114
void Test_AddFontResourceA()
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2146
GLuint64EXT * result
Definition: glext.h:11304
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define sprintf(buf, format,...)
Definition: sprintf.c:55
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
int WINAPI AddFontResourceA(_In_ LPCSTR pszFilename)
BOOL WINAPI RemoveFontResourceA(_In_ LPCSTR)
#define AddFontResource
Definition: wingdi.h:4435
#define snprintf
Definition: wintirpc.h:48
char CHAR
Definition: xmlstorage.h:175