ReactOS  0.4.14-dev-614-gbfd8a84
CreatePen.c
Go to the documentation of this file.
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 
11 {
12  HPEN hPen;
13  LOGPEN logpen;
14 
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 */
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;
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;
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;
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 
82 {
84 }
85 
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define ERROR_SUCCESS
Definition: deptool.c:10
long x
Definition: polytest.cpp:48
START_TEST(CreatePen)
Definition: CreatePen.c:81
POINT lopnWidth
Definition: wingdi.h:1845
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define PS_GEOMETRIC
Definition: wingdi.h:582
#define PS_SOLID
Definition: wingdi.h:585
UINT lopnStyle
Definition: wingdi.h:1844
COLORREF lopnColor
Definition: wingdi.h:1846
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
#define PS_ALTERNATE
Definition: wingdi.h:584
#define GDI_OBJECT_TYPE_PEN
Definition: gdi.h:54
#define RGB(r, g, b)
Definition: wingdi.h:2939
#define SetLastError(x)
Definition: compat.h:417
#define GetObject
Definition: wingdi.h:4467
#define PS_INSIDEFRAME
Definition: wingdi.h:592
#define ok(value,...)
Definition: atltest.h:57
#define PS_DASHDOT
Definition: wingdi.h:588
void Test_CreatePen()
Definition: CreatePen.c:10
#define PS_USERSTYLE
Definition: wingdi.h:591