ReactOS 0.4.16-dev-306-g647d351
ExtCreatePen.c File Reference
#include "precomp.h"
#include <pseh/pseh2.h>
Include dependency graph for ExtCreatePen.c:

Go to the source code of this file.

Macros

#define ok_lasterror(err)    ok(GetLastError() == err, "expected last error " #err " but got 0x%lx\n", GetLastError());
 
#define ok_elp(hPen, elp, pstyle, width, bstyle, color, hatch, cstyle)
 
#define ok2(expression, text, expected, got)
 

Functions

void Test_ExtCreatePen_Params ()
 
BOOL Test_ExtCreatePen_Expect (DWORD dwPenStyle, DWORD dwWidth, DWORD dwStyleCount, PDWORD pdwStyles, UINT lbStyle, ULONG_PTR lbHatch, PBOOL pbExpectException, PEXTLOGPEN pelpExpect)
 
void Test_ExtCreatePen_Helper (DWORD dwPenStyle, DWORD dwWidth, DWORD dwStyleCount, PDWORD pdwStyles, UINT lbStyle, ULONG_PTR lbHatch)
 
void Test_ExtCreatePen_Params2 ()
 
 START_TEST (ExtCreatePen)
 

Macro Definition Documentation

◆ ok2

#define ok2 (   expression,
  text,
  expected,
  got 
)
Value:
ok(expression, text \
"(dwPenStyle=0x%lx, dwWidth=%lu, dwStyleCount=%lu, pdwStyles=%p, lbStyle=%u, lbHatch=%p)\n", \
expected, got, dwPenStyle, dwWidth, dwStyleCount, pdwStyles, lbStyle, (PVOID)lbHatch);
#define ok(value,...)
Definition: atltest.h:57
static const WCHAR dwWidth[]
Definition: provider.c:62
const WCHAR * text
Definition: package.c:1794
BOOL expected
Definition: store.c:2063

◆ ok_elp

#define ok_elp (   hPen,
  elp,
  pstyle,
  width,
  bstyle,
  color,
  hatch,
  cstyle 
)
Value:
ok(GetObjectA(hPen, sizeof(elpBuffer), elp) != 0, "GetObject failed\n"); \
ok((elp)->elpPenStyle == (pstyle), "Wrong elpPenStyle, expected 0x%lx, got 0x%lx\n", (DWORD)pstyle, (elp)->elpPenStyle); \
ok((elp)->elpWidth == width, "Wrong elpWidth, expected %lu, got %lu\n", (DWORD)width, (elp)->elpWidth); \
ok((elp)->elpBrushStyle == (bstyle), "Wrong elpBrushStyle, expected 0x%x, got 0x%x\n", bstyle, (elp)->elpBrushStyle); \
ok((elp)->elpColor == color, "Wrong elpColor, expected 0x%lx, got 0x%lx\n", (COLORREF)color, (elp)->elpColor); \
ok((elp)->elpHatch == hatch, "Wrong elpHatch, expected 0x%p, got 0x%p\n", (PVOID)hatch, (PVOID)(elp)->elpHatch); \
ok((elp)->elpNumEntries == cstyle, "Wrong elpNumEntries, expected %lu got %lu\n", (DWORD)cstyle, (elp)->elpNumEntries);
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLint GLsizei width
Definition: gl.h:1546
GLuint color
Definition: glext.h:6243
DWORD COLORREF
Definition: windef.h:300
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)

Definition at line 15 of file ExtCreatePen.c.

◆ ok_lasterror

#define ok_lasterror (   err)     ok(GetLastError() == err, "expected last error " #err " but got 0x%lx\n", GetLastError());

Definition at line 12 of file ExtCreatePen.c.

Function Documentation

◆ START_TEST()

START_TEST ( ExtCreatePen  )

Definition at line 534 of file ExtCreatePen.c.

535{
537 //Test_ExtCreatePen_Params2();
538}
void Test_ExtCreatePen_Params()
Definition: ExtCreatePen.c:24

◆ Test_ExtCreatePen_Expect()

BOOL Test_ExtCreatePen_Expect ( DWORD  dwPenStyle,
DWORD  dwWidth,
DWORD  dwStyleCount,
PDWORD  pdwStyles,
UINT  lbStyle,
ULONG_PTR  lbHatch,
PBOOL  pbExpectException,
PEXTLOGPEN  pelpExpect 
)

Definition at line 206 of file ExtCreatePen.c.

215{
216 *pbExpectException = FALSE;
217
218 if ((dwPenStyle & PS_STYLE_MASK) == PS_USERSTYLE)
219 {
220 if (pdwStyles == NULL)
221 {
222 return FALSE;
223 }
224 }
225 else
226 {
227 if ((dwStyleCount != 0) || (pdwStyles != NULL))
228 {
229 return FALSE;
230 }
231 }
232
233 if (lbStyle == BS_PATTERN)
234 {
235 if (lbHatch == 0) return FALSE;
236 }
237
238 if (lbStyle == BS_DIBPATTERNPT)
239 {
240 if (lbHatch == 0) return FALSE;
241 if (lbHatch < 0xFFFF)
242 {
243 *pbExpectException = TRUE;
244 return FALSE;
245 }
246 }
247
248 if (lbStyle == BS_DIBPATTERN)
249 {
250 return FALSE;
251 }
252
253 if ((dwPenStyle & PS_STYLE_MASK) == PS_USERSTYLE)
254 {
255 if (dwStyleCount == 0)
256 {
257 return FALSE;
258 }
259
260 if (dwStyleCount > 16)
261 {
262 return FALSE;
263 }
264
265 if ((dwPenStyle & PS_TYPE_MASK) == PS_COSMETIC)
266 {
267 if (pdwStyles[0] == 0)
268 {
269 return FALSE;
270 }
271 }
272 else
273 {
274 if ((pdwStyles[0] == 0) && (dwStyleCount == 1))
275 {
276 return FALSE;
277 }
278 }
279 }
280
281 if ((dwPenStyle & PS_STYLE_MASK) == PS_NULL)
282 {
283 pelpExpect->elpPenStyle = PS_NULL;
284 pelpExpect->elpWidth = 0;
285 pelpExpect->elpBrushStyle = BS_SOLID;
286 pelpExpect->elpColor = 0;
287 pelpExpect->elpHatch = 0;
288 pelpExpect->elpNumEntries = 0;
289 return TRUE;
290 }
291
292
293 if (((dwPenStyle & PS_STYLE_MASK) >> 0) > PS_ALTERNATE) return FALSE;
294 if (((dwPenStyle & PS_ENDCAP_MASK) >> 8) > 2) return FALSE;
295 if (((dwPenStyle & PS_JOIN_MASK) >> 12) > 2) return FALSE;
296 if (((dwPenStyle & PS_TYPE_MASK) >> 16) > 1) return FALSE;
297
298 dwWidth = abs(((LONG)dwWidth));
299
300 if ((dwPenStyle & PS_TYPE_MASK) == PS_COSMETIC)
301 {
302 if (dwWidth != 1) return FALSE;
303
304 if ((lbStyle != BS_SOLID) &&
305 (lbStyle != BS_HATCHED))
306 {
307 return FALSE;
308 }
309
310 if (lbStyle == BS_HATCHED)
311 {
312 if ((lbHatch != 8) &&
313 (lbHatch != 10) &&
314 (lbHatch != 12))
315 {
316 return FALSE;
317 }
318
319 if (lbHatch >= HS_API_MAX)
320 {
321 return FALSE;
322 }
323 }
324
325 if ((dwPenStyle & PS_STYLE_MASK) == PS_INSIDEFRAME)
326 {
327 return FALSE;
328 }
329 }
330 else
331 {
332 if ((dwPenStyle & PS_STYLE_MASK) == PS_ALTERNATE)
333 {
334 return FALSE;
335 }
336
337 if (((dwPenStyle & PS_STYLE_MASK) != PS_SOLID) &&
338 ((dwPenStyle & PS_STYLE_MASK) != PS_INSIDEFRAME) &&
339 ((dwPenStyle & PS_STYLE_MASK) != PS_USERSTYLE))
340 {
341 if (dwWidth == 0)
342 {
343 return FALSE;
344 }
345 }
346
347 if (lbStyle == BS_NULL)
348 {
349 pelpExpect->elpPenStyle = PS_NULL;
350 pelpExpect->elpWidth = 0;
351 pelpExpect->elpBrushStyle = BS_SOLID;
352 pelpExpect->elpColor = 0;
353 pelpExpect->elpHatch = 0;
354 pelpExpect->elpNumEntries = 0;
355 return TRUE;
356 }
357
358 if (lbStyle > BS_HATCHED)
359 {
360 return FALSE;
361 }
362
363 if (lbStyle == BS_HATCHED)
364 {
365 if (lbHatch >= HS_API_MAX)
366 {
367 return FALSE;
368 }
369 }
370
371 }
372
373 pelpExpect->elpPenStyle = dwPenStyle;
374 pelpExpect->elpWidth = dwWidth;
375 pelpExpect->elpBrushStyle = lbStyle;
376 pelpExpect->elpColor = RGB(1,2,3);
377 pelpExpect->elpHatch = lbHatch;
378 pelpExpect->elpNumEntries = dwStyleCount;
379 //pelpExpect->elpStyleEntry[1];
380
381 return TRUE;
382}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define RGB(r, g, b)
Definition: precomp.h:71
#define abs(i)
Definition: fconv.c:206
long LONG
Definition: pedump.c:60
DWORD elpNumEntries
Definition: wingdi.h:1947
DWORD elpWidth
Definition: wingdi.h:1943
DWORD elpPenStyle
Definition: wingdi.h:1942
UINT elpBrushStyle
Definition: wingdi.h:1944
ULONG_PTR elpHatch
Definition: wingdi.h:1946
COLORREF elpColor
Definition: wingdi.h:1945
#define PS_NULL
Definition: wingdi.h:591
#define HS_API_MAX
Definition: wingdi.h:582
#define PS_ALTERNATE
Definition: wingdi.h:585
#define BS_HATCHED
Definition: wingdi.h:1089
#define BS_PATTERN
Definition: wingdi.h:1090
#define PS_COSMETIC
Definition: wingdi.h:584
#define BS_DIBPATTERNPT
Definition: wingdi.h:1093
#define PS_STYLE_MASK
Definition: wingdi.h:601
#define BS_DIBPATTERN
Definition: wingdi.h:1092
#define PS_USERSTYLE
Definition: wingdi.h:592
#define PS_JOIN_MASK
Definition: wingdi.h:600
#define BS_NULL
Definition: wingdi.h:1087
#define PS_INSIDEFRAME
Definition: wingdi.h:593
#define BS_SOLID
Definition: wingdi.h:1086
#define PS_ENDCAP_MASK
Definition: wingdi.h:602
#define PS_SOLID
Definition: wingdi.h:586
#define PS_TYPE_MASK
Definition: wingdi.h:603

Referenced by Test_ExtCreatePen_Helper().

◆ Test_ExtCreatePen_Helper()

void Test_ExtCreatePen_Helper ( DWORD  dwPenStyle,
DWORD  dwWidth,
DWORD  dwStyleCount,
PDWORD  pdwStyles,
UINT  lbStyle,
ULONG_PTR  lbHatch 
)

Definition at line 385 of file ExtCreatePen.c.

392{
393 LOGBRUSH lb;
394 HPEN hpen;
395 BOOL bExpectSuccess, bExpectException, bGotException = FALSE;
396 struct
397 {
398 EXTLOGPEN extlogpen;
399 ULONG styles[16];
400 } elpBuffer;
401 PEXTLOGPEN pelp = &elpBuffer.extlogpen;
402 EXTLOGPEN elpExpect;
403
404 lb.lbStyle = lbStyle;
405 lb.lbColor = RGB(1,2,3);
406 lb.lbHatch = lbHatch;
407
408 bExpectSuccess = Test_ExtCreatePen_Expect(
409 dwPenStyle,
410 dwWidth,
411 dwStyleCount,
412 pdwStyles,
413 lbStyle,
414 lbHatch,
415 &bExpectException,
416 &elpExpect);
417
419 {
420 hpen = ExtCreatePen(dwPenStyle, dwWidth, &lb, dwStyleCount, pdwStyles);
421 }
423 {
425 }
426 _SEH2_END;
427
428#define ok2(expression, text, expected, got) \
429 ok(expression, text \
430 "(dwPenStyle=0x%lx, dwWidth=%lu, dwStyleCount=%lu, pdwStyles=%p, lbStyle=%u, lbHatch=%p)\n", \
431 expected, got, dwPenStyle, dwWidth, dwStyleCount, pdwStyles, lbStyle, (PVOID)lbHatch);
432
433 //ok(bGotException == bExpectException, "ExtCreatePen expected exception=%lu for "
434 // "dwPenStyle=0x%lx, dwWidth=%lu, dwStyleCount=%lu, pdwStyles=%p, lbStyle=%lu, lbHatch=%p\n",
435 // bExpectException, dwPenStyle, dwWidth, dwStyleCount, pdwStyles, lbStyle, (PVOID)lbHatch);
436
437 ok2(bGotException == bExpectException, "ExtCreatePen expception, expected %u, got %u", bExpectException, bGotException);
438
439 if (!bExpectSuccess)
440 {
441 ok(hpen == NULL, "ExtCreatePen should fail for "
442 "dwPenStyle=0x%lx, dwWidth=%lu, dwStyleCount=%lu, pdwStyles=%p, lbStyle=%u, lbHatch=%p\n",
443 dwPenStyle, dwWidth, dwStyleCount, pdwStyles, lbStyle, (PVOID)lbHatch);
444 }
445 else
446 {
447 ok(hpen != NULL, "ExtCreatePen failed for "
448 "dwPenStyle=0x%lx, dwWidth=%lu, dwStyleCount=%lu, pdwStyles=%p, lbStyle=%u, lbHatch=%p\n",
449 dwPenStyle, dwWidth, dwStyleCount, pdwStyles, lbStyle, (PVOID)lbHatch);
450 if (hpen != NULL)
451 {
452 if (GetObjectA(hpen, sizeof(elpBuffer), pelp) < sizeof(EXTLOGPEN))
453 {
454 if (!GetObjectA(hpen, sizeof(EXTLOGPEN), pelp))
455 {
456 ok(0, "failed again?\n");
457 return;
458 }
459 }
460
461 ok2(pelp->elpPenStyle == elpExpect.elpPenStyle, "elpPenStyle, expected 0x%lx, got 0x%lx\n", elpExpect.elpPenStyle, pelp->elpPenStyle);
462 ok2(pelp->elpWidth == elpExpect.elpWidth, "elpWidth, expected 0x%lx, got 0x%lx\n", elpExpect.elpWidth, pelp->elpWidth);
463 ok2(pelp->elpBrushStyle == elpExpect.elpBrushStyle, "elpBrushStyle, expected 0x%x, got 0x%x\n", elpExpect.elpBrushStyle, pelp->elpBrushStyle);
464 ok2(pelp->elpColor == elpExpect.elpColor, "elpColor, expected 0x%lx, got 0x%lx\n", elpExpect.elpColor, pelp->elpColor);
465 ok2(pelp->elpHatch == elpExpect.elpHatch, "elpHatch, expected 0x%lx, got 0x%lx\n", elpExpect.elpHatch, pelp->elpHatch);
466 ok2(pelp->elpNumEntries == elpExpect.elpNumEntries, "elpNumEntries, expected 0x%lx, got 0x%lx\n", elpExpect.elpNumEntries, pelp->elpNumEntries);
467 //for (i = 0; i < pelp->elpNumEntries; i++)
468 //{
469 // ok2(pelp->elpStyleEntry[i] == elpExpect.elpStyleEntry[i], "elpHatch, expected 0x%lx, got 0x%lx\n", elpExpect.elpStyleEntry[i], pelp->elpStyleEntry[i]);
470 //}
471 }
472 }
473
474}
BOOL bGotException
#define ok2(expression, text, expected, got)
BOOL Test_ExtCreatePen_Expect(DWORD dwPenStyle, DWORD dwWidth, DWORD dwStyleCount, PDWORD pdwStyles, UINT lbStyle, ULONG_PTR lbHatch, PBOOL pbExpectException, PEXTLOGPEN pelpExpect)
Definition: ExtCreatePen.c:206
static HPEN hpen
unsigned int BOOL
Definition: ntddk_ex.h:94
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_END
Definition: pseh2_64.h:155
#define _SEH2_TRY
Definition: pseh2_64.h:55
UINT lbStyle
Definition: wingdi.h:1747
ULONG_PTR lbHatch
Definition: wingdi.h:1749
COLORREF lbColor
Definition: wingdi.h:1748
uint32_t ULONG
Definition: typedefs.h:59
HPEN WINAPI ExtCreatePen(_In_ DWORD iPenStyle, _In_ DWORD cWidth, _In_ const LOGBRUSH *plbrush, _In_ DWORD cStyle, _In_reads_opt_(cStyle) const DWORD *pstyle)

Referenced by Test_ExtCreatePen_Params2().

◆ Test_ExtCreatePen_Params()

void Test_ExtCreatePen_Params ( )

Definition at line 24 of file ExtCreatePen.c.

25{
26 HPEN hPen;
27 LOGBRUSH logbrush;
28 struct
29 {
30 EXTLOGPEN extlogpen;
31 ULONG styles[16];
32 } elpBuffer;
33 PEXTLOGPEN pelp = &elpBuffer.extlogpen;
34
35 DWORD adwStyles[17] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17};
36
37 /* Test NULL logbrush */
38 SetLastError(0);
40 {
41 hPen = ExtCreatePen(PS_COSMETIC, 1, NULL, 0, 0);
42 }
44 {
45 SetLastError(0xdeadc0de);
46 }
48 ok_lasterror(0xdeadc0de);
49
50 logbrush.lbStyle = BS_SOLID;
51 logbrush.lbColor = RGB(1, 2, 3);
52 logbrush.lbHatch = 0;
53 hPen = ExtCreatePen(PS_COSMETIC, 1, &logbrush, 0, 0);
54 ok(hPen != NULL, "ExtCreatePen failed\n");
55 ok_elp(hPen, pelp, PS_COSMETIC, 1, BS_SOLID, RGB(1,2,3), 0, 0);
56
57 /* Test if we have an EXTPEN */
58 ok(GDI_HANDLE_GET_TYPE(hPen) == GDI_OBJECT_TYPE_EXTPEN, "hPen=%p\n", hPen);
59 DeleteObject(hPen);
60
61 /* Test invalid style mask (0x0F) */
62 SetLastError(0xdeadc0de);
63 hPen = ExtCreatePen(9, 1, &logbrush, 0, 0);
64 ok(hPen == NULL, "ExtCreatePen should fail\n");
66
67 /* Test PS_ALTERNATE with PS_GEOMETRIC */
68 SetLastError(0xdeadc0de);
69 hPen = ExtCreatePen(PS_ALTERNATE | PS_GEOMETRIC, 1, &logbrush, 0, NULL);
70 ok(hPen == NULL, "ExtCreatePen should fail\n");
72
73 /* Test invalid endcap mask (0xF00) */
74 SetLastError(0xdeadc0de);
75 hPen = ExtCreatePen(0x300, 1, &logbrush, 0, 0);
76 ok(hPen == NULL, "ExtCreatePen should fail\n");
78
79 /* Test invalid join mask (F000) */
80 SetLastError(0xdeadc0de);
81 hPen = ExtCreatePen(0x3000, 1, &logbrush, 0, 0);
82 ok(hPen == NULL, "ExtCreatePen should fail\n");
84
85 /* Test invalid type mask (F0000) */
86 SetLastError(0xdeadc0de);
87 hPen = ExtCreatePen(0x20000, 1, &logbrush, 0, 0);
88 ok(hPen == NULL, "ExtCreatePen should fail\n");
90
91 /* Test PS_COSMETIC with dwWidth != 1 */
92 SetLastError(0xdeadc0de);
93 hPen = ExtCreatePen(PS_COSMETIC, -1, &logbrush, 0, 0);
94 ok(hPen != NULL, "ExtCreatePen failed\n");
95 ok_lasterror(0xdeadc0de);
96 ok_elp(hPen, pelp, PS_COSMETIC, 1, BS_SOLID, RGB(1,2,3), 0, 0);
97 DeleteObject(hPen);
98 SetLastError(0xdeadc0de);
99 hPen = ExtCreatePen(PS_COSMETIC, 2, &logbrush, 0, 0);
100 ok(hPen == NULL, "ExtCreatePen should fail\n");
102 SetLastError(0xdeadc0de);
103 hPen = ExtCreatePen(PS_COSMETIC, 0, &logbrush, 0, 0);
104 ok(hPen == NULL, "ExtCreatePen should fail\n");
106
107 /* Test PS_COSMETIC with PS_ENDCAP_SQUARE */
108 SetLastError(0xdeadc0de);
109 hPen = ExtCreatePen(PS_COSMETIC | PS_ENDCAP_SQUARE, 1, &logbrush, 0, NULL);
110 ok(hPen != NULL, "ExtCreatePen failed\n");
111 ok_lasterror(0xdeadc0de);
112 ok_elp(hPen, pelp, PS_COSMETIC | PS_ENDCAP_SQUARE, 1, BS_SOLID, RGB(1,2,3), 0, 0);
113 DeleteObject(hPen);
114
115 /* Test styles without PS_USERSTYLE */
116 SetLastError(0xdeadc0de);
117 hPen = ExtCreatePen(PS_GEOMETRIC, 1, &logbrush, 16, adwStyles);
118 ok(hPen == NULL, "ExtCreatePen should fail\n");
120 SetLastError(0xdeadc0de);
121 hPen = ExtCreatePen(PS_GEOMETRIC, 1, &logbrush, 0, adwStyles);
122 ok(hPen == NULL, "ExtCreatePen should fail\n");
124 SetLastError(0xdeadc0de);
125 hPen = ExtCreatePen(PS_GEOMETRIC, 1, &logbrush, 16, NULL);
126 ok(hPen == NULL, "ExtCreatePen should fail\n");
128
129 /* Test PS_USERSTYLE */
130 SetLastError(0xdeadc0de);
131 hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 5, &logbrush, 16, adwStyles);
132 ok(hPen != NULL, "ExtCreatePen failed\n");
133 ok_lasterror(0xdeadc0de);
134 ok_elp(hPen, pelp, PS_GEOMETRIC | PS_USERSTYLE, 5, BS_SOLID, RGB(1,2,3), 0, 16);
135 DeleteObject(hPen);
136
137 /* Test PS_USERSTYLE with PS_COSMETIC */
138 SetLastError(0xdeadc0de);
139 hPen = ExtCreatePen(PS_COSMETIC | PS_USERSTYLE, 5, &logbrush, 16, adwStyles);
140 ok(hPen == NULL, "ExtCreatePen should fail\n");
142
143 /* Test PS_USERSTYLE with 17 styles */
144 SetLastError(0xdeadc0de);
145 hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 5, &logbrush, 17, adwStyles);
146 ok(hPen == NULL, "ExtCreatePen should fail\n");
148
149 /* Test PS_USERSTYLE with 1 style */
150 SetLastError(0xdeadc0de);
151 hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 5, &logbrush, 1, adwStyles);
152 ok(hPen != NULL, "ExtCreatePen failed\n");
153 ok_lasterror(0xdeadc0de);
154 ok_elp(hPen, pelp, PS_GEOMETRIC | PS_USERSTYLE, 5, BS_SOLID, RGB(1,2,3), 0, 1);
155 DeleteObject(hPen);
156
157 /* Test PS_USERSTYLE with NULL lpStyles */
158 SetLastError(0xdeadc0de);
159 hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 1, &logbrush, 2, NULL);
160 ok(hPen == NULL, "ExtCreatePen should fail\n");
162
163 /* Test PS_NULL */
164 SetLastError(0xdeadc0de);
165 hPen = ExtCreatePen(PS_NULL, 1, &logbrush, 0, NULL);
166 ok(hPen == GetStockObject(NULL_PEN), "ExtCreatePen should return NULL_PEN, but returned %p\n", hPen);
167 ok_lasterror(0xdeadc0de);
168
169 /* When the size is anything other than sizeof(EXTLOGPEN), we will get a LOGPEN! */
170 ok(GetObjectA(hPen, sizeof(EXTLOGPEN) + 1, pelp) == sizeof(LOGPEN), "GetObject failed\n");
171
172 /* ACHTUNG: special handling, we want sizeof(EXTLOGPEN) and nothing else */
173 ok(GetObjectA(hPen, sizeof(EXTLOGPEN), pelp) == sizeof(EXTLOGPEN), "GetObject failed\n");
174 ok(pelp->elpPenStyle == PS_NULL, "Wrong elpPenStyle, expected PS_NULL, got 0x%lx\n", pelp->elpPenStyle);
175 ok(pelp->elpWidth == 0, "Wrong elpWidth, expected 0, got %lu\n", pelp->elpWidth);
176 ok(pelp->elpBrushStyle == BS_SOLID, "Wrong elpBrushStyle, expected BS_SOLID, got 0x%x\n", pelp->elpBrushStyle);
177 ok(pelp->elpColor == 0, "Wrong elpColor, expected 0, got 0x%lx\n", pelp->elpColor);
178 ok(pelp->elpHatch == 0, "Wrong elpHatch, expected 0, got 0x%lx\n", pelp->elpHatch);
179 ok(pelp->elpNumEntries == 0, "Wrong elpNumEntries, expected %u got %lu\n", 0, pelp->elpNumEntries);
180
181 /* Test PS_NULL with styles */
182 SetLastError(0xdeadc0de);
183 hPen = ExtCreatePen(PS_NULL, 1, &logbrush, 1, adwStyles);
184 ok(hPen == NULL, "ExtCreatePen should fail\n");
186
187 /* Test 0 width */
188 SetLastError(0xdeadc0de);
189 hPen = ExtCreatePen(PS_GEOMETRIC, 0, &logbrush, 0, 0);
190 ok(hPen != NULL, "ExtCreatePen failed\n");
191 ok_lasterror(0xdeadc0de);
192 ok_elp(hPen, pelp, PS_GEOMETRIC, 0, BS_SOLID, RGB(1,2,3), 0, 0);
193 DeleteObject(hPen);
194
195 /* Test negative width */
196 SetLastError(0xdeadc0de);
197 hPen = ExtCreatePen(PS_GEOMETRIC, -7942, &logbrush, 0, 0);
198 ok(hPen != NULL, "ExtCreatePen failed\n");
199 ok_lasterror(0xdeadc0de);
200 ok_elp(hPen, pelp, PS_GEOMETRIC, 7942, BS_SOLID, RGB(1,2,3), 0, 0);
201 DeleteObject(hPen);
202
203}
#define ok_lasterror(err)
Definition: ExtCreatePen.c:12
#define ok_elp(hPen, elp, pstyle, width, bstyle, color, hatch, cstyle)
Definition: ExtCreatePen.c:15
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
pKey DeleteObject()
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
#define GDI_OBJECT_TYPE_EXTPEN
Definition: gdi.h:55
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define PS_ENDCAP_SQUARE
Definition: wingdi.h:595
#define PS_GEOMETRIC
Definition: wingdi.h:583
#define NULL_PEN
Definition: wingdi.h:904

Referenced by START_TEST().

◆ Test_ExtCreatePen_Params2()

void Test_ExtCreatePen_Params2 ( )

Definition at line 476 of file ExtCreatePen.c.

477{
478 ULONG aflPenType[] = {PS_COSMETIC, PS_GEOMETRIC, 0x20000};
479 ULONG iType, iStyle, iEndCap, iJoin, iWidth, iStyleCount, iStyles, iBrushStyle, iHatch;
480 DWORD adwStyles[17] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17};
481 DWORD adwStyles2[17] = {0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17};
482
483 printf("adwStyles=%p, adwStyles2=%p\n", adwStyles, adwStyles2);
484
485 //for (iType = 0; iType < sizeof(aflPenType) / sizeof(aflPenType[0]); iType++)
486 for (iType = 0; iType < 3; iType++)
487 {
489 //for (iStyle = 0; iStyle < sizeof(aflPenStyle) / sizeof(aflPenStyle[0]); iStyle++)
490 for (iStyle = 0; iStyle < 10; iStyle++)
491 {
492 ULONG aflEndCap[] = {PS_ENDCAP_ROUND, PS_ENDCAP_SQUARE, PS_ENDCAP_FLAT, 0x300, 0x400};
493 for (iEndCap = 0; iEndCap < sizeof(aflEndCap) / sizeof(aflEndCap[0]); iEndCap++)
494 {
495 ULONG aflJoin[] = {PS_JOIN_ROUND, PS_JOIN_BEVEL, PS_JOIN_MITER, 0x3000, 0x4000};
496 for (iJoin = 0; iJoin < sizeof(aflJoin) / sizeof(aflJoin[0]); iJoin++)
497 {
498 DWORD adwWidth[] = {0, 1, 2};
499 ULONG flPenStyle = aflPenType[iType] | aflPenStyle[iStyle] | aflEndCap[iEndCap] | aflJoin[iJoin];
500
501 for (iWidth = 0; iWidth < sizeof(adwWidth) / sizeof(adwWidth[0]); iWidth++)
502 {
503 ULONG adwStyleCount[] = {0, 1, 2, 16, 17};
504 for (iStyleCount = 0; iStyleCount < sizeof(adwStyleCount) / sizeof(adwStyleCount[0]); iStyleCount++)
505 {
506 PULONG apdwStyles[] = {NULL, adwStyles, adwStyles2};
507 for (iStyles = 0; iStyles < sizeof(apdwStyles) / sizeof(apdwStyles[0]); iStyles++)
508 {
509 UINT albStyle[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
510 for (iBrushStyle = 0; iBrushStyle < sizeof(albStyle) / sizeof(albStyle[0]); iBrushStyle++)
511 {
512 ULONG_PTR alHatch[] = {0, 1, 6, 7, 8, 9, 10, 11, 12, 13};
513
514 for (iHatch = 0; iHatch < sizeof(alHatch) / sizeof(alHatch[0]); iHatch++)
515 {
516 Test_ExtCreatePen_Helper(flPenStyle,
517 adwWidth[iWidth],
518 adwStyleCount[iStyleCount],
519 apdwStyles[iStyles],
520 albStyle[iBrushStyle],
521 alHatch[iHatch]);
522 }
523 }
524 }
525 }
526 }
527 }
528 }
529 }
530 }
531
532}
void Test_ExtCreatePen_Helper(DWORD dwPenStyle, DWORD dwWidth, DWORD dwStyleCount, PDWORD pdwStyles, UINT lbStyle, ULONG_PTR lbHatch)
Definition: ExtCreatePen.c:385
#define printf
Definition: freeldr.h:97
unsigned int UINT
Definition: ndis.h:50
uint32_t * PULONG
Definition: typedefs.h:59
uint32_t ULONG_PTR
Definition: typedefs.h:65
_In_ ULONG iType
Definition: winddi.h:3748
_Inout_ SURFOBJ _In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_opt_ XLATEOBJ _In_ ULONG iHatch
Definition: winddi.h:3963
#define PS_DASH
Definition: wingdi.h:587
#define PS_JOIN_BEVEL
Definition: wingdi.h:597
#define PS_DOT
Definition: wingdi.h:588
#define PS_JOIN_ROUND
Definition: wingdi.h:599
#define PS_ENDCAP_ROUND
Definition: wingdi.h:594
#define PS_JOIN_MITER
Definition: wingdi.h:598
#define PS_DASHDOT
Definition: wingdi.h:589
#define PS_ENDCAP_FLAT
Definition: wingdi.h:596
#define PS_DASHDOTDOT
Definition: wingdi.h:590