Release 0.9.39.
[wine/gsoc-2012-control.git] / dlls / gdi32 / tests / path.c
blobe9a6d39aeebfe200dff887d1f691d6b79ef623f8
1 /*
2 * Unit test suite for paths
4 * Copyright 2007 Laurent Vromman
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.
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.
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
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "wingdi.h"
27 #include "wine/test.h"
29 #include "winuser.h"
30 #include "winerror.h"
32 static void test_widenpath(void)
34 HDC hdc = GetDC(0);
35 HPEN greenPen, narrowPen;
36 HPEN oldPen;
37 POINT pnt[6];
38 INT nSize, ret;
39 DWORD error;
41 /* Create a pen to be used in WidenPath */
42 greenPen = CreatePen(PS_SOLID, 10, RGB(0,0,0));
43 oldPen = SelectObject(hdc, greenPen);
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;
59 /* Set a polyline path */
60 BeginPath(hdc);
61 Polyline(hdc, pnt, 6);
62 EndPath(hdc);
64 /* Widen the polyline path */
65 ok(WidenPath(hdc), "WidenPath fails while widening a poyline path.\n");
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);
72 AbortPath(hdc);
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);
81 AbortPath(hdc);
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);
92 ReleaseDC(0, hdc);
93 return;
96 START_TEST(path)
98 test_widenpath();