ReactOS  0.4.15-dev-1177-g6cb3b62
NtGdiSelectBrush.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 NtGdiSelectBrush
5  * PROGRAMMERS:
6  */
7 
8 #include <win32nt.h>
9 
11 {
12  HDC hDC;
13  HBRUSH hBrush, hOldBrush;
14  DC_ATTR *pdcattr;
15 
16  hDC = CreateDCW(L"DISPLAY", NULL, NULL, NULL);
17 
18  hBrush = GetStockObject(GRAY_BRUSH);
19 
20  /* Test NULL DC */
22  hOldBrush = NtGdiSelectBrush(NULL, hBrush);
23  TEST(hOldBrush == NULL);
25 
26  /* Test invalid DC */
28  hOldBrush = NtGdiSelectBrush((HDC)((ULONG_PTR)hDC & 0x0000ffff), hBrush);
29  TEST(hOldBrush == NULL);
31 
32  /* Test NULL brush */
34  hOldBrush = NtGdiSelectBrush(hDC, NULL);
35  TEST(hOldBrush == NULL);
37 
38  /* Test invalid brush */
40  hOldBrush = NtGdiSelectBrush(hDC, (HBRUSH)((ULONG_PTR)hBrush & 0x0000ffff));
41  TEST(hOldBrush == NULL);
43 
45  hOldBrush = NtGdiSelectBrush(hDC, hBrush);
46  TEST(hOldBrush != NULL);
47  hOldBrush = NtGdiSelectBrush(hDC, hOldBrush);
48  TEST(hOldBrush == hBrush);
50 
51  /* Begin with a white brush */
53  /* Select a brush in user mode */
55  /* See what we get returned */
57  TEST(hOldBrush == GetStockObject(BLACK_BRUSH));
58 
59 
60  /* Begin with a white brush */
62 
63  pdcattr = GdiGetHandleUserData(hDC);
64  /* Change the brush in user mode, without setting flags */
65  pdcattr->hbrush = (HBRUSH)12345;
66 
68  TEST(hOldBrush == (HBRUSH)12345);
69 
70 
71  DeleteDC(hDC);
72 }
73 
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define ERROR_SUCCESS
Definition: deptool.c:10
HANDLE hbrush
Definition: ntgdihdl.h:299
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define WHITE_BRUSH
Definition: wingdi.h:901
__kernel_entry W32KAPI HBRUSH APIENTRY NtGdiSelectBrush(_In_ HDC hdc, _In_ HBRUSH hbrush)
uint32_t ULONG_PTR
Definition: typedefs.h:65
smooth NULL
Definition: ftsmooth.c:416
#define GRAY_BRUSH
Definition: wingdi.h:897
#define BLACK_BRUSH
Definition: wingdi.h:895
#define TEST(x)
Definition: precomp.h:20
#define SetLastError(x)
Definition: compat.h:500
static const WCHAR L[]
Definition: oid.c:1250
static HDC hDC
Definition: 3dtext.c:33
PVOID GdiGetHandleUserData(_In_ HGDIOBJ hobj)
Definition: gditools.c:68
BOOL WINAPI DeleteDC(_In_ HDC)
HDC WINAPI CreateDCW(_In_opt_ LPCWSTR pszDriver, _In_opt_ LPCWSTR pszDevice, _In_opt_ LPCWSTR psz, _In_opt_ const DEVMODEW *pdmInit)
START_TEST(NtGdiSelectBrush)