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 */
62 stat
= GdipCreateCustomLineCap(path
, NULL
, LineCapFlat
, 10.0, &custom
);
63 todo_wine
expect(NotImplemented
, stat
);
65 GdipDeletePath(path2
);
69 static void test_linejoin(void)
71 GpCustomLineCap
*custom
;
76 stat
= GdipCreatePath(FillModeAlternate
, &path
);
78 stat
= GdipAddPathRectangle(path
, 5.0, 5.0, 10.0, 10.0);
81 stat
= GdipCreateCustomLineCap(NULL
, path
, LineCapFlat
, 0.0, &custom
);
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
);
97 expect(LineJoinMiter
, join
);
100 stat
= GdipSetCustomLineCapStrokeJoin(custom
, LineJoinBevel
);
102 stat
= GdipGetCustomLineCapStrokeJoin(custom
, &join
);
104 expect(LineJoinBevel
, join
);
105 stat
= GdipSetCustomLineCapStrokeJoin(custom
, LineJoinRound
);
107 stat
= GdipGetCustomLineCapStrokeJoin(custom
, &join
);
109 expect(LineJoinRound
, join
);
110 stat
= GdipSetCustomLineCapStrokeJoin(custom
, LineJoinMiterClipped
);
112 stat
= GdipGetCustomLineCapStrokeJoin(custom
, &join
);
114 expect(LineJoinMiterClipped
, join
);
116 GdipDeleteCustomLineCap(custom
);
117 GdipDeletePath(path
);
120 static void test_inset(void)
122 GpCustomLineCap
*custom
;
127 stat
= GdipCreatePath(FillModeAlternate
, &path
);
129 stat
= GdipAddPathRectangle(path
, 5.0, 5.0, 10.0, 10.0);
132 stat
= GdipCreateCustomLineCap(NULL
, path
, LineCapFlat
, 0.0, &custom
);
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
);
143 inset
= (REAL
)0xdeadbeef;
144 stat
= GdipGetCustomLineCapBaseInset(custom
, &inset
);
148 GdipDeleteCustomLineCap(custom
);
149 GdipDeletePath(path
);
152 static void test_scale(void)
154 GpCustomLineCap
*custom
;
159 stat
= GdipCreatePath(FillModeAlternate
, &path
);
161 stat
= GdipAddPathRectangle(path
, 5.0, 5.0, 10.0, 10.0);
164 stat
= GdipCreateCustomLineCap(NULL
, path
, LineCapFlat
, 0.0, &custom
);
168 stat
= GdipGetCustomLineCapWidthScale(NULL
, NULL
);
169 expect(InvalidParameter
, stat
);
170 stat
= GdipGetCustomLineCapWidthScale(NULL
, &scale
);
171 expect(InvalidParameter
, stat
);
172 stat
= GdipGetCustomLineCapWidthScale(custom
, NULL
);
173 expect(InvalidParameter
, stat
);
175 scale
= (REAL
)0xdeadbeef;
176 stat
= GdipGetCustomLineCapWidthScale(custom
, &scale
);
180 GdipDeleteCustomLineCap(custom
);
181 GdipDeletePath(path
);
184 START_TEST(customlinecap
)
186 struct GdiplusStartupInput gdiplusStartupInput
;
187 ULONG_PTR gdiplusToken
;
189 gdiplusStartupInput
.GdiplusVersion
= 1;
190 gdiplusStartupInput
.DebugEventCallback
= NULL
;
191 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
192 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
194 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
196 test_constructor_destructor();
201 GdiplusShutdown(gdiplusToken
);