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
11{
12 HDC hDC;
13 HPEN hPen, hOldPen;
14 LOGBRUSH logbrush;
15
16 hDC = GetDC(NULL);
17 ASSERT(hDC);
18
20
21 /* Test NULL DC */
23 hOldPen = NtGdiSelectPen(NULL, hPen);
24 TEST(hOldPen == NULL);
26
27 /* Test invalid DC */
29 hOldPen = NtGdiSelectPen((HDC)((ULONG_PTR)hDC & 0x0000ffff), hPen);
30 TEST(hOldPen == NULL);
32
33 /* Test NULL pen */
35 hOldPen = NtGdiSelectPen(hDC, NULL);
36 TEST(hOldPen == NULL);
38
39 /* Test invalid pen */
41 hOldPen = NtGdiSelectPen(hDC, (HPEN)((ULONG_PTR)hPen & 0x0000ffff));
42 TEST(hOldPen == NULL);
44
45 /* Test valid pen */
48 hOldPen = NtGdiSelectPen(hDC, hPen);
49 TEST(hOldPen == GetStockObject(BLACK_PEN));
50 hOldPen = NtGdiSelectPen(hDC, hOldPen);
51 TEST(hOldPen == hPen);
53
54 /* Test extpen */
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);
65
66 /* Test deleting pen */
68 hOldPen = NtGdiSelectPen(hDC, hPen);
69 TEST(DeleteObject(hPen) == 1);
70 hOldPen = NtGdiSelectPen(hDC, hOldPen);
71 TEST(hOldPen == hPen);
73
74 /* Test that fallback pen is BLACK_PEN */
75
77}
static HDC hDC
Definition: 3dtext.c:33
#define START_TEST(x)
Definition: atltest.h:75
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define SetLastError(x)
Definition: compat.h:752
#define RGB(r, g, b)
Definition: precomp.h:71
pKey DeleteObject()
#define ASSERT(a)
Definition: mode.c:44
#define TEST(x)
Definition: precomp.h:20
static HDC
Definition: imagelist.c:88
__kernel_entry W32KAPI HPEN APIENTRY NtGdiSelectPen(_In_ HDC hdc, _In_ HPEN hpen)
UINT lbStyle
Definition: wingdi.h:1747
COLORREF lbColor
Definition: wingdi.h:1748
uint32_t ULONG_PTR
Definition: typedefs.h:65
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define PS_ALTERNATE
Definition: wingdi.h:585
HPEN WINAPI ExtCreatePen(_In_ DWORD iPenStyle, _In_ DWORD cWidth, _In_ const LOGBRUSH *plbrush, _In_ DWORD cStyle, _In_reads_opt_(cStyle) const DWORD *pstyle)
#define PS_COSMETIC
Definition: wingdi.h:584
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
#define WHITE_PEN
Definition: wingdi.h:905
#define BLACK_PEN
Definition: wingdi.h:903
BOOL WINAPI DeleteDC(_In_ HDC)
#define BS_SOLID
Definition: wingdi.h:1086
HDC WINAPI GetDC(_In_opt_ HWND)