ReactOS 0.4.17-dev-243-g1369312
customlinecap.c File Reference
#include <limits.h>
#include "objbase.h"
#include "gdiplus.h"
#include "wine/test.h"
Include dependency graph for customlinecap.c:

Go to the source code of this file.

Macros

#define expect(expected, got)   ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
 
#define expectf(expected, got)   ok(got == expected, "Expected %.2f, got %.2f\n", expected, got)
 

Functions

static BOOL compare_uint (unsigned int x, unsigned int y, unsigned int max_diff)
 
static BOOL compare_float (float f, float g, unsigned int ulps)
 
static void test_constructor_destructor (void)
 
static void test_linejoin (void)
 
static void test_inset (void)
 
static void test_scale (void)
 
static void test_create_adjustable_cap (void)
 
static void test_captype (void)
 
static void test_strokecap (void)
 
 START_TEST (customlinecap)
 

Macro Definition Documentation

◆ expect

#define expect (   expected,
  got 
)    ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)

Definition at line 26 of file customlinecap.c.

◆ expectf

#define expectf (   expected,
  got 
)    ok(got == expected, "Expected %.2f, got %.2f\n", expected, got)

Definition at line 27 of file customlinecap.c.

Function Documentation

◆ compare_float()

static BOOL compare_float ( float  f,
float  g,
unsigned int  ulps 
)
static

Definition at line 36 of file customlinecap.c.

37{
38 int x = *(int *)&f;
39 int y = *(int *)&g;
40
41 if (x < 0)
42 x = INT_MIN - x;
43 if (y < 0)
44 y = INT_MIN - y;
45
46 return compare_uint(x, y, ulps);
47}
#define INT_MIN
Definition: limits.h:25
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLfloat f
Definition: glext.h:7540
GLboolean GLboolean g
Definition: glext.h:6204
unsigned int ulps
Definition: effect.c:4332
static BOOL compare_uint(unsigned int x, unsigned int y, unsigned int max_diff)
Definition: customlinecap.c:29

◆ compare_uint()

static BOOL compare_uint ( unsigned int  x,
unsigned int  y,
unsigned int  max_diff 
)
static

Definition at line 29 of file customlinecap.c.

30{
31 unsigned int diff = x > y ? x - y : y - x;
32
33 return diff <= max_diff;
34}

Referenced by compare_float().

◆ START_TEST()

START_TEST ( customlinecap  )

Definition at line 440 of file customlinecap.c.

441{
442 struct GdiplusStartupInput gdiplusStartupInput;
443 ULONG_PTR gdiplusToken;
444 HMODULE hmsvcrt;
445 int (CDECL * _controlfp_s)(unsigned int *cur, unsigned int newval, unsigned int mask);
446
447 /* Enable all FP exceptions except _EM_INEXACT, which gdi32 can trigger */
448 hmsvcrt = LoadLibraryA("msvcrt");
449 _controlfp_s = (void*)GetProcAddress(hmsvcrt, "_controlfp_s");
450 if (_controlfp_s) _controlfp_s(0, 0, 0x0008001e);
451
452 gdiplusStartupInput.GdiplusVersion = 1;
453 gdiplusStartupInput.DebugEventCallback = NULL;
454 gdiplusStartupInput.SuppressBackgroundThread = 0;
455 gdiplusStartupInput.SuppressExternalCodecs = 0;
456
457 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
458
461 test_inset();
462 test_scale();
464 test_captype();
466
467 GdiplusShutdown(gdiplusToken);
468}
#define NULL
Definition: types.h:112
#define CDECL
Definition: compat.h:29
#define GetProcAddress(x, y)
Definition: compat.h:753
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
_ACRTIMP errno_t __cdecl _controlfp_s(unsigned int *, unsigned int, unsigned int)
Definition: math.c:1304
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
FxCollectionEntry * cur
Status WINAPI GdiplusStartup(ULONG_PTR *token, const struct GdiplusStartupInput *input, struct GdiplusStartupOutput *output)
Definition: gdiplus.c:83
void WINAPI GdiplusShutdown(ULONG_PTR)
GLenum GLint GLuint mask
Definition: glext.h:6028
static void test_strokecap(void)
static void test_inset(void)
static void test_scale(void)
static void test_linejoin(void)
static void test_captype(void)
static void test_create_adjustable_cap(void)
static void test_constructor_destructor(void)
Definition: customlinecap.c:49
uint32_t ULONG_PTR
Definition: typedefs.h:65

◆ test_captype()

static void test_captype ( void  )
static

Definition at line 372 of file customlinecap.c.

373{
374 GpAdjustableArrowCap *arrowcap;
375 GpCustomLineCap *custom;
378 GpPath *path;
379
381 ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat);
382
383 type = 10;
385 ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat);
386 ok(type == 10, "Unexpected cap type, %d\n", type);
387
388 /* default cap */
390 ok(stat == Ok, "Failed to create path, %d\n", stat);
391 stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
392 ok(stat == Ok, "AddPathRectangle failed, %d\n", stat);
393
395 ok(stat == Ok, "Failed to create cap, %d\n", stat);
397 ok(stat == Ok, "Failed to get cap type, %d\n", stat);
398 ok(type == CustomLineCapTypeDefault, "Unexpected cap type %d\n", stat);
401
402 /* arrow cap */
403 stat = GdipCreateAdjustableArrowCap(17.0, 15.0, TRUE, &arrowcap);
404 ok(stat == Ok, "Failed to create adjustable cap, %d\n", stat);
405
407 ok(stat == Ok, "Failed to get cap type, %d\n", stat);
408 ok(type == CustomLineCapTypeAdjustableArrow, "Unexpected cap type %d\n", stat);
409
411}
#define stat
Definition: acwin.h:100
#define ok(value,...)
Definition: atltest.h:57
#define TRUE
Definition: types.h:120
GpStatus WINGDIPAPI GdipCreateCustomLineCap(GpPath *fillPath, GpPath *strokePath, GpLineCap baseCap, REAL baseInset, GpCustomLineCap **customCap)
GpStatus WINGDIPAPI GdipDeleteCustomLineCap(GpCustomLineCap *customCap)
GpStatus WINGDIPAPI GdipGetCustomLineCapType(GpCustomLineCap *customCap, CustomLineCapType *type)
GpStatus WINGDIPAPI GdipCreateAdjustableArrowCap(REAL height, REAL width, BOOL fill, GpAdjustableArrowCap **cap)
GpStatus WINGDIPAPI GdipCreatePath(GpFillMode fill, GpPath **path)
GpStatus WINGDIPAPI GdipDeletePath(GpPath *path)
GpStatus WINGDIPAPI GdipAddPathRectangle(GpPath *path, REAL x, REAL y, REAL width, REAL height)
CustomLineCapType
Definition: gdiplusenums.h:77
@ CustomLineCapTypeAdjustableArrow
Definition: gdiplusenums.h:79
@ CustomLineCapTypeDefault
Definition: gdiplusenums.h:78
@ LineCapFlat
Definition: gdiplusenums.h:61
@ FillModeAlternate
Definition: gdiplusenums.h:55
Status
Definition: gdiplustypes.h:24
@ Ok
Definition: gdiplustypes.h:25
@ InvalidParameter
Definition: gdiplustypes.h:27
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
Definition: stat.h:66

Referenced by START_TEST().

◆ test_constructor_destructor()

static void test_constructor_destructor ( void  )
static

Definition at line 49 of file customlinecap.c.

50{
51 GpCustomLineCap *custom;
52 GpPath *path, *path2, *pathFarAway;
54
56 expect(Ok, stat);
57 stat = GdipAddPathRectangle(path, -5.0, -4.0, 10.0, 8.0);
58 expect(Ok, stat);
59
61 expect(Ok, stat);
62 stat = GdipAddPathRectangle(path2, -5.0, -5.0, 10.0, 10.0);
63 expect(Ok, stat);
64
65 stat = GdipCreatePath(FillModeAlternate, &pathFarAway);
66 expect(Ok, stat);
67 stat = GdipAddPathRectangle(pathFarAway, 5.0, 5.0, 10.0, 10.0);
68 expect(Ok, stat);
69
70 /* NULL args */
81
82 /* If both parameters are provided, then fillPath will be ignored. */
83 custom = NULL;
85 expect(Ok, stat);
86 ok(custom != NULL, "Custom line cap was not created\n");
88 expect(Ok, stat);
89
90 /* valid args */
91 custom = NULL;
93 expect(Ok, stat);
94 ok(custom != NULL, "Custom line cap was not created\n");
96 expect(Ok, stat);
97
98 custom = NULL;
100 expect(Ok, stat);
101 ok(custom != NULL, "Custom line cap was not created\n");
103 expect(Ok, stat);
104
105 /* Custom line cap position (0, 0) is a place corresponding to the end of line.
106 * If Custom Line Cap is too big and too far from position (0, 0),
107 * then NotImplemented will be returned, due to floating point precision limitation. */
108 custom = NULL;
109 stat = GdipCreateCustomLineCap(pathFarAway, NULL, LineCapFlat, 10.0, &custom);
111 todo_wine ok(custom == NULL, "Expected a failure on creation\n");
112 if(stat == Ok) GdipDeleteCustomLineCap(custom);
113
114 GdipDeletePath(pathFarAway);
117}
@ NotImplemented
Definition: gdiplustypes.h:31
#define todo_wine
Definition: minitest.h:80
#define expect(expected, got)
Definition: customlinecap.c:26
static const WCHAR path2[]
Definition: path.c:29

Referenced by START_TEST().

◆ test_create_adjustable_cap()

static void test_create_adjustable_cap ( void  )
static

Definition at line 275 of file customlinecap.c.

276{
277 REAL inset, scale, height, width;
282 BOOL ret;
283
285 ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat);
286
287 stat = GdipCreateAdjustableArrowCap(17.0, 15.0, TRUE, &cap);
288 ok(stat == Ok, "Failed to create adjustable cap, %d\n", stat);
289
291 ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat);
292
293 ret = FALSE;
295 ok(stat == Ok, "Unexpected return code, %d\n", stat);
296 ok(ret, "Unexpected fill state %d\n", ret);
297
299 ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat);
300
302 ok(stat == Ok, "Unexpected return code, %d\n", stat);
303 ok(height == 17.0, "Unexpected cap height %f\n", height);
304
306 ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat);
307
309 ok(stat == Ok, "Unexpected return code, %d\n", stat);
310 ok(width == 15.0, "Unexpected cap width %f\n", width);
311
313 ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat);
314
316 ok(stat == Ok, "Unexpected return code, %d\n", stat);
317 ok(inset == 0.0f, "Unexpected middle inset %f\n", inset);
318
320 ok(stat == Ok, "Unexpected return code, %d\n", stat);
321 ok(base == LineCapTriangle, "Unexpected base cap %d\n", base);
322
324 ok(stat == Ok, "Unexpected return code, %d\n", stat);
325
327 ok(stat == Ok, "Unexpected return code, %d\n", stat);
328 ok(base == LineCapSquare, "Unexpected base cap %d\n", base);
329
331 ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat);
332
333 /* Base inset */
335 ok(stat == Ok, "Unexpected return code, %d\n", stat);
336
338 ok(stat == Ok, "Unexpected return code, %d\n", stat);
339
340 inset = 0.0;
342 ok(stat == Ok, "Unexpected return code, %d\n", stat);
343 ok(compare_float(inset, height / width, 1), "Unexpected inset %f\n", inset);
344
346 ok(stat == Ok, "Unexpected return code, %d\n", stat);
347
348 inset = 0.0;
350 ok(stat == Ok, "Unexpected return code, %d\n", stat);
351 ok(compare_float(inset, height / width, 1), "Unexpected inset %f\n", inset);
352
354 ok(stat == Ok, "Unexpected return code, %d\n", stat);
355
356 inset = 0.0;
358 ok(stat == Ok, "Unexpected return code, %d\n", stat);
359 ok(compare_float(inset, 2.0 * height / width, 1), "Unexpected inset %f\n", inset);
360
362 ok(stat == Ok, "Unexpected return code, %d\n", stat);
363 ok(scale == 1.0f, "Unexpected width scale %f\n", scale);
364
366 ok(stat == Ok, "Unexpected return code, %d\n", stat);
367 ok(join == LineJoinMiter, "Unexpected stroke join %d\n", join);
368
370}
#define FALSE
Definition: types.h:117
float REAL
Definition: types.h:41
GpStatus WINGDIPAPI GdipGetCustomLineCapBaseCap(GpCustomLineCap *customCap, GpLineCap *baseCap)
GpStatus WINGDIPAPI GdipGetAdjustableArrowCapFillState(GpAdjustableArrowCap *cap, BOOL *fill)
GpStatus WINGDIPAPI GdipGetCustomLineCapBaseInset(GpCustomLineCap *custom, REAL *inset)
GpStatus WINGDIPAPI GdipSetAdjustableArrowCapHeight(GpAdjustableArrowCap *cap, REAL height)
GpStatus WINGDIPAPI GdipGetAdjustableArrowCapHeight(GpAdjustableArrowCap *cap, REAL *height)
GpStatus WINGDIPAPI GdipGetCustomLineCapStrokeJoin(GpCustomLineCap *customCap, GpLineJoin *lineJoin)
GpStatus WINGDIPAPI GdipSetCustomLineCapBaseCap(GpCustomLineCap *custom, GpLineCap basecap)
GpStatus WINGDIPAPI GdipGetCustomLineCapWidthScale(GpCustomLineCap *custom, REAL *widthScale)
GpStatus WINGDIPAPI GdipGetAdjustableArrowCapWidth(GpAdjustableArrowCap *cap, REAL *width)
GpStatus WINGDIPAPI GdipGetAdjustableArrowCapMiddleInset(GpAdjustableArrowCap *cap, REAL *middle)
GpStatus WINGDIPAPI GdipSetAdjustableArrowCapMiddleInset(GpAdjustableArrowCap *cap, REAL middle)
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
LineJoin
Definition: gdiplusenums.h:104
@ LineJoinMiter
Definition: gdiplusenums.h:105
LineCap
Definition: gdiplusenums.h:60
@ LineCapTriangle
Definition: gdiplusenums.h:64
@ LineCapSquare
Definition: gdiplusenums.h:62
@ LineCapSquareAnchor
Definition: gdiplusenums.h:67
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032
GLenum cap
Definition: glext.h:9639
LOCAL int join(int *aux, int a, int b)
Definition: match.c:560
#define compare_float(got, exp)
Definition: mesh.c:52
#define cap
Definition: glfuncs.h:226

Referenced by START_TEST().

◆ test_inset()

static void test_inset ( void  )
static

Definition at line 170 of file customlinecap.c.

171{
172 GpCustomLineCap *custom;
173 GpPath *path;
174 REAL inset;
176
178 expect(Ok, stat);
179 stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
180 expect(Ok, stat);
181
183 expect(Ok, stat);
184
185 /* NULL args */
192 /* valid args */
193 inset = (REAL)0xdeadbeef;
194 stat = GdipGetCustomLineCapBaseInset(custom, &inset);
195 expect(Ok, stat);
196 expectf(0.0, inset);
197
198 stat = GdipSetCustomLineCapBaseInset(custom, 2.0);
199 expect(Ok, stat);
200
201 inset = (REAL)0xdeadbeef;
202 stat = GdipGetCustomLineCapBaseInset(custom, &inset);
203 expect(Ok, stat);
204 ok(inset == 2.0, "Unexpected inset value %f\n", inset);
205
208}
GpStatus WINGDIPAPI GdipSetCustomLineCapBaseInset(GpCustomLineCap *custom, REAL inset)
#define expectf(expected, got)
Definition: customlinecap.c:27

Referenced by START_TEST().

◆ test_linejoin()

static void test_linejoin ( void  )
static

Definition at line 119 of file customlinecap.c.

120{
121 GpCustomLineCap *custom;
122 GpPath *path;
125
127 expect(Ok, stat);
128 stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
129 expect(Ok, stat);
130
132 expect(Ok, stat);
133
134 /* NULL args */
143
144 /* LineJoinMiter is default */
146 expect(Ok, stat);
148
149 /* set/get */
151 expect(Ok, stat);
153 expect(Ok, stat);
156 expect(Ok, stat);
158 expect(Ok, stat);
161 expect(Ok, stat);
163 expect(Ok, stat);
165
168}
GpStatus WINGDIPAPI GdipSetCustomLineCapStrokeJoin(GpCustomLineCap *custom, GpLineJoin join)
@ LineJoinMiterClipped
Definition: gdiplusenums.h:108
@ LineJoinBevel
Definition: gdiplusenums.h:106
@ LineJoinRound
Definition: gdiplusenums.h:107

Referenced by START_TEST().

◆ test_scale()

static void test_scale ( void  )
static

Definition at line 210 of file customlinecap.c.

211{
212 GpCustomLineCap *custom;
213 GpPath *path;
214 REAL scale;
216
218 expect(Ok, stat);
219 stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
220 expect(Ok, stat);
221
223 expect(Ok, stat);
224
225 /* NULL args */
232
235
236 /* valid args: read default */
237 scale = (REAL)0xdeadbeef;
239 expect(Ok, stat);
240 expectf(1.0, scale);
241
242 /* set and read back some scale values: there is no limit for the scale */
244 expect(Ok, stat);
245 scale = (REAL)0xdeadbeef;
247 expect(Ok, stat);
248 expectf(2.5, scale);
249
250 stat = GdipSetCustomLineCapWidthScale(custom, 42.0);
251 expect(Ok, stat);
252 scale = (REAL)0xdeadbeef;
254 expect(Ok, stat);
255 expectf(42.0, scale);
256
257 stat = GdipSetCustomLineCapWidthScale(custom, 3000.0);
258 expect(Ok, stat);
259 scale = (REAL)0xdeadbeef;
261 expect(Ok, stat);
262 expectf(3000.0, scale);
263
265 expect(Ok, stat);
266 scale = (REAL)0xdeadbeef;
268 expect(Ok, stat);
269 expectf(0.0, scale);
270
273}
GpStatus WINGDIPAPI GdipSetCustomLineCapWidthScale(GpCustomLineCap *custom, REAL width)

Referenced by START_TEST().

◆ test_strokecap()

static void test_strokecap ( void  )
static

Definition at line 413 of file customlinecap.c.

414{
417 GpPath *path;
418
419 /* default cap */
421 ok(stat == Ok, "Failed to create path, %d\n", stat);
422 stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
423 ok(stat == Ok, "AddPathRectangle failed, %d\n", stat);
424
426 ok(stat == Ok, "Failed to create cap, %d\n", stat);
427
429 ok(stat == Ok, "Unexpected return code, %d\n", stat);
430
432 ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat);
433
435 ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat);
438}
GpStatus WINGDIPAPI GdipSetCustomLineCapStrokeCaps(GpCustomLineCap *custom, GpLineCap startcap, GpLineCap endcap)

Referenced by START_TEST().