krnl386.exe16: Update a comment.
[wine/testsucceed.git] / dlls / gdiplus / tests / customlinecap.c
blob218e46d2c4813f142b122cb22605fa661f689ff7
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 custom = NULL;
63 stat = GdipCreateCustomLineCap(path, NULL, LineCapFlat, 10.0, &custom);
64 todo_wine expect(NotImplemented, stat);
65 todo_wine ok(custom == NULL, "Expected a failure on creation\n");
66 if(stat == Ok) GdipDeleteCustomLineCap(custom);
68 GdipDeletePath(path2);
69 GdipDeletePath(path);
72 static void test_linejoin(void)
74 GpCustomLineCap *custom;
75 GpPath *path;
76 GpLineJoin join;
77 GpStatus stat;
79 stat = GdipCreatePath(FillModeAlternate, &path);
80 expect(Ok, stat);
81 stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
82 expect(Ok, stat);
84 stat = GdipCreateCustomLineCap(NULL, path, LineCapFlat, 0.0, &custom);
85 expect(Ok, stat);
87 /* NULL args */
88 stat = GdipGetCustomLineCapStrokeJoin(NULL, NULL);
89 expect(InvalidParameter, stat);
90 stat = GdipGetCustomLineCapStrokeJoin(custom, NULL);
91 expect(InvalidParameter, stat);
92 stat = GdipGetCustomLineCapStrokeJoin(NULL, &join);
93 expect(InvalidParameter, stat);
94 stat = GdipSetCustomLineCapStrokeJoin(NULL, LineJoinBevel);
95 expect(InvalidParameter, stat);
97 /* LineJoinMiter is default */
98 stat = GdipGetCustomLineCapStrokeJoin(custom, &join);
99 expect(Ok, stat);
100 expect(LineJoinMiter, join);
102 /* set/get */
103 stat = GdipSetCustomLineCapStrokeJoin(custom, LineJoinBevel);
104 expect(Ok, stat);
105 stat = GdipGetCustomLineCapStrokeJoin(custom, &join);
106 expect(Ok, stat);
107 expect(LineJoinBevel, join);
108 stat = GdipSetCustomLineCapStrokeJoin(custom, LineJoinRound);
109 expect(Ok, stat);
110 stat = GdipGetCustomLineCapStrokeJoin(custom, &join);
111 expect(Ok, stat);
112 expect(LineJoinRound, join);
113 stat = GdipSetCustomLineCapStrokeJoin(custom, LineJoinMiterClipped);
114 expect(Ok, stat);
115 stat = GdipGetCustomLineCapStrokeJoin(custom, &join);
116 expect(Ok, stat);
117 expect(LineJoinMiterClipped, join);
119 GdipDeleteCustomLineCap(custom);
120 GdipDeletePath(path);
123 static void test_inset(void)
125 GpCustomLineCap *custom;
126 GpPath *path;
127 REAL inset;
128 GpStatus stat;
130 stat = GdipCreatePath(FillModeAlternate, &path);
131 expect(Ok, stat);
132 stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
133 expect(Ok, stat);
135 stat = GdipCreateCustomLineCap(NULL, path, LineCapFlat, 0.0, &custom);
136 expect(Ok, stat);
138 /* NULL args */
139 stat = GdipGetCustomLineCapBaseInset(NULL, NULL);
140 expect(InvalidParameter, stat);
141 stat = GdipGetCustomLineCapBaseInset(NULL, &inset);
142 expect(InvalidParameter, stat);
143 stat = GdipGetCustomLineCapBaseInset(custom, NULL);
144 expect(InvalidParameter, stat);
145 /* valid args */
146 inset = (REAL)0xdeadbeef;
147 stat = GdipGetCustomLineCapBaseInset(custom, &inset);
148 expect(Ok, stat);
149 expectf(0.0, inset);
151 GdipDeleteCustomLineCap(custom);
152 GdipDeletePath(path);
155 static void test_scale(void)
157 GpCustomLineCap *custom;
158 GpPath *path;
159 REAL scale;
160 GpStatus stat;
162 stat = GdipCreatePath(FillModeAlternate, &path);
163 expect(Ok, stat);
164 stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
165 expect(Ok, stat);
167 stat = GdipCreateCustomLineCap(NULL, path, LineCapFlat, 0.0, &custom);
168 expect(Ok, stat);
170 /* NULL args */
171 stat = GdipGetCustomLineCapWidthScale(NULL, NULL);
172 expect(InvalidParameter, stat);
173 stat = GdipGetCustomLineCapWidthScale(NULL, &scale);
174 expect(InvalidParameter, stat);
175 stat = GdipGetCustomLineCapWidthScale(custom, NULL);
176 expect(InvalidParameter, stat);
177 /* valid args */
178 scale = (REAL)0xdeadbeef;
179 stat = GdipGetCustomLineCapWidthScale(custom, &scale);
180 expect(Ok, stat);
181 expectf(1.0, scale);
183 GdipDeleteCustomLineCap(custom);
184 GdipDeletePath(path);
187 START_TEST(customlinecap)
189 struct GdiplusStartupInput gdiplusStartupInput;
190 ULONG_PTR gdiplusToken;
192 gdiplusStartupInput.GdiplusVersion = 1;
193 gdiplusStartupInput.DebugEventCallback = NULL;
194 gdiplusStartupInput.SuppressBackgroundThread = 0;
195 gdiplusStartupInput.SuppressExternalCodecs = 0;
197 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
199 test_constructor_destructor();
200 test_linejoin();
201 test_inset();
202 test_scale();
204 GdiplusShutdown(gdiplusToken);