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, precision) ok(fabs(expected - got) < precision, "Expected %.2f, got %.2f\n", expected, got)
29 #define expectf(expected, got) expectf_(expected, got, 0.0001)
30 #define TABLE_LEN (23)
34 static void test_constructor_destructor(void)
37 GpGraphics *graphics = NULL;
38 HDC hdc = GetDC( hwnd );
40 stat = GdipCreateFromHDC(NULL, &graphics);
41 expect(OutOfMemory, stat);
42 stat = GdipDeleteGraphics(graphics);
43 expect(InvalidParameter, stat);
45 stat = GdipCreateFromHDC(hdc, &graphics);
47 stat = GdipDeleteGraphics(graphics);
50 stat = GdipCreateFromHWND(NULL, &graphics);
52 stat = GdipDeleteGraphics(graphics);
55 stat = GdipCreateFromHWNDICM(NULL, &graphics);
57 stat = GdipDeleteGraphics(graphics);
60 stat = GdipDeleteGraphics(NULL);
61 expect(InvalidParameter, stat);
70 /* Linked list prepend function. */
71 static void log_state(GraphicsState data, node ** log)
73 node * new_entry = HeapAlloc(GetProcessHeap(), 0, sizeof(node));
75 new_entry->data = data;
76 new_entry->next = *log;
80 /* Checks if there are duplicates in the list, and frees it. */
81 static void check_no_duplicates(node * log)
93 while((temp = temp->next)){
94 if(log->data == temp->data){
101 }while((log = log->next));
106 HeapFree(GetProcessHeap(), 0, temp);
114 static void test_save_restore(void)
117 GraphicsState state_a, state_b, state_c;
118 InterpolationMode mode;
119 GpGraphics *graphics1, *graphics2;
120 node * state_log = NULL;
121 HDC hdc = GetDC( hwnd );
122 state_a = state_b = state_c = 0xdeadbeef;
124 /* Invalid saving. */
125 GdipCreateFromHDC(hdc, &graphics1);
126 stat = GdipSaveGraphics(graphics1, NULL);
127 expect(InvalidParameter, stat);
128 stat = GdipSaveGraphics(NULL, &state_a);
129 expect(InvalidParameter, stat);
130 GdipDeleteGraphics(graphics1);
132 log_state(state_a, &state_log);
134 /* Basic save/restore. */
135 GdipCreateFromHDC(hdc, &graphics1);
136 GdipSetInterpolationMode(graphics1, InterpolationModeBilinear);
137 stat = GdipSaveGraphics(graphics1, &state_a);
139 GdipSetInterpolationMode(graphics1, InterpolationModeBicubic);
140 stat = GdipRestoreGraphics(graphics1, state_a);
142 GdipGetInterpolationMode(graphics1, &mode);
143 expect(InterpolationModeBilinear, mode);
144 GdipDeleteGraphics(graphics1);
146 log_state(state_a, &state_log);
148 /* Restoring garbage doesn't affect saves. */
149 GdipCreateFromHDC(hdc, &graphics1);
150 GdipSetInterpolationMode(graphics1, InterpolationModeBilinear);
151 GdipSaveGraphics(graphics1, &state_a);
152 GdipSetInterpolationMode(graphics1, InterpolationModeBicubic);
153 GdipSaveGraphics(graphics1, &state_b);
154 GdipSetInterpolationMode(graphics1, InterpolationModeNearestNeighbor);
155 stat = GdipRestoreGraphics(graphics1, 0xdeadbeef);
157 GdipRestoreGraphics(graphics1, state_b);
158 GdipGetInterpolationMode(graphics1, &mode);
159 expect(InterpolationModeBicubic, mode);
160 GdipRestoreGraphics(graphics1, state_a);
161 GdipGetInterpolationMode(graphics1, &mode);
162 expect(InterpolationModeBilinear, mode);
163 GdipDeleteGraphics(graphics1);
165 log_state(state_a, &state_log);
166 log_state(state_b, &state_log);
168 /* Restoring older state invalidates newer saves (but not older saves). */
169 GdipCreateFromHDC(hdc, &graphics1);
170 GdipSetInterpolationMode(graphics1, InterpolationModeBilinear);
171 GdipSaveGraphics(graphics1, &state_a);
172 GdipSetInterpolationMode(graphics1, InterpolationModeBicubic);
173 GdipSaveGraphics(graphics1, &state_b);
174 GdipSetInterpolationMode(graphics1, InterpolationModeNearestNeighbor);
175 GdipSaveGraphics(graphics1, &state_c);
176 GdipSetInterpolationMode(graphics1, InterpolationModeHighQualityBilinear);
177 GdipRestoreGraphics(graphics1, state_b);
178 GdipGetInterpolationMode(graphics1, &mode);
179 expect(InterpolationModeBicubic, mode);
180 GdipRestoreGraphics(graphics1, state_c);
181 GdipGetInterpolationMode(graphics1, &mode);
182 expect(InterpolationModeBicubic, mode);
183 GdipRestoreGraphics(graphics1, state_a);
184 GdipGetInterpolationMode(graphics1, &mode);
185 expect(InterpolationModeBilinear, mode);
186 GdipDeleteGraphics(graphics1);
188 log_state(state_a, &state_log);
189 log_state(state_b, &state_log);
190 log_state(state_c, &state_log);
192 /* Restoring older save from one graphics object does not invalidate
193 * newer save from other graphics object. */
194 GdipCreateFromHDC(hdc, &graphics1);
195 GdipCreateFromHDC(hdc, &graphics2);
196 GdipSetInterpolationMode(graphics1, InterpolationModeBilinear);
197 GdipSaveGraphics(graphics1, &state_a);
198 GdipSetInterpolationMode(graphics2, InterpolationModeBicubic);
199 GdipSaveGraphics(graphics2, &state_b);
200 GdipSetInterpolationMode(graphics1, InterpolationModeNearestNeighbor);
201 GdipSetInterpolationMode(graphics2, InterpolationModeNearestNeighbor);
202 GdipRestoreGraphics(graphics1, state_a);
203 GdipGetInterpolationMode(graphics1, &mode);
204 expect(InterpolationModeBilinear, mode);
205 GdipRestoreGraphics(graphics2, state_b);
206 GdipGetInterpolationMode(graphics2, &mode);
207 expect(InterpolationModeBicubic, mode);
208 GdipDeleteGraphics(graphics1);
209 GdipDeleteGraphics(graphics2);
211 /* You can't restore a state to a graphics object that didn't save it. */
212 GdipCreateFromHDC(hdc, &graphics1);
213 GdipCreateFromHDC(hdc, &graphics2);
214 GdipSetInterpolationMode(graphics1, InterpolationModeBilinear);
215 GdipSaveGraphics(graphics1, &state_a);
216 GdipSetInterpolationMode(graphics1, InterpolationModeNearestNeighbor);
217 GdipSetInterpolationMode(graphics2, InterpolationModeNearestNeighbor);
218 GdipRestoreGraphics(graphics2, state_a);
219 GdipGetInterpolationMode(graphics2, &mode);
220 expect(InterpolationModeNearestNeighbor, mode);
221 GdipDeleteGraphics(graphics1);
222 GdipDeleteGraphics(graphics2);
224 log_state(state_a, &state_log);
226 /* The same state value should never be returned twice. */
228 check_no_duplicates(state_log);
230 ReleaseDC(hwnd, hdc);
233 static void test_GdipFillClosedCurve2(void)
236 GpGraphics *graphics = NULL;
237 GpSolidFill *brush = NULL;
238 HDC hdc = GetDC( hwnd );
250 /* make a graphics object and brush object */
251 ok(hdc != NULL, "Expected HDC to be initialized\n");
253 status = GdipCreateFromHDC(hdc, &graphics);
255 ok(graphics != NULL, "Expected graphics to be initialized\n");
257 GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
259 /* InvalidParameter cases: null graphics, null brush, null points */
260 status = GdipFillClosedCurve2(NULL, NULL, NULL, 3, 0.5, FillModeAlternate);
261 expect(InvalidParameter, status);
263 status = GdipFillClosedCurve2(graphics, NULL, NULL, 3, 0.5, FillModeAlternate);
264 expect(InvalidParameter, status);
266 status = GdipFillClosedCurve2(NULL, (GpBrush*)brush, NULL, 3, 0.5, FillModeAlternate);
267 expect(InvalidParameter, status);
269 status = GdipFillClosedCurve2(NULL, NULL, points, 3, 0.5, FillModeAlternate);
270 expect(InvalidParameter, status);
272 status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, NULL, 3, 0.5, FillModeAlternate);
273 expect(InvalidParameter, status);
275 status = GdipFillClosedCurve2(graphics, NULL, points, 3, 0.5, FillModeAlternate);
276 expect(InvalidParameter, status);
278 status = GdipFillClosedCurve2(NULL, (GpBrush*)brush, points, 3, 0.5, FillModeAlternate);
279 expect(InvalidParameter, status);
281 /* InvalidParameter cases: invalid count */
282 status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, points, -1, 0.5, FillModeAlternate);
283 expect(InvalidParameter, status);
285 status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, points, 0, 0.5, FillModeAlternate);
286 expect(InvalidParameter, status);
288 /* Valid test cases */
289 status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, points, 1, 0.5, FillModeAlternate);
292 status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, points, 2, 0.5, FillModeAlternate);
295 status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, points, 3, 0.5, FillModeAlternate);
298 GdipDeleteGraphics(graphics);
299 GdipDeleteBrush((GpBrush*)brush);
301 ReleaseDC(hwnd, hdc);
304 static void test_GdipFillClosedCurve2I(void)
307 GpGraphics *graphics = NULL;
308 GpSolidFill *brush = NULL;
309 HDC hdc = GetDC( hwnd );
321 /* make a graphics object and brush object */
322 ok(hdc != NULL, "Expected HDC to be initialized\n");
324 status = GdipCreateFromHDC(hdc, &graphics);
326 ok(graphics != NULL, "Expected graphics to be initialized\n");
328 GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
330 /* InvalidParameter cases: null graphics, null brush */
331 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
332 when points == NULL, so don't test this condition */
333 status = GdipFillClosedCurve2I(NULL, NULL, points, 3, 0.5, FillModeAlternate);
334 expect(InvalidParameter, status);
336 status = GdipFillClosedCurve2I(graphics, NULL, points, 3, 0.5, FillModeAlternate);
337 expect(InvalidParameter, status);
339 status = GdipFillClosedCurve2I(NULL, (GpBrush*)brush, points, 3, 0.5, FillModeAlternate);
340 expect(InvalidParameter, status);
342 /* InvalidParameter cases: invalid count */
343 status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, points, 0, 0.5, FillModeAlternate);
344 expect(InvalidParameter, status);
346 /* OutOfMemory cases: large (unsigned) int */
347 status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, points, -1, 0.5, FillModeAlternate);
348 expect(OutOfMemory, status);
350 /* Valid test cases */
351 status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, points, 1, 0.5, FillModeAlternate);
354 status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, points, 2, 0.5, FillModeAlternate);
357 status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, points, 3, 0.5, FillModeAlternate);
360 GdipDeleteGraphics(graphics);
361 GdipDeleteBrush((GpBrush*)brush);
363 ReleaseDC(hwnd, hdc);
366 static void test_GdipDrawArc(void)
369 GpGraphics *graphics = NULL;
371 HDC hdc = GetDC( hwnd );
373 /* make a graphics object and pen object */
374 ok(hdc != NULL, "Expected HDC to be initialized\n");
376 status = GdipCreateFromHDC(hdc, &graphics);
378 ok(graphics != NULL, "Expected graphics to be initialized\n");
380 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
382 ok(pen != NULL, "Expected pen to be initialized\n");
384 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
385 status = GdipDrawArc(NULL, NULL, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
386 expect(InvalidParameter, status);
388 status = GdipDrawArc(graphics, NULL, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
389 expect(InvalidParameter, status);
391 status = GdipDrawArc(NULL, pen, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
392 expect(InvalidParameter, status);
394 status = GdipDrawArc(graphics, pen, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
395 expect(InvalidParameter, status);
397 status = GdipDrawArc(graphics, pen, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
398 expect(InvalidParameter, status);
400 /* successful case */
401 status = GdipDrawArc(graphics, pen, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
405 GdipDeleteGraphics(graphics);
407 ReleaseDC(hwnd, hdc);
410 static void test_GdipDrawArcI(void)
413 GpGraphics *graphics = NULL;
415 HDC hdc = GetDC( hwnd );
417 /* make a graphics object and pen object */
418 ok(hdc != NULL, "Expected HDC to be initialized\n");
420 status = GdipCreateFromHDC(hdc, &graphics);
422 ok(graphics != NULL, "Expected graphics to be initialized\n");
424 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
426 ok(pen != NULL, "Expected pen to be initialized\n");
428 /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */
429 status = GdipDrawArcI(NULL, NULL, 0, 0, 0, 0, 0, 0);
430 expect(InvalidParameter, status);
432 status = GdipDrawArcI(graphics, NULL, 0, 0, 1, 1, 0, 0);
433 expect(InvalidParameter, status);
435 status = GdipDrawArcI(NULL, pen, 0, 0, 1, 1, 0, 0);
436 expect(InvalidParameter, status);
438 status = GdipDrawArcI(graphics, pen, 0, 0, 1, 0, 0, 0);
439 expect(InvalidParameter, status);
441 status = GdipDrawArcI(graphics, pen, 0, 0, 0, 1, 0, 0);
442 expect(InvalidParameter, status);
444 /* successful case */
445 status = GdipDrawArcI(graphics, pen, 0, 0, 1, 1, 0, 0);
449 GdipDeleteGraphics(graphics);
451 ReleaseDC(hwnd, hdc);
454 static void test_BeginContainer2(void)
458 REAL defClip[] = {5, 10, 15, 20};
459 REAL elems[6], defTrans[] = {1, 2, 3, 4, 5, 6};
460 GraphicsContainer cont1, cont2, cont3, cont4;
461 CompositingQuality compqual, defCompqual = CompositingQualityHighSpeed;
462 CompositingMode compmode, defCompmode = CompositingModeSourceOver;
463 InterpolationMode interp, defInterp = InterpolationModeHighQualityBicubic;
464 REAL scale, defScale = 17;
465 GpUnit unit, defUnit = UnitPixel;
466 PixelOffsetMode offsetmode, defOffsetmode = PixelOffsetModeHighSpeed;
467 SmoothingMode smoothmode, defSmoothmode = SmoothingModeAntiAlias;
468 UINT contrast, defContrast = 5;
469 TextRenderingHint texthint, defTexthint = TextRenderingHintAntiAlias;
472 GpGraphics *graphics = NULL;
473 HDC hdc = GetDC( hwnd );
475 ok(hdc != NULL, "Expected HDC to be initialized\n");
477 status = GdipCreateFromHDC(hdc, &graphics);
479 ok(graphics != NULL, "Expected graphics to be initialized\n");
481 /* null graphics, null container */
482 status = GdipBeginContainer2(NULL, &cont1);
483 expect(InvalidParameter, status);
485 status = GdipBeginContainer2(graphics, NULL);
486 expect(InvalidParameter, status);
488 status = GdipEndContainer(NULL, cont1);
489 expect(InvalidParameter, status);
491 /* test all quality-related values */
492 GdipSetCompositingMode(graphics, defCompmode);
493 GdipSetCompositingQuality(graphics, defCompqual);
494 GdipSetInterpolationMode(graphics, defInterp);
495 GdipSetPageScale(graphics, defScale);
496 GdipSetPageUnit(graphics, defUnit);
497 GdipSetPixelOffsetMode(graphics, defOffsetmode);
498 GdipSetSmoothingMode(graphics, defSmoothmode);
499 GdipSetTextContrast(graphics, defContrast);
500 GdipSetTextRenderingHint(graphics, defTexthint);
502 status = GdipBeginContainer2(graphics, &cont1);
505 GdipSetCompositingMode(graphics, CompositingModeSourceCopy);
506 GdipSetCompositingQuality(graphics, CompositingQualityHighQuality);
507 GdipSetInterpolationMode(graphics, InterpolationModeBilinear);
508 GdipSetPageScale(graphics, 10);
509 GdipSetPageUnit(graphics, UnitDocument);
510 GdipSetPixelOffsetMode(graphics, PixelOffsetModeHalf);
511 GdipSetSmoothingMode(graphics, SmoothingModeNone);
512 GdipSetTextContrast(graphics, 7);
513 GdipSetTextRenderingHint(graphics, TextRenderingHintClearTypeGridFit);
515 status = GdipEndContainer(graphics, cont1);
518 GdipGetCompositingMode(graphics, &compmode);
519 ok(defCompmode == compmode, "Expected Compositing Mode to be restored to %d, got %d\n", defCompmode, compmode);
521 GdipGetCompositingQuality(graphics, &compqual);
522 ok(defCompqual == compqual, "Expected Compositing Quality to be restored to %d, got %d\n", defCompqual, compqual);
524 GdipGetInterpolationMode(graphics, &interp);
525 ok(defInterp == interp, "Expected Interpolation Mode to be restored to %d, got %d\n", defInterp, interp);
527 GdipGetPageScale(graphics, &scale);
528 ok(fabs(defScale - scale) < 0.0001, "Expected Page Scale to be restored to %f, got %f\n", defScale, scale);
530 GdipGetPageUnit(graphics, &unit);
531 ok(defUnit == unit, "Expected Page Unit to be restored to %d, got %d\n", defUnit, unit);
533 GdipGetPixelOffsetMode(graphics, &offsetmode);
534 ok(defOffsetmode == offsetmode, "Expected Pixel Offset Mode to be restored to %d, got %d\n", defOffsetmode, offsetmode);
536 GdipGetSmoothingMode(graphics, &smoothmode);
537 ok(defSmoothmode == smoothmode, "Expected Smoothing Mode to be restored to %d, got %d\n", defSmoothmode, smoothmode);
539 GdipGetTextContrast(graphics, &contrast);
540 ok(defContrast == contrast, "Expected Text Contrast to be restored to %d, got %d\n", defContrast, contrast);
542 GdipGetTextRenderingHint(graphics, &texthint);
543 ok(defTexthint == texthint, "Expected Text Hint to be restored to %d, got %d\n", defTexthint, texthint);
545 /* test world transform */
546 status = GdipBeginContainer2(graphics, &cont1);
549 GdipCreateMatrix2(defTrans[0], defTrans[1], defTrans[2], defTrans[3],
550 defTrans[4], defTrans[5], &transform);
551 GdipSetWorldTransform(graphics, transform);
552 GdipDeleteMatrix(transform);
555 status = GdipBeginContainer2(graphics, &cont2);
558 GdipCreateMatrix2(10, 20, 30, 40, 50, 60, &transform);
559 GdipSetWorldTransform(graphics, transform);
560 GdipDeleteMatrix(transform);
563 status = GdipEndContainer(graphics, cont2);
566 GdipCreateMatrix(&transform);
567 GdipGetWorldTransform(graphics, transform);
568 GdipGetMatrixElements(transform, elems);
569 ok(fabs(defTrans[0] - elems[0]) < 0.0001 &&
570 fabs(defTrans[1] - elems[1]) < 0.0001 &&
571 fabs(defTrans[2] - elems[2]) < 0.0001 &&
572 fabs(defTrans[3] - elems[3]) < 0.0001 &&
573 fabs(defTrans[4] - elems[4]) < 0.0001 &&
574 fabs(defTrans[5] - elems[5]) < 0.0001,
575 "Expected World Transform Matrix to be restored to [%f, %f, %f, %f, %f, %f], got [%f, %f, %f, %f, %f, %f]\n",
576 defTrans[0], defTrans[1], defTrans[2], defTrans[3], defTrans[4], defTrans[5],
577 elems[0], elems[1], elems[2], elems[3], elems[4], elems[5]);
578 GdipDeleteMatrix(transform);
581 status = GdipEndContainer(graphics, cont1);
585 status = GdipBeginContainer2(graphics, &cont1);
588 GdipSetClipRect(graphics, defClip[0], defClip[1], defClip[2], defClip[3], CombineModeReplace);
590 status = GdipBeginContainer2(graphics, &cont2);
593 GdipSetClipRect(graphics, 2, 4, 6, 8, CombineModeReplace);
595 status = GdipEndContainer(graphics, cont2);
598 GdipGetClipBounds(graphics, &clip);
599 ok(fabs(defClip[0] - clip.X) < 0.0001 &&
600 fabs(defClip[1] - clip.Y) < 0.0001 &&
601 fabs(defClip[2] - clip.Width) < 0.0001 &&
602 fabs(defClip[3] - clip.Height) < 0.0001,
603 "Expected Clipping Rectangle to be restored to [%f, %f, %f, %f], got [%f, %f, %f, %f]\n",
604 defClip[0], defClip[1], defClip[2], defClip[3],
605 clip.X, clip.Y, clip.Width, clip.Height);
607 status = GdipEndContainer(graphics, cont1);
611 status = GdipBeginContainer2(graphics, &cont1);
614 status = GdipBeginContainer2(graphics, &cont2);
617 status = GdipBeginContainer2(graphics, &cont3);
620 status = GdipEndContainer(graphics, cont3);
623 status = GdipBeginContainer2(graphics, &cont4);
626 status = GdipEndContainer(graphics, cont4);
630 status = GdipEndContainer(graphics, cont1);
633 /* end an already-ended container */
634 status = GdipEndContainer(graphics, cont1);
637 GdipDeleteGraphics(graphics);
638 ReleaseDC(hwnd, hdc);
641 static void test_GdipDrawBezierI(void)
644 GpGraphics *graphics = NULL;
646 HDC hdc = GetDC( hwnd );
648 /* make a graphics object and pen object */
649 ok(hdc != NULL, "Expected HDC to be initialized\n");
651 status = GdipCreateFromHDC(hdc, &graphics);
653 ok(graphics != NULL, "Expected graphics to be initialized\n");
655 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
657 ok(pen != NULL, "Expected pen to be initialized\n");
659 /* InvalidParameter cases: null graphics, null pen */
660 status = GdipDrawBezierI(NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0);
661 expect(InvalidParameter, status);
663 status = GdipDrawBezierI(graphics, NULL, 0, 0, 0, 0, 0, 0, 0, 0);
664 expect(InvalidParameter, status);
666 status = GdipDrawBezierI(NULL, pen, 0, 0, 0, 0, 0, 0, 0, 0);
667 expect(InvalidParameter, status);
669 /* successful case */
670 status = GdipDrawBezierI(graphics, pen, 0, 0, 0, 0, 0, 0, 0, 0);
674 GdipDeleteGraphics(graphics);
676 ReleaseDC(hwnd, hdc);
679 static void test_GdipDrawCurve3(void)
682 GpGraphics *graphics = NULL;
684 HDC hdc = GetDC( hwnd );
696 /* make a graphics object and pen object */
697 ok(hdc != NULL, "Expected HDC to be initialized\n");
699 status = GdipCreateFromHDC(hdc, &graphics);
701 ok(graphics != NULL, "Expected graphics to be initialized\n");
703 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
705 ok(pen != NULL, "Expected pen to be initialized\n");
707 /* InvalidParameter cases: null graphics, null pen */
708 status = GdipDrawCurve3(NULL, NULL, points, 3, 0, 2, 1);
709 expect(InvalidParameter, status);
711 status = GdipDrawCurve3(graphics, NULL, points, 3, 0, 2, 1);
712 expect(InvalidParameter, status);
714 status = GdipDrawCurve3(NULL, pen, points, 3, 0, 2, 1);
715 expect(InvalidParameter, status);
717 /* InvalidParameter cases: invalid count */
718 status = GdipDrawCurve3(graphics, pen, points, -1, 0, 2, 1);
719 expect(InvalidParameter, status);
721 status = GdipDrawCurve3(graphics, pen, points, 0, 0, 2, 1);
722 expect(InvalidParameter, status);
724 status = GdipDrawCurve3(graphics, pen, points, 1, 0, 0, 1);
725 expect(InvalidParameter, status);
727 status = GdipDrawCurve3(graphics, pen, points, 3, 4, 2, 1);
728 expect(InvalidParameter, status);
730 /* InvalidParameter cases: invalid number of segments */
731 status = GdipDrawCurve3(graphics, pen, points, 3, 0, -1, 1);
732 expect(InvalidParameter, status);
734 status = GdipDrawCurve3(graphics, pen, points, 3, 1, 2, 1);
735 expect(InvalidParameter, status);
737 status = GdipDrawCurve3(graphics, pen, points, 2, 0, 2, 1);
738 expect(InvalidParameter, status);
740 /* Valid test cases */
741 status = GdipDrawCurve3(graphics, pen, points, 2, 0, 1, 1);
744 status = GdipDrawCurve3(graphics, pen, points, 3, 0, 2, 2);
747 status = GdipDrawCurve3(graphics, pen, points, 2, 0, 1, -2);
750 status = GdipDrawCurve3(graphics, pen, points, 3, 1, 1, 0);
754 GdipDeleteGraphics(graphics);
756 ReleaseDC(hwnd, hdc);
759 static void test_GdipDrawCurve3I(void)
762 GpGraphics *graphics = NULL;
764 HDC hdc = GetDC( hwnd );
776 /* make a graphics object and pen object */
777 ok(hdc != NULL, "Expected HDC to be initialized\n");
779 status = GdipCreateFromHDC(hdc, &graphics);
781 ok(graphics != NULL, "Expected graphics to be initialized\n");
783 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
785 ok(pen != NULL, "Expected pen to be initialized\n");
787 /* InvalidParameter cases: null graphics, null pen */
788 status = GdipDrawCurve3I(NULL, NULL, points, 3, 0, 2, 1);
789 expect(InvalidParameter, status);
791 status = GdipDrawCurve3I(graphics, NULL, points, 3, 0, 2, 1);
792 expect(InvalidParameter, status);
794 status = GdipDrawCurve3I(NULL, pen, points, 3, 0, 2, 1);
795 expect(InvalidParameter, status);
797 /* InvalidParameter cases: invalid count */
798 status = GdipDrawCurve3I(graphics, pen, points, -1, -1, -1, 1);
799 expect(OutOfMemory, status);
801 status = GdipDrawCurve3I(graphics, pen, points, 0, 0, 2, 1);
802 expect(InvalidParameter, status);
804 status = GdipDrawCurve3I(graphics, pen, points, 1, 0, 0, 1);
805 expect(InvalidParameter, status);
807 status = GdipDrawCurve3I(graphics, pen, points, 3, 4, 2, 1);
808 expect(InvalidParameter, status);
810 /* InvalidParameter cases: invalid number of segments */
811 status = GdipDrawCurve3I(graphics, pen, points, 3, 0, -1, 1);
812 expect(InvalidParameter, status);
814 status = GdipDrawCurve3I(graphics, pen, points, 3, 1, 2, 1);
815 expect(InvalidParameter, status);
817 status = GdipDrawCurve3I(graphics, pen, points, 2, 0, 2, 1);
818 expect(InvalidParameter, status);
820 /* Valid test cases */
821 status = GdipDrawCurve3I(graphics, pen, points, 2, 0, 1, 1);
824 status = GdipDrawCurve3I(graphics, pen, points, 3, 0, 2, 2);
827 status = GdipDrawCurve3I(graphics, pen, points, 2, 0, 1, -2);
830 status = GdipDrawCurve3I(graphics, pen, points, 3, 1, 1, 0);
834 GdipDeleteGraphics(graphics);
836 ReleaseDC(hwnd, hdc);
839 static void test_GdipDrawCurve2(void)
842 GpGraphics *graphics = NULL;
844 HDC hdc = GetDC( hwnd );
856 /* make a graphics object and pen object */
857 ok(hdc != NULL, "Expected HDC to be initialized\n");
859 status = GdipCreateFromHDC(hdc, &graphics);
861 ok(graphics != NULL, "Expected graphics to be initialized\n");
863 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
865 ok(pen != NULL, "Expected pen to be initialized\n");
867 /* InvalidParameter cases: null graphics, null pen */
868 status = GdipDrawCurve2(NULL, NULL, points, 3, 1);
869 expect(InvalidParameter, status);
871 status = GdipDrawCurve2(graphics, NULL, points, 3, 1);
872 expect(InvalidParameter, status);
874 status = GdipDrawCurve2(NULL, pen, points, 3, 1);
875 expect(InvalidParameter, status);
877 /* InvalidParameter cases: invalid count */
878 status = GdipDrawCurve2(graphics, pen, points, -1, 1);
879 expect(InvalidParameter, status);
881 status = GdipDrawCurve2(graphics, pen, points, 0, 1);
882 expect(InvalidParameter, status);
884 status = GdipDrawCurve2(graphics, pen, points, 1, 1);
885 expect(InvalidParameter, status);
887 /* Valid test cases */
888 status = GdipDrawCurve2(graphics, pen, points, 2, 1);
891 status = GdipDrawCurve2(graphics, pen, points, 3, 2);
894 status = GdipDrawCurve2(graphics, pen, points, 3, -2);
897 status = GdipDrawCurve2(graphics, pen, points, 3, 0);
901 GdipDeleteGraphics(graphics);
903 ReleaseDC(hwnd, hdc);
906 static void test_GdipDrawCurve2I(void)
909 GpGraphics *graphics = NULL;
911 HDC hdc = GetDC( hwnd );
923 /* make a graphics object and pen object */
924 ok(hdc != NULL, "Expected HDC to be initialized\n");
926 status = GdipCreateFromHDC(hdc, &graphics);
928 ok(graphics != NULL, "Expected graphics to be initialized\n");
930 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
932 ok(pen != NULL, "Expected pen to be initialized\n");
934 /* InvalidParameter cases: null graphics, null pen */
935 status = GdipDrawCurve2I(NULL, NULL, points, 3, 1);
936 expect(InvalidParameter, status);
938 status = GdipDrawCurve2I(graphics, NULL, points, 3, 1);
939 expect(InvalidParameter, status);
941 status = GdipDrawCurve2I(NULL, pen, points, 3, 1);
942 expect(InvalidParameter, status);
944 /* InvalidParameter cases: invalid count */
945 status = GdipDrawCurve2I(graphics, pen, points, -1, 1);
946 expect(OutOfMemory, status);
948 status = GdipDrawCurve2I(graphics, pen, points, 0, 1);
949 expect(InvalidParameter, status);
951 status = GdipDrawCurve2I(graphics, pen, points, 1, 1);
952 expect(InvalidParameter, status);
954 /* Valid test cases */
955 status = GdipDrawCurve2I(graphics, pen, points, 2, 1);
958 status = GdipDrawCurve2I(graphics, pen, points, 3, 2);
961 status = GdipDrawCurve2I(graphics, pen, points, 3, -2);
964 status = GdipDrawCurve2I(graphics, pen, points, 3, 0);
968 GdipDeleteGraphics(graphics);
970 ReleaseDC(hwnd, hdc);
973 static void test_GdipDrawCurve(void)
976 GpGraphics *graphics = NULL;
978 HDC hdc = GetDC( hwnd );
990 /* make a graphics object and pen object */
991 ok(hdc != NULL, "Expected HDC to be initialized\n");
993 status = GdipCreateFromHDC(hdc, &graphics);
995 ok(graphics != NULL, "Expected graphics to be initialized\n");
997 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
999 ok(pen != NULL, "Expected pen to be initialized\n");
1001 /* InvalidParameter cases: null graphics, null pen */
1002 status = GdipDrawCurve(NULL, NULL, points, 3);
1003 expect(InvalidParameter, status);
1005 status = GdipDrawCurve(graphics, NULL, points, 3);
1006 expect(InvalidParameter, status);
1008 status = GdipDrawCurve(NULL, pen, points, 3);
1009 expect(InvalidParameter, status);
1011 /* InvalidParameter cases: invalid count */
1012 status = GdipDrawCurve(graphics, pen, points, -1);
1013 expect(InvalidParameter, status);
1015 status = GdipDrawCurve(graphics, pen, points, 0);
1016 expect(InvalidParameter, status);
1018 status = GdipDrawCurve(graphics, pen, points, 1);
1019 expect(InvalidParameter, status);
1021 /* Valid test cases */
1022 status = GdipDrawCurve(graphics, pen, points, 2);
1025 status = GdipDrawCurve(graphics, pen, points, 3);
1029 GdipDeleteGraphics(graphics);
1031 ReleaseDC(hwnd, hdc);
1034 static void test_GdipDrawCurveI(void)
1037 GpGraphics *graphics = NULL;
1039 HDC hdc = GetDC( hwnd );
1051 /* make a graphics object and pen object */
1052 ok(hdc != NULL, "Expected HDC to be initialized\n");
1054 status = GdipCreateFromHDC(hdc, &graphics);
1056 ok(graphics != NULL, "Expected graphics to be initialized\n");
1058 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
1060 ok(pen != NULL, "Expected pen to be initialized\n");
1062 /* InvalidParameter cases: null graphics, null pen */
1063 status = GdipDrawCurveI(NULL, NULL, points, 3);
1064 expect(InvalidParameter, status);
1066 status = GdipDrawCurveI(graphics, NULL, points, 3);
1067 expect(InvalidParameter, status);
1069 status = GdipDrawCurveI(NULL, pen, points, 3);
1070 expect(InvalidParameter, status);
1072 /* InvalidParameter cases: invalid count */
1073 status = GdipDrawCurveI(graphics, pen, points, -1);
1074 expect(OutOfMemory, status);
1076 status = GdipDrawCurveI(graphics, pen, points, 0);
1077 expect(InvalidParameter, status);
1079 status = GdipDrawCurveI(graphics, pen, points, 1);
1080 expect(InvalidParameter, status);
1082 /* Valid test cases */
1083 status = GdipDrawCurveI(graphics, pen, points, 2);
1086 status = GdipDrawCurveI(graphics, pen, points, 3);
1090 GdipDeleteGraphics(graphics);
1092 ReleaseDC(hwnd, hdc);
1095 static void test_GdipDrawLineI(void)
1098 GpGraphics *graphics = NULL;
1100 HDC hdc = GetDC( hwnd );
1102 /* make a graphics object and pen object */
1103 ok(hdc != NULL, "Expected HDC to be initialized\n");
1105 status = GdipCreateFromHDC(hdc, &graphics);
1107 ok(graphics != NULL, "Expected graphics to be initialized\n");
1109 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
1111 ok(pen != NULL, "Expected pen to be initialized\n");
1113 /* InvalidParameter cases: null graphics, null pen */
1114 status = GdipDrawLineI(NULL, NULL, 0, 0, 0, 0);
1115 expect(InvalidParameter, status);
1117 status = GdipDrawLineI(graphics, NULL, 0, 0, 0, 0);
1118 expect(InvalidParameter, status);
1120 status = GdipDrawLineI(NULL, pen, 0, 0, 0, 0);
1121 expect(InvalidParameter, status);
1123 /* successful case */
1124 status = GdipDrawLineI(graphics, pen, 0, 0, 0, 0);
1128 GdipDeleteGraphics(graphics);
1130 ReleaseDC(hwnd, hdc);
1133 static void test_GdipDrawLinesI(void)
1136 GpGraphics *graphics = NULL;
1138 GpPoint *ptf = NULL;
1139 HDC hdc = GetDC( hwnd );
1141 /* make a graphics object and pen object */
1142 ok(hdc != NULL, "Expected HDC to be initialized\n");
1144 status = GdipCreateFromHDC(hdc, &graphics);
1146 ok(graphics != NULL, "Expected graphics to be initialized\n");
1148 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
1150 ok(pen != NULL, "Expected pen to be initialized\n");
1152 /* make some arbitrary valid points*/
1153 ptf = GdipAlloc(2 * sizeof(GpPointF));
1161 /* InvalidParameter cases: null graphics, null pen, null points, count < 2*/
1162 status = GdipDrawLinesI(NULL, NULL, NULL, 0);
1163 expect(InvalidParameter, status);
1165 status = GdipDrawLinesI(graphics, pen, ptf, 0);
1166 expect(InvalidParameter, status);
1168 status = GdipDrawLinesI(graphics, NULL, ptf, 2);
1169 expect(InvalidParameter, status);
1171 status = GdipDrawLinesI(NULL, pen, ptf, 2);
1172 expect(InvalidParameter, status);
1174 /* successful case */
1175 status = GdipDrawLinesI(graphics, pen, ptf, 2);
1180 GdipDeleteGraphics(graphics);
1182 ReleaseDC(hwnd, hdc);
1185 static void test_GdipFillClosedCurve(void)
1188 GpGraphics *graphics = NULL;
1189 GpSolidFill *brush = NULL;
1190 HDC hdc = GetDC( hwnd );
1202 /* make a graphics object and brush object */
1203 ok(hdc != NULL, "Expected HDC to be initialized\n");
1205 status = GdipCreateFromHDC(hdc, &graphics);
1207 ok(graphics != NULL, "Expected graphics to be initialized\n");
1209 GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
1211 /* InvalidParameter cases: null graphics, null brush, null points */
1212 status = GdipFillClosedCurve(NULL, NULL, NULL, 3);
1213 expect(InvalidParameter, status);
1215 status = GdipFillClosedCurve(graphics, NULL, NULL, 3);
1216 expect(InvalidParameter, status);
1218 status = GdipFillClosedCurve(NULL, (GpBrush*)brush, NULL, 3);
1219 expect(InvalidParameter, status);
1221 status = GdipFillClosedCurve(NULL, NULL, points, 3);
1222 expect(InvalidParameter, status);
1224 status = GdipFillClosedCurve(graphics, (GpBrush*)brush, NULL, 3);
1225 expect(InvalidParameter, status);
1227 status = GdipFillClosedCurve(graphics, NULL, points, 3);
1228 expect(InvalidParameter, status);
1230 status = GdipFillClosedCurve(NULL, (GpBrush*)brush, points, 3);
1231 expect(InvalidParameter, status);
1233 /* InvalidParameter cases: invalid count */
1234 status = GdipFillClosedCurve(graphics, (GpBrush*)brush, points, -1);
1235 expect(InvalidParameter, status);
1237 status = GdipFillClosedCurve(graphics, (GpBrush*)brush, points, 0);
1238 expect(InvalidParameter, status);
1240 /* Valid test cases */
1241 status = GdipFillClosedCurve(graphics, (GpBrush*)brush, points, 1);
1244 status = GdipFillClosedCurve(graphics, (GpBrush*)brush, points, 2);
1247 status = GdipFillClosedCurve(graphics, (GpBrush*)brush, points, 3);
1250 GdipDeleteGraphics(graphics);
1251 GdipDeleteBrush((GpBrush*)brush);
1253 ReleaseDC(hwnd, hdc);
1256 static void test_GdipFillClosedCurveI(void)
1259 GpGraphics *graphics = NULL;
1260 GpSolidFill *brush = NULL;
1261 HDC hdc = GetDC( hwnd );
1273 /* make a graphics object and brush object */
1274 ok(hdc != NULL, "Expected HDC to be initialized\n");
1276 status = GdipCreateFromHDC(hdc, &graphics);
1278 ok(graphics != NULL, "Expected graphics to be initialized\n");
1280 GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
1282 /* InvalidParameter cases: null graphics, null brush */
1283 /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
1284 when points == NULL, so don't test this condition */
1285 status = GdipFillClosedCurveI(NULL, NULL, points, 3);
1286 expect(InvalidParameter, status);
1288 status = GdipFillClosedCurveI(graphics, NULL, points, 3);
1289 expect(InvalidParameter, status);
1291 status = GdipFillClosedCurveI(NULL, (GpBrush*)brush, points, 3);
1292 expect(InvalidParameter, status);
1294 /* InvalidParameter cases: invalid count */
1295 status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, points, 0);
1296 expect(InvalidParameter, status);
1298 /* OutOfMemory cases: large (unsigned) int */
1299 status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, points, -1);
1300 expect(OutOfMemory, status);
1302 /* Valid test cases */
1303 status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, points, 1);
1306 status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, points, 2);
1309 status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, points, 3);
1312 GdipDeleteGraphics(graphics);
1313 GdipDeleteBrush((GpBrush*)brush);
1315 ReleaseDC(hwnd, hdc);
1318 static void test_Get_Release_DC(void)
1321 GpGraphics *graphics = NULL;
1325 HDC hdc = GetDC( hwnd );
1328 CompositingQuality quality;
1329 CompositingMode compmode;
1330 InterpolationMode intmode;
1334 PixelOffsetMode offsetmode;
1335 SmoothingMode smoothmode;
1336 TextRenderingHint texthint;
1344 ARGB color = 0x00000000;
1345 HRGN hrgn = CreateRectRgn(0, 0, 10, 10);
1358 for(i = 0; i < 5;i++){
1359 ptf[i].X = (REAL)pt[i].X;
1360 ptf[i].Y = (REAL)pt[i].Y;
1366 rect[0].Height = 70;
1370 rect[1].Height = 20;
1372 for(i = 0; i < 2;i++){
1373 rectf[i].X = (REAL)rect[i].X;
1374 rectf[i].Y = (REAL)rect[i].Y;
1375 rectf[i].Height = (REAL)rect[i].Height;
1376 rectf[i].Width = (REAL)rect[i].Width;
1379 GdipCreateMatrix(&m);
1380 GdipCreateRegion(®ion);
1381 GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
1382 GdipCreatePath(FillModeAlternate, &path);
1383 GdipCreateRegion(&clip);
1385 status = GdipCreateFromHDC(hdc, &graphics);
1387 ok(graphics != NULL, "Expected graphics to be initialized\n");
1388 status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
1391 /* NULL arguments */
1392 status = GdipGetDC(NULL, NULL);
1393 expect(InvalidParameter, status);
1394 status = GdipGetDC(graphics, NULL);
1395 expect(InvalidParameter, status);
1396 status = GdipGetDC(NULL, &retdc);
1397 expect(InvalidParameter, status);
1399 status = GdipReleaseDC(NULL, NULL);
1400 expect(InvalidParameter, status);
1401 status = GdipReleaseDC(graphics, NULL);
1402 expect(InvalidParameter, status);
1403 status = GdipReleaseDC(NULL, (HDC)0xdeadbeef);
1404 expect(InvalidParameter, status);
1406 /* Release without Get */
1407 status = GdipReleaseDC(graphics, hdc);
1408 expect(InvalidParameter, status);
1411 status = GdipGetDC(graphics, &retdc);
1413 ok(retdc == hdc, "Invalid HDC returned\n");
1414 /* call it once more */
1415 status = GdipGetDC(graphics, &retdc);
1416 expect(ObjectBusy, status);
1418 /* try all Graphics calls here */
1420 status = GdipDrawArc(graphics, pen, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
1421 expect(ObjectBusy, status);
1422 status = GdipDrawArcI(graphics, pen, 0, 0, 1, 1, 0.0, 0.0);
1423 expect(ObjectBusy, status);
1424 status = GdipDrawBezier(graphics, pen, 0.0, 10.0, 20.0, 15.0, 35.0, -10.0, 10.0, 10.0);
1425 expect(ObjectBusy, status);
1426 status = GdipDrawBezierI(graphics, pen, 0, 0, 0, 0, 0, 0, 0, 0);
1427 expect(ObjectBusy, status);
1428 status = GdipDrawBeziers(graphics, pen, ptf, 5);
1429 expect(ObjectBusy, status);
1430 status = GdipDrawBeziersI(graphics, pen, pt, 5);
1431 expect(ObjectBusy, status);
1432 status = GdipDrawClosedCurve(graphics, pen, ptf, 5);
1433 expect(ObjectBusy, status);
1434 status = GdipDrawClosedCurveI(graphics, pen, pt, 5);
1435 expect(ObjectBusy, status);
1436 status = GdipDrawClosedCurve2(graphics, pen, ptf, 5, 1.0);
1437 expect(ObjectBusy, status);
1438 status = GdipDrawClosedCurve2I(graphics, pen, pt, 5, 1.0);
1439 expect(ObjectBusy, status);
1440 status = GdipDrawCurve(graphics, pen, ptf, 5);
1441 expect(ObjectBusy, status);
1442 status = GdipDrawCurveI(graphics, pen, pt, 5);
1443 expect(ObjectBusy, status);
1444 status = GdipDrawCurve2(graphics, pen, ptf, 5, 1.0);
1445 expect(ObjectBusy, status);
1446 status = GdipDrawCurve2I(graphics, pen, pt, 5, 1.0);
1447 expect(ObjectBusy, status);
1448 status = GdipDrawEllipse(graphics, pen, 0.0, 0.0, 100.0, 50.0);
1449 expect(ObjectBusy, status);
1450 status = GdipDrawEllipseI(graphics, pen, 0, 0, 100, 50);
1451 expect(ObjectBusy, status);
1452 /* GdipDrawImage/GdipDrawImageI */
1453 /* GdipDrawImagePointsRect/GdipDrawImagePointsRectI */
1454 /* GdipDrawImageRectRect/GdipDrawImageRectRectI */
1455 /* GdipDrawImageRect/GdipDrawImageRectI */
1456 status = GdipDrawLine(graphics, pen, 0.0, 0.0, 100.0, 200.0);
1457 expect(ObjectBusy, status);
1458 status = GdipDrawLineI(graphics, pen, 0, 0, 100, 200);
1459 expect(ObjectBusy, status);
1460 status = GdipDrawLines(graphics, pen, ptf, 5);
1461 expect(ObjectBusy, status);
1462 status = GdipDrawLinesI(graphics, pen, pt, 5);
1463 expect(ObjectBusy, status);
1464 status = GdipDrawPath(graphics, pen, path);
1465 expect(ObjectBusy, status);
1466 status = GdipDrawPie(graphics, pen, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
1467 expect(ObjectBusy, status);
1468 status = GdipDrawPieI(graphics, pen, 0, 0, 100, 100, 0.0, 90.0);
1469 expect(ObjectBusy, status);
1470 status = GdipDrawRectangle(graphics, pen, 0.0, 0.0, 100.0, 300.0);
1471 expect(ObjectBusy, status);
1472 status = GdipDrawRectangleI(graphics, pen, 0, 0, 100, 300);
1473 expect(ObjectBusy, status);
1474 status = GdipDrawRectangles(graphics, pen, rectf, 2);
1475 expect(ObjectBusy, status);
1476 status = GdipDrawRectanglesI(graphics, pen, rect, 2);
1477 expect(ObjectBusy, status);
1478 /* GdipDrawString */
1479 status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, ptf, 5, 1.0, FillModeAlternate);
1480 expect(ObjectBusy, status);
1481 status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, pt, 5, 1.0, FillModeAlternate);
1482 expect(ObjectBusy, status);
1483 status = GdipFillClosedCurve(graphics, (GpBrush*)brush, ptf, 5);
1484 expect(ObjectBusy, status);
1485 status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, pt, 5);
1486 expect(ObjectBusy, status);
1487 status = GdipFillEllipse(graphics, (GpBrush*)brush, 0.0, 0.0, 100.0, 100.0);
1488 expect(ObjectBusy, status);
1489 status = GdipFillEllipseI(graphics, (GpBrush*)brush, 0, 0, 100, 100);
1490 expect(ObjectBusy, status);
1491 status = GdipFillPath(graphics, (GpBrush*)brush, path);
1492 expect(ObjectBusy, status);
1493 status = GdipFillPie(graphics, (GpBrush*)brush, 0.0, 0.0, 100.0, 100.0, 0.0, 15.0);
1494 expect(ObjectBusy, status);
1495 status = GdipFillPieI(graphics, (GpBrush*)brush, 0, 0, 100, 100, 0.0, 15.0);
1496 expect(ObjectBusy, status);
1497 status = GdipFillPolygon(graphics, (GpBrush*)brush, ptf, 5, FillModeAlternate);
1498 expect(ObjectBusy, status);
1499 status = GdipFillPolygonI(graphics, (GpBrush*)brush, pt, 5, FillModeAlternate);
1500 expect(ObjectBusy, status);
1501 status = GdipFillPolygon2(graphics, (GpBrush*)brush, ptf, 5);
1502 expect(ObjectBusy, status);
1503 status = GdipFillPolygon2I(graphics, (GpBrush*)brush, pt, 5);
1504 expect(ObjectBusy, status);
1505 status = GdipFillRectangle(graphics, (GpBrush*)brush, 0.0, 0.0, 100.0, 100.0);
1506 expect(ObjectBusy, status);
1507 status = GdipFillRectangleI(graphics, (GpBrush*)brush, 0, 0, 100, 100);
1508 expect(ObjectBusy, status);
1509 status = GdipFillRectangles(graphics, (GpBrush*)brush, rectf, 2);
1510 expect(ObjectBusy, status);
1511 status = GdipFillRectanglesI(graphics, (GpBrush*)brush, rect, 2);
1512 expect(ObjectBusy, status);
1513 status = GdipFillRegion(graphics, (GpBrush*)brush, region);
1514 expect(ObjectBusy, status);
1515 status = GdipFlush(graphics, FlushIntentionFlush);
1516 expect(ObjectBusy, status);
1517 status = GdipGetClipBounds(graphics, rectf);
1518 expect(ObjectBusy, status);
1519 status = GdipGetClipBoundsI(graphics, rect);
1520 expect(ObjectBusy, status);
1521 status = GdipGetCompositingMode(graphics, &compmode);
1522 expect(ObjectBusy, status);
1523 status = GdipGetCompositingQuality(graphics, &quality);
1524 expect(ObjectBusy, status);
1525 status = GdipGetInterpolationMode(graphics, &intmode);
1526 expect(ObjectBusy, status);
1527 status = GdipGetNearestColor(graphics, &color);
1528 expect(ObjectBusy, status);
1529 status = GdipGetPageScale(graphics, &r);
1530 expect(ObjectBusy, status);
1531 status = GdipGetPageUnit(graphics, &unit);
1532 expect(ObjectBusy, status);
1533 status = GdipGetPixelOffsetMode(graphics, &offsetmode);
1534 expect(ObjectBusy, status);
1535 status = GdipGetSmoothingMode(graphics, &smoothmode);
1536 expect(ObjectBusy, status);
1537 status = GdipGetTextRenderingHint(graphics, &texthint);
1538 expect(ObjectBusy, status);
1539 status = GdipGetWorldTransform(graphics, m);
1540 expect(ObjectBusy, status);
1541 status = GdipGraphicsClear(graphics, 0xdeadbeef);
1542 expect(ObjectBusy, status);
1543 status = GdipIsVisiblePoint(graphics, 0.0, 0.0, &res);
1544 expect(ObjectBusy, status);
1545 status = GdipIsVisiblePointI(graphics, 0, 0, &res);
1546 expect(ObjectBusy, status);
1547 /* GdipMeasureCharacterRanges */
1548 /* GdipMeasureString */
1549 status = GdipResetClip(graphics);
1550 expect(ObjectBusy, status);
1551 status = GdipResetWorldTransform(graphics);
1552 expect(ObjectBusy, status);
1553 /* GdipRestoreGraphics */
1554 status = GdipRotateWorldTransform(graphics, 15.0, MatrixOrderPrepend);
1555 expect(ObjectBusy, status);
1556 /* GdipSaveGraphics */
1557 status = GdipScaleWorldTransform(graphics, 1.0, 1.0, MatrixOrderPrepend);
1558 expect(ObjectBusy, status);
1559 status = GdipSetCompositingMode(graphics, CompositingModeSourceOver);
1560 expect(ObjectBusy, status);
1561 status = GdipSetCompositingQuality(graphics, CompositingQualityDefault);
1562 expect(ObjectBusy, status);
1563 status = GdipSetInterpolationMode(graphics, InterpolationModeDefault);
1564 expect(ObjectBusy, status);
1565 status = GdipSetPageScale(graphics, 1.0);
1566 expect(ObjectBusy, status);
1567 status = GdipSetPageUnit(graphics, UnitWorld);
1568 expect(ObjectBusy, status);
1569 status = GdipSetPixelOffsetMode(graphics, PixelOffsetModeDefault);
1570 expect(ObjectBusy, status);
1571 status = GdipSetSmoothingMode(graphics, SmoothingModeDefault);
1572 expect(ObjectBusy, status);
1573 status = GdipSetTextRenderingHint(graphics, TextRenderingHintSystemDefault);
1574 expect(ObjectBusy, status);
1575 status = GdipSetWorldTransform(graphics, m);
1576 expect(ObjectBusy, status);
1577 status = GdipTranslateWorldTransform(graphics, 0.0, 0.0, MatrixOrderPrepend);
1578 expect(ObjectBusy, status);
1579 status = GdipSetClipHrgn(graphics, hrgn, CombineModeReplace);
1580 expect(ObjectBusy, status);
1581 status = GdipSetClipPath(graphics, path, CombineModeReplace);
1582 expect(ObjectBusy, status);
1583 status = GdipSetClipRect(graphics, 0.0, 0.0, 10.0, 10.0, CombineModeReplace);
1584 expect(ObjectBusy, status);
1585 status = GdipSetClipRectI(graphics, 0, 0, 10, 10, CombineModeReplace);
1586 expect(ObjectBusy, status);
1587 status = GdipSetClipRegion(graphics, clip, CombineModeReplace);
1588 expect(ObjectBusy, status);
1589 status = GdipTranslateClip(graphics, 0.0, 0.0);
1590 expect(ObjectBusy, status);
1591 status = GdipTranslateClipI(graphics, 0, 0);
1592 expect(ObjectBusy, status);
1593 status = GdipDrawPolygon(graphics, pen, ptf, 5);
1594 expect(ObjectBusy, status);
1595 status = GdipDrawPolygonI(graphics, pen, pt, 5);
1596 expect(ObjectBusy, status);
1597 status = GdipGetDpiX(graphics, &r);
1598 expect(ObjectBusy, status);
1599 status = GdipGetDpiY(graphics, &r);
1600 expect(ObjectBusy, status);
1601 status = GdipMultiplyWorldTransform(graphics, m, MatrixOrderPrepend);
1602 status = GdipGetClip(graphics, region);
1603 expect(ObjectBusy, status);
1604 status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, ptf, 5);
1605 expect(ObjectBusy, status);
1606 /* try to delete before release */
1607 status = GdipDeleteGraphics(graphics);
1608 expect(ObjectBusy, status);
1610 status = GdipReleaseDC(graphics, retdc);
1614 GdipDeleteGraphics(graphics);
1616 GdipDeleteRegion(clip);
1617 GdipDeletePath(path);
1618 GdipDeleteBrush((GpBrush*)brush);
1619 GdipDeleteRegion(region);
1620 GdipDeleteMatrix(m);
1623 ReleaseDC(hwnd, hdc);
1626 static void test_transformpoints(void)
1629 GpGraphics *graphics = NULL;
1630 HDC hdc = GetDC( hwnd );
1634 status = GdipCreateFromHDC(hdc, &graphics);
1637 /* NULL arguments */
1638 status = GdipTransformPoints(NULL, CoordinateSpacePage, CoordinateSpaceWorld, NULL, 0);
1639 expect(InvalidParameter, status);
1640 status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, NULL, 0);
1641 expect(InvalidParameter, status);
1642 status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, ptf, 0);
1643 expect(InvalidParameter, status);
1644 status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, ptf, -1);
1645 expect(InvalidParameter, status);
1651 status = GdipTransformPoints(graphics, CoordinateSpaceDevice, CoordinateSpaceWorld, ptf, 2);
1653 expectf(1.0, ptf[0].X);
1654 expectf(0.0, ptf[0].Y);
1655 expectf(0.0, ptf[1].X);
1656 expectf(1.0, ptf[1].Y);
1658 status = GdipTranslateWorldTransform(graphics, 5.0, 5.0, MatrixOrderAppend);
1660 status = GdipSetPageUnit(graphics, UnitPixel);
1662 status = GdipSetPageScale(graphics, 3.0);
1669 status = GdipTransformPoints(graphics, CoordinateSpaceDevice, CoordinateSpaceWorld, ptf, 2);
1671 expectf(18.0, ptf[0].X);
1672 expectf(15.0, ptf[0].Y);
1673 expectf(15.0, ptf[1].X);
1674 expectf(18.0, ptf[1].Y);
1680 status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, ptf, 2);
1682 expectf(6.0, ptf[0].X);
1683 expectf(5.0, ptf[0].Y);
1684 expectf(5.0, ptf[1].X);
1685 expectf(6.0, ptf[1].Y);
1691 status = GdipTransformPoints(graphics, CoordinateSpaceDevice, CoordinateSpacePage, ptf, 2);
1693 expectf(3.0, ptf[0].X);
1694 expectf(0.0, ptf[0].Y);
1695 expectf(0.0, ptf[1].X);
1696 expectf(3.0, ptf[1].Y);
1702 status = GdipTransformPoints(graphics, CoordinateSpaceWorld, CoordinateSpaceDevice, ptf, 2);
1704 expectf(1.0, ptf[0].X);
1705 expectf(0.0, ptf[0].Y);
1706 expectf(0.0, ptf[1].X);
1707 expectf(1.0, ptf[1].Y);
1713 status = GdipTransformPoints(graphics, CoordinateSpaceWorld, CoordinateSpacePage, ptf, 2);
1715 expectf(1.0, ptf[0].X);
1716 expectf(0.0, ptf[0].Y);
1717 expectf(0.0, ptf[1].X);
1718 expectf(1.0, ptf[1].Y);
1724 status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceDevice, ptf, 2);
1726 expectf(1.0, ptf[0].X);
1727 expectf(0.0, ptf[0].Y);
1728 expectf(0.0, ptf[1].X);
1729 expectf(1.0, ptf[1].Y);
1735 status = GdipTransformPointsI(graphics, CoordinateSpaceDevice, CoordinateSpaceWorld, pt, 2);
1737 expect(18, pt[0].X);
1738 expect(15, pt[0].Y);
1739 expect(15, pt[1].X);
1740 expect(18, pt[1].Y);
1742 GdipDeleteGraphics(graphics);
1743 ReleaseDC(hwnd, hdc);
1746 static void test_get_set_clip(void)
1749 GpGraphics *graphics = NULL;
1750 HDC hdc = GetDC( hwnd );
1755 status = GdipCreateFromHDC(hdc, &graphics);
1758 rect.X = rect.Y = 0.0;
1759 rect.Height = rect.Width = 100.0;
1761 status = GdipCreateRegionRect(&rect, &clip);
1764 /* NULL arguments */
1765 status = GdipGetClip(NULL, NULL);
1766 expect(InvalidParameter, status);
1767 status = GdipGetClip(graphics, NULL);
1768 expect(InvalidParameter, status);
1769 status = GdipGetClip(NULL, clip);
1770 expect(InvalidParameter, status);
1772 status = GdipSetClipRegion(NULL, NULL, CombineModeReplace);
1773 expect(InvalidParameter, status);
1774 status = GdipSetClipRegion(graphics, NULL, CombineModeReplace);
1775 expect(InvalidParameter, status);
1777 status = GdipSetClipPath(NULL, NULL, CombineModeReplace);
1778 expect(InvalidParameter, status);
1779 status = GdipSetClipPath(graphics, NULL, CombineModeReplace);
1780 expect(InvalidParameter, status);
1783 status = GdipGetClip(graphics, clip);
1785 status = GdipIsInfiniteRegion(clip, graphics, &res);
1789 /* remains infinite after reset */
1791 status = GdipResetClip(graphics);
1793 status = GdipGetClip(graphics, clip);
1795 status = GdipIsInfiniteRegion(clip, graphics, &res);
1799 /* set to empty and then reset to infinite */
1800 status = GdipSetEmpty(clip);
1802 status = GdipSetClipRegion(graphics, clip, CombineModeReplace);
1805 status = GdipGetClip(graphics, clip);
1808 status = GdipIsEmptyRegion(clip, graphics, &res);
1811 status = GdipResetClip(graphics);
1813 status = GdipGetClip(graphics, clip);
1816 status = GdipIsInfiniteRegion(clip, graphics, &res);
1820 GdipDeleteRegion(clip);
1822 GdipDeleteGraphics(graphics);
1823 ReleaseDC(hwnd, hdc);
1826 static void test_isempty(void)
1829 GpGraphics *graphics = NULL;
1830 HDC hdc = GetDC( hwnd );
1834 status = GdipCreateFromHDC(hdc, &graphics);
1837 status = GdipCreateRegion(&clip);
1841 status = GdipIsClipEmpty(NULL, NULL);
1842 expect(InvalidParameter, status);
1843 status = GdipIsClipEmpty(graphics, NULL);
1844 expect(InvalidParameter, status);
1845 status = GdipIsClipEmpty(NULL, &res);
1846 expect(InvalidParameter, status);
1848 /* default is infinite */
1850 status = GdipIsClipEmpty(graphics, &res);
1854 GdipDeleteRegion(clip);
1856 GdipDeleteGraphics(graphics);
1857 ReleaseDC(hwnd, hdc);
1860 static void test_clear(void)
1864 status = GdipGraphicsClear(NULL, 0xdeadbeef);
1865 expect(InvalidParameter, status);
1868 static void test_textcontrast(void)
1871 HDC hdc = GetDC( hwnd );
1872 GpGraphics *graphics;
1875 status = GdipGetTextContrast(NULL, NULL);
1876 expect(InvalidParameter, status);
1878 status = GdipCreateFromHDC(hdc, &graphics);
1881 status = GdipGetTextContrast(graphics, NULL);
1882 expect(InvalidParameter, status);
1883 status = GdipGetTextContrast(graphics, &contrast);
1885 expect(4, contrast);
1887 GdipDeleteGraphics(graphics);
1888 ReleaseDC(hwnd, hdc);
1891 static void test_GdipDrawString(void)
1894 GpGraphics *graphics = NULL;
1897 GpStringFormat *format;
1900 HDC hdc = GetDC( hwnd );
1901 static const WCHAR string[] = {'T','e','s','t',0};
1903 memset(&logfont,0,sizeof(logfont));
1904 strcpy(logfont.lfFaceName,"Arial");
1905 logfont.lfHeight = 12;
1906 logfont.lfCharSet = DEFAULT_CHARSET;
1908 status = GdipCreateFromHDC(hdc, &graphics);
1911 status = GdipCreateFontFromLogfontA(hdc, &logfont, &fnt);
1912 if (status == FileNotFound)
1914 skip("Arial not installed.\n");
1919 status = GdipCreateSolidFill((ARGB)0xdeadbeef, (GpSolidFill**)&brush);
1922 status = GdipCreateStringFormat(0,0,&format);
1930 status = GdipDrawString(graphics, string, 4, fnt, &rect, format, brush);
1933 GdipDeleteGraphics(graphics);
1934 GdipDeleteBrush(brush);
1935 GdipDeleteFont(fnt);
1936 GdipDeleteStringFormat(format);
1938 ReleaseDC(hwnd, hdc);
1941 static void test_GdipGetVisibleClipBounds_screen(void)
1944 GpGraphics *graphics = NULL;
1946 GpRectF rectf, exp, clipr;
1949 ok(hdc != NULL, "Expected HDC to be initialized\n");
1951 status = GdipCreateFromHDC(hdc, &graphics);
1953 ok(graphics != NULL, "Expected graphics to be initialized\n");
1955 /* no clipping rect */
1958 exp.Width = GetDeviceCaps(hdc, HORZRES);
1959 exp.Height = GetDeviceCaps(hdc, VERTRES);
1961 status = GdipGetVisibleClipBounds(graphics, &rectf);
1963 ok(rectf.X == exp.X &&
1965 rectf.Width == exp.Width &&
1966 rectf.Height == exp.Height,
1967 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1968 "the screen (%0.f, %0.f, %0.f, %0.f)\n",
1969 rectf.X, rectf.Y, rectf.Width, rectf.Height,
1970 exp.X, exp.Y, exp.Width, exp.Height);
1972 /* clipping rect entirely within window */
1973 exp.X = clipr.X = 10;
1974 exp.Y = clipr.Y = 12;
1975 exp.Width = clipr.Width = 14;
1976 exp.Height = clipr.Height = 16;
1978 status = GdipSetClipRect(graphics, clipr.X, clipr.Y, clipr.Width, clipr.Height, CombineModeReplace);
1981 status = GdipGetVisibleClipBounds(graphics, &rectf);
1983 ok(rectf.X == exp.X &&
1985 rectf.Width == exp.Width &&
1986 rectf.Height == exp.Height,
1987 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
1988 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
1989 rectf.X, rectf.Y, rectf.Width, rectf.Height,
1990 exp.X, exp.Y, exp.Width, exp.Height);
1992 /* clipping rect partially outside of screen */
1998 status = GdipSetClipRect(graphics, clipr.X, clipr.Y, clipr.Width, clipr.Height, CombineModeReplace);
2006 status = GdipGetVisibleClipBounds(graphics, &rectf);
2008 ok(rectf.X == exp.X &&
2010 rectf.Width == exp.Width &&
2011 rectf.Height == exp.Height,
2012 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2013 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2014 rectf.X, rectf.Y, rectf.Width, rectf.Height,
2015 exp.X, exp.Y, exp.Width, exp.Height);
2017 status = GdipGetVisibleClipBoundsI(graphics, &recti);
2019 ok(recti.X == exp.X &&
2021 recti.Width == exp.Width &&
2022 recti.Height == exp.Height,
2023 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2024 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2025 recti.X, recti.Y, recti.Width, recti.Height,
2026 exp.X, exp.Y, exp.Width, exp.Height);
2028 GdipDeleteGraphics(graphics);
2032 static void test_GdipGetVisibleClipBounds_window(void)
2035 GpGraphics *graphics = NULL;
2036 GpRectF rectf, window, exp, clipr;
2042 /* get client area size */
2043 ok(GetClientRect(hwnd, &wnd_rect), "GetClientRect should have succeeded\n");
2044 window.X = wnd_rect.left;
2045 window.Y = wnd_rect.top;
2046 window.Width = wnd_rect.right - wnd_rect.left;
2047 window.Height = wnd_rect.bottom - wnd_rect.top;
2049 hdc = BeginPaint(hwnd, &ps);
2051 status = GdipCreateFromHDC(hdc, &graphics);
2053 ok(graphics != NULL, "Expected graphics to be initialized\n");
2055 status = GdipGetVisibleClipBounds(graphics, &rectf);
2057 ok(rectf.X == window.X &&
2058 rectf.Y == window.Y &&
2059 rectf.Width == window.Width &&
2060 rectf.Height == window.Height,
2061 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2062 "the window (%0.f, %0.f, %0.f, %0.f)\n",
2063 rectf.X, rectf.Y, rectf.Width, rectf.Height,
2064 window.X, window.Y, window.Width, window.Height);
2066 /* clipping rect entirely within window */
2067 exp.X = clipr.X = 20;
2068 exp.Y = clipr.Y = 8;
2069 exp.Width = clipr.Width = 30;
2070 exp.Height = clipr.Height = 20;
2072 status = GdipSetClipRect(graphics, clipr.X, clipr.Y, clipr.Width, clipr.Height, CombineModeReplace);
2075 status = GdipGetVisibleClipBounds(graphics, &rectf);
2077 ok(rectf.X == exp.X &&
2079 rectf.Width == exp.Width &&
2080 rectf.Height == exp.Height,
2081 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2082 "the clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2083 rectf.X, rectf.Y, rectf.Width, rectf.Height,
2084 exp.X, exp.Y, exp.Width, exp.Height);
2086 /* clipping rect partially outside of window */
2087 clipr.X = window.Width - 10;
2088 clipr.Y = window.Height - 15;
2092 status = GdipSetClipRect(graphics, clipr.X, clipr.Y, clipr.Width, clipr.Height, CombineModeReplace);
2095 exp.X = window.Width - 10;
2096 exp.Y = window.Height - 15;
2100 status = GdipGetVisibleClipBounds(graphics, &rectf);
2102 ok(rectf.X == exp.X &&
2104 rectf.Width == exp.Width &&
2105 rectf.Height == exp.Height,
2106 "Expected clip bounds (%0.f, %0.f, %0.f, %0.f) to be the size of "
2107 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2108 rectf.X, rectf.Y, rectf.Width, rectf.Height,
2109 exp.X, exp.Y, exp.Width, exp.Height);
2111 status = GdipGetVisibleClipBoundsI(graphics, &recti);
2113 ok(recti.X == exp.X &&
2115 recti.Width == exp.Width &&
2116 recti.Height == exp.Height,
2117 "Expected clip bounds (%d, %d, %d, %d) to be the size of "
2118 "the visible clipping rect (%0.f, %0.f, %0.f, %0.f)\n",
2119 recti.X, recti.Y, recti.Width, recti.Height,
2120 exp.X, exp.Y, exp.Width, exp.Height);
2122 GdipDeleteGraphics(graphics);
2123 EndPaint(hwnd, &ps);
2126 static void test_GdipGetVisibleClipBounds(void)
2128 GpGraphics* graphics = NULL;
2131 HDC hdc = GetDC( hwnd );
2134 status = GdipCreateFromHDC(hdc, &graphics);
2136 ok(graphics != NULL, "Expected graphics to be initialized\n");
2138 /* test null parameters */
2139 status = GdipGetVisibleClipBounds(graphics, NULL);
2140 expect(InvalidParameter, status);
2142 status = GdipGetVisibleClipBounds(NULL, &rectf);
2143 expect(InvalidParameter, status);
2145 status = GdipGetVisibleClipBoundsI(graphics, NULL);
2146 expect(InvalidParameter, status);
2148 status = GdipGetVisibleClipBoundsI(NULL, &rect);
2149 expect(InvalidParameter, status);
2151 GdipDeleteGraphics(graphics);
2152 ReleaseDC(hwnd, hdc);
2154 test_GdipGetVisibleClipBounds_screen();
2155 test_GdipGetVisibleClipBounds_window();
2158 static void test_fromMemoryBitmap(void)
2161 GpGraphics *graphics = NULL;
2162 GpBitmap *bitmap = NULL;
2163 BYTE bits[48] = {0};
2167 status = GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB, bits, &bitmap);
2170 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2173 status = GdipGraphicsClear(graphics, 0xff686868);
2176 GdipDeleteGraphics(graphics);
2178 /* drawing writes to the memory provided */
2179 todo_wine expect(0x68, bits[10]);
2181 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2184 status = GdipGetDC(graphics, &hdc);
2186 ok(hdc != NULL, "got NULL hdc\n");
2188 color = GetPixel(hdc, 0, 0);
2189 /* The HDC is write-only, and native fills with a solid color to figure out
2190 * which pixels have changed. */
2191 todo_wine expect(0x0c0b0d, color);
2193 SetPixel(hdc, 0, 0, 0x797979);
2194 SetPixel(hdc, 1, 0, 0x0c0b0d);
2196 status = GdipReleaseDC(graphics, hdc);
2199 GdipDeleteGraphics(graphics);
2201 expect(0x79, bits[0]);
2202 todo_wine expect(0x68, bits[3]);
2204 GdipDisposeImage((GpImage*)bitmap);
2206 /* We get the same kind of write-only HDC for a "normal" bitmap */
2207 status = GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB, NULL, &bitmap);
2210 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2213 status = GdipGetDC(graphics, &hdc);
2215 ok(hdc != NULL, "got NULL hdc\n");
2217 color = GetPixel(hdc, 0, 0);
2218 todo_wine expect(0x0c0b0d, color);
2220 status = GdipReleaseDC(graphics, hdc);
2223 GdipDeleteGraphics(graphics);
2225 GdipDisposeImage((GpImage*)bitmap);
2228 static void test_GdipIsVisiblePoint(void)
2231 GpGraphics *graphics = NULL;
2232 HDC hdc = GetDC( hwnd );
2236 ok(hdc != NULL, "Expected HDC to be initialized\n");
2238 status = GdipCreateFromHDC(hdc, &graphics);
2240 ok(graphics != NULL, "Expected graphics to be initialized\n");
2242 /* null parameters */
2243 status = GdipIsVisiblePoint(NULL, 0, 0, &val);
2244 expect(InvalidParameter, status);
2246 status = GdipIsVisiblePoint(graphics, 0, 0, NULL);
2247 expect(InvalidParameter, status);
2249 status = GdipIsVisiblePointI(NULL, 0, 0, &val);
2250 expect(InvalidParameter, status);
2252 status = GdipIsVisiblePointI(graphics, 0, 0, NULL);
2253 expect(InvalidParameter, status);
2257 status = GdipIsVisiblePoint(graphics, x, y, &val);
2259 ok(val == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
2263 status = GdipIsVisiblePoint(graphics, x, y, &val);
2265 ok(val == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
2269 status = GdipIsVisiblePoint(graphics, x, y, &val);
2271 ok(val == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
2275 status = GdipIsVisiblePoint(graphics, x, y, &val);
2277 ok(val == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
2279 status = GdipSetClipRect(graphics, 10, 20, 30, 40, CombineModeReplace);
2284 status = GdipIsVisiblePoint(graphics, x, y, &val);
2286 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2290 status = GdipIsVisiblePoint(graphics, x, y, &val);
2292 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2294 /* translate into the center of the rect */
2295 GdipTranslateWorldTransform(graphics, 25, 40, MatrixOrderAppend);
2299 status = GdipIsVisiblePoint(graphics, x, y, &val);
2301 ok(val == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
2305 status = GdipIsVisiblePoint(graphics, x, y, &val);
2307 ok(val == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
2309 GdipTranslateWorldTransform(graphics, -25, -40, MatrixOrderAppend);
2314 status = GdipIsVisiblePoint(graphics, x, y, &val);
2316 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2320 status = GdipIsVisiblePoint(graphics, x, y, &val);
2322 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2326 status = GdipIsVisiblePoint(graphics, x, y, &val);
2328 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2332 status = GdipIsVisiblePoint(graphics, x, y, &val);
2334 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2338 status = GdipIsVisiblePoint(graphics, x, y, &val);
2340 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2344 status = GdipIsVisiblePoint(graphics, x, y, &val);
2346 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2350 status = GdipIsVisiblePoint(graphics, x, y, &val);
2352 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2356 status = GdipIsVisiblePoint(graphics, x, y, &val);
2358 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2362 status = GdipIsVisiblePoint(graphics, x, y, &val);
2364 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2368 status = GdipIsVisiblePoint(graphics, x, y, &val);
2370 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2374 status = GdipIsVisiblePoint(graphics, x, y, &val);
2376 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2380 status = GdipIsVisiblePoint(graphics, x, y, &val);
2382 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2386 status = GdipIsVisiblePoint(graphics, x, y, &val);
2388 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2390 /* integer version */
2393 status = GdipIsVisiblePointI(graphics, (INT)x, (INT)y, &val);
2395 ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
2399 status = GdipIsVisiblePointI(graphics, (INT)x, (INT)y, &val);
2401 ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
2403 GdipDeleteGraphics(graphics);
2404 ReleaseDC(hwnd, hdc);
2407 static void test_GdipIsVisibleRect(void)
2410 GpGraphics *graphics = NULL;
2411 HDC hdc = GetDC( hwnd );
2412 REAL x, y, width, height;
2415 ok(hdc != NULL, "Expected HDC to be initialized\n");
2417 status = GdipCreateFromHDC(hdc, &graphics);
2419 ok(graphics != NULL, "Expected graphics to be initialized\n");
2421 status = GdipIsVisibleRect(NULL, 0, 0, 0, 0, &val);
2422 expect(InvalidParameter, status);
2424 status = GdipIsVisibleRect(graphics, 0, 0, 0, 0, NULL);
2425 expect(InvalidParameter, status);
2427 status = GdipIsVisibleRectI(NULL, 0, 0, 0, 0, &val);
2428 expect(InvalidParameter, status);
2430 status = GdipIsVisibleRectI(graphics, 0, 0, 0, 0, NULL);
2431 expect(InvalidParameter, status);
2433 /* entirely within the visible region */
2436 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2438 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2440 /* partially outside */
2441 x = -10; width = 20;
2442 y = -10; height = 20;
2443 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2445 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2447 /* entirely outside */
2449 y = -10; height = 5;
2450 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2452 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
2454 status = GdipSetClipRect(graphics, 10, 20, 30, 40, CombineModeReplace);
2457 /* entirely within the visible region */
2459 y = 22; height = 10;
2460 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2462 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2464 /* partially outside */
2466 y = 55; height = 10;
2467 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2469 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2471 /* entirely outside */
2474 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2476 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
2478 /* translate into center of clipping rect */
2479 GdipTranslateWorldTransform(graphics, 25, 40, MatrixOrderAppend);
2483 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2485 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2489 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2491 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
2493 GdipTranslateWorldTransform(graphics, -25, -40, MatrixOrderAppend);
2495 /* corners entirely outside, but some intersections */
2498 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2500 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2504 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2506 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2510 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2512 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2516 y = 20; height = 40;
2517 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2519 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
2523 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2525 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
2528 y = 20; height = 40;
2529 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2531 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
2534 y = 60; height = 10;
2535 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2537 ok(val == FALSE, "Expected (%.2f, %.2f, %.2f, %.2f) not to be visible\n", x, y, width, height);
2539 /* rounding tests */
2540 x = 0.4; width = 10.4;
2541 y = 20; height = 40;
2542 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2544 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2547 y = 0.4; height = 20.4;
2548 status = GdipIsVisibleRect(graphics, x, y, width, height, &val);
2550 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2552 /* integer version */
2555 status = GdipIsVisibleRectI(graphics, (INT)x, (INT)y, (INT)width, (INT)height, &val);
2557 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2560 y = 22; height = 10;
2561 status = GdipIsVisibleRectI(graphics, (INT)x, (INT)y, (INT)width, (INT)height, &val);
2563 ok(val == TRUE, "Expected (%.2f, %.2f, %.2f, %.2f) to be visible\n", x, y, width, height);
2565 GdipDeleteGraphics(graphics);
2566 ReleaseDC(hwnd, hdc);
2569 static void test_GdipGetNearestColor(void)
2572 GpGraphics *graphics;
2574 ARGB color = 0xdeadbeef;
2575 HDC hdc = GetDC( hwnd );
2577 /* create a graphics object */
2578 ok(hdc != NULL, "Expected HDC to be initialized\n");
2580 status = GdipCreateFromHDC(hdc, &graphics);
2582 ok(graphics != NULL, "Expected graphics to be initialized\n");
2584 status = GdipGetNearestColor(graphics, NULL);
2585 expect(InvalidParameter, status);
2587 status = GdipGetNearestColor(NULL, &color);
2588 expect(InvalidParameter, status);
2589 GdipDeleteGraphics(graphics);
2591 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat1bppIndexed, NULL, &bitmap);
2593 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2594 ok(broken(status == OutOfMemory) /* winver < Win7 */ || status == Ok, "status=%u\n", status);
2597 status = GdipGetNearestColor(graphics, &color);
2599 expect(0xdeadbeef, color);
2600 GdipDeleteGraphics(graphics);
2602 GdipDisposeImage((GpImage*)bitmap);
2604 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat4bppIndexed, NULL, &bitmap);
2606 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2607 ok(broken(status == OutOfMemory) /* winver < Win7 */ || status == Ok, "status=%u\n", status);
2610 status = GdipGetNearestColor(graphics, &color);
2612 expect(0xdeadbeef, color);
2613 GdipDeleteGraphics(graphics);
2615 GdipDisposeImage((GpImage*)bitmap);
2617 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat8bppIndexed, NULL, &bitmap);
2619 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2620 ok(broken(status == OutOfMemory) /* winver < Win7 */ || status == Ok, "status=%u\n", status);
2623 status = GdipGetNearestColor(graphics, &color);
2625 expect(0xdeadbeef, color);
2626 GdipDeleteGraphics(graphics);
2628 GdipDisposeImage((GpImage*)bitmap);
2630 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppGrayScale, NULL, &bitmap);
2632 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2633 todo_wine expect(OutOfMemory, status);
2635 GdipDeleteGraphics(graphics);
2636 GdipDisposeImage((GpImage*)bitmap);
2638 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB, NULL, &bitmap);
2640 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2642 status = GdipGetNearestColor(graphics, &color);
2644 expect(0xdeadbeef, color);
2645 GdipDeleteGraphics(graphics);
2646 GdipDisposeImage((GpImage*)bitmap);
2648 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppRGB, NULL, &bitmap);
2650 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2652 status = GdipGetNearestColor(graphics, &color);
2654 expect(0xdeadbeef, color);
2655 GdipDeleteGraphics(graphics);
2656 GdipDisposeImage((GpImage*)bitmap);
2658 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppARGB, NULL, &bitmap);
2660 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2662 status = GdipGetNearestColor(graphics, &color);
2664 expect(0xdeadbeef, color);
2665 GdipDeleteGraphics(graphics);
2666 GdipDisposeImage((GpImage*)bitmap);
2668 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB, NULL, &bitmap);
2672 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2674 status = GdipGetNearestColor(graphics, &color);
2676 expect(0xdeadbeef, color);
2677 GdipDeleteGraphics(graphics);
2678 GdipDisposeImage((GpImage*)bitmap);
2681 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB, NULL, &bitmap);
2685 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2687 status = GdipGetNearestColor(graphics, &color);
2689 expect(0xdeadbeef, color);
2690 GdipDeleteGraphics(graphics);
2691 GdipDisposeImage((GpImage*)bitmap);
2694 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB, NULL, &bitmap);
2698 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2700 status = GdipGetNearestColor(graphics, &color);
2702 expect(0xdeadbeef, color);
2703 GdipDeleteGraphics(graphics);
2704 GdipDisposeImage((GpImage*)bitmap);
2707 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565, NULL, &bitmap);
2709 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2711 status = GdipGetNearestColor(graphics, &color);
2713 todo_wine expect(0xffa8bce8, color);
2714 GdipDeleteGraphics(graphics);
2715 GdipDisposeImage((GpImage*)bitmap);
2717 status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB555, NULL, &bitmap);
2719 status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
2721 status = GdipGetNearestColor(graphics, &color);
2724 ok(color == 0xffa8b8e8 ||
2725 broken(color == 0xffa0b8e0), /* Win98/WinMe */
2726 "Expected ffa8b8e8, got %.8x\n", color);
2727 GdipDeleteGraphics(graphics);
2728 GdipDisposeImage((GpImage*)bitmap);
2730 ReleaseDC(hwnd, hdc);
2733 static void test_string_functions(void)
2736 GpGraphics *graphics;
2737 GpFontFamily *family;
2739 RectF rc, char_bounds, bounds;
2741 ARGB color = 0xff000000;
2742 HDC hdc = GetDC( hwnd );
2743 const WCHAR fontname[] = {'T','a','h','o','m','a',0};
2744 const WCHAR teststring[] = {'M','M',' ','M','\n','M',0};
2745 REAL char_width, char_height;
2746 INT codepointsfitted, linesfilled;
2747 GpStringFormat *format;
2748 CharacterRange ranges[3] = {{0, 1}, {1, 3}, {5, 1}};
2749 GpRegion *regions[4] = {0};
2750 BOOL region_isempty[4];
2753 ok(hdc != NULL, "Expected HDC to be initialized\n");
2754 status = GdipCreateFromHDC(hdc, &graphics);
2756 ok(graphics != NULL, "Expected graphics to be initialized\n");
2758 status = GdipCreateFontFamilyFromName(fontname, NULL, &family);
2761 status = GdipCreateFont(family, 10.0, FontStyleRegular, UnitPixel, &font);
2764 status = GdipCreateSolidFill(color, (GpSolidFill**)&brush);
2767 status = GdipCreateStringFormat(0, LANG_NEUTRAL, &format);
2775 status = GdipDrawString(NULL, teststring, 6, font, &rc, NULL, brush);
2776 expect(InvalidParameter, status);
2778 status = GdipDrawString(graphics, NULL, 6, font, &rc, NULL, brush);
2779 expect(InvalidParameter, status);
2781 status = GdipDrawString(graphics, teststring, 6, NULL, &rc, NULL, brush);
2782 expect(InvalidParameter, status);
2784 status = GdipDrawString(graphics, teststring, 6, font, NULL, NULL, brush);
2785 expect(InvalidParameter, status);
2787 status = GdipDrawString(graphics, teststring, 6, font, &rc, NULL, NULL);
2788 expect(InvalidParameter, status);
2790 status = GdipDrawString(graphics, teststring, 6, font, &rc, NULL, brush);
2793 status = GdipMeasureString(NULL, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
2794 expect(InvalidParameter, status);
2796 status = GdipMeasureString(graphics, NULL, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
2797 expect(InvalidParameter, status);
2799 status = GdipMeasureString(graphics, teststring, 6, NULL, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
2800 expect(InvalidParameter, status);
2802 status = GdipMeasureString(graphics, teststring, 6, font, NULL, NULL, &bounds, &codepointsfitted, &linesfilled);
2803 expect(InvalidParameter, status);
2805 status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, NULL, &codepointsfitted, &linesfilled);
2806 expect(InvalidParameter, status);
2808 status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, NULL, &linesfilled);
2811 status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, NULL);
2814 status = GdipMeasureString(graphics, teststring, 1, font, &rc, NULL, &char_bounds, &codepointsfitted, &linesfilled);
2816 expectf(0.0, char_bounds.X);
2817 expectf(0.0, char_bounds.Y);
2818 ok(char_bounds.Width > 0, "got %0.2f\n", bounds.Width);
2819 ok(char_bounds.Height > 0, "got %0.2f\n", bounds.Height);
2820 expect(1, codepointsfitted);
2821 expect(1, linesfilled);
2823 status = GdipMeasureString(graphics, teststring, 2, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
2825 expectf(0.0, bounds.X);
2826 expectf(0.0, bounds.Y);
2827 ok(bounds.Width > char_bounds.Width, "got %0.2f, expected at least %0.2f\n", bounds.Width, char_bounds.Width);
2828 expectf(char_bounds.Height, bounds.Height);
2829 expect(2, codepointsfitted);
2830 expect(1, linesfilled);
2831 char_width = bounds.Width - char_bounds.Width;
2833 status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
2835 expectf(0.0, bounds.X);
2836 expectf(0.0, bounds.Y);
2837 ok(bounds.Width > char_bounds.Width + char_width * 2, "got %0.2f, expected at least %0.2f\n",
2838 bounds.Width, char_bounds.Width + char_width * 2);
2839 ok(bounds.Height > char_bounds.Height, "got %0.2f, expected at least %0.2f\n", bounds.Height, char_bounds.Height);
2840 expect(6, codepointsfitted);
2841 expect(2, linesfilled);
2842 char_height = bounds.Height - char_bounds.Height;
2844 /* Cut off everything after the first space. */
2845 rc.Width = char_bounds.Width + char_width * 2.1;
2847 status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
2849 expectf(0.0, bounds.X);
2850 expectf(0.0, bounds.Y);
2851 expectf_(char_bounds.Width + char_width, bounds.Width, 0.01);
2852 expectf_(char_bounds.Height + char_height * 2, bounds.Height, 0.01);
2853 expect(6, codepointsfitted);
2854 expect(3, linesfilled);
2856 /* Cut off everything including the first space. */
2857 rc.Width = char_bounds.Width + char_width * 1.5;
2859 status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
2861 expectf(0.0, bounds.X);
2862 expectf(0.0, bounds.Y);
2863 expectf_(char_bounds.Width + char_width, bounds.Width, 0.01);
2864 expectf_(char_bounds.Height + char_height * 2, bounds.Height, 0.01);
2865 expect(6, codepointsfitted);
2866 expect(3, linesfilled);
2868 /* Cut off everything after the first character. */
2869 rc.Width = char_bounds.Width + char_width * 0.5;
2871 status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
2873 expectf(0.0, bounds.X);
2874 expectf(0.0, bounds.Y);
2875 expectf_(char_bounds.Width, bounds.Width, 0.01);
2876 todo_wine expectf_(char_bounds.Height + char_height * 3, bounds.Height, 0.05);
2877 expect(6, codepointsfitted);
2878 todo_wine expect(4, linesfilled);
2880 status = GdipSetStringFormatMeasurableCharacterRanges(format, 3, ranges);
2887 status = GdipCreateRegion(®ions[i]);
2891 status = GdipMeasureCharacterRanges(NULL, teststring, 6, font, &rc, format, 3, regions);
2892 expect(InvalidParameter, status);
2894 status = GdipMeasureCharacterRanges(graphics, NULL, 6, font, &rc, format, 3, regions);
2895 expect(InvalidParameter, status);
2897 status = GdipMeasureCharacterRanges(graphics, teststring, 6, NULL, &rc, format, 3, regions);
2898 expect(InvalidParameter, status);
2900 status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, NULL, format, 3, regions);
2901 expect(InvalidParameter, status);
2905 /* Crashes on Windows XP */
2906 status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, NULL, 3, regions);
2907 expect(InvalidParameter, status);
2910 status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, format, 3, NULL);
2911 expect(InvalidParameter, status);
2913 status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, format, 2, regions);
2914 expect(InvalidParameter, status);
2916 status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, format, 4, regions);
2921 status = GdipIsEmptyRegion(regions[i], graphics, ®ion_isempty[i]);
2925 ok(!region_isempty[0], "region shouldn't be empty\n");
2926 ok(!region_isempty[1], "region shouldn't be empty\n");
2927 ok(!region_isempty[2], "region shouldn't be empty\n");
2928 ok(!region_isempty[3], "region shouldn't be empty\n");
2930 /* Cut off everything after the first space, and the second line. */
2931 rc.Width = char_bounds.Width + char_width * 2.1;
2932 rc.Height = char_bounds.Height + char_height * 0.5;
2934 status = GdipMeasureCharacterRanges(graphics, teststring, 6, font, &rc, format, 3, regions);
2939 status = GdipIsEmptyRegion(regions[i], graphics, ®ion_isempty[i]);
2943 ok(!region_isempty[0], "region shouldn't be empty\n");
2944 ok(!region_isempty[1], "region shouldn't be empty\n");
2945 ok(region_isempty[2], "region should be empty\n");
2946 ok(!region_isempty[3], "region shouldn't be empty\n");
2949 GdipDeleteRegion(regions[i]);
2951 GdipDeleteStringFormat(format);
2952 GdipDeleteBrush(brush);
2953 GdipDeleteFont(font);
2954 GdipDeleteFontFamily(family);
2955 GdipDeleteGraphics(graphics);
2957 ReleaseDC(hwnd, hdc);
2960 START_TEST(graphics)
2962 struct GdiplusStartupInput gdiplusStartupInput;
2963 ULONG_PTR gdiplusToken;
2966 memset( &class, 0, sizeof(class) );
2967 class.lpszClassName = "gdiplus_test";
2968 class.style = CS_HREDRAW | CS_VREDRAW;
2969 class.lpfnWndProc = DefWindowProcA;
2970 class.hInstance = GetModuleHandleA(0);
2971 class.hIcon = LoadIcon(0, IDI_APPLICATION);
2972 class.hCursor = LoadCursor(NULL, IDC_ARROW);
2973 class.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
2974 RegisterClassA( &class );
2975 hwnd = CreateWindowA( "gdiplus_test", "graphics test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
2976 CW_USEDEFAULT, CW_USEDEFAULT, 200, 200, 0, 0, GetModuleHandleA(0), 0 );
2977 ok(hwnd != NULL, "Expected window to be created\n");
2979 gdiplusStartupInput.GdiplusVersion = 1;
2980 gdiplusStartupInput.DebugEventCallback = NULL;
2981 gdiplusStartupInput.SuppressBackgroundThread = 0;
2982 gdiplusStartupInput.SuppressExternalCodecs = 0;
2984 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
2986 test_constructor_destructor();
2987 test_save_restore();
2988 test_GdipFillClosedCurve2();
2989 test_GdipFillClosedCurve2I();
2990 test_GdipDrawBezierI();
2992 test_GdipDrawArcI();
2993 test_GdipDrawCurve();
2994 test_GdipDrawCurveI();
2995 test_GdipDrawCurve2();
2996 test_GdipDrawCurve2I();
2997 test_GdipDrawCurve3();
2998 test_GdipDrawCurve3I();
2999 test_GdipDrawLineI();
3000 test_GdipDrawLinesI();
3001 test_GdipFillClosedCurve();
3002 test_GdipFillClosedCurveI();
3003 test_GdipDrawString();
3004 test_GdipGetNearestColor();
3005 test_GdipGetVisibleClipBounds();
3006 test_GdipIsVisiblePoint();
3007 test_GdipIsVisibleRect();
3008 test_Get_Release_DC();
3009 test_BeginContainer2();
3010 test_transformpoints();
3011 test_get_set_clip();
3014 test_textcontrast();
3015 test_fromMemoryBitmap();
3016 test_string_functions();
3018 GdiplusShutdown(gdiplusToken);
3019 DestroyWindow( hwnd );