ReactOS
0.4.16-dev-197-g92996da
NtGdiSelectPen.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 NtGdiSelectPen
5
* PROGRAMMERS:
6
*/
7
8
#include "../win32nt.h"
9
10
START_TEST
(
NtGdiSelectPen
)
11
{
12
HDC
hDC
;
13
HPEN hPen, hOldPen;
14
LOGBRUSH
logbrush;
15
16
hDC
=
GetDC
(
NULL
);
17
ASSERT
(
hDC
);
18
19
hPen =
GetStockObject
(
WHITE_PEN
);
20
21
/* Test NULL DC */
22
SetLastError
(
ERROR_SUCCESS
);
23
hOldPen =
NtGdiSelectPen
(
NULL
, hPen);
24
TEST
(hOldPen ==
NULL
);
25
TEST
(
GetLastError
() ==
ERROR_SUCCESS
);
26
27
/* Test invalid DC */
28
SetLastError
(
ERROR_SUCCESS
);
29
hOldPen =
NtGdiSelectPen
((
HDC
)((
ULONG_PTR
)
hDC
& 0x0000ffff), hPen);
30
TEST
(hOldPen ==
NULL
);
31
TEST
(
GetLastError
() ==
ERROR_SUCCESS
);
32
33
/* Test NULL pen */
34
SetLastError
(
ERROR_SUCCESS
);
35
hOldPen =
NtGdiSelectPen
(
hDC
,
NULL
);
36
TEST
(hOldPen ==
NULL
);
37
TEST
(
GetLastError
() ==
ERROR_SUCCESS
);
38
39
/* Test invalid pen */
40
SetLastError
(
ERROR_SUCCESS
);
41
hOldPen =
NtGdiSelectPen
(
hDC
, (HPEN)((
ULONG_PTR
)hPen & 0x0000ffff));
42
TEST
(hOldPen ==
NULL
);
43
TEST
(
GetLastError
() ==
ERROR_SUCCESS
);
44
45
/* Test valid pen */
46
SelectObject
(
hDC
,
GetStockObject
(
BLACK_PEN
));
47
SetLastError
(
ERROR_SUCCESS
);
48
hOldPen =
NtGdiSelectPen
(
hDC
, hPen);
49
TEST
(hOldPen ==
GetStockObject
(
BLACK_PEN
));
50
hOldPen =
NtGdiSelectPen
(
hDC
, hOldPen);
51
TEST
(hOldPen == hPen);
52
TEST
(
GetLastError
() ==
ERROR_SUCCESS
);
53
54
/* Test extpen */
55
SetLastError
(
ERROR_SUCCESS
);
56
logbrush.
lbStyle
=
BS_SOLID
;
57
logbrush.
lbColor
=
RGB
(0x12,0x34,0x56);
58
hPen =
ExtCreatePen
(
PS_COSMETIC
|
PS_ALTERNATE
, 1, &logbrush, 0,
NULL
);
59
ASSERT
(hPen);
60
hOldPen =
NtGdiSelectPen
(
hDC
, hPen);
61
TEST
(hOldPen !=
NULL
);
62
hOldPen =
NtGdiSelectPen
(
hDC
, hOldPen);
63
TEST
(hOldPen == hPen);
64
TEST
(
GetLastError
() ==
ERROR_SUCCESS
);
65
66
/* Test deleting pen */
67
SetLastError
(
ERROR_SUCCESS
);
68
hOldPen =
NtGdiSelectPen
(
hDC
, hPen);
69
TEST
(
DeleteObject
(hPen) == 1);
70
hOldPen =
NtGdiSelectPen
(
hDC
, hOldPen);
71
TEST
(hOldPen == hPen);
72
TEST
(
GetLastError
() ==
ERROR_SUCCESS
);
73
74
/* Test that fallback pen is BLACK_PEN */
75
76
DeleteDC
(
hDC
);
77
}
hDC
static HDC hDC
Definition:
3dtext.c:33
START_TEST
#define START_TEST(x)
Definition:
atltest.h:75
ERROR_SUCCESS
#define ERROR_SUCCESS
Definition:
deptool.c:10
NULL
#define NULL
Definition:
types.h:112
SetLastError
#define SetLastError(x)
Definition:
compat.h:752
RGB
#define RGB(r, g, b)
Definition:
precomp.h:71
DeleteObject
pKey DeleteObject()
ASSERT
#define ASSERT(a)
Definition:
mode.c:44
TEST
#define TEST(x)
Definition:
precomp.h:20
HDC
static HDC
Definition:
imagelist.c:88
NtGdiSelectPen
__kernel_entry W32KAPI HPEN APIENTRY NtGdiSelectPen(_In_ HDC hdc, _In_ HPEN hpen)
tagLOGBRUSH
Definition:
wingdi.h:1746
tagLOGBRUSH::lbStyle
UINT lbStyle
Definition:
wingdi.h:1747
tagLOGBRUSH::lbColor
COLORREF lbColor
Definition:
wingdi.h:1748
ULONG_PTR
uint32_t ULONG_PTR
Definition:
typedefs.h:65
GetLastError
DWORD WINAPI GetLastError(void)
Definition:
except.c:1042
GetStockObject
HGDIOBJ WINAPI GetStockObject(_In_ int)
PS_ALTERNATE
#define PS_ALTERNATE
Definition:
wingdi.h:585
ExtCreatePen
HPEN WINAPI ExtCreatePen(_In_ DWORD iPenStyle, _In_ DWORD cWidth, _In_ const LOGBRUSH *plbrush, _In_ DWORD cStyle, _In_reads_opt_(cStyle) const DWORD *pstyle)
PS_COSMETIC
#define PS_COSMETIC
Definition:
wingdi.h:584
SelectObject
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition:
dc.c:1546
WHITE_PEN
#define WHITE_PEN
Definition:
wingdi.h:905
BLACK_PEN
#define BLACK_PEN
Definition:
wingdi.h:903
DeleteDC
BOOL WINAPI DeleteDC(_In_ HDC)
BS_SOLID
#define BS_SOLID
Definition:
wingdi.h:1086
GetDC
HDC WINAPI GetDC(_In_opt_ HWND)
modules
rostests
apitests
win32nt
ntgdi
NtGdiSelectPen.c
Generated on Wed Oct 30 2024 06:07:44 for ReactOS by
1.9.6