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
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
;
34 stat
= GdipCreatePath(FillModeAlternate
, &path
);
36 stat
= GdipAddPathRectangle(path
, 5.0, 5.0, 10.0, 10.0);
39 stat
= GdipCreatePath(FillModeAlternate
, &path2
);
41 stat
= GdipAddPathRectangle(path2
, 5.0, 5.0, 10.0, 10.0);
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
);
57 stat
= GdipCreateCustomLineCap(NULL
, path2
, LineCapFlat
, 0.0, &custom
);
59 stat
= GdipDeleteCustomLineCap(custom
);
61 /* it's strange but native returns NotImplemented on stroke == 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
);
72 static void test_linejoin(void)
74 GpCustomLineCap
*custom
;
79 stat
= GdipCreatePath(FillModeAlternate
, &path
);
81 stat
= GdipAddPathRectangle(path
, 5.0, 5.0, 10.0, 10.0);
84 stat
= GdipCreateCustomLineCap(NULL
, path
, LineCapFlat
, 0.0, &custom
);
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
);
100 expect(LineJoinMiter
, join
);
103 stat
= GdipSetCustomLineCapStrokeJoin(custom
, LineJoinBevel
);
105 stat
= GdipGetCustomLineCapStrokeJoin(custom
, &join
);
107 expect(LineJoinBevel
, join
);
108 stat
= GdipSetCustomLineCapStrokeJoin(custom
, LineJoinRound
);
110 stat
= GdipGetCustomLineCapStrokeJoin(custom
, &join
);
112 expect(LineJoinRound
, join
);
113 stat
= GdipSetCustomLineCapStrokeJoin(custom
, LineJoinMiterClipped
);
115 stat
= GdipGetCustomLineCapStrokeJoin(custom
, &join
);
117 expect(LineJoinMiterClipped
, join
);
119 GdipDeleteCustomLineCap(custom
);
120 GdipDeletePath(path
);
123 static void test_inset(void)
125 GpCustomLineCap
*custom
;
130 stat
= GdipCreatePath(FillModeAlternate
, &path
);
132 stat
= GdipAddPathRectangle(path
, 5.0, 5.0, 10.0, 10.0);
135 stat
= GdipCreateCustomLineCap(NULL
, path
, LineCapFlat
, 0.0, &custom
);
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
);
146 inset
= (REAL
)0xdeadbeef;
147 stat
= GdipGetCustomLineCapBaseInset(custom
, &inset
);
151 GdipDeleteCustomLineCap(custom
);
152 GdipDeletePath(path
);
155 static void test_scale(void)
157 GpCustomLineCap
*custom
;
162 stat
= GdipCreatePath(FillModeAlternate
, &path
);
164 stat
= GdipAddPathRectangle(path
, 5.0, 5.0, 10.0, 10.0);
167 stat
= GdipCreateCustomLineCap(NULL
, path
, LineCapFlat
, 0.0, &custom
);
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
);
178 scale
= (REAL
)0xdeadbeef;
179 stat
= GdipGetCustomLineCapWidthScale(custom
, &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();
204 GdiplusShutdown(gdiplusToken
);