1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for CreatePen
5 * PROGRAMMERS: Timo Kreuzer
6 */
7
8 #include "precomp.h"
9
Test_CreatePen()10 void Test_CreatePen()
11 {
12 HPEN hPen;
13 LOGPEN logpen;
14
15 SetLastError(ERROR_SUCCESS);
16 hPen = CreatePen(PS_DASHDOT, 5, RGB(1,2,3));
17 ok(hPen != 0, "CreatePen failed\n");
18 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %lu\n", GetLastError());
19
20 /* Test if we have a PEN */
21 ok(GDI_HANDLE_GET_TYPE(hPen) == GDI_OBJECT_TYPE_PEN, "Expected GDI_OBJECT_TYPE_PEN, got %lu\n", GDI_HANDLE_GET_TYPE(hPen));
22
23 ok(GetObject(hPen, sizeof(logpen), &logpen), "GetObject failed\n");
24 ok(logpen.lopnStyle == PS_DASHDOT, "Expected PS_DASHDOT, got %u\n", logpen.lopnStyle);
25 ok(logpen.lopnWidth.x == 5, "Expected 5, got %lu\n", logpen.lopnWidth.x);
26 ok(logpen.lopnColor == RGB(1,2,3), "Expected %x, got %x\n", (unsigned)RGB(1,2,3), (unsigned)logpen.lopnColor);
27 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %lu\n", GetLastError());
28 if(hPen)
29 ok(DeleteObject(hPen), "DeleteObject failed\n");
30 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %lu\n", GetLastError());
31
32 /* PS_GEOMETRIC | PS_DASHDOT = 0x00001011 will become PS_SOLID */
33 SetLastError(ERROR_SUCCESS);
34 logpen.lopnStyle = 22;
35 hPen = CreatePen(PS_GEOMETRIC | PS_DASHDOT, 5, RGB(1,2,3));
36 ok(hPen != 0, "CreatePen failed\n");
37 ok(GetObject(hPen, sizeof(logpen), &logpen), "GetObject failed\n");
38 ok(logpen.lopnStyle == PS_SOLID, "Expected PS_SOLID, got %u\n", logpen.lopnStyle);
39 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %lu\n", GetLastError());
40 if(hPen)
41 ok(DeleteObject(hPen), "DeleteObject failed\n");
42 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %lu\n", GetLastError());
43
44 /* PS_USERSTYLE will become PS_SOLID */
45 logpen.lopnStyle = 22;
46 SetLastError(ERROR_SUCCESS);
47 hPen = CreatePen(PS_USERSTYLE, 5, RGB(1,2,3));
48 ok(hPen != 0, "CreatePen failed\n");
49 ok(GetObject(hPen, sizeof(logpen), &logpen), "GetObject failed\n");
50 ok(logpen.lopnStyle == PS_SOLID, "Expected PS_SOLID, got %u\n", logpen.lopnStyle);
51 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %lu\n", GetLastError());
52 if(hPen)
53 ok(DeleteObject(hPen), "DeleteObject failed\n");
54 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %lu\n", GetLastError());
55
56 /* PS_ALTERNATE will become PS_SOLID */
57 logpen.lopnStyle = 22;
58 SetLastError(ERROR_SUCCESS);
59 hPen = CreatePen(PS_ALTERNATE, 5, RGB(1,2,3));
60 ok(hPen != 0, "CreatePen failed\n");
61 ok(GetObject(hPen, sizeof(logpen), &logpen), "GetObject failed\n");
62 ok(logpen.lopnStyle == PS_SOLID, "Expected PS_SOLID, got %u\n", logpen.lopnStyle);
63 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %lu\n", GetLastError());
64 if(hPen)
65 ok(DeleteObject(hPen), "DeleteObject failed\n");
66 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %lu\n", GetLastError());
67
68 /* PS_INSIDEFRAME is ok */
69 logpen.lopnStyle = 22;
70 SetLastError(ERROR_SUCCESS);
71 hPen = CreatePen(PS_INSIDEFRAME, 5, RGB(1,2,3));
72 ok(hPen != 0, "CreatePen failed\n");
73 ok(GetObject(hPen, sizeof(logpen), &logpen), "GetObject failed\n");
74 ok(logpen.lopnStyle == PS_INSIDEFRAME, "Expected PS_INSIDEFRAME, got %u\n", logpen.lopnStyle);
75 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %lu\n", GetLastError());
76 if(hPen)
77 ok(DeleteObject(hPen), "DeleteObject failed\n");
78 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %lu\n", GetLastError());
79 }
80
START_TEST(CreatePen)81 START_TEST(CreatePen)
82 {
83 Test_CreatePen();
84 }
85
86