1c2c66affSColin Finck /*
2c2c66affSColin Finck  * PROJECT:         ReactOS api tests
3c2c66affSColin Finck  * LICENSE:         GPL - See COPYING in the top level directory
4c2c66affSColin Finck  * PURPOSE:         Test for NtGdiSelectBrush
5c2c66affSColin Finck  * PROGRAMMERS:
6c2c66affSColin Finck  */
7c2c66affSColin Finck 
8*a5c3bb5bSSerge Gautherie #include "../win32nt.h"
9c2c66affSColin Finck 
START_TEST(NtGdiSelectBrush)10c2c66affSColin Finck START_TEST(NtGdiSelectBrush)
11c2c66affSColin Finck {
12c2c66affSColin Finck     HDC hDC;
13c2c66affSColin Finck     HBRUSH hBrush, hOldBrush;
14c2c66affSColin Finck     DC_ATTR *pdcattr;
15c2c66affSColin Finck 
16c2c66affSColin Finck     hDC = CreateDCW(L"DISPLAY", NULL, NULL, NULL);
17c2c66affSColin Finck 
18c2c66affSColin Finck     hBrush = GetStockObject(GRAY_BRUSH);
19c2c66affSColin Finck 
20c2c66affSColin Finck     /* Test NULL DC */
21c2c66affSColin Finck     SetLastError(ERROR_SUCCESS);
22c2c66affSColin Finck     hOldBrush = NtGdiSelectBrush(NULL, hBrush);
23c2c66affSColin Finck     TEST(hOldBrush == NULL);
24c2c66affSColin Finck     TEST(GetLastError() == ERROR_SUCCESS);
25c2c66affSColin Finck 
26c2c66affSColin Finck     /* Test invalid DC */
27c2c66affSColin Finck     SetLastError(ERROR_SUCCESS);
28c2c66affSColin Finck     hOldBrush = NtGdiSelectBrush((HDC)((ULONG_PTR)hDC & 0x0000ffff), hBrush);
29c2c66affSColin Finck     TEST(hOldBrush == NULL);
30c2c66affSColin Finck     TEST(GetLastError() == ERROR_SUCCESS);
31c2c66affSColin Finck 
32c2c66affSColin Finck     /* Test NULL brush */
33c2c66affSColin Finck     SetLastError(ERROR_SUCCESS);
34c2c66affSColin Finck     hOldBrush = NtGdiSelectBrush(hDC, NULL);
35c2c66affSColin Finck     TEST(hOldBrush == NULL);
36c2c66affSColin Finck     TEST(GetLastError() == ERROR_SUCCESS);
37c2c66affSColin Finck 
38c2c66affSColin Finck     /* Test invalid brush */
39c2c66affSColin Finck     SetLastError(ERROR_SUCCESS);
40c2c66affSColin Finck     hOldBrush = NtGdiSelectBrush(hDC, (HBRUSH)((ULONG_PTR)hBrush & 0x0000ffff));
41c2c66affSColin Finck     TEST(hOldBrush == NULL);
42c2c66affSColin Finck     TEST(GetLastError() == ERROR_SUCCESS);
43c2c66affSColin Finck 
44c2c66affSColin Finck     SetLastError(ERROR_SUCCESS);
45c2c66affSColin Finck     hOldBrush = NtGdiSelectBrush(hDC, hBrush);
46c2c66affSColin Finck     TEST(hOldBrush != NULL);
47c2c66affSColin Finck     hOldBrush = NtGdiSelectBrush(hDC, hOldBrush);
48c2c66affSColin Finck     TEST(hOldBrush == hBrush);
49c2c66affSColin Finck     TEST(GetLastError() == ERROR_SUCCESS);
50c2c66affSColin Finck 
51c2c66affSColin Finck     /* Begin with a white brush */
52c2c66affSColin Finck     NtGdiSelectBrush(hDC, GetStockObject(WHITE_BRUSH));
53c2c66affSColin Finck     /* Select a brush in user mode */
54c2c66affSColin Finck     SelectObject(hDC, GetStockObject(BLACK_BRUSH));
55c2c66affSColin Finck     /* See what we get returned */
56c2c66affSColin Finck     hOldBrush = NtGdiSelectBrush(hDC, GetStockObject(WHITE_BRUSH));
57c2c66affSColin Finck     TEST(hOldBrush == GetStockObject(BLACK_BRUSH));
58c2c66affSColin Finck 
59c2c66affSColin Finck 
60c2c66affSColin Finck     /* Begin with a white brush */
61c2c66affSColin Finck     NtGdiSelectBrush(hDC, GetStockObject(WHITE_BRUSH));
62c2c66affSColin Finck 
63c2c66affSColin Finck     pdcattr = GdiGetHandleUserData(hDC);
64c2c66affSColin Finck     /* Change the brush in user mode, without setting flags */
65c2c66affSColin Finck     pdcattr->hbrush = (HBRUSH)12345;
66c2c66affSColin Finck 
67c2c66affSColin Finck     hOldBrush = NtGdiSelectBrush(hDC, GetStockObject(BLACK_BRUSH));
68c2c66affSColin Finck     TEST(hOldBrush == (HBRUSH)12345);
69c2c66affSColin Finck 
70c2c66affSColin Finck 
71c2c66affSColin Finck     DeleteDC(hDC);
72c2c66affSColin Finck }
73c2c66affSColin Finck 
74