ReactOS
0.4.16-dev-889-g9563c07
GetTextFace.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 GetTextFace
5
* PROGRAMMERS: Timo Kreuzer
6
* Katayama Hirofumi MZ
7
* Doug Lyons
8
*/
9
10
#include "
precomp.h
"
11
12
/* Exported by gdi32.dll but undocumented */
13
INT
14
WINAPI
15
GetTextFaceAliasW
(
16
IN
HDC
hdc
,
17
IN
INT
c
,
18
OUT
LPWSTR
lpAliasName);
19
20
void
Test_GetTextFace
(
void
)
21
{
22
HDC
hDC
;
23
INT
ret
;
24
INT
ret2;
25
WCHAR
Buffer
[20];
26
27
hDC
=
CreateCompatibleDC
(
NULL
);
28
ok
(
hDC
!= 0,
"CreateCompatibleDC failed, skipping tests.\n"
);
29
if
(!
hDC
)
return
;
30
31
/* Whether asking for the string size (NULL buffer) ignores the size argument */
32
SetLastError
(0xE000BEEF);
33
ret
=
GetTextFaceW
(
hDC
, 0,
NULL
);
34
TEST
(
ret
!= 0);
35
ok_err
(0xE000BEEF);
36
ret2 =
ret
;
37
38
SetLastError
(0xE000BEEF);
39
ret
=
GetTextFaceW
(
hDC
, -1,
NULL
);
40
TEST
(
ret
!= 0);
41
ok_int
(
ret
, ret2);
42
ok_err
(0xE000BEEF);
43
ret2 =
ret
;
44
45
SetLastError
(0xE000BEEF);
46
ret
=
GetTextFaceW
(
hDC
, 10000,
NULL
);
47
TEST
(
ret
!= 0);
48
ok_int
(
ret
, ret2);
49
ok_err
(0xE000BEEF);
50
ret2 =
ret
;
51
52
/* Whether the buffer is correctly filled */
53
SetLastError
(0xE000BEEF);
54
ret
=
GetTextFaceW
(
hDC
, 20,
Buffer
);
55
TEST
(
ret
!= 0);
56
TEST
(
ret
<= 20);
57
ok_int
(
Buffer
[
ret
- 1], 0);
58
ok_err
(0xE000BEEF);
59
60
SetLastError
(0xE000BEEF);
61
ret
=
GetTextFaceW
(
hDC
, 1,
Buffer
);
62
ok_int
(
ret
, 1);
63
ok_int
(
Buffer
[
ret
- 1], 0);
64
ok_err
(0xE000BEEF);
65
66
SetLastError
(0xE000BEEF);
67
ret
=
GetTextFaceW
(
hDC
, 2,
Buffer
);
68
ok_int
(
ret
, 2);
69
ok_int
(
Buffer
[
ret
- 1], 0);
70
ok_err
(0xE000BEEF);
71
72
/* Whether invalid buffer sizes are correctly ignored */
73
SetLastError
(0xE000BEEF);
74
ret
=
GetTextFaceW
(
hDC
, 0,
Buffer
);
75
ok_int
(
ret
, 0);
76
ok_err
(
ERROR_INVALID_PARAMETER
);
77
78
SetLastError
(0xE000BEEF);
79
ret
=
GetTextFaceW
(
hDC
, -1,
Buffer
);
80
ok_int
(
ret
, 0);
81
ok_err
(
ERROR_INVALID_PARAMETER
);
82
83
DeleteDC
(
hDC
);
84
}
85
86
void
Test_GetTextFaceAliasW
(
void
)
87
{
88
HDC
hDC
;
89
INT
ret
;
90
INT
ret2;
91
UINT
i
;
92
LOGFONTW
lf;
93
HFONT
hFontOld,
hFont
;
94
WCHAR
buf1[
LF_FACESIZE
];
95
WCHAR
buf2[
LF_FACESIZE
];
96
97
static
struct
98
{
99
LPCWSTR
lpFaceName;
100
LPCWSTR
lpExpectedFaceName;
101
LPCWSTR
lpExpectedAlias;
102
} FaceTests[] =
103
{
104
{
L
"Arial"
,
L
"Arial"
,
L
"Arial"
},
105
{
L
"Tahoma"
,
L
"Tahoma"
,
L
"Tahoma"
},
106
// {L"Tahoma Bold", L"MS Sans Serif", L"MS Sans Serif"}, // That's what Windows 2003 and 7/10 returns. But not WHS testbot.
107
{
L
"Helv"
,
L
"Helv"
,
L
"Helv"
},
108
{
L
"Tms Rmn"
,
L
"Tms Rmn"
,
L
"Tms Rmn"
},
109
{
L
"Times"
,
L
"Times"
,
L
"Times"
},
110
{
L
"invalid"
,
L
"MS Sans Serif"
,
L
"MS Sans Serif"
}
111
};
112
113
hDC
=
CreateCompatibleDC
(
NULL
);
114
ok
(
hDC
!= 0,
"CreateCompatibleDC failed, skipping tests.\n"
);
115
if
(!
hDC
)
return
;
116
117
for
(
i
= 0;
i
<
ARRAYSIZE
(FaceTests); ++
i
)
118
{
119
ZeroMemory
(&lf,
sizeof
(lf));
120
StringCchCopyW
(lf.
lfFaceName
,
ARRAYSIZE
(lf.
lfFaceName
), FaceTests[
i
].lpFaceName);
121
122
hFont
=
CreateFontIndirectW
(&lf);
123
if
(!
hFont
)
124
{
125
trace
(
"Failed to create font '%S'!\n"
, lf.
lfFaceName
);
126
continue
;
127
}
128
129
hFontOld =
SelectObject
(
hDC
,
hFont
);
130
131
ret
=
GetTextFaceW
(
hDC
,
ARRAYSIZE
(buf1), buf1);
132
ok
(
ret
!= 0,
"%S GetTextFaceW failed.\n"
, FaceTests[
i
].lpFaceName);
133
ok
(
wcscmp
(buf1, FaceTests[
i
].lpExpectedFaceName) == 0,
"'%S' GetTextFaceW failed, got '%S', expected '%S'.\n"
,
134
FaceTests[
i
].lpFaceName, buf1, FaceTests[
i
].lpExpectedFaceName);
135
136
ret2 =
GetTextFaceAliasW
(
hDC
,
ARRAYSIZE
(buf2), buf2);
137
ok
(ret2 != 0,
"%S GetTextFaceAliasW failed.\n"
, FaceTests[
i
].lpFaceName);
138
ok
(
wcscmp
(buf2, FaceTests[
i
].lpExpectedAlias) == 0,
"'%S' GetTextFaceAliasW failed, got '%S', expected '%S'.\n"
,
139
FaceTests[
i
].lpFaceName, buf2, FaceTests[
i
].lpExpectedAlias);
140
141
SelectObject
(
hDC
, hFontOld);
142
DeleteObject
(
hFont
);
143
}
144
145
DeleteDC
(
hDC
);
146
}
147
148
START_TEST
(
GetTextFace
)
149
{
150
Test_GetTextFace
();
151
Test_GetTextFaceAliasW
();
152
}
hDC
static HDC hDC
Definition:
3dtext.c:33
GetTextFaceAliasW
INT WINAPI GetTextFaceAliasW(IN HDC hdc, IN INT c, OUT LPWSTR lpAliasName)
Test_GetTextFace
void Test_GetTextFace(void)
Definition:
GetTextFace.c:20
Test_GetTextFaceAliasW
void Test_GetTextFaceAliasW(void)
Definition:
GetTextFace.c:86
trace
#define trace
Definition:
atltest.h:70
ok
#define ok(value,...)
Definition:
atltest.h:57
ok_err
#define ok_err(error)
Definition:
atltest.h:124
START_TEST
#define START_TEST(x)
Definition:
atltest.h:75
ok_int
#define ok_int(expression, result)
Definition:
atltest.h:134
hFont
HFONT hFont
Definition:
main.c:53
Buffer
Definition:
bufpool.h:45
LF_FACESIZE
#define LF_FACESIZE
Definition:
dimm.idl:39
NULL
#define NULL
Definition:
types.h:112
ARRAYSIZE
#define ARRAYSIZE(array)
Definition:
filtermapper.c:47
ERROR_INVALID_PARAMETER
#define ERROR_INVALID_PARAMETER
Definition:
compat.h:101
SetLastError
#define SetLastError(x)
Definition:
compat.h:752
DeleteObject
pKey DeleteObject()
c
const GLubyte * c
Definition:
glext.h:8905
i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition:
glfuncs.h:248
TEST
#define TEST(x)
Definition:
precomp.h:20
hdc
HDC hdc
Definition:
main.c:9
HDC
static HDC
Definition:
imagelist.c:88
HFONT
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
UINT
unsigned int UINT
Definition:
ndis.h:50
L
#define L(x)
Definition:
ntvdm.h:50
wcscmp
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
StringCchCopyW
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition:
strsafe.h:149
LOGFONTW
Definition:
dimm.idl:58
LOGFONTW::lfFaceName
WCHAR lfFaceName[LF_FACESIZE]
Definition:
dimm.idl:72
INT
int32_t INT
Definition:
typedefs.h:58
IN
#define IN
Definition:
typedefs.h:39
OUT
#define OUT
Definition:
typedefs.h:40
ret
int ret
Definition:
wcstombs-tests.c:31
precomp.h
ZeroMemory
#define ZeroMemory
Definition:
winbase.h:1737
WINAPI
#define WINAPI
Definition:
msvc.h:6
SelectObject
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition:
dc.c:1546
CreateCompatibleDC
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
GetTextFaceW
int WINAPI GetTextFaceW(_In_ HDC hdc, _In_ int c, _Out_writes_to_opt_(c, return) LPWSTR lpName)
GetTextFace
#define GetTextFace
Definition:
wingdi.h:4473
CreateFontIndirectW
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
DeleteDC
BOOL WINAPI DeleteDC(_In_ HDC)
WCHAR
__wchar_t WCHAR
Definition:
xmlstorage.h:180
LPWSTR
WCHAR * LPWSTR
Definition:
xmlstorage.h:184
LPCWSTR
const WCHAR * LPCWSTR
Definition:
xmlstorage.h:185
modules
rostests
apitests
gdi32
GetTextFace.c
Generated on Tue Mar 25 2025 06:07:22 for ReactOS by
1.9.6