2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for NtGdiSelectBrush
10 START_TEST(NtGdiSelectBrush
)
13 HBRUSH hBrush
, hOldBrush
;
16 hDC
= CreateDCW(L
"DISPLAY", NULL
, NULL
, NULL
);
18 hBrush
= GetStockObject(GRAY_BRUSH
);
21 SetLastError(ERROR_SUCCESS
);
22 hOldBrush
= NtGdiSelectBrush(NULL
, hBrush
);
23 TEST(hOldBrush
== NULL
);
24 TEST(GetLastError() == ERROR_SUCCESS
);
27 SetLastError(ERROR_SUCCESS
);
28 hOldBrush
= NtGdiSelectBrush((HDC
)((ULONG_PTR
)hDC
& 0x0000ffff), hBrush
);
29 TEST(hOldBrush
== NULL
);
30 TEST(GetLastError() == ERROR_SUCCESS
);
33 SetLastError(ERROR_SUCCESS
);
34 hOldBrush
= NtGdiSelectBrush(hDC
, NULL
);
35 TEST(hOldBrush
== NULL
);
36 TEST(GetLastError() == ERROR_SUCCESS
);
38 /* Test invalid brush */
39 SetLastError(ERROR_SUCCESS
);
40 hOldBrush
= NtGdiSelectBrush(hDC
, (HBRUSH
)((ULONG_PTR
)hBrush
& 0x0000ffff));
41 TEST(hOldBrush
== NULL
);
42 TEST(GetLastError() == ERROR_SUCCESS
);
44 SetLastError(ERROR_SUCCESS
);
45 hOldBrush
= NtGdiSelectBrush(hDC
, hBrush
);
46 TEST(hOldBrush
!= NULL
);
47 hOldBrush
= NtGdiSelectBrush(hDC
, hOldBrush
);
48 TEST(hOldBrush
== hBrush
);
49 TEST(GetLastError() == ERROR_SUCCESS
);
51 /* Begin with a white brush */
52 NtGdiSelectBrush(hDC
, GetStockObject(WHITE_BRUSH
));
53 /* Select a brush in user mode */
54 SelectObject(hDC
, GetStockObject(BLACK_BRUSH
));
55 /* See what we get returned */
56 hOldBrush
= NtGdiSelectBrush(hDC
, GetStockObject(WHITE_BRUSH
));
57 TEST(hOldBrush
== GetStockObject(BLACK_BRUSH
));
60 /* Begin with a white brush */
61 NtGdiSelectBrush(hDC
, GetStockObject(WHITE_BRUSH
));
63 pdcattr
= GdiGetHandleUserData(hDC
);
64 /* Change the brush in user mode, without setting flags */
65 pdcattr
->hbrush
= (HBRUSH
)12345;
67 hOldBrush
= NtGdiSelectBrush(hDC
, GetStockObject(BLACK_BRUSH
));
68 TEST(hOldBrush
== (HBRUSH
)12345);