6a67699d932f475764c01715b181969491932786
[reactos.git] / rostests / apitests / gdi32 / AddFontResource.c
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 <apitest.h>
9
10 #include <wine/test.h>
11 #include <wingdi.h>
12
13 #define COUNT 26
14
15 void Test_AddFontResourceA()
16 {
17 CHAR szFileNameA[MAX_PATH];
18 CHAR szFileNameFont1A[MAX_PATH];
19 CHAR szFileNameFont2A[MAX_PATH];
20 int result;
21
22 GetCurrentDirectoryA(MAX_PATH,szFileNameA);
23
24 memcpy(szFileNameFont1A,szFileNameA,MAX_PATH );
25 strcat(szFileNameFont1A, "\\testdata\\test.ttf");
26
27 memcpy(szFileNameFont2A,szFileNameA,MAX_PATH );
28 strcat(szFileNameFont2A, "\\testdata\\test.otf");
29
30 RtlZeroMemory(szFileNameA,MAX_PATH);
31
32 /*
33 * Start testing Ansi version
34 *
35 */
36
37 /* Testing NULL pointer */
38 SetLastError(ERROR_SUCCESS);
39 result = AddFontResourceA(NULL);
40 ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
41 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
42
43 /* Testing -1 pointer */
44 SetLastError(ERROR_SUCCESS);
45 result = AddFontResourceA((CHAR*)-1);
46 ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
47 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
48
49 /* Testing address 1 pointer */
50 SetLastError(ERROR_SUCCESS);
51 result = AddFontResourceA((CHAR*)1);
52 ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
53 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
54
55 /* Testing address empty string */
56 SetLastError(ERROR_SUCCESS);
57 result = AddFontResourceA("");
58 ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
59 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%ld\n", GetLastError());
60
61 /* Testing one ttf font */
62 SetLastError(ERROR_SUCCESS);
63 result = AddFontResourceA(szFileNameFont1A);
64 ok(result == 1, "AddFontResourceA(\"%s\") failed, result=%d\n", szFileNameFont1A, result);
65 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
66
67 /* Testing one otf font */
68 SetLastError(ERROR_SUCCESS);
69 result = AddFontResourceA(szFileNameFont2A);
70 ok(result == 1, "AddFontResourceA failed, result=%d\n", result);
71 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
72
73 /* Testing two fonts */
74 SetLastError(ERROR_SUCCESS);
75 sprintf(szFileNameA,"%s|%s",szFileNameFont1A, szFileNameFont2A);
76 result = AddFontResourceA(szFileNameA);
77 ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
78 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
79
80 SetLastError(ERROR_SUCCESS);
81 sprintf(szFileNameA,"%s |%s",szFileNameFont1A, szFileNameFont2A);
82 result = AddFontResourceA(szFileNameA);
83 ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
84 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
85
86 SetLastError(ERROR_SUCCESS);
87 sprintf(szFileNameA,"%s | %s",szFileNameFont1A, szFileNameFont2A);
88 result = AddFontResourceA(szFileNameA);
89 ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
90 ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError()=%ld\n", GetLastError());
91
92
93 GetCurrentDirectoryA(MAX_PATH, szFileNameA);
94 strcpy(szFileNameFont1A, szFileNameA);
95 strcat(szFileNameFont1A, "\\testdata\\test.pfm");
96
97 strcpy(szFileNameFont2A, szFileNameA);
98 strcat(szFileNameFont2A, "\\testdata\\test.pfb");
99
100 SetLastError(ERROR_SUCCESS);
101
102 sprintf(szFileNameA,"%s|%s", szFileNameFont1A, szFileNameFont2A);
103 result = AddFontResourceA(szFileNameA);
104 ok(result == 1, "AddFontResourceA(\"%s|%s\") failed, result=%d\n",
105 szFileNameFont1A, szFileNameFont2A, result);
106 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
107
108 sprintf(szFileNameA,"%s | %s", szFileNameFont1A, szFileNameFont2A);
109 result = AddFontResourceA(szFileNameA);
110 ok(result == 0, "AddFontResourceA(\"%s | %s\") succeeded, result=%d\n",
111 szFileNameFont1A, szFileNameFont2A, result);
112 ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError()=%ld\n", GetLastError());
113
114 sprintf(szFileNameA,"%s|%s", szFileNameFont2A, szFileNameFont1A);
115 result = AddFontResourceA(szFileNameA);
116 ok(result == 0, "AddFontResourceA(\"%s|%s\") succeeded, result=%d\n",
117 szFileNameFont2A, szFileNameFont1A, result);
118 ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError()=%ld\n", GetLastError());
119
120
121 }
122
123 START_TEST(AddFontResource)
124 {
125 Test_AddFontResourceA();
126 }
127