wintrust: Implement WintrustLoadFunctionPointers.
[wine] / dlls / gdi32 / tests / path.c
1 /*
2  * Unit test suite for paths
3  *
4  * Copyright 2007 Laurent Vromman
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "wingdi.h"
26
27 #include "wine/test.h"
28
29 #include "winuser.h"
30 #include "winerror.h"
31
32 static void test_widenpath(void)
33 {
34     HDC hdc = GetDC(0);
35     HPEN greenPen, narrowPen;
36     HPEN oldPen;
37     POINT pnt[6];
38     INT nSize, ret;
39     DWORD error;
40
41     /* Create a pen to be used in WidenPath */
42     greenPen = CreatePen(PS_SOLID, 10, RGB(0,0,0));
43     oldPen = SelectObject(hdc, greenPen);
44
45     /* Prepare a path */
46     pnt[0].x = 100;
47     pnt[0].y = 0;
48     pnt[1].x = 200;
49     pnt[1].y = 0;
50     pnt[2].x = 300;
51     pnt[2].y = 100;
52     pnt[3].x = 300;
53     pnt[3].y = 200;
54     pnt[4].x = 200;
55     pnt[4].y = 300;
56     pnt[5].x = 100;
57     pnt[5].y = 300;
58
59     /* Set a polyline path */
60     BeginPath(hdc);
61     Polyline(hdc, pnt, 6);
62     EndPath(hdc);
63
64     /* Widen the polyline path */
65     ok(WidenPath(hdc), "WidenPath fails while widening a poyline path.\n");
66
67     /* Test if WidenPath seems to have done his job */
68     nSize = GetPath(hdc, NULL, NULL, 0);
69     ok(nSize != -1, "GetPath fails after calling WidenPath.\n");
70     ok(nSize > 6, "Path number of points is to low. Should be more than 6 but is %d\n", nSize);
71
72     AbortPath(hdc);
73
74     /* Test WidenPath with an open path */
75     SetLastError(0xdeadbeef);
76     BeginPath(hdc);
77     ret = WidenPath(hdc);
78     error = GetLastError();
79     ok(ret == FALSE && GetLastError() == ERROR_CAN_NOT_COMPLETE, "WidenPath fails while widening an open path. Return value is %d, should be %d. Error is %08x, should be %08x\n", ret, FALSE, GetLastError(), ERROR_CAN_NOT_COMPLETE);
80
81     AbortPath(hdc);
82
83     /* Test when the pen width is equal to 1. The path should not change */
84     narrowPen = CreatePen(PS_SOLID, 1, RGB(0,0,0));
85     oldPen = SelectObject(hdc, narrowPen);
86     BeginPath(hdc);
87     Polyline(hdc, pnt, 6);
88     EndPath(hdc);
89     nSize = GetPath(hdc, NULL, NULL, 0);
90     ok(nSize == 6, "WidenPath fails detecting 1px wide pen. Path length is %d, should be 6\n", nSize);
91
92     ReleaseDC(0, hdc);
93     return;
94 }
95
96 START_TEST(path)
97 {
98     test_widenpath();
99 }