ReactOS  0.4.15-dev-489-g75a0787
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_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)
 
 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 29 of file customlinecap.c.

30 {
31  int x = *(int *)&f;
32  int y = *(int *)&g;
33 
34  if (x < 0)
35  x = INT_MIN - x;
36  if (y < 0)
37  y = INT_MIN - y;
38 
39  if (abs(x - y) > ulps)
40  return FALSE;
41 
42  return TRUE;
43 }
#define abs(i)
Definition: fconv.c:206
#define TRUE
Definition: types.h:120
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLboolean GLboolean g
Definition: glext.h:6204
GLfloat f
Definition: glext.h:7540
#define INT_MIN
Definition: limits.h:39
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
unsigned int ulps
Definition: effect.c:4351

Referenced by test_create_adjustable_cap().

◆ START_TEST()

START_TEST ( customlinecap  )

Definition at line 374 of file customlinecap.c.

375 {
376  struct GdiplusStartupInput gdiplusStartupInput;
378  HMODULE hmsvcrt;
379  int (CDECL * _controlfp_s)(unsigned int *cur, unsigned int newval, unsigned int mask);
380 
381  /* Enable all FP exceptions except _EM_INEXACT, which gdi32 can trigger */
382  hmsvcrt = LoadLibraryA("msvcrt");
383  _controlfp_s = (void*)GetProcAddress(hmsvcrt, "_controlfp_s");
384  if (_controlfp_s) _controlfp_s(0, 0, 0x0008001e);
385 
386  gdiplusStartupInput.GdiplusVersion = 1;
387  gdiplusStartupInput.DebugEventCallback = NULL;
388  gdiplusStartupInput.SuppressBackgroundThread = 0;
389  gdiplusStartupInput.SuppressExternalCodecs = 0;
390 
391  GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
392 
394  test_linejoin();
395  test_inset();
396  test_scale();
398  test_captype();
399 
401 }
static void test_create_adjustable_cap(void)
uint32_t ULONG_PTR
Definition: typedefs.h:64
GLenum GLint GLuint mask
Definition: glext.h:6028
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
smooth NULL
Definition: ftsmooth.c:416
int CDECL _controlfp_s(unsigned int *cur, unsigned int newval, unsigned int mask)
Definition: cntrlfp.c:120
static void test_scale(void)
void WINAPI GdiplusShutdown(ULONG_PTR)
Status WINAPI GdiplusStartup(ULONG_PTR *token, const struct GdiplusStartupInput *input, struct GdiplusStartupOutput *output)
Definition: gdiplus.c:81
static ULONG_PTR gdiplusToken
Definition: CImage.cpp:79
static void test_linejoin(void)
Definition: customlinecap.c:89
static void test_constructor_destructor(void)
Definition: customlinecap.c:45
#define CDECL
Definition: compat.h:21
static void test_inset(void)
#define GetProcAddress(x, y)
Definition: compat.h:419
static void test_captype(void)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

◆ test_captype()

static void test_captype ( void  )
static

Definition at line 333 of file customlinecap.c.

334 {
335  GpAdjustableArrowCap *arrowcap;
336  GpCustomLineCap *custom;
338  GpStatus stat;
339  GpPath *path;
340 
342  ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat);
343 
344  type = 10;
346  ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat);
347  ok(type == 10, "Unexpected cap type, %d\n", type);
348 
349  /* default cap */
351  ok(stat == Ok, "Failed to create path, %d\n", stat);
352  stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
353  ok(stat == Ok, "AddPathRectangle failed, %d\n", stat);
354 
355  stat = GdipCreateCustomLineCap(NULL, path, LineCapFlat, 0.0, &custom);
356  ok(stat == Ok, "Failed to create cap, %d\n", stat);
357  stat = GdipGetCustomLineCapType(custom, &type);
358  ok(stat == Ok, "Failed to get cap type, %d\n", stat);
359  ok(type == CustomLineCapTypeDefault, "Unexpected cap type %d\n", stat);
360  GdipDeleteCustomLineCap(custom);
362 
363  /* arrow cap */
364  stat = GdipCreateAdjustableArrowCap(17.0, 15.0, TRUE, &arrowcap);
365  ok(stat == Ok, "Failed to create adjustable cap, %d\n", stat);
366 
368  ok(stat == Ok, "Failed to get cap type, %d\n", stat);
369  ok(type == CustomLineCapTypeAdjustableArrow, "Unexpected cap type %d\n", stat);
370 
372 }
GpStatus WINGDIPAPI GdipCreateCustomLineCap(GpPath *fillPath, GpPath *strokePath, GpLineCap baseCap, REAL baseInset, GpCustomLineCap **customCap)
#define TRUE
Definition: types.h:120
GLsizei const GLchar ** path
Definition: glext.h:7234
GpStatus WINGDIPAPI GdipGetCustomLineCapType(GpCustomLineCap *customCap, CustomLineCapType *type)
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GpStatus WINGDIPAPI GdipDeletePath(GpPath *path)
GpStatus WINGDIPAPI GdipDeleteCustomLineCap(GpCustomLineCap *customCap)
smooth NULL
Definition: ftsmooth.c:416
GpStatus WINGDIPAPI GdipAddPathRectangle(GpPath *path, REAL x, REAL y, REAL width, REAL height)
GpStatus WINGDIPAPI GdipCreatePath(GpFillMode fill, GpPath **path)
Definition: stat.h:55
Status
Definition: gdiplustypes.h:24
GpStatus WINGDIPAPI GdipCreateAdjustableArrowCap(REAL height, REAL width, BOOL fill, GpAdjustableArrowCap **cap)
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
#define ok(value,...)
Definition: atltest.h:57
CustomLineCapType
Definition: gdiplusenums.h:76

Referenced by START_TEST().

◆ test_constructor_destructor()

static void test_constructor_destructor ( void  )
static

Definition at line 45 of file customlinecap.c.

46 {
47  GpCustomLineCap *custom;
48  GpPath *path, *path2;
49  GpStatus stat;
50 
52  expect(Ok, stat);
53  stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
54  expect(Ok, stat);
55 
57  expect(Ok, stat);
58  stat = GdipAddPathRectangle(path2, 5.0, 5.0, 10.0, 10.0);
59  expect(Ok, stat);
60 
61  /* NULL args */
72 
73  /* valid args */
75  expect(Ok, stat);
76  stat = GdipDeleteCustomLineCap(custom);
77  expect(Ok, stat);
78  /* it's strange but native returns NotImplemented on stroke == NULL */
79  custom = NULL;
80  stat = GdipCreateCustomLineCap(path, NULL, LineCapFlat, 10.0, &custom);
82  todo_wine ok(custom == NULL, "Expected a failure on creation\n");
83  if(stat == Ok) GdipDeleteCustomLineCap(custom);
84 
87 }
GpStatus WINGDIPAPI GdipCreateCustomLineCap(GpPath *fillPath, GpPath *strokePath, GpLineCap baseCap, REAL baseInset, GpCustomLineCap **customCap)
static const WCHAR path2[]
Definition: path.c:29
GLsizei const GLchar ** path
Definition: glext.h:7234
GpStatus WINGDIPAPI GdipDeletePath(GpPath *path)
GpStatus WINGDIPAPI GdipDeleteCustomLineCap(GpCustomLineCap *customCap)
smooth NULL
Definition: ftsmooth.c:416
GpStatus WINGDIPAPI GdipAddPathRectangle(GpPath *path, REAL x, REAL y, REAL width, REAL height)
#define todo_wine
Definition: test.h:162
GpStatus WINGDIPAPI GdipCreatePath(GpFillMode fill, GpPath **path)
Definition: stat.h:55
Status
Definition: gdiplustypes.h:24
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
#define ok(value,...)
Definition: atltest.h:57
#define expect(expected, got)
Definition: customlinecap.c:26

Referenced by START_TEST().

◆ test_create_adjustable_cap()

static void test_create_adjustable_cap ( void  )
static

Definition at line 237 of file customlinecap.c.

238 {
239  REAL inset, scale, height, width;
242  GpStatus stat;
243  GpLineCap base;
244  BOOL ret;
245 
246  stat = GdipCreateAdjustableArrowCap(10.0, 10.0, TRUE, NULL);
247  ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat);
248 
249  stat = GdipCreateAdjustableArrowCap(17.0, 15.0, TRUE, &cap);
250  ok(stat == Ok, "Failed to create adjustable cap, %d\n", stat);
251 
253  ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat);
254 
255  ret = FALSE;
257  ok(stat == Ok, "Unexpected return code, %d\n", stat);
258  ok(ret, "Unexpected fill state %d\n", ret);
259 
261  ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat);
262 
264  ok(stat == Ok, "Unexpected return code, %d\n", stat);
265  ok(height == 17.0, "Unexpected cap height %f\n", height);
266 
268  ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat);
269 
271  ok(stat == Ok, "Unexpected return code, %d\n", stat);
272  ok(width == 15.0, "Unexpected cap width %f\n", width);
273 
275  ok(stat == InvalidParameter, "Unexpected return code, %d\n", stat);
276 
278  ok(stat == Ok, "Unexpected return code, %d\n", stat);
279  ok(inset == 0.0f, "Unexpected middle inset %f\n", inset);
280 
282  ok(stat == Ok, "Unexpected return code, %d\n", stat);
283  ok(base == LineCapTriangle, "Unexpected base cap %d\n", base);
284 
286 todo_wine
287  ok(stat == Ok, "Unexpected return code, %d\n", stat);
288 
290  ok(stat == Ok, "Unexpected return code, %d\n", stat);
291 todo_wine
292  ok(base == LineCapSquare, "Unexpected base cap %d\n", base);
293 
294  /* Base inset */
296  ok(stat == Ok, "Unexpected return code, %d\n", stat);
297 
299  ok(stat == Ok, "Unexpected return code, %d\n", stat);
300 
301  inset = 0.0;
303  ok(stat == Ok, "Unexpected return code, %d\n", stat);
304  ok(compare_float(inset, height / width, 1), "Unexpected inset %f\n", inset);
305 
307  ok(stat == Ok, "Unexpected return code, %d\n", stat);
308 
309  inset = 0.0;
311  ok(stat == Ok, "Unexpected return code, %d\n", stat);
312  ok(compare_float(inset, height / width, 1), "Unexpected inset %f\n", inset);
313 
315  ok(stat == Ok, "Unexpected return code, %d\n", stat);
316 
317  inset = 0.0;
319  ok(stat == Ok, "Unexpected return code, %d\n", stat);
320  ok(compare_float(inset, 2.0 * height / width, 1), "Unexpected inset %f\n", inset);
321 
323  ok(stat == Ok, "Unexpected return code, %d\n", stat);
324  ok(scale == 1.0f, "Unexpected width scale %f\n", scale);
325 
327  ok(stat == Ok, "Unexpected return code, %d\n", stat);
328  ok(join == LineJoinMiter, "Unexpected stroke join %d\n", join);
329 
331 }
GLint GLint GLsizei width
Definition: gl.h:1546
GpStatus WINGDIPAPI GdipGetCustomLineCapWidthScale(GpCustomLineCap *custom, REAL *widthScale)
#define TRUE
Definition: types.h:120
GpStatus WINGDIPAPI GdipGetCustomLineCapBaseInset(GpCustomLineCap *custom, REAL *inset)
GpStatus WINGDIPAPI GdipSetCustomLineCapBaseCap(GpCustomLineCap *custom, GpLineCap base)
GpStatus WINGDIPAPI GdipGetAdjustableArrowCapWidth(GpAdjustableArrowCap *cap, REAL *width)
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032
LineJoin
Definition: gdiplusenums.h:104
GpStatus WINGDIPAPI GdipDeleteCustomLineCap(GpCustomLineCap *customCap)
GLenum cap
Definition: glext.h:9639
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint base
Definition: 3dtext.c:35
smooth NULL
Definition: ftsmooth.c:416
GpStatus WINGDIPAPI GdipGetAdjustableArrowCapHeight(GpAdjustableArrowCap *cap, REAL *height)
LOCAL int join(int *aux, int a, int b)
Definition: match.c:560
GLfloat f
Definition: glext.h:7540
LineCap
Definition: gdiplusenums.h:59
GpStatus WINGDIPAPI GdipSetAdjustableArrowCapHeight(GpAdjustableArrowCap *cap, REAL height)
int ret
#define todo_wine
Definition: test.h:162
Definition: stat.h:55
#define cap
Definition: glfuncs.h:226
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
Status
Definition: gdiplustypes.h:24
GpStatus WINGDIPAPI GdipCreateAdjustableArrowCap(REAL height, REAL width, BOOL fill, GpAdjustableArrowCap **cap)
GpStatus WINGDIPAPI GdipGetCustomLineCapBaseCap(GpCustomLineCap *customCap, GpLineCap *baseCap)
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
GpStatus WINGDIPAPI GdipGetAdjustableArrowCapMiddleInset(GpAdjustableArrowCap *cap, REAL *middle)
GpStatus WINGDIPAPI GdipSetAdjustableArrowCapMiddleInset(GpAdjustableArrowCap *cap, REAL middle)
#define ok(value,...)
Definition: atltest.h:57
GpStatus WINGDIPAPI GdipGetCustomLineCapStrokeJoin(GpCustomLineCap *customCap, GpLineJoin *lineJoin)
float REAL
Definition: types.h:41
GpStatus WINGDIPAPI GdipGetAdjustableArrowCapFillState(GpAdjustableArrowCap *cap, BOOL *fill)
static BOOL compare_float(float f, float g, unsigned int ulps)
Definition: customlinecap.c:29

Referenced by START_TEST().

◆ test_inset()

static void test_inset ( void  )
static

Definition at line 140 of file customlinecap.c.

141 {
142  GpCustomLineCap *custom;
143  GpPath *path;
144  REAL inset;
145  GpStatus stat;
146 
148  expect(Ok, stat);
149  stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
150  expect(Ok, stat);
151 
152  stat = GdipCreateCustomLineCap(NULL, path, LineCapFlat, 0.0, &custom);
153  expect(Ok, stat);
154 
155  /* NULL args */
162  /* valid args */
163  inset = (REAL)0xdeadbeef;
164  stat = GdipGetCustomLineCapBaseInset(custom, &inset);
165  expect(Ok, stat);
166  expectf(0.0, inset);
167 
168  GdipDeleteCustomLineCap(custom);
170 }
GpStatus WINGDIPAPI GdipCreateCustomLineCap(GpPath *fillPath, GpPath *strokePath, GpLineCap baseCap, REAL baseInset, GpCustomLineCap **customCap)
GpStatus WINGDIPAPI GdipGetCustomLineCapBaseInset(GpCustomLineCap *custom, REAL *inset)
GLsizei const GLchar ** path
Definition: glext.h:7234
#define expectf(expected, got)
Definition: customlinecap.c:27
GpStatus WINGDIPAPI GdipDeletePath(GpPath *path)
GpStatus WINGDIPAPI GdipDeleteCustomLineCap(GpCustomLineCap *customCap)
smooth NULL
Definition: ftsmooth.c:416
GpStatus WINGDIPAPI GdipAddPathRectangle(GpPath *path, REAL x, REAL y, REAL width, REAL height)
GpStatus WINGDIPAPI GdipCreatePath(GpFillMode fill, GpPath **path)
Definition: stat.h:55
Status
Definition: gdiplustypes.h:24
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
#define expect(expected, got)
Definition: customlinecap.c:26
float REAL
Definition: types.h:41

Referenced by START_TEST().

◆ test_linejoin()

static void test_linejoin ( void  )
static

Definition at line 89 of file customlinecap.c.

90 {
91  GpCustomLineCap *custom;
92  GpPath *path;
94  GpStatus stat;
95 
97  expect(Ok, stat);
98  stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
99  expect(Ok, stat);
100 
101  stat = GdipCreateCustomLineCap(NULL, path, LineCapFlat, 0.0, &custom);
102  expect(Ok, stat);
103 
104  /* NULL args */
113 
114  /* LineJoinMiter is default */
116  expect(Ok, stat);
118 
119  /* set/get */
121  expect(Ok, stat);
123  expect(Ok, stat);
126  expect(Ok, stat);
128  expect(Ok, stat);
131  expect(Ok, stat);
133  expect(Ok, stat);
135 
136  GdipDeleteCustomLineCap(custom);
138 }
GpStatus WINGDIPAPI GdipCreateCustomLineCap(GpPath *fillPath, GpPath *strokePath, GpLineCap baseCap, REAL baseInset, GpCustomLineCap **customCap)
GLsizei const GLchar ** path
Definition: glext.h:7234
LineJoin
Definition: gdiplusenums.h:104
GpStatus WINGDIPAPI GdipDeletePath(GpPath *path)
GpStatus WINGDIPAPI GdipDeleteCustomLineCap(GpCustomLineCap *customCap)
smooth NULL
Definition: ftsmooth.c:416
LOCAL int join(int *aux, int a, int b)
Definition: match.c:560
GpStatus WINGDIPAPI GdipAddPathRectangle(GpPath *path, REAL x, REAL y, REAL width, REAL height)
GpStatus WINGDIPAPI GdipCreatePath(GpFillMode fill, GpPath **path)
Definition: stat.h:55
Status
Definition: gdiplustypes.h:24
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
GpStatus WINGDIPAPI GdipSetCustomLineCapStrokeJoin(GpCustomLineCap *custom, GpLineJoin join)
#define expect(expected, got)
Definition: customlinecap.c:26
GpStatus WINGDIPAPI GdipGetCustomLineCapStrokeJoin(GpCustomLineCap *customCap, GpLineJoin *lineJoin)

Referenced by START_TEST().

◆ test_scale()

static void test_scale ( void  )
static

Definition at line 172 of file customlinecap.c.

173 {
174  GpCustomLineCap *custom;
175  GpPath *path;
176  REAL scale;
177  GpStatus stat;
178 
180  expect(Ok, stat);
181  stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
182  expect(Ok, stat);
183 
184  stat = GdipCreateCustomLineCap(NULL, path, LineCapFlat, 0.0, &custom);
185  expect(Ok, stat);
186 
187  /* NULL args */
194 
197 
198  /* valid args: read default */
199  scale = (REAL)0xdeadbeef;
201  expect(Ok, stat);
202  expectf(1.0, scale);
203 
204  /* set and read back some scale values: there is no limit for the scale */
205  stat = GdipSetCustomLineCapWidthScale(custom, 2.5);
206  expect(Ok, stat);
207  scale = (REAL)0xdeadbeef;
209  expect(Ok, stat);
210  expectf(2.5, scale);
211 
212  stat = GdipSetCustomLineCapWidthScale(custom, 42.0);
213  expect(Ok, stat);
214  scale = (REAL)0xdeadbeef;
216  expect(Ok, stat);
217  expectf(42.0, scale);
218 
219  stat = GdipSetCustomLineCapWidthScale(custom, 3000.0);
220  expect(Ok, stat);
221  scale = (REAL)0xdeadbeef;
223  expect(Ok, stat);
224  expectf(3000.0, scale);
225 
226  stat = GdipSetCustomLineCapWidthScale(custom, 0.0);
227  expect(Ok, stat);
228  scale = (REAL)0xdeadbeef;
230  expect(Ok, stat);
231  expectf(0.0, scale);
232 
233  GdipDeleteCustomLineCap(custom);
235 }
GpStatus WINGDIPAPI GdipCreateCustomLineCap(GpPath *fillPath, GpPath *strokePath, GpLineCap baseCap, REAL baseInset, GpCustomLineCap **customCap)
GpStatus WINGDIPAPI GdipGetCustomLineCapWidthScale(GpCustomLineCap *custom, REAL *widthScale)
GLsizei const GLchar ** path
Definition: glext.h:7234
#define expectf(expected, got)
Definition: customlinecap.c:27
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032
GpStatus WINGDIPAPI GdipDeletePath(GpPath *path)
GpStatus WINGDIPAPI GdipDeleteCustomLineCap(GpCustomLineCap *customCap)
smooth NULL
Definition: ftsmooth.c:416
GpStatus WINGDIPAPI GdipAddPathRectangle(GpPath *path, REAL x, REAL y, REAL width, REAL height)
GpStatus WINGDIPAPI GdipCreatePath(GpFillMode fill, GpPath **path)
Definition: stat.h:55
GpStatus WINGDIPAPI GdipSetCustomLineCapWidthScale(GpCustomLineCap *custom, REAL width)
Status
Definition: gdiplustypes.h:24
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
#define expect(expected, got)
Definition: customlinecap.c:26
float REAL
Definition: types.h:41

Referenced by START_TEST().