[GDI32_APITEST] Add a PCH.
[reactos.git] / modules / rostests / apitests / gdi32 / SetDCPenColor.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for SetDCPenColor
5 * PROGRAMMERS: Timo Kreuzer
6 */
7
8 #include "precomp.h"
9
10 void Test_SetDCPenColor()
11 {
12 HDC hScreenDC, hDC;
13 HBITMAP hbmp, hbmpOld;
14
15 // Test an incorrect DC
16 SetLastError(ERROR_SUCCESS);
17 ok(SetDCPenColor(0, RGB(0,0,0)) == CLR_INVALID, "\n");
18 ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n");
19
20 // Get the Screen DC
21 hScreenDC = GetDC(NULL);
22 ok(hScreenDC != 0, "GetDC failed, skipping tests\n");
23 if (hScreenDC == NULL) return;
24
25 // Test the screen DC
26 SetDCPenColor(hScreenDC, RGB(1,2,3));
27 ok(SetDCPenColor(hScreenDC, RGB(4,5,6)) == RGB(1,2,3), "\n");
28
29 // Create a new DC
30 hDC = CreateCompatibleDC(hScreenDC);
31 ReleaseDC(0, hScreenDC);
32 ok(hDC != 0, "CreateCompatibleDC failed, skipping tests\n");
33 if (!hDC) return;
34
35 // Select the DC_PEN and check if the pen returned by a new call is DC_PEN
36 SelectObject(hDC, GetStockObject(DC_PEN));
37 ok(SelectObject(hDC, GetStockObject(BLACK_PEN)) == GetStockObject(DC_PEN), "\n");
38
39 // Test an incorrect color, yes windows sets the color!
40 SetDCPenColor(hDC, 0x21123456);
41 ok(SetDCPenColor(hDC, RGB(0,0,0)) == 0x21123456, "\n");
42
43 // Test CLR_INVALID, it sets CLR_INVALID!
44 SetDCPenColor(hDC, CLR_INVALID);
45 ok(SetDCPenColor(hDC, RGB(0,0,0)) == CLR_INVALID, "\n");
46
47 hbmp = CreateBitmap(10, 10, 1, 32, NULL);
48 ok(hbmp != 0, "CreateBitmap failed, skipping tests\n");
49 if (!hbmp) return;
50 hbmpOld = SelectObject(hDC, hbmp);
51 #if 0 // this only works on 32 bpp screen resolution
52 ok(hbmpOld != NULL, "\n");
53 SelectObject(hDC, GetStockObject(DC_PEN));
54 SetDCPenColor(hDC, 0x123456);
55 MoveToEx(hDC, 0, 0, NULL);
56 LineTo(hDC, 10, 0);
57 ok(GetPixel(hDC, 5, 0) == 0x123456, "\n");
58 #endif
59
60 // Delete the DC
61 SelectObject(hDC, hbmpOld);
62 DeleteDC(hDC);
63 }
64
65 START_TEST(SetDCPenColor)
66 {
67 Test_SetDCPenColor();
68 }
69