225379c0bce88a7ee8270b0806d9aefae5c8ebe7
[reactos.git] / rostests / apitests / gdi32api / tests / SetDCPenColor.c
1 INT
2 Test_SetDCPenColor(PTESTINFO pti)
3 {
4 HDC hScreenDC, hDC;
5
6 // Test an incorrect DC
7 SetLastError(ERROR_SUCCESS);
8 RTEST(SetDCPenColor(0, RGB(0,0,0)) == CLR_INVALID);
9 TEST(GetLastError() == ERROR_INVALID_PARAMETER);
10
11 // Get the Screen DC
12 hScreenDC = GetDC(NULL);
13 if (hScreenDC == NULL) return FALSE;
14
15 // Test the screen DC
16 SetDCPenColor(hScreenDC, RGB(1,2,3));
17 TEST(SetDCPenColor(hScreenDC, RGB(4,5,6)) == RGB(1,2,3));
18
19 // Create a new DC
20 hDC = CreateCompatibleDC(hScreenDC);
21 ReleaseDC(0, hScreenDC);
22 if (hDC == NULL)
23 {
24 return FALSE;
25 }
26
27 // Select the DC_PEN and check if the pen returned by a new call is DC_PEN
28 SelectObject(hDC, GetStockObject(DC_PEN));
29 TEST(SelectObject(hDC, GetStockObject(BLACK_PEN)) == GetStockObject(DC_PEN));
30
31 // Test an incorrect color, yes windows sets the color!
32 SetDCPenColor(hDC, 0x21123456);
33 TEST(SetDCPenColor(hDC, RGB(0,0,0)) == 0x21123456);
34
35 // Test CLR_INVALID, it sets CLR_INVALID!
36 SetDCPenColor(hDC, CLR_INVALID);
37 RTEST(SetDCPenColor(hDC, RGB(0,0,0)) == CLR_INVALID);
38
39 // Delete the DC
40 DeleteDC(hDC);
41
42 return APISTATUS_NORMAL;
43 }