2 * Unit test suite for graphics objects
4 * Copyright (C) 2007 Google (Evan Stade)
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
24 #include "wine/test.h"
27 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
28 #define expectf(expected, got) ok(fabs(expected - got) < 0.0001, "Expected %.2f, got %.2f\n", expected, got)
29 #define TABLE_LEN (23)
31 static void test_constructor_destructor(void)
34 GpGraphics
*graphics
= NULL
;
37 stat
= GdipCreateFromHDC(NULL
, &graphics
);
38 expect(OutOfMemory
, stat
);
39 stat
= GdipDeleteGraphics(graphics
);
40 expect(InvalidParameter
, stat
);
42 stat
= GdipCreateFromHDC(hdc
, &graphics
);
44 stat
= GdipDeleteGraphics(graphics
);
47 stat
= GdipCreateFromHWND(NULL
, &graphics
);
49 stat
= GdipDeleteGraphics(graphics
);
52 stat
= GdipCreateFromHWNDICM(NULL
, &graphics
);
54 stat
= GdipDeleteGraphics(graphics
);
57 stat
= GdipDeleteGraphics(NULL
);
58 expect(InvalidParameter
, stat
);
67 /* Linked list prepend function. */
68 static void log_state(GraphicsState data
, node
** log
)
70 node
* new_entry
= HeapAlloc(GetProcessHeap(), 0, sizeof(node
));
72 new_entry
->data
= data
;
73 new_entry
->next
= *log
;
77 /* Checks if there are duplicates in the list, and frees it. */
78 static void check_no_duplicates(node
* log
)
90 while((temp
= temp
->next
)){
91 if(log
->data
== temp
->data
){
98 }while((log
= log
->next
));
103 HeapFree(GetProcessHeap(), 0, temp
);
111 static void test_save_restore(void)
114 GraphicsState state_a
, state_b
, state_c
;
115 InterpolationMode mode
;
116 GpGraphics
*graphics1
, *graphics2
;
117 node
* state_log
= NULL
;
119 state_a
= state_b
= state_c
= 0xdeadbeef;
121 /* Invalid saving. */
122 GdipCreateFromHDC(hdc
, &graphics1
);
123 stat
= GdipSaveGraphics(graphics1
, NULL
);
124 expect(InvalidParameter
, stat
);
125 stat
= GdipSaveGraphics(NULL
, &state_a
);
126 expect(InvalidParameter
, stat
);
127 GdipDeleteGraphics(graphics1
);
129 log_state(state_a
, &state_log
);
131 /* Basic save/restore. */
132 GdipCreateFromHDC(hdc
, &graphics1
);
133 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
134 stat
= GdipSaveGraphics(graphics1
, &state_a
);
136 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
137 stat
= GdipRestoreGraphics(graphics1
, state_a
);
139 GdipGetInterpolationMode(graphics1
, &mode
);
140 expect(InterpolationModeBilinear
, mode
);
141 GdipDeleteGraphics(graphics1
);
143 log_state(state_a
, &state_log
);
145 /* Restoring garbage doesn't affect saves. */
146 GdipCreateFromHDC(hdc
, &graphics1
);
147 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
148 GdipSaveGraphics(graphics1
, &state_a
);
149 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
150 GdipSaveGraphics(graphics1
, &state_b
);
151 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
152 stat
= GdipRestoreGraphics(graphics1
, 0xdeadbeef);
154 GdipRestoreGraphics(graphics1
, state_b
);
155 GdipGetInterpolationMode(graphics1
, &mode
);
156 expect(InterpolationModeBicubic
, mode
);
157 GdipRestoreGraphics(graphics1
, state_a
);
158 GdipGetInterpolationMode(graphics1
, &mode
);
159 expect(InterpolationModeBilinear
, mode
);
160 GdipDeleteGraphics(graphics1
);
162 log_state(state_a
, &state_log
);
163 log_state(state_b
, &state_log
);
165 /* Restoring older state invalidates newer saves (but not older saves). */
166 GdipCreateFromHDC(hdc
, &graphics1
);
167 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
168 GdipSaveGraphics(graphics1
, &state_a
);
169 GdipSetInterpolationMode(graphics1
, InterpolationModeBicubic
);
170 GdipSaveGraphics(graphics1
, &state_b
);
171 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
172 GdipSaveGraphics(graphics1
, &state_c
);
173 GdipSetInterpolationMode(graphics1
, InterpolationModeHighQualityBilinear
);
174 GdipRestoreGraphics(graphics1
, state_b
);
175 GdipGetInterpolationMode(graphics1
, &mode
);
176 expect(InterpolationModeBicubic
, mode
);
177 GdipRestoreGraphics(graphics1
, state_c
);
178 GdipGetInterpolationMode(graphics1
, &mode
);
179 expect(InterpolationModeBicubic
, mode
);
180 GdipRestoreGraphics(graphics1
, state_a
);
181 GdipGetInterpolationMode(graphics1
, &mode
);
182 expect(InterpolationModeBilinear
, mode
);
183 GdipDeleteGraphics(graphics1
);
185 log_state(state_a
, &state_log
);
186 log_state(state_b
, &state_log
);
187 log_state(state_c
, &state_log
);
189 /* Restoring older save from one graphics object does not invalidate
190 * newer save from other graphics object. */
191 GdipCreateFromHDC(hdc
, &graphics1
);
192 GdipCreateFromHDC(hdc
, &graphics2
);
193 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
194 GdipSaveGraphics(graphics1
, &state_a
);
195 GdipSetInterpolationMode(graphics2
, InterpolationModeBicubic
);
196 GdipSaveGraphics(graphics2
, &state_b
);
197 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
198 GdipSetInterpolationMode(graphics2
, InterpolationModeNearestNeighbor
);
199 GdipRestoreGraphics(graphics1
, state_a
);
200 GdipGetInterpolationMode(graphics1
, &mode
);
201 expect(InterpolationModeBilinear
, mode
);
202 GdipRestoreGraphics(graphics2
, state_b
);
203 GdipGetInterpolationMode(graphics2
, &mode
);
204 expect(InterpolationModeBicubic
, mode
);
205 GdipDeleteGraphics(graphics1
);
206 GdipDeleteGraphics(graphics2
);
208 /* You can't restore a state to a graphics object that didn't save it. */
209 GdipCreateFromHDC(hdc
, &graphics1
);
210 GdipCreateFromHDC(hdc
, &graphics2
);
211 GdipSetInterpolationMode(graphics1
, InterpolationModeBilinear
);
212 GdipSaveGraphics(graphics1
, &state_a
);
213 GdipSetInterpolationMode(graphics1
, InterpolationModeNearestNeighbor
);
214 GdipSetInterpolationMode(graphics2
, InterpolationModeNearestNeighbor
);
215 GdipRestoreGraphics(graphics2
, state_a
);
216 GdipGetInterpolationMode(graphics2
, &mode
);
217 expect(InterpolationModeNearestNeighbor
, mode
);
218 GdipDeleteGraphics(graphics1
);
219 GdipDeleteGraphics(graphics2
);
221 log_state(state_a
, &state_log
);
223 /* The same state value should never be returned twice. */
225 check_no_duplicates(state_log
);
230 static void test_GdipDrawArc(void)
233 GpGraphics
*graphics
= NULL
;
237 /* make a graphics object and pen object */
238 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
240 status
= GdipCreateFromHDC(hdc
, &graphics
);
242 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
244 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
246 ok(pen
!= NULL
, "Expected pen to be initialized\n");
248 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
249 status
= GdipDrawArc(NULL
, NULL
, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
250 expect(InvalidParameter
, status
);
252 status
= GdipDrawArc(graphics
, NULL
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
253 expect(InvalidParameter
, status
);
255 status
= GdipDrawArc(NULL
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
256 expect(InvalidParameter
, status
);
258 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
259 expect(InvalidParameter
, status
);
261 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
262 expect(InvalidParameter
, status
);
264 /* successful case */
265 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
269 GdipDeleteGraphics(graphics
);
274 static void test_GdipDrawArcI(void)
277 GpGraphics
*graphics
= NULL
;
281 /* make a graphics object and pen object */
282 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
284 status
= GdipCreateFromHDC(hdc
, &graphics
);
286 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
288 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
290 ok(pen
!= NULL
, "Expected pen to be initialized\n");
292 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
293 status
= GdipDrawArcI(NULL
, NULL
, 0, 0, 0, 0, 0, 0);
294 expect(InvalidParameter
, status
);
296 status
= GdipDrawArcI(graphics
, NULL
, 0, 0, 1, 1, 0, 0);
297 expect(InvalidParameter
, status
);
299 status
= GdipDrawArcI(NULL
, pen
, 0, 0, 1, 1, 0, 0);
300 expect(InvalidParameter
, status
);
302 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 0, 0, 0);
303 expect(InvalidParameter
, status
);
305 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 0, 1, 0, 0);
306 expect(InvalidParameter
, status
);
308 /* successful case */
309 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0, 0);
313 GdipDeleteGraphics(graphics
);
318 static void test_BeginContainer2(void)
322 REAL defClip
[] = {5, 10, 15, 20};
323 REAL elems
[6], defTrans
[] = {1, 2, 3, 4, 5, 6};
324 GraphicsContainer cont1
, cont2
, cont3
, cont4
;
325 CompositingQuality compqual
, defCompqual
= CompositingQualityHighSpeed
;
326 CompositingMode compmode
, defCompmode
= CompositingModeSourceOver
;
327 InterpolationMode interp
, defInterp
= InterpolationModeHighQualityBicubic
;
328 REAL scale
, defScale
= 17;
329 GpUnit unit
, defUnit
= UnitPixel
;
330 PixelOffsetMode offsetmode
, defOffsetmode
= PixelOffsetModeHighSpeed
;
331 SmoothingMode smoothmode
, defSmoothmode
= SmoothingModeAntiAlias
;
332 UINT contrast
, defContrast
= 5;
333 TextRenderingHint texthint
, defTexthint
= TextRenderingHintAntiAlias
;
336 GpGraphics
*graphics
= NULL
;
339 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
341 status
= GdipCreateFromHDC(hdc
, &graphics
);
343 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
345 /* null graphics, null container */
346 status
= GdipBeginContainer2(NULL
, &cont1
);
347 expect(InvalidParameter
, status
);
349 status
= GdipBeginContainer2(graphics
, NULL
);
350 expect(InvalidParameter
, status
);
352 status
= GdipEndContainer(NULL
, cont1
);
353 expect(InvalidParameter
, status
);
355 /* test all quality-related values */
356 GdipSetCompositingMode(graphics
, defCompmode
);
357 GdipSetCompositingQuality(graphics
, defCompqual
);
358 GdipSetInterpolationMode(graphics
, defInterp
);
359 GdipSetPageScale(graphics
, defScale
);
360 GdipSetPageUnit(graphics
, defUnit
);
361 GdipSetPixelOffsetMode(graphics
, defOffsetmode
);
362 GdipSetSmoothingMode(graphics
, defSmoothmode
);
363 GdipSetTextContrast(graphics
, defContrast
);
364 GdipSetTextRenderingHint(graphics
, defTexthint
);
366 status
= GdipBeginContainer2(graphics
, &cont1
);
369 GdipSetCompositingMode(graphics
, CompositingModeSourceCopy
);
370 GdipSetCompositingQuality(graphics
, CompositingQualityHighQuality
);
371 GdipSetInterpolationMode(graphics
, InterpolationModeBilinear
);
372 GdipSetPageScale(graphics
, 10);
373 GdipSetPageUnit(graphics
, UnitDocument
);
374 GdipSetPixelOffsetMode(graphics
, PixelOffsetModeHalf
);
375 GdipSetSmoothingMode(graphics
, SmoothingModeNone
);
376 GdipSetTextContrast(graphics
, 7);
377 GdipSetTextRenderingHint(graphics
, TextRenderingHintClearTypeGridFit
);
379 status
= GdipEndContainer(graphics
, cont1
);
382 GdipGetCompositingMode(graphics
, &compmode
);
383 ok(defCompmode
== compmode
, "Expected Compositing Mode to be restored to %d, got %d\n", defCompmode
, compmode
);
385 GdipGetCompositingQuality(graphics
, &compqual
);
386 ok(defCompqual
== compqual
, "Expected Compositing Quality to be restored to %d, got %d\n", defCompqual
, compqual
);
388 GdipGetInterpolationMode(graphics
, &interp
);
389 ok(defInterp
== interp
, "Expected Interpolation Mode to be restored to %d, got %d\n", defInterp
, interp
);
391 GdipGetPageScale(graphics
, &scale
);
392 ok(fabs(defScale
- scale
) < 0.0001, "Expected Page Scale to be restored to %f, got %f\n", defScale
, scale
);
394 GdipGetPageUnit(graphics
, &unit
);
395 ok(defUnit
== unit
, "Expected Page Unit to be restored to %d, got %d\n", defUnit
, unit
);
397 GdipGetPixelOffsetMode(graphics
, &offsetmode
);
398 ok(defOffsetmode
== offsetmode
, "Expected Pixel Offset Mode to be restored to %d, got %d\n", defOffsetmode
, offsetmode
);
400 GdipGetSmoothingMode(graphics
, &smoothmode
);
401 ok(defSmoothmode
== smoothmode
, "Expected Smoothing Mode to be restored to %d, got %d\n", defSmoothmode
, smoothmode
);
403 GdipGetTextContrast(graphics
, &contrast
);
404 ok(defContrast
== contrast
, "Expected Text Contrast to be restored to %d, got %d\n", defContrast
, contrast
);
406 GdipGetTextRenderingHint(graphics
, &texthint
);
407 ok(defTexthint
== texthint
, "Expected Text Hint to be restored to %d, got %d\n", defTexthint
, texthint
);
409 /* test world transform */
410 status
= GdipBeginContainer2(graphics
, &cont1
);
413 GdipCreateMatrix2(defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3],
414 defTrans
[4], defTrans
[5], &transform
);
415 GdipSetWorldTransform(graphics
, transform
);
416 GdipDeleteMatrix(transform
);
419 status
= GdipBeginContainer2(graphics
, &cont2
);
422 GdipCreateMatrix2(10, 20, 30, 40, 50, 60, &transform
);
423 GdipSetWorldTransform(graphics
, transform
);
424 GdipDeleteMatrix(transform
);
427 status
= GdipEndContainer(graphics
, cont2
);
430 GdipCreateMatrix(&transform
);
431 GdipGetWorldTransform(graphics
, transform
);
432 GdipGetMatrixElements(transform
, elems
);
433 ok(fabs(defTrans
[0] - elems
[0]) < 0.0001 &&
434 fabs(defTrans
[1] - elems
[1]) < 0.0001 &&
435 fabs(defTrans
[2] - elems
[2]) < 0.0001 &&
436 fabs(defTrans
[3] - elems
[3]) < 0.0001 &&
437 fabs(defTrans
[4] - elems
[4]) < 0.0001 &&
438 fabs(defTrans
[5] - elems
[5]) < 0.0001,
439 "Expected World Transform Matrix to be restored to [%f, %f, %f, %f, %f, %f], got [%f, %f, %f, %f, %f, %f]\n",
440 defTrans
[0], defTrans
[1], defTrans
[2], defTrans
[3], defTrans
[4], defTrans
[5],
441 elems
[0], elems
[1], elems
[2], elems
[3], elems
[4], elems
[5]);
442 GdipDeleteMatrix(transform
);
445 status
= GdipEndContainer(graphics
, cont1
);
449 status
= GdipBeginContainer2(graphics
, &cont1
);
452 GdipSetClipRect(graphics
, defClip
[0], defClip
[1], defClip
[2], defClip
[3], CombineModeReplace
);
454 status
= GdipBeginContainer2(graphics
, &cont2
);
457 GdipSetClipRect(graphics
, 2, 4, 6, 8, CombineModeReplace
);
459 status
= GdipEndContainer(graphics
, cont2
);
461 GdipGetClipBounds(graphics
, &clip
);
462 ok(fabs(defClip
[0] - clip
.X
) < 0.0001 &&
463 fabs(defClip
[1] - clip
.Y
) < 0.0001 &&
464 fabs(defClip
[2] - clip
.Width
) < 0.0001 &&
465 fabs(defClip
[3] - clip
.Height
) < 0.0001,
466 "Expected Clipping Rectangle to be restored to [%f, %f, %f, %f], got [%f, %f, %f, %f]\n",
467 defClip
[0], defClip
[1], defClip
[2], defClip
[3],
468 clip
.X
, clip
.Y
, clip
.Width
, clip
.Height
);
470 status
= GdipEndContainer(graphics
, cont1
);
473 status
= GdipBeginContainer2(graphics
, &cont1
);
476 status
= GdipBeginContainer2(graphics
, &cont2
);
479 status
= GdipBeginContainer2(graphics
, &cont3
);
482 status
= GdipEndContainer(graphics
, cont3
);
485 status
= GdipBeginContainer2(graphics
, &cont4
);
488 status
= GdipEndContainer(graphics
, cont4
);
492 status
= GdipEndContainer(graphics
, cont1
);
495 /* end an already-ended container */
496 status
= GdipEndContainer(graphics
, cont1
);
499 GdipDeleteGraphics(graphics
);
503 static void test_GdipDrawBezierI(void)
506 GpGraphics
*graphics
= NULL
;
510 /* make a graphics object and pen object */
511 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
513 status
= GdipCreateFromHDC(hdc
, &graphics
);
515 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
517 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
519 ok(pen
!= NULL
, "Expected pen to be initialized\n");
521 /* InvalidParameter cases: null graphics, null pen */
522 status
= GdipDrawBezierI(NULL
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
523 expect(InvalidParameter
, status
);
525 status
= GdipDrawBezierI(graphics
, NULL
, 0, 0, 0, 0, 0, 0, 0, 0);
526 expect(InvalidParameter
, status
);
528 status
= GdipDrawBezierI(NULL
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
529 expect(InvalidParameter
, status
);
531 /* successful case */
532 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
536 GdipDeleteGraphics(graphics
);
541 static void test_GdipDrawCurve3(void)
544 GpGraphics
*graphics
= NULL
;
558 /* make a graphics object and pen object */
559 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
561 status
= GdipCreateFromHDC(hdc
, &graphics
);
563 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
565 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
567 ok(pen
!= NULL
, "Expected pen to be initialized\n");
569 /* InvalidParameter cases: null graphics, null pen */
570 status
= GdipDrawCurve3(NULL
, NULL
, points
, 3, 0, 2, 1);
571 expect(InvalidParameter
, status
);
573 status
= GdipDrawCurve3(graphics
, NULL
, points
, 3, 0, 2, 1);
574 expect(InvalidParameter
, status
);
576 status
= GdipDrawCurve3(NULL
, pen
, points
, 3, 0, 2, 1);
577 expect(InvalidParameter
, status
);
579 /* InvalidParameter cases: invalid count */
580 status
= GdipDrawCurve3(graphics
, pen
, points
, -1, 0, 2, 1);
581 expect(InvalidParameter
, status
);
583 status
= GdipDrawCurve3(graphics
, pen
, points
, 0, 0, 2, 1);
584 expect(InvalidParameter
, status
);
586 status
= GdipDrawCurve3(graphics
, pen
, points
, 1, 0, 0, 1);
587 expect(InvalidParameter
, status
);
589 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 4, 2, 1);
590 expect(InvalidParameter
, status
);
592 /* InvalidParameter cases: invalid number of segments */
593 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, -1, 1);
594 expect(InvalidParameter
, status
);
596 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 2, 1);
597 expect(InvalidParameter
, status
);
599 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 2, 1);
600 expect(InvalidParameter
, status
);
602 /* Valid test cases */
603 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, 1);
606 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 0, 2, 2);
609 status
= GdipDrawCurve3(graphics
, pen
, points
, 2, 0, 1, -2);
612 status
= GdipDrawCurve3(graphics
, pen
, points
, 3, 1, 1, 0);
616 GdipDeleteGraphics(graphics
);
621 static void test_GdipDrawCurve3I(void)
624 GpGraphics
*graphics
= NULL
;
638 /* make a graphics object and pen object */
639 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
641 status
= GdipCreateFromHDC(hdc
, &graphics
);
643 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
645 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
647 ok(pen
!= NULL
, "Expected pen to be initialized\n");
649 /* InvalidParameter cases: null graphics, null pen */
650 status
= GdipDrawCurve3I(NULL
, NULL
, points
, 3, 0, 2, 1);
651 expect(InvalidParameter
, status
);
653 status
= GdipDrawCurve3I(graphics
, NULL
, points
, 3, 0, 2, 1);
654 expect(InvalidParameter
, status
);
656 status
= GdipDrawCurve3I(NULL
, pen
, points
, 3, 0, 2, 1);
657 expect(InvalidParameter
, status
);
659 /* InvalidParameter cases: invalid count */
660 status
= GdipDrawCurve3I(graphics
, pen
, points
, -1, -1, -1, 1);
661 expect(OutOfMemory
, status
);
663 status
= GdipDrawCurve3I(graphics
, pen
, points
, 0, 0, 2, 1);
664 expect(InvalidParameter
, status
);
666 status
= GdipDrawCurve3I(graphics
, pen
, points
, 1, 0, 0, 1);
667 expect(InvalidParameter
, status
);
669 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 4, 2, 1);
670 expect(InvalidParameter
, status
);
672 /* InvalidParameter cases: invalid number of segments */
673 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, -1, 1);
674 expect(InvalidParameter
, status
);
676 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 2, 1);
677 expect(InvalidParameter
, status
);
679 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 2, 1);
680 expect(InvalidParameter
, status
);
682 /* Valid test cases */
683 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, 1);
686 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 0, 2, 2);
689 status
= GdipDrawCurve3I(graphics
, pen
, points
, 2, 0, 1, -2);
692 status
= GdipDrawCurve3I(graphics
, pen
, points
, 3, 1, 1, 0);
696 GdipDeleteGraphics(graphics
);
701 static void test_GdipDrawCurve2(void)
704 GpGraphics
*graphics
= NULL
;
718 /* make a graphics object and pen object */
719 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
721 status
= GdipCreateFromHDC(hdc
, &graphics
);
723 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
725 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
727 ok(pen
!= NULL
, "Expected pen to be initialized\n");
729 /* InvalidParameter cases: null graphics, null pen */
730 status
= GdipDrawCurve2(NULL
, NULL
, points
, 3, 1);
731 expect(InvalidParameter
, status
);
733 status
= GdipDrawCurve2(graphics
, NULL
, points
, 3, 1);
734 expect(InvalidParameter
, status
);
736 status
= GdipDrawCurve2(NULL
, pen
, points
, 3, 1);
737 expect(InvalidParameter
, status
);
739 /* InvalidParameter cases: invalid count */
740 status
= GdipDrawCurve2(graphics
, pen
, points
, -1, 1);
741 expect(InvalidParameter
, status
);
743 status
= GdipDrawCurve2(graphics
, pen
, points
, 0, 1);
744 expect(InvalidParameter
, status
);
746 status
= GdipDrawCurve2(graphics
, pen
, points
, 1, 1);
747 expect(InvalidParameter
, status
);
749 /* Valid test cases */
750 status
= GdipDrawCurve2(graphics
, pen
, points
, 2, 1);
753 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 2);
756 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, -2);
759 status
= GdipDrawCurve2(graphics
, pen
, points
, 3, 0);
763 GdipDeleteGraphics(graphics
);
768 static void test_GdipDrawCurve2I(void)
771 GpGraphics
*graphics
= NULL
;
785 /* make a graphics object and pen object */
786 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
788 status
= GdipCreateFromHDC(hdc
, &graphics
);
790 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
792 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
794 ok(pen
!= NULL
, "Expected pen to be initialized\n");
796 /* InvalidParameter cases: null graphics, null pen */
797 status
= GdipDrawCurve2I(NULL
, NULL
, points
, 3, 1);
798 expect(InvalidParameter
, status
);
800 status
= GdipDrawCurve2I(graphics
, NULL
, points
, 3, 1);
801 expect(InvalidParameter
, status
);
803 status
= GdipDrawCurve2I(NULL
, pen
, points
, 3, 1);
804 expect(InvalidParameter
, status
);
806 /* InvalidParameter cases: invalid count */
807 status
= GdipDrawCurve2I(graphics
, pen
, points
, -1, 1);
808 expect(OutOfMemory
, status
);
810 status
= GdipDrawCurve2I(graphics
, pen
, points
, 0, 1);
811 expect(InvalidParameter
, status
);
813 status
= GdipDrawCurve2I(graphics
, pen
, points
, 1, 1);
814 expect(InvalidParameter
, status
);
816 /* Valid test cases */
817 status
= GdipDrawCurve2I(graphics
, pen
, points
, 2, 1);
820 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 2);
823 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, -2);
826 status
= GdipDrawCurve2I(graphics
, pen
, points
, 3, 0);
830 GdipDeleteGraphics(graphics
);
835 static void test_GdipDrawCurve(void)
838 GpGraphics
*graphics
= NULL
;
852 /* make a graphics object and pen object */
853 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
855 status
= GdipCreateFromHDC(hdc
, &graphics
);
857 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
859 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
861 ok(pen
!= NULL
, "Expected pen to be initialized\n");
863 /* InvalidParameter cases: null graphics, null pen */
864 status
= GdipDrawCurve(NULL
, NULL
, points
, 3);
865 expect(InvalidParameter
, status
);
867 status
= GdipDrawCurve(graphics
, NULL
, points
, 3);
868 expect(InvalidParameter
, status
);
870 status
= GdipDrawCurve(NULL
, pen
, points
, 3);
871 expect(InvalidParameter
, status
);
873 /* InvalidParameter cases: invalid count */
874 status
= GdipDrawCurve(graphics
, pen
, points
, -1);
875 expect(InvalidParameter
, status
);
877 status
= GdipDrawCurve(graphics
, pen
, points
, 0);
878 expect(InvalidParameter
, status
);
880 status
= GdipDrawCurve(graphics
, pen
, points
, 1);
881 expect(InvalidParameter
, status
);
883 /* Valid test cases */
884 status
= GdipDrawCurve(graphics
, pen
, points
, 2);
887 status
= GdipDrawCurve(graphics
, pen
, points
, 3);
891 GdipDeleteGraphics(graphics
);
896 static void test_GdipDrawCurveI(void)
899 GpGraphics
*graphics
= NULL
;
913 /* make a graphics object and pen object */
914 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
916 status
= GdipCreateFromHDC(hdc
, &graphics
);
918 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
920 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
922 ok(pen
!= NULL
, "Expected pen to be initialized\n");
924 /* InvalidParameter cases: null graphics, null pen */
925 status
= GdipDrawCurveI(NULL
, NULL
, points
, 3);
926 expect(InvalidParameter
, status
);
928 status
= GdipDrawCurveI(graphics
, NULL
, points
, 3);
929 expect(InvalidParameter
, status
);
931 status
= GdipDrawCurveI(NULL
, pen
, points
, 3);
932 expect(InvalidParameter
, status
);
934 /* InvalidParameter cases: invalid count */
935 status
= GdipDrawCurveI(graphics
, pen
, points
, -1);
936 expect(OutOfMemory
, status
);
938 status
= GdipDrawCurveI(graphics
, pen
, points
, 0);
939 expect(InvalidParameter
, status
);
941 status
= GdipDrawCurveI(graphics
, pen
, points
, 1);
942 expect(InvalidParameter
, status
);
944 /* Valid test cases */
945 status
= GdipDrawCurveI(graphics
, pen
, points
, 2);
948 status
= GdipDrawCurveI(graphics
, pen
, points
, 3);
952 GdipDeleteGraphics(graphics
);
957 static void test_GdipDrawLineI(void)
960 GpGraphics
*graphics
= NULL
;
964 /* make a graphics object and pen object */
965 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
967 status
= GdipCreateFromHDC(hdc
, &graphics
);
969 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
971 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
973 ok(pen
!= NULL
, "Expected pen to be initialized\n");
975 /* InvalidParameter cases: null graphics, null pen */
976 status
= GdipDrawLineI(NULL
, NULL
, 0, 0, 0, 0);
977 expect(InvalidParameter
, status
);
979 status
= GdipDrawLineI(graphics
, NULL
, 0, 0, 0, 0);
980 expect(InvalidParameter
, status
);
982 status
= GdipDrawLineI(NULL
, pen
, 0, 0, 0, 0);
983 expect(InvalidParameter
, status
);
985 /* successful case */
986 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 0, 0);
990 GdipDeleteGraphics(graphics
);
995 static void test_GdipDrawLinesI(void)
998 GpGraphics
*graphics
= NULL
;
1000 GpPoint
*ptf
= NULL
;
1003 /* make a graphics object and pen object */
1004 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1006 status
= GdipCreateFromHDC(hdc
, &graphics
);
1008 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1010 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1012 ok(pen
!= NULL
, "Expected pen to be initialized\n");
1014 /* make some arbitrary valid points*/
1015 ptf
= GdipAlloc(2 * sizeof(GpPointF
));
1023 /* InvalidParameter cases: null graphics, null pen, null points, count < 2*/
1024 status
= GdipDrawLinesI(NULL
, NULL
, NULL
, 0);
1025 expect(InvalidParameter
, status
);
1027 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 0);
1028 expect(InvalidParameter
, status
);
1030 status
= GdipDrawLinesI(graphics
, NULL
, ptf
, 2);
1031 expect(InvalidParameter
, status
);
1033 status
= GdipDrawLinesI(NULL
, pen
, ptf
, 2);
1034 expect(InvalidParameter
, status
);
1036 /* successful case */
1037 status
= GdipDrawLinesI(graphics
, pen
, ptf
, 2);
1042 GdipDeleteGraphics(graphics
);
1047 static void test_Get_Release_DC(void)
1050 GpGraphics
*graphics
= NULL
;
1057 CompositingQuality quality
;
1058 CompositingMode compmode
;
1059 InterpolationMode intmode
;
1063 PixelOffsetMode offsetmode
;
1064 SmoothingMode smoothmode
;
1065 TextRenderingHint texthint
;
1073 ARGB color
= 0x00000000;
1074 HRGN hrgn
= CreateRectRgn(0, 0, 10, 10);
1087 for(i
= 0; i
< 5;i
++){
1088 ptf
[i
].X
= (REAL
)pt
[i
].X
;
1089 ptf
[i
].Y
= (REAL
)pt
[i
].Y
;
1095 rect
[0].Height
= 70;
1099 rect
[1].Height
= 20;
1101 for(i
= 0; i
< 2;i
++){
1102 rectf
[i
].X
= (REAL
)rect
[i
].X
;
1103 rectf
[i
].Y
= (REAL
)rect
[i
].Y
;
1104 rectf
[i
].Height
= (REAL
)rect
[i
].Height
;
1105 rectf
[i
].Width
= (REAL
)rect
[i
].Width
;
1108 GdipCreateMatrix(&m
);
1109 GdipCreateRegion(®ion
);
1110 GdipCreateSolidFill((ARGB
)0xdeadbeef, &brush
);
1111 GdipCreatePath(FillModeAlternate
, &path
);
1112 GdipCreateRegion(&clip
);
1114 status
= GdipCreateFromHDC(hdc
, &graphics
);
1116 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1117 status
= GdipCreatePen1((ARGB
)0xffff00ff, 10.0f
, UnitPixel
, &pen
);
1120 /* NULL arguments */
1121 status
= GdipGetDC(NULL
, NULL
);
1122 expect(InvalidParameter
, status
);
1123 status
= GdipGetDC(graphics
, NULL
);
1124 expect(InvalidParameter
, status
);
1125 status
= GdipGetDC(NULL
, &retdc
);
1126 expect(InvalidParameter
, status
);
1128 status
= GdipReleaseDC(NULL
, NULL
);
1129 expect(InvalidParameter
, status
);
1130 status
= GdipReleaseDC(graphics
, NULL
);
1131 expect(InvalidParameter
, status
);
1132 status
= GdipReleaseDC(NULL
, (HDC
)0xdeadbeef);
1133 expect(InvalidParameter
, status
);
1135 /* Release without Get */
1136 status
= GdipReleaseDC(graphics
, hdc
);
1137 expect(InvalidParameter
, status
);
1140 status
= GdipGetDC(graphics
, &retdc
);
1142 ok(retdc
== hdc
, "Invalid HDC returned\n");
1143 /* call it once more */
1144 status
= GdipGetDC(graphics
, &retdc
);
1145 expect(ObjectBusy
, status
);
1147 /* try all Graphics calls here */
1149 status
= GdipDrawArc(graphics
, pen
, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
1150 expect(ObjectBusy
, status
); status
= Ok
;
1151 status
= GdipDrawArcI(graphics
, pen
, 0, 0, 1, 1, 0.0, 0.0);
1152 expect(ObjectBusy
, status
); status
= Ok
;
1153 status
= GdipDrawBezier(graphics
, pen
, 0.0, 10.0, 20.0, 15.0, 35.0, -10.0, 10.0, 10.0);
1154 expect(ObjectBusy
, status
); status
= Ok
;
1155 status
= GdipDrawBezierI(graphics
, pen
, 0, 0, 0, 0, 0, 0, 0, 0);
1156 expect(ObjectBusy
, status
); status
= Ok
;
1157 status
= GdipDrawBeziers(graphics
, pen
, ptf
, 5);
1158 expect(ObjectBusy
, status
); status
= Ok
;
1159 status
= GdipDrawBeziersI(graphics
, pen
, pt
, 5);
1160 expect(ObjectBusy
, status
); status
= Ok
;
1161 status
= GdipDrawClosedCurve(graphics
, pen
, ptf
, 5);
1162 expect(ObjectBusy
, status
); status
= Ok
;
1163 status
= GdipDrawClosedCurveI(graphics
, pen
, pt
, 5);
1164 expect(ObjectBusy
, status
); status
= Ok
;
1165 status
= GdipDrawClosedCurve2(graphics
, pen
, ptf
, 5, 1.0);
1166 expect(ObjectBusy
, status
); status
= Ok
;
1167 status
= GdipDrawClosedCurve2I(graphics
, pen
, pt
, 5, 1.0);
1168 expect(ObjectBusy
, status
); status
= Ok
;
1169 status
= GdipDrawCurve(graphics
, pen
, ptf
, 5);
1170 expect(ObjectBusy
, status
); status
= Ok
;
1171 status
= GdipDrawCurveI(graphics
, pen
, pt
, 5);
1172 expect(ObjectBusy
, status
); status
= Ok
;
1173 status
= GdipDrawCurve2(graphics
, pen
, ptf
, 5, 1.0);
1174 expect(ObjectBusy
, status
); status
= Ok
;
1175 status
= GdipDrawCurve2I(graphics
, pen
, pt
, 5, 1.0);
1176 expect(ObjectBusy
, status
); status
= Ok
;
1177 status
= GdipDrawEllipse(graphics
, pen
, 0.0, 0.0, 100.0, 50.0);
1178 expect(ObjectBusy
, status
); status
= Ok
;
1179 status
= GdipDrawEllipseI(graphics
, pen
, 0, 0, 100, 50);
1180 expect(ObjectBusy
, status
); status
= Ok
;
1181 /* GdipDrawImage/GdipDrawImageI */
1182 /* GdipDrawImagePointsRect/GdipDrawImagePointsRectI */
1183 /* GdipDrawImageRectRect/GdipDrawImageRectRectI */
1184 /* GdipDrawImageRect/GdipDrawImageRectI */
1185 status
= GdipDrawLine(graphics
, pen
, 0.0, 0.0, 100.0, 200.0);
1186 expect(ObjectBusy
, status
); status
= Ok
;
1187 status
= GdipDrawLineI(graphics
, pen
, 0, 0, 100, 200);
1188 expect(ObjectBusy
, status
); status
= Ok
;
1189 status
= GdipDrawLines(graphics
, pen
, ptf
, 5);
1190 expect(ObjectBusy
, status
); status
= Ok
;
1191 status
= GdipDrawLinesI(graphics
, pen
, pt
, 5);
1192 expect(ObjectBusy
, status
); status
= Ok
;
1193 status
= GdipDrawPath(graphics
, pen
, path
);
1194 expect(ObjectBusy
, status
); status
= Ok
;
1195 status
= GdipDrawPie(graphics
, pen
, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
1196 expect(ObjectBusy
, status
); status
= Ok
;
1197 status
= GdipDrawPieI(graphics
, pen
, 0, 0, 100, 100, 0.0, 90.0);
1198 expect(ObjectBusy
, status
); status
= Ok
;
1199 status
= GdipDrawRectangle(graphics
, pen
, 0.0, 0.0, 100.0, 300.0);
1200 expect(ObjectBusy
, status
); status
= Ok
;
1201 status
= GdipDrawRectangleI(graphics
, pen
, 0, 0, 100, 300);
1202 expect(ObjectBusy
, status
); status
= Ok
;
1203 status
= GdipDrawRectangles(graphics
, pen
, rectf
, 2);
1204 expect(ObjectBusy
, status
); status
= Ok
;
1205 status
= GdipDrawRectanglesI(graphics
, pen
, rect
, 2);
1206 expect(ObjectBusy
, status
); status
= Ok
;
1207 /* GdipDrawString */
1208 status
= GdipFillClosedCurve2(graphics
, (GpBrush
*)brush
, ptf
, 5, 1.0, FillModeAlternate
);
1209 expect(ObjectBusy
, status
); status
= Ok
;
1210 status
= GdipFillClosedCurve2I(graphics
, (GpBrush
*)brush
, pt
, 5, 1.0, FillModeAlternate
);
1211 expect(ObjectBusy
, status
); status
= Ok
;
1212 status
= GdipFillEllipse(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1213 expect(ObjectBusy
, status
); status
= Ok
;
1214 status
= GdipFillEllipseI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1215 expect(ObjectBusy
, status
); status
= Ok
;
1216 status
= GdipFillPath(graphics
, (GpBrush
*)brush
, path
);
1217 expect(ObjectBusy
, status
); status
= Ok
;
1218 status
= GdipFillPie(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0, 0.0, 15.0);
1219 expect(ObjectBusy
, status
); status
= Ok
;
1220 status
= GdipFillPieI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100, 0.0, 15.0);
1221 expect(ObjectBusy
, status
); status
= Ok
;
1222 status
= GdipFillPolygon(graphics
, (GpBrush
*)brush
, ptf
, 5, FillModeAlternate
);
1223 expect(ObjectBusy
, status
); status
= Ok
;
1224 status
= GdipFillPolygonI(graphics
, (GpBrush
*)brush
, pt
, 5, FillModeAlternate
);
1225 expect(ObjectBusy
, status
); status
= Ok
;
1226 status
= GdipFillPolygon2(graphics
, (GpBrush
*)brush
, ptf
, 5);
1227 expect(ObjectBusy
, status
); status
= Ok
;
1228 status
= GdipFillPolygon2I(graphics
, (GpBrush
*)brush
, pt
, 5);
1229 expect(ObjectBusy
, status
); status
= Ok
;
1230 status
= GdipFillRectangle(graphics
, (GpBrush
*)brush
, 0.0, 0.0, 100.0, 100.0);
1231 expect(ObjectBusy
, status
); status
= Ok
;
1232 status
= GdipFillRectangleI(graphics
, (GpBrush
*)brush
, 0, 0, 100, 100);
1233 expect(ObjectBusy
, status
); status
= Ok
;
1234 status
= GdipFillRectangles(graphics
, (GpBrush
*)brush
, rectf
, 2);
1235 expect(ObjectBusy
, status
); status
= Ok
;
1236 status
= GdipFillRectanglesI(graphics
, (GpBrush
*)brush
, rect
, 2);
1237 expect(ObjectBusy
, status
); status
= Ok
;
1238 status
= GdipFillRegion(graphics
, (GpBrush
*)brush
, region
);
1239 expect(ObjectBusy
, status
); status
= Ok
;
1240 status
= GdipFlush(graphics
, FlushIntentionFlush
);
1241 expect(ObjectBusy
, status
); status
= Ok
;
1242 status
= GdipGetClipBounds(graphics
, rectf
);
1243 expect(ObjectBusy
, status
); status
= Ok
;
1244 status
= GdipGetClipBoundsI(graphics
, rect
);
1245 expect(ObjectBusy
, status
); status
= Ok
;
1246 status
= GdipGetCompositingMode(graphics
, &compmode
);
1247 expect(ObjectBusy
, status
); status
= Ok
;
1248 status
= GdipGetCompositingQuality(graphics
, &quality
);
1249 expect(ObjectBusy
, status
); status
= Ok
;
1250 status
= GdipGetInterpolationMode(graphics
, &intmode
);
1251 expect(ObjectBusy
, status
); status
= Ok
;
1252 status
= GdipGetNearestColor(graphics
, &color
);
1253 expect(ObjectBusy
, status
); status
= Ok
;
1254 status
= GdipGetPageScale(graphics
, &r
);
1255 expect(ObjectBusy
, status
); status
= Ok
;
1256 status
= GdipGetPageUnit(graphics
, &unit
);
1257 expect(ObjectBusy
, status
); status
= Ok
;
1258 status
= GdipGetPixelOffsetMode(graphics
, &offsetmode
);
1259 expect(ObjectBusy
, status
); status
= Ok
;
1260 status
= GdipGetSmoothingMode(graphics
, &smoothmode
);
1261 expect(ObjectBusy
, status
); status
= Ok
;
1262 status
= GdipGetTextRenderingHint(graphics
, &texthint
);
1263 expect(ObjectBusy
, status
); status
= Ok
;
1264 status
= GdipGetWorldTransform(graphics
, m
);
1265 expect(ObjectBusy
, status
); status
= Ok
;
1266 status
= GdipGraphicsClear(graphics
, 0xdeadbeef);
1267 expect(ObjectBusy
, status
); status
= Ok
;
1268 status
= GdipIsVisiblePoint(graphics
, 0.0, 0.0, &res
);
1269 expect(ObjectBusy
, status
); status
= Ok
;
1270 status
= GdipIsVisiblePointI(graphics
, 0, 0, &res
);
1271 expect(ObjectBusy
, status
); status
= Ok
;
1272 /* GdipMeasureCharacterRanges */
1273 /* GdipMeasureString */
1274 status
= GdipResetClip(graphics
);
1275 expect(ObjectBusy
, status
); status
= Ok
;
1276 status
= GdipResetWorldTransform(graphics
);
1277 expect(ObjectBusy
, status
); status
= Ok
;
1278 /* GdipRestoreGraphics */
1279 status
= GdipRotateWorldTransform(graphics
, 15.0, MatrixOrderPrepend
);
1280 expect(ObjectBusy
, status
); status
= Ok
;
1281 /* GdipSaveGraphics */
1282 status
= GdipScaleWorldTransform(graphics
, 1.0, 1.0, MatrixOrderPrepend
);
1283 expect(ObjectBusy
, status
); status
= Ok
;
1284 status
= GdipSetCompositingMode(graphics
, CompositingModeSourceOver
);
1285 expect(ObjectBusy
, status
); status
= Ok
;
1286 status
= GdipSetCompositingQuality(graphics
, CompositingQualityDefault
);
1287 expect(ObjectBusy
, status
); status
= Ok
;
1288 status
= GdipSetInterpolationMode(graphics
, InterpolationModeDefault
);
1289 expect(ObjectBusy
, status
); status
= Ok
;
1290 status
= GdipSetPageScale(graphics
, 1.0);
1291 expect(ObjectBusy
, status
); status
= Ok
;
1292 status
= GdipSetPageUnit(graphics
, UnitWorld
);
1293 expect(ObjectBusy
, status
); status
= Ok
;
1294 status
= GdipSetPixelOffsetMode(graphics
, PixelOffsetModeDefault
);
1295 expect(ObjectBusy
, status
); status
= Ok
;
1296 status
= GdipSetSmoothingMode(graphics
, SmoothingModeDefault
);
1297 expect(ObjectBusy
, status
); status
= Ok
;
1298 status
= GdipSetTextRenderingHint(graphics
, TextRenderingHintSystemDefault
);
1299 expect(ObjectBusy
, status
); status
= Ok
;
1300 status
= GdipSetWorldTransform(graphics
, m
);
1301 expect(ObjectBusy
, status
); status
= Ok
;
1302 status
= GdipTranslateWorldTransform(graphics
, 0.0, 0.0, MatrixOrderPrepend
);
1303 expect(ObjectBusy
, status
); status
= Ok
;
1304 status
= GdipSetClipHrgn(graphics
, hrgn
, CombineModeReplace
);
1305 expect(ObjectBusy
, status
); status
= Ok
;
1306 status
= GdipSetClipPath(graphics
, path
, CombineModeReplace
);
1307 expect(ObjectBusy
, status
); status
= Ok
;
1308 status
= GdipSetClipRect(graphics
, 0.0, 0.0, 10.0, 10.0, CombineModeReplace
);
1309 expect(ObjectBusy
, status
); status
= Ok
;
1310 status
= GdipSetClipRectI(graphics
, 0, 0, 10, 10, CombineModeReplace
);
1311 expect(ObjectBusy
, status
); status
= Ok
;
1312 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
1313 expect(ObjectBusy
, status
); status
= Ok
;
1314 status
= GdipTranslateClip(graphics
, 0.0, 0.0);
1315 expect(ObjectBusy
, status
); status
= Ok
;
1316 status
= GdipTranslateClipI(graphics
, 0, 0);
1317 expect(ObjectBusy
, status
); status
= Ok
;
1318 status
= GdipDrawPolygon(graphics
, pen
, ptf
, 5);
1319 expect(ObjectBusy
, status
); status
= Ok
;
1320 status
= GdipDrawPolygonI(graphics
, pen
, pt
, 5);
1321 expect(ObjectBusy
, status
); status
= Ok
;
1322 status
= GdipGetDpiX(graphics
, &r
);
1323 expect(ObjectBusy
, status
); status
= Ok
;
1324 status
= GdipGetDpiY(graphics
, &r
);
1325 expect(ObjectBusy
, status
); status
= Ok
;
1326 status
= GdipMultiplyWorldTransform(graphics
, m
, MatrixOrderPrepend
);
1327 status
= GdipGetClip(graphics
, region
);
1328 expect(ObjectBusy
, status
); status
= Ok
;
1329 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 5);
1330 expect(ObjectBusy
, status
); status
= Ok
;
1331 /* try to delete before release */
1332 status
= GdipDeleteGraphics(graphics
);
1333 expect(ObjectBusy
, status
);
1335 status
= GdipReleaseDC(graphics
, retdc
);
1339 GdipDeleteGraphics(graphics
);
1341 GdipDeleteRegion(clip
);
1342 GdipDeletePath(path
);
1343 GdipDeleteBrush((GpBrush
*)brush
);
1344 GdipDeleteRegion(region
);
1345 GdipDeleteMatrix(m
);
1351 static void test_transformpoints(void)
1354 GpGraphics
*graphics
= NULL
;
1359 status
= GdipCreateFromHDC(hdc
, &graphics
);
1362 /* NULL arguments */
1363 status
= GdipTransformPoints(NULL
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1364 expect(InvalidParameter
, status
);
1365 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, NULL
, 0);
1366 expect(InvalidParameter
, status
);
1367 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 0);
1368 expect(InvalidParameter
, status
);
1369 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, -1);
1370 expect(InvalidParameter
, status
);
1376 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1378 expectf(1.0, ptf
[0].X
);
1379 expectf(0.0, ptf
[0].Y
);
1380 expectf(0.0, ptf
[1].X
);
1381 expectf(1.0, ptf
[1].Y
);
1383 status
= GdipTranslateWorldTransform(graphics
, 5.0, 5.0, MatrixOrderAppend
);
1385 status
= GdipSetPageUnit(graphics
, UnitPixel
);
1387 status
= GdipSetPageScale(graphics
, 3.0);
1394 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, ptf
, 2);
1396 expectf(18.0, ptf
[0].X
);
1397 expectf(15.0, ptf
[0].Y
);
1398 expectf(15.0, ptf
[1].X
);
1399 expectf(18.0, ptf
[1].Y
);
1405 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceWorld
, ptf
, 2);
1407 expectf(6.0, ptf
[0].X
);
1408 expectf(5.0, ptf
[0].Y
);
1409 expectf(5.0, ptf
[1].X
);
1410 expectf(6.0, ptf
[1].Y
);
1416 status
= GdipTransformPoints(graphics
, CoordinateSpaceDevice
, CoordinateSpacePage
, ptf
, 2);
1418 expectf(3.0, ptf
[0].X
);
1419 expectf(0.0, ptf
[0].Y
);
1420 expectf(0.0, ptf
[1].X
);
1421 expectf(3.0, ptf
[1].Y
);
1427 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpaceDevice
, ptf
, 2);
1429 expectf(1.0, ptf
[0].X
);
1430 expectf(0.0, ptf
[0].Y
);
1431 expectf(0.0, ptf
[1].X
);
1432 expectf(1.0, ptf
[1].Y
);
1438 status
= GdipTransformPoints(graphics
, CoordinateSpaceWorld
, CoordinateSpacePage
, ptf
, 2);
1440 expectf(1.0, ptf
[0].X
);
1441 expectf(0.0, ptf
[0].Y
);
1442 expectf(0.0, ptf
[1].X
);
1443 expectf(1.0, ptf
[1].Y
);
1449 status
= GdipTransformPoints(graphics
, CoordinateSpacePage
, CoordinateSpaceDevice
, ptf
, 2);
1451 expectf(1.0, ptf
[0].X
);
1452 expectf(0.0, ptf
[0].Y
);
1453 expectf(0.0, ptf
[1].X
);
1454 expectf(1.0, ptf
[1].Y
);
1460 status
= GdipTransformPointsI(graphics
, CoordinateSpaceDevice
, CoordinateSpaceWorld
, pt
, 2);
1462 expect(18, pt
[0].X
);
1463 expect(15, pt
[0].Y
);
1464 expect(15, pt
[1].X
);
1465 expect(18, pt
[1].Y
);
1467 GdipDeleteGraphics(graphics
);
1471 static void test_get_set_clip(void)
1474 GpGraphics
*graphics
= NULL
;
1480 status
= GdipCreateFromHDC(hdc
, &graphics
);
1483 rect
.X
= rect
.Y
= 0.0;
1484 rect
.Height
= rect
.Width
= 100.0;
1486 status
= GdipCreateRegionRect(&rect
, &clip
);
1488 /* NULL arguments */
1489 status
= GdipGetClip(NULL
, NULL
);
1490 expect(InvalidParameter
, status
);
1491 status
= GdipGetClip(graphics
, NULL
);
1492 expect(InvalidParameter
, status
);
1493 status
= GdipGetClip(NULL
, clip
);
1494 expect(InvalidParameter
, status
);
1496 status
= GdipSetClipRegion(NULL
, NULL
, CombineModeReplace
);
1497 expect(InvalidParameter
, status
);
1498 status
= GdipSetClipRegion(graphics
, NULL
, CombineModeReplace
);
1499 expect(InvalidParameter
, status
);
1501 status
= GdipSetClipPath(NULL
, NULL
, CombineModeReplace
);
1502 expect(InvalidParameter
, status
);
1503 status
= GdipSetClipPath(graphics
, NULL
, CombineModeReplace
);
1504 expect(InvalidParameter
, status
);
1507 status
= GdipGetClip(graphics
, clip
);
1509 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1513 /* remains infinite after reset */
1515 status
= GdipResetClip(graphics
);
1517 status
= GdipGetClip(graphics
, clip
);
1519 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1523 /* set to empty and then reset to infinite */
1524 status
= GdipSetEmpty(clip
);
1526 status
= GdipSetClipRegion(graphics
, clip
, CombineModeReplace
);
1529 status
= GdipGetClip(graphics
, clip
);
1532 status
= GdipIsEmptyRegion(clip
, graphics
, &res
);
1535 status
= GdipResetClip(graphics
);
1537 status
= GdipGetClip(graphics
, clip
);
1540 status
= GdipIsInfiniteRegion(clip
, graphics
, &res
);
1544 GdipDeleteRegion(clip
);
1546 GdipDeleteGraphics(graphics
);
1550 static void test_isempty(void)
1553 GpGraphics
*graphics
= NULL
;
1558 status
= GdipCreateFromHDC(hdc
, &graphics
);
1561 status
= GdipCreateRegion(&clip
);
1565 status
= GdipIsClipEmpty(NULL
, NULL
);
1566 expect(InvalidParameter
, status
);
1567 status
= GdipIsClipEmpty(graphics
, NULL
);
1568 expect(InvalidParameter
, status
);
1569 status
= GdipIsClipEmpty(NULL
, &res
);
1570 expect(InvalidParameter
, status
);
1572 /* default is infinite */
1574 status
= GdipIsClipEmpty(graphics
, &res
);
1578 GdipDeleteRegion(clip
);
1580 GdipDeleteGraphics(graphics
);
1584 static void test_clear(void)
1588 status
= GdipGraphicsClear(NULL
, 0xdeadbeef);
1589 expect(InvalidParameter
, status
);
1592 static void test_textcontrast(void)
1596 GpGraphics
*graphics
;
1599 status
= GdipGetTextContrast(NULL
, NULL
);
1600 expect(InvalidParameter
, status
);
1602 status
= GdipCreateFromHDC(hdc
, &graphics
);
1605 status
= GdipGetTextContrast(graphics
, NULL
);
1606 expect(InvalidParameter
, status
);
1607 status
= GdipGetTextContrast(graphics
, &contrast
);
1608 expect(4, contrast
);
1610 GdipDeleteGraphics(graphics
);
1614 static void test_GdipDrawString(void)
1617 GpGraphics
*graphics
= NULL
;
1620 GpStringFormat
*format
;
1624 static const WCHAR string
[] = {'T','e','s','t',0};
1626 memset(&logfont
,0,sizeof(logfont
));
1627 strcpy(logfont
.lfFaceName
,"Arial");
1628 logfont
.lfHeight
= 12;
1629 logfont
.lfCharSet
= DEFAULT_CHARSET
;
1631 status
= GdipCreateFromHDC(hdc
, &graphics
);
1634 status
= GdipCreateFontFromLogfontA(hdc
, &logfont
, &fnt
);
1635 if (status
== FileNotFound
)
1637 skip("Arial not installed.\n");
1642 status
= GdipCreateSolidFill((ARGB
)0xdeadbeef, (GpSolidFill
**)&brush
);
1645 status
= GdipCreateStringFormat(0,0,&format
);
1653 status
= GdipDrawString(graphics
, string
, 4, fnt
, &rect
, format
, brush
);
1656 GdipDeleteGraphics(graphics
);
1657 GdipDeleteBrush(brush
);
1658 GdipDeleteFont(fnt
);
1659 GdipDeleteStringFormat(format
);
1664 static void test_GdipGetVisibleClipBounds_screen(void)
1667 GpGraphics
*graphics
= NULL
;
1669 GpRectF rectf
, exp
, clipr
;
1672 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1674 status
= GdipCreateFromHDC(hdc
, &graphics
);
1676 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1678 /* no clipping rect */
1681 exp
.Width
= GetDeviceCaps(hdc
, HORZRES
);
1682 exp
.Height
= GetDeviceCaps(hdc
, VERTRES
);
1684 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
1686 ok(rectf
.X
== exp
.X
&&
1688 rectf
.Width
== exp
.Width
&&
1689 rectf
.Height
== exp
.Height
,
1690 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1691 "the screen (%0.f, %0.f, %0.f, %0.f)\n",
1692 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
1693 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
1695 /* clipping rect entirely within window */
1696 exp
.X
= clipr
.X
= 10;
1697 exp
.Y
= clipr
.Y
= 12;
1698 exp
.Width
= clipr
.Width
= 14;
1699 exp
.Height
= clipr
.Height
= 16;
1701 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
1704 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
1706 ok(rectf
.X
== exp
.X
&&
1708 rectf
.Width
== exp
.Width
&&
1709 rectf
.Height
== exp
.Height
,
1710 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1711 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1712 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
1713 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
1715 /* clipping rect partially outside of screen */
1721 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
1729 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
1731 ok(rectf
.X
== exp
.X
&&
1733 rectf
.Width
== exp
.Width
&&
1734 rectf
.Height
== exp
.Height
,
1735 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1736 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1737 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
1738 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
1740 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
1742 ok(recti
.X
== exp
.X
&&
1744 recti
.Width
== exp
.Width
&&
1745 recti
.Height
== exp
.Height
,
1746 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
1747 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1748 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
1749 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
1751 GdipDeleteGraphics(graphics
);
1755 static void test_GdipGetVisibleClipBounds_window(void)
1758 GpGraphics
*graphics
= NULL
;
1759 GpRectF rectf
, window
, exp
, clipr
;
1765 HINSTANCE hInstance
= GetModuleHandle(NULL
);
1771 window
.Height
= 300;
1773 class.lpszClassName
= "ClipBoundsTestClass";
1774 class.style
= CS_HREDRAW
| CS_VREDRAW
;
1775 class.lpfnWndProc
= DefWindowProcA
;
1776 class.hInstance
= hInstance
;
1777 class.hIcon
= LoadIcon(0, IDI_APPLICATION
);
1778 class.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
1779 class.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
1780 class.lpszMenuName
= 0;
1781 class.cbClsExtra
= 0;
1782 class.cbWndExtra
= 0;
1783 RegisterClass(&class);
1785 hwnd
= CreateWindow(class.lpszClassName
, "ClipboundsTest",
1786 WS_OVERLAPPEDWINDOW
, window
.X
, window
.Y
, window
.Width
, window
.Height
,
1787 NULL
, NULL
, hInstance
, NULL
);
1789 ok(hwnd
!= NULL
, "Expected window to be created\n");
1791 /* get client area size */
1792 ok(GetClientRect(hwnd
, &wnd_rect
), "GetClientRect should have succeeded\n");
1793 window
.X
= wnd_rect
.left
;
1794 window
.Y
= wnd_rect
.top
;
1795 window
.Width
= wnd_rect
.right
- wnd_rect
.left
;
1796 window
.Height
= wnd_rect
.bottom
- wnd_rect
.top
;
1798 hdc
= BeginPaint(hwnd
, &ps
);
1800 status
= GdipCreateFromHDC(hdc
, &graphics
);
1802 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1804 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
1806 ok(rectf
.X
== window
.X
&&
1807 rectf
.Y
== window
.Y
&&
1808 rectf
.Width
== window
.Width
&&
1809 rectf
.Height
== window
.Height
,
1810 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1811 "the window (%0.f, %0.f, %0.f, %0.f)\n",
1812 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
1813 window
.X
, window
.Y
, window
.Width
, window
.Height
);
1815 /* clipping rect entirely within window */
1816 exp
.X
= clipr
.X
= 20;
1817 exp
.Y
= clipr
.Y
= 8;
1818 exp
.Width
= clipr
.Width
= 30;
1819 exp
.Height
= clipr
.Height
= 20;
1821 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
1824 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
1826 ok(rectf
.X
== exp
.X
&&
1828 rectf
.Width
== exp
.Width
&&
1829 rectf
.Height
== exp
.Height
,
1830 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1831 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1832 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
1833 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
1835 /* clipping rect partially outside of window */
1836 clipr
.X
= window
.Width
- 10;
1837 clipr
.Y
= window
.Height
- 15;
1841 status
= GdipSetClipRect(graphics
, clipr
.X
, clipr
.Y
, clipr
.Width
, clipr
.Height
, CombineModeReplace
);
1844 exp
.X
= window
.Width
- 10;
1845 exp
.Y
= window
.Height
- 15;
1849 status
= GdipGetVisibleClipBounds(graphics
, &rectf
);
1851 ok(rectf
.X
== exp
.X
&&
1853 rectf
.Width
== exp
.Width
&&
1854 rectf
.Height
== exp
.Height
,
1855 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1856 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1857 rectf
.X
, rectf
.Y
, rectf
.Width
, rectf
.Height
,
1858 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
1860 status
= GdipGetVisibleClipBoundsI(graphics
, &recti
);
1862 ok(recti
.X
== exp
.X
&&
1864 recti
.Width
== exp
.Width
&&
1865 recti
.Height
== exp
.Height
,
1866 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
1867 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1868 recti
.X
, recti
.Y
, recti
.Width
, recti
.Height
,
1869 exp
.X
, exp
.Y
, exp
.Width
, exp
.Height
);
1871 GdipDeleteGraphics(graphics
);
1872 EndPaint(hwnd
, &ps
);
1873 DestroyWindow(hwnd
);
1876 static void test_GdipGetVisibleClipBounds(void)
1878 GpGraphics
* graphics
= NULL
;
1884 status
= GdipCreateFromHDC(hdc
, &graphics
);
1886 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1888 /* test null parameters */
1889 status
= GdipGetVisibleClipBounds(graphics
, NULL
);
1890 expect(InvalidParameter
, status
);
1892 status
= GdipGetVisibleClipBounds(NULL
, &rectf
);
1893 expect(InvalidParameter
, status
);
1895 status
= GdipGetVisibleClipBoundsI(graphics
, NULL
);
1896 expect(InvalidParameter
, status
);
1898 status
= GdipGetVisibleClipBoundsI(NULL
, &rect
);
1899 expect(InvalidParameter
, status
);
1901 GdipDeleteGraphics(graphics
);
1904 test_GdipGetVisibleClipBounds_screen();
1905 test_GdipGetVisibleClipBounds_window();
1908 static void test_fromMemoryBitmap(void)
1911 GpGraphics
*graphics
= NULL
;
1912 GpBitmap
*bitmap
= NULL
;
1913 BYTE bits
[48] = {0};
1915 status
= GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB
, bits
, &bitmap
);
1918 status
= GdipGetImageGraphicsContext((GpImage
*)bitmap
, &graphics
);
1921 status
= GdipGraphicsClear(graphics
, 0xff686868);
1924 GdipDeleteGraphics(graphics
);
1926 /* drawing writes to the memory provided */
1927 todo_wine
expect(0x68, bits
[10]);
1929 GdipDisposeImage((GpImage
*)bitmap
);
1932 static void test_GdipIsVisiblePoint(void)
1935 GpGraphics
*graphics
= NULL
;
1940 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
1942 status
= GdipCreateFromHDC(hdc
, &graphics
);
1944 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
1946 /* null parameters */
1947 status
= GdipIsVisiblePoint(NULL
, 0, 0, &val
);
1948 expect(InvalidParameter
, status
);
1950 status
= GdipIsVisiblePoint(graphics
, 0, 0, NULL
);
1951 expect(InvalidParameter
, status
);
1953 status
= GdipIsVisiblePointI(NULL
, 0, 0, &val
);
1954 expect(InvalidParameter
, status
);
1956 status
= GdipIsVisiblePointI(graphics
, 0, 0, NULL
);
1957 expect(InvalidParameter
, status
);
1961 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1963 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1967 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1969 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1973 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1975 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
1979 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1981 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
1983 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
1988 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1990 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
1994 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
1996 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
1998 /* translate into the center of the rect */
1999 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2003 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2005 ok(val
== TRUE
, "Expected (%.2f, %.2f) to be visible\n", x
, y
);
2009 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2011 ok(val
== FALSE
, "Expected (%.2f, %.2f) not to be visible\n", x
, y
);
2013 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2018 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2020 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2024 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2026 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2030 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2032 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2036 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2038 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2042 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2044 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2048 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2050 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2054 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2056 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2060 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2062 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2066 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2068 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2072 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2074 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2078 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2080 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2084 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2086 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2090 status
= GdipIsVisiblePoint(graphics
, x
, y
, &val
);
2092 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2094 /* integer version */
2097 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2099 ok(val
== TRUE
, "After clipping, expected (%.2f, %.2f) to be visible\n", x
, y
);
2103 status
= GdipIsVisiblePointI(graphics
, (INT
)x
, (INT
)y
, &val
);
2105 ok(val
== FALSE
, "After clipping, expected (%.2f, %.2f) not to be visible\n", x
, y
);
2107 GdipDeleteGraphics(graphics
);
2111 static void test_GdipIsVisibleRect(void)
2114 GpGraphics
*graphics
= NULL
;
2116 REAL x
, y
, width
, height
;
2119 ok(hdc
!= NULL
, "Expected HDC to be initialized\n");
2121 status
= GdipCreateFromHDC(hdc
, &graphics
);
2123 ok(graphics
!= NULL
, "Expected graphics to be initialized\n");
2125 status
= GdipIsVisibleRect(NULL
, 0, 0, 0, 0, &val
);
2126 expect(InvalidParameter
, status
);
2128 status
= GdipIsVisibleRect(graphics
, 0, 0, 0, 0, NULL
);
2129 expect(InvalidParameter
, status
);
2131 status
= GdipIsVisibleRectI(NULL
, 0, 0, 0, 0, &val
);
2132 expect(InvalidParameter
, status
);
2134 status
= GdipIsVisibleRectI(graphics
, 0, 0, 0, 0, NULL
);
2135 expect(InvalidParameter
, status
);
2137 /* entirely within the visible region */
2140 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2142 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2144 /* partially outside */
2145 x
= -10; width
= 20;
2146 y
= -10; height
= 20;
2147 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2149 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2151 /* entirely outside */
2153 y
= -10; height
= 5;
2154 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2156 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2158 status
= GdipSetClipRect(graphics
, 10, 20, 30, 40, CombineModeReplace
);
2161 /* entirely within the visible region */
2163 y
= 22; height
= 10;
2164 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2166 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2168 /* partially outside */
2170 y
= 55; height
= 10;
2171 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2173 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2175 /* entirely outside */
2178 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2180 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2182 /* translate into center of clipping rect */
2183 GdipTranslateWorldTransform(graphics
, 25, 40, MatrixOrderAppend
);
2187 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2189 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2193 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2195 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2197 GdipTranslateWorldTransform(graphics
, -25, -40, MatrixOrderAppend
);
2199 /* corners entirely outside, but some intersections */
2202 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2204 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2208 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2210 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2214 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2216 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2220 y
= 20; height
= 40;
2221 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2223 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2227 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2229 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2232 y
= 20; height
= 40;
2233 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2235 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2238 y
= 60; height
= 10;
2239 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2241 ok(val
== FALSE
, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x
, y
, width
, height
);
2243 /* rounding tests */
2244 x
= 0.4; width
= 10.4;
2245 y
= 20; height
= 40;
2246 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2248 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2251 y
= 0.4; height
= 20.4;
2252 status
= GdipIsVisibleRect(graphics
, x
, y
, width
, height
, &val
);
2254 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2256 /* integer version */
2259 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2261 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2264 y
= 22; height
= 10;
2265 status
= GdipIsVisibleRectI(graphics
, (INT
)x
, (INT
)y
, (INT
)width
, (INT
)height
, &val
);
2267 ok(val
== TRUE
, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x
, y
, width
, height
);
2269 GdipDeleteGraphics(graphics
);
2273 START_TEST(graphics
)
2275 struct GdiplusStartupInput gdiplusStartupInput
;
2276 ULONG_PTR gdiplusToken
;
2278 gdiplusStartupInput
.GdiplusVersion
= 1;
2279 gdiplusStartupInput
.DebugEventCallback
= NULL
;
2280 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
2281 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
2283 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
2285 test_constructor_destructor();
2286 test_save_restore();
2287 test_GdipDrawBezierI();
2289 test_GdipDrawArcI();
2290 test_GdipDrawCurve();
2291 test_GdipDrawCurveI();
2292 test_GdipDrawCurve2();
2293 test_GdipDrawCurve2I();
2294 test_GdipDrawCurve3();
2295 test_GdipDrawCurve3I();
2296 test_GdipDrawLineI();
2297 test_GdipDrawLinesI();
2298 test_GdipDrawString();
2299 test_GdipGetVisibleClipBounds();
2300 test_GdipIsVisiblePoint();
2301 test_GdipIsVisibleRect();
2302 test_Get_Release_DC();
2303 test_BeginContainer2();
2304 test_transformpoints();
2305 test_get_set_clip();
2308 test_textcontrast();
2309 test_fromMemoryBitmap();
2311 GdiplusShutdown(gdiplusToken
);