ReactOS  0.4.14-dev-323-g6fe6a88
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 szFileNameA[MAX_PATH*2 + 3];
15  CHAR szFileNameFont1A[MAX_PATH];
16  CHAR szFileNameFont2A[MAX_PATH];
17  int result;
18 
19  GetCurrentDirectoryA(MAX_PATH, szFileNameA);
20 
21  memcpy(szFileNameFont1A, szFileNameA, MAX_PATH );
22  strcat(szFileNameFont1A, "\\testdata\\test.ttf");
23 
24  memcpy(szFileNameFont2A, szFileNameA, MAX_PATH );
25  strcat(szFileNameFont2A, "\\testdata\\test.otf");
26 
27  RtlZeroMemory(szFileNameA, sizeof(szFileNameA));
28 
29  /*
30  * Start testing Ansi version
31  *
32  */
33 
34  /* Testing NULL pointer */
37  ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
38  ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
39 
40  /* Testing -1 pointer */
43  ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
44  ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
45 
46  /* Testing address 1 pointer */
49  ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
50  ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
51 
52  /* Testing address empty string */
55  ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
56  ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%ld\n", GetLastError());
57 
58  /* Testing one ttf font */
60  result = AddFontResourceA(szFileNameFont1A);
61  ok(result == 1, "AddFontResourceA(\"%s\") failed, result=%d\n", szFileNameFont1A, result);
62  ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
63 
64  /* Testing one otf font */
66  result = AddFontResourceA(szFileNameFont2A);
67  ok(result == 1, "AddFontResourceA failed, result=%d\n", result);
68  ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
69 
70  /* Testing two fonts */
72  sprintf(szFileNameA,"%s|%s",szFileNameFont1A, szFileNameFont2A);
73  result = AddFontResourceA(szFileNameA);
74  ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
75  ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
76 
78  sprintf(szFileNameA,"%s |%s",szFileNameFont1A, szFileNameFont2A);
79  result = AddFontResourceA(szFileNameA);
80  ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
81  ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
82 
84  sprintf(szFileNameA,"%s | %s",szFileNameFont1A, szFileNameFont2A);
85  result = AddFontResourceA(szFileNameA);
86  ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
87  ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError()=%ld\n", GetLastError());
88 
89 
90  GetCurrentDirectoryA(MAX_PATH, szFileNameA);
91  strcpy(szFileNameFont1A, szFileNameA);
92  strcat(szFileNameFont1A, "\\testdata\\test.pfm");
93 
94  strcpy(szFileNameFont2A, szFileNameA);
95  strcat(szFileNameFont2A, "\\testdata\\test.pfb");
96 
98 
99  sprintf(szFileNameA,"%s|%s", szFileNameFont1A, szFileNameFont2A);
100  result = AddFontResourceA(szFileNameA);
101  ok(result == 1, "AddFontResourceA(\"%s|%s\") failed, result=%d\n",
102  szFileNameFont1A, szFileNameFont2A, result);
103  ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
104 
105  sprintf(szFileNameA,"%s | %s", szFileNameFont1A, szFileNameFont2A);
106  result = AddFontResourceA(szFileNameA);
107  ok(result == 0, "AddFontResourceA(\"%s | %s\") succeeded, result=%d\n",
108  szFileNameFont1A, szFileNameFont2A, result);
109  ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError()=%ld\n", GetLastError());
110 
111  sprintf(szFileNameA,"%s|%s", szFileNameFont2A, szFileNameFont1A);
112  result = AddFontResourceA(szFileNameA);
113  ok(result == 0, "AddFontResourceA(\"%s|%s\") succeeded, result=%d\n",
114  szFileNameFont2A, szFileNameFont1A, result);
115  ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError()=%ld\n", GetLastError());
116 
117 
118 }
119 
121 {
123 }
124 
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
START_TEST(AddFontResource)
int WINAPI AddFontResourceA(_In_ LPCSTR pszFilename)
#define ERROR_SUCCESS
Definition: deptool.c:10
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
char CHAR
Definition: xmlstorage.h:175
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define sprintf(buf, format,...)
Definition: sprintf.c:55
smooth NULL
Definition: ftsmooth.c:416
#define AddFontResource
Definition: wingdi.h:4430
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define MAX_PATH
Definition: compat.h:26
#define SetLastError(x)
Definition: compat.h:409
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ok(value,...)
Definition: atltest.h:57
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2145
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
void Test_AddFontResourceA()
GLuint64EXT * result
Definition: glext.h:11304