gdiplus: Implemented GdipGetCustomLineCapBaseInset + test.
[wine/gsoc_dplay.git] / dlls / gdiplus / tests / customlinecap.c
blob26b964524ce2ee33849d71020f683e17ad81f927
1 /*
2 * Unit test suite for customlinecap
4 * Copyright (C) 2008 Nikolay Sivov
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 "windows.h"
22 #include "gdiplus.h"
23 #include "wine/test.h"
25 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
26 #define expectf(expected, got) ok(got == expected, "Expected %.2f, got %.2f\n", expected, got)
28 static void test_constructor_destructor(void)
30 GpCustomLineCap *custom;
31 GpPath *path, *path2;
32 GpStatus stat;
34 stat = GdipCreatePath(FillModeAlternate, &path);
35 expect(Ok, stat);
36 stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
37 expect(Ok, stat);
39 stat = GdipCreatePath(FillModeAlternate, &path2);
40 expect(Ok, stat);
41 stat = GdipAddPathRectangle(path2, 5.0, 5.0, 10.0, 10.0);
42 expect(Ok, stat);
44 /* NULL args */
45 stat = GdipCreateCustomLineCap(NULL, NULL, LineCapFlat, 0.0, NULL);
46 expect(InvalidParameter, stat);
47 stat = GdipCreateCustomLineCap(path, NULL, LineCapFlat, 0.0, NULL);
48 expect(InvalidParameter, stat);
49 stat = GdipCreateCustomLineCap(NULL, path, LineCapFlat, 0.0, NULL);
50 expect(InvalidParameter, stat);
51 stat = GdipCreateCustomLineCap(NULL, NULL, LineCapFlat, 0.0, &custom);
52 expect(InvalidParameter, stat);
53 stat = GdipDeleteCustomLineCap(NULL);
54 expect(InvalidParameter, stat);
56 /* valid args */
57 stat = GdipCreateCustomLineCap(NULL, path2, LineCapFlat, 0.0, &custom);
58 expect(Ok, stat);
59 stat = GdipDeleteCustomLineCap(custom);
60 expect(Ok, stat);
61 /* it's strange but native returns NotImplemented on stroke == NULL */
62 stat = GdipCreateCustomLineCap(path, NULL, LineCapFlat, 10.0, &custom);
63 todo_wine expect(NotImplemented, stat);
65 GdipDeletePath(path2);
66 GdipDeletePath(path);
69 static void test_linejoin(void)
71 GpCustomLineCap *custom;
72 GpPath *path;
73 GpLineJoin join;
74 GpStatus stat;
76 stat = GdipCreatePath(FillModeAlternate, &path);
77 expect(Ok, stat);
78 stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
79 expect(Ok, stat);
81 stat = GdipCreateCustomLineCap(NULL, path, LineCapFlat, 0.0, &custom);
82 expect(Ok, stat);
84 /* NULL args */
85 stat = GdipGetCustomLineCapStrokeJoin(NULL, NULL);
86 expect(InvalidParameter, stat);
87 stat = GdipGetCustomLineCapStrokeJoin(custom, NULL);
88 expect(InvalidParameter, stat);
89 stat = GdipGetCustomLineCapStrokeJoin(NULL, &join);
90 expect(InvalidParameter, stat);
91 stat = GdipSetCustomLineCapStrokeJoin(NULL, LineJoinBevel);
92 expect(InvalidParameter, stat);
94 /* LineJoinMiter is default */
95 stat = GdipGetCustomLineCapStrokeJoin(custom, &join);
96 expect(Ok, stat);
97 expect(LineJoinMiter, join);
99 /* set/get */
100 stat = GdipSetCustomLineCapStrokeJoin(custom, LineJoinBevel);
101 expect(Ok, stat);
102 stat = GdipGetCustomLineCapStrokeJoin(custom, &join);
103 expect(Ok, stat);
104 expect(LineJoinBevel, join);
105 stat = GdipSetCustomLineCapStrokeJoin(custom, LineJoinRound);
106 expect(Ok, stat);
107 stat = GdipGetCustomLineCapStrokeJoin(custom, &join);
108 expect(Ok, stat);
109 expect(LineJoinRound, join);
110 stat = GdipSetCustomLineCapStrokeJoin(custom, LineJoinMiterClipped);
111 expect(Ok, stat);
112 stat = GdipGetCustomLineCapStrokeJoin(custom, &join);
113 expect(Ok, stat);
114 expect(LineJoinMiterClipped, join);
116 GdipDeleteCustomLineCap(custom);
117 GdipDeletePath(path);
120 static void test_inset(void)
122 GpCustomLineCap *custom;
123 GpPath *path;
124 REAL inset;
125 GpStatus stat;
127 stat = GdipCreatePath(FillModeAlternate, &path);
128 expect(Ok, stat);
129 stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
130 expect(Ok, stat);
132 stat = GdipCreateCustomLineCap(NULL, path, LineCapFlat, 0.0, &custom);
133 expect(Ok, stat);
135 /* NULL args */
136 stat = GdipGetCustomLineCapBaseInset(NULL, NULL);
137 expect(InvalidParameter, stat);
138 stat = GdipGetCustomLineCapBaseInset(NULL, &inset);
139 expect(InvalidParameter, stat);
140 stat = GdipGetCustomLineCapBaseInset(custom, NULL);
141 expect(InvalidParameter, stat);
142 /* valid args */
143 inset = (REAL)0xdeadbeef;
144 stat = GdipGetCustomLineCapBaseInset(custom, &inset);
145 expect(Ok, stat);
146 expectf(0.0, inset);
148 GdipDeleteCustomLineCap(custom);
149 GdipDeletePath(path);
152 START_TEST(customlinecap)
154 struct GdiplusStartupInput gdiplusStartupInput;
155 ULONG_PTR gdiplusToken;
157 gdiplusStartupInput.GdiplusVersion = 1;
158 gdiplusStartupInput.DebugEventCallback = NULL;
159 gdiplusStartupInput.SuppressBackgroundThread = 0;
160 gdiplusStartupInput.SuppressExternalCodecs = 0;
162 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
164 test_constructor_destructor();
165 test_linejoin();
166 test_inset();
168 GdiplusShutdown(gdiplusToken);