ReactOS 0.4.15-dev-7934-g1dc8d80
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
72}
73
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
PVOID GdiGetHandleUserData(_In_ HGDIOBJ hobj)
Definition: gditools.c:68
#define TEST(x)
Definition: precomp.h:20
static HDC
Definition: imagelist.c:92
__kernel_entry W32KAPI HBRUSH APIENTRY NtGdiSelectBrush(_In_ HDC hdc, _In_ HBRUSH hbrush)
#define L(x)
Definition: ntvdm.h:50
HANDLE hbrush
Definition: ntgdihdl.h:295
uint32_t ULONG_PTR
Definition: typedefs.h:65
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
HGDIOBJ WINAPI GetStockObject(_In_ int)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
#define WHITE_BRUSH
Definition: wingdi.h:902
#define GRAY_BRUSH
Definition: wingdi.h:898
#define BLACK_BRUSH
Definition: wingdi.h:896
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)