sync rostests to r44455
[reactos.git] / rostests / winetests / gdiplus / graphics.c
index 168eae3..ae3b801 100644 (file)
 #include "gdiplus.h"
 #include "wingdi.h"
 #include "wine/test.h"
+#include <math.h>
 
 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
+#define expectf(expected, got) ok(fabs(expected - got) < 0.0001, "Expected %.2f, got %.2f\n", expected, got)
 #define TABLE_LEN (23)
 
 static void test_constructor_destructor(void)
@@ -130,11 +132,9 @@ static void test_save_restore(void)
     GdipCreateFromHDC(hdc, &graphics1);
     GdipSetInterpolationMode(graphics1, InterpolationModeBilinear);
     stat = GdipSaveGraphics(graphics1, &state_a);
-    todo_wine
         expect(Ok, stat);
     GdipSetInterpolationMode(graphics1, InterpolationModeBicubic);
     stat = GdipRestoreGraphics(graphics1, state_a);
-    todo_wine
         expect(Ok, stat);
     GdipGetInterpolationMode(graphics1, &mode);
     todo_wine
@@ -151,7 +151,6 @@ static void test_save_restore(void)
     GdipSaveGraphics(graphics1, &state_b);
     GdipSetInterpolationMode(graphics1, InterpolationModeNearestNeighbor);
     stat = GdipRestoreGraphics(graphics1, 0xdeadbeef);
-    todo_wine
         expect(Ok, stat);
     GdipRestoreGraphics(graphics1, state_b);
     GdipGetInterpolationMode(graphics1, &mode);
@@ -277,6 +276,8 @@ static void test_GdipDrawArc(void)
     expect(Ok, status);
 
     GdipDeletePen(pen);
+    GdipDeleteGraphics(graphics);
+
     ReleaseDC(0, hdc);
 }
 
@@ -321,6 +322,8 @@ static void test_GdipDrawArcI(void)
     expect(Ok, status);
 
     GdipDeletePen(pen);
+    GdipDeleteGraphics(graphics);
+
     ReleaseDC(0, hdc);
 }
 
@@ -359,6 +362,8 @@ static void test_GdipDrawBezierI(void)
     expect(Ok, status);
 
     GdipDeletePen(pen);
+    GdipDeleteGraphics(graphics);
+
     ReleaseDC(0, hdc);
 }
 
@@ -397,6 +402,8 @@ static void test_GdipDrawLineI(void)
     expect(Ok, status);
 
     GdipDeletePen(pen);
+    GdipDeleteGraphics(graphics);
+
     ReleaseDC(0, hdc);
 }
 
@@ -449,9 +456,628 @@ static void test_GdipDrawLinesI(void)
 
     GdipFree(ptf);
     GdipDeletePen(pen);
+    GdipDeleteGraphics(graphics);
+
+    ReleaseDC(0, hdc);
+}
+
+static void test_Get_Release_DC(void)
+{
+    GpStatus status;
+    GpGraphics *graphics = NULL;
+    GpPen *pen;
+    GpSolidFill *brush;
+    GpPath *path;
+    HDC hdc = GetDC(0);
+    HDC retdc;
+    REAL r;
+    CompositingQuality quality;
+    CompositingMode compmode;
+    InterpolationMode intmode;
+    GpMatrix *m;
+    GpRegion *region;
+    GpUnit unit;
+    PixelOffsetMode offsetmode;
+    SmoothingMode smoothmode;
+    TextRenderingHint texthint;
+    GpPointF ptf[5];
+    GpPoint  pt[5];
+    GpRectF  rectf[2];
+    GpRect   rect[2];
+    GpRegion *clip;
+    INT i;
+    BOOL res;
+    ARGB color = 0x00000000;
+    HRGN hrgn = CreateRectRgn(0, 0, 10, 10);
+
+    pt[0].X = 10;
+    pt[0].Y = 10;
+    pt[1].X = 20;
+    pt[1].Y = 15;
+    pt[2].X = 40;
+    pt[2].Y = 80;
+    pt[3].X = -20;
+    pt[3].Y = 20;
+    pt[4].X = 50;
+    pt[4].Y = 110;
+
+    for(i = 0; i < 5;i++){
+        ptf[i].X = (REAL)pt[i].X;
+        ptf[i].Y = (REAL)pt[i].Y;
+    }
+
+    rect[0].X = 0;
+    rect[0].Y = 0;
+    rect[0].Width  = 50;
+    rect[0].Height = 70;
+    rect[1].X = 0;
+    rect[1].Y = 0;
+    rect[1].Width  = 10;
+    rect[1].Height = 20;
+
+    for(i = 0; i < 2;i++){
+        rectf[i].X = (REAL)rect[i].X;
+        rectf[i].Y = (REAL)rect[i].Y;
+        rectf[i].Height = (REAL)rect[i].Height;
+        rectf[i].Width  = (REAL)rect[i].Width;
+    }
+
+    GdipCreateMatrix(&m);
+    GdipCreateRegion(&region);
+    GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
+    GdipCreatePath(FillModeAlternate, &path);
+    GdipCreateRegion(&clip);
+
+    status = GdipCreateFromHDC(hdc, &graphics);
+    expect(Ok, status);
+    ok(graphics != NULL, "Expected graphics to be initialized\n");
+    status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
+    expect(Ok, status);
+
+    /* NULL arguments */
+    status = GdipGetDC(NULL, NULL);
+    expect(InvalidParameter, status);
+    status = GdipGetDC(graphics, NULL);
+    expect(InvalidParameter, status);
+    status = GdipGetDC(NULL, &retdc);
+    expect(InvalidParameter, status);
+
+    status = GdipReleaseDC(NULL, NULL);
+    expect(InvalidParameter, status);
+    status = GdipReleaseDC(graphics, NULL);
+    expect(InvalidParameter, status);
+    status = GdipReleaseDC(NULL, (HDC)0xdeadbeef);
+    expect(InvalidParameter, status);
+
+    /* Release without Get */
+    status = GdipReleaseDC(graphics, hdc);
+    expect(InvalidParameter, status);
+
+    retdc = NULL;
+    status = GdipGetDC(graphics, &retdc);
+    expect(Ok, status);
+    ok(retdc == hdc, "Invalid HDC returned\n");
+    /* call it once more */
+    status = GdipGetDC(graphics, &retdc);
+    expect(ObjectBusy, status);
+
+    /* try all Graphics calls here */
+    status = Ok;
+    status = GdipDrawArc(graphics, pen, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawArcI(graphics, pen, 0, 0, 1, 1, 0.0, 0.0);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawBezier(graphics, pen, 0.0, 10.0, 20.0, 15.0, 35.0, -10.0, 10.0, 10.0);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawBezierI(graphics, pen, 0, 0, 0, 0, 0, 0, 0, 0);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawBeziers(graphics, pen, ptf, 5);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawBeziersI(graphics, pen, pt, 5);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawClosedCurve(graphics, pen, ptf, 5);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawClosedCurveI(graphics, pen, pt, 5);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawClosedCurve2(graphics, pen, ptf, 5, 1.0);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawClosedCurve2I(graphics, pen, pt, 5, 1.0);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawCurve(graphics, pen, ptf, 5);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawCurveI(graphics, pen, pt, 5);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawCurve2(graphics, pen, ptf, 5, 1.0);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawCurve2I(graphics, pen, pt, 5, 1.0);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawEllipse(graphics, pen, 0.0, 0.0, 100.0, 50.0);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawEllipseI(graphics, pen, 0, 0, 100, 50);
+    expect(ObjectBusy, status); status = Ok;
+    /* GdipDrawImage/GdipDrawImageI */
+    /* GdipDrawImagePointsRect/GdipDrawImagePointsRectI */
+    /* GdipDrawImageRectRect/GdipDrawImageRectRectI */
+    /* GdipDrawImageRect/GdipDrawImageRectI */
+    status = GdipDrawLine(graphics, pen, 0.0, 0.0, 100.0, 200.0);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawLineI(graphics, pen, 0, 0, 100, 200);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawLines(graphics, pen, ptf, 5);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawLinesI(graphics, pen, pt, 5);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawPath(graphics, pen, path);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawPie(graphics, pen, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawPieI(graphics, pen, 0, 0, 100, 100, 0.0, 90.0);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawRectangle(graphics, pen, 0.0, 0.0, 100.0, 300.0);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawRectangleI(graphics, pen, 0, 0, 100, 300);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawRectangles(graphics, pen, rectf, 2);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawRectanglesI(graphics, pen, rect, 2);
+    expect(ObjectBusy, status); status = Ok;
+    /* GdipDrawString */
+    status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, ptf, 5, 1.0, FillModeAlternate);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, pt, 5, 1.0, FillModeAlternate);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipFillEllipse(graphics, (GpBrush*)brush, 0.0, 0.0, 100.0, 100.0);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipFillEllipseI(graphics, (GpBrush*)brush, 0, 0, 100, 100);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipFillPath(graphics, (GpBrush*)brush, path);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipFillPie(graphics, (GpBrush*)brush, 0.0, 0.0, 100.0, 100.0, 0.0, 15.0);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipFillPieI(graphics, (GpBrush*)brush, 0, 0, 100, 100, 0.0, 15.0);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipFillPolygon(graphics, (GpBrush*)brush, ptf, 5, FillModeAlternate);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipFillPolygonI(graphics, (GpBrush*)brush, pt, 5, FillModeAlternate);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipFillPolygon2(graphics, (GpBrush*)brush, ptf, 5);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipFillPolygon2I(graphics, (GpBrush*)brush, pt, 5);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipFillRectangle(graphics, (GpBrush*)brush, 0.0, 0.0, 100.0, 100.0);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipFillRectangleI(graphics, (GpBrush*)brush, 0, 0, 100, 100);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipFillRectangles(graphics, (GpBrush*)brush, rectf, 2);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipFillRectanglesI(graphics, (GpBrush*)brush, rect, 2);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipFillRegion(graphics, (GpBrush*)brush, region);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipFlush(graphics, FlushIntentionFlush);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipGetClipBounds(graphics, rectf);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipGetClipBoundsI(graphics, rect);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipGetCompositingMode(graphics, &compmode);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipGetCompositingQuality(graphics, &quality);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipGetInterpolationMode(graphics, &intmode);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipGetNearestColor(graphics, &color);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipGetPageScale(graphics, &r);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipGetPageUnit(graphics, &unit);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipGetPixelOffsetMode(graphics, &offsetmode);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipGetSmoothingMode(graphics, &smoothmode);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipGetTextRenderingHint(graphics, &texthint);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipGetWorldTransform(graphics, m);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipGraphicsClear(graphics, 0xdeadbeef);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipIsVisiblePoint(graphics, 0.0, 0.0, &res);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipIsVisiblePointI(graphics, 0, 0, &res);
+    expect(ObjectBusy, status); status = Ok;
+    /* GdipMeasureCharacterRanges */
+    /* GdipMeasureString */
+    status = GdipResetClip(graphics);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipResetWorldTransform(graphics);
+    expect(ObjectBusy, status); status = Ok;
+    /* GdipRestoreGraphics */
+    status = GdipRotateWorldTransform(graphics, 15.0, MatrixOrderPrepend);
+    expect(ObjectBusy, status); status = Ok;
+    /*  GdipSaveGraphics */
+    status = GdipScaleWorldTransform(graphics, 1.0, 1.0, MatrixOrderPrepend);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipSetCompositingMode(graphics, CompositingModeSourceOver);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipSetCompositingQuality(graphics, CompositingQualityDefault);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipSetInterpolationMode(graphics, InterpolationModeDefault);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipSetPageScale(graphics, 1.0);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipSetPageUnit(graphics, UnitWorld);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipSetPixelOffsetMode(graphics, PixelOffsetModeDefault);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipSetSmoothingMode(graphics, SmoothingModeDefault);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipSetTextRenderingHint(graphics, TextRenderingHintSystemDefault);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipSetWorldTransform(graphics, m);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipTranslateWorldTransform(graphics, 0.0, 0.0, MatrixOrderPrepend);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipSetClipHrgn(graphics, hrgn, CombineModeReplace);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipSetClipPath(graphics, path, CombineModeReplace);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipSetClipRect(graphics, 0.0, 0.0, 10.0, 10.0, CombineModeReplace);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipSetClipRectI(graphics, 0, 0, 10, 10, CombineModeReplace);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipSetClipRegion(graphics, clip, CombineModeReplace);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipTranslateClip(graphics, 0.0, 0.0);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipTranslateClipI(graphics, 0, 0);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawPolygon(graphics, pen, ptf, 5);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipDrawPolygonI(graphics, pen, pt, 5);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipGetDpiX(graphics, &r);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipGetDpiY(graphics, &r);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipMultiplyWorldTransform(graphics, m, MatrixOrderPrepend);
+    status = GdipGetClip(graphics, region);
+    expect(ObjectBusy, status); status = Ok;
+    status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, ptf, 5);
+    expect(ObjectBusy, status); status = Ok;
+    /* try to delete before release */
+    status = GdipDeleteGraphics(graphics);
+    expect(ObjectBusy, status);
+
+    status = GdipReleaseDC(graphics, retdc);
+    expect(Ok, status);
+
+    GdipDeletePen(pen);
+    GdipDeleteGraphics(graphics);
+
+    GdipDeletePath(path);
+    GdipDeleteBrush((GpBrush*)brush);
+    GdipDeleteRegion(region);
+    GdipDeleteMatrix(m);
+    DeleteObject(hrgn);
+
+    ReleaseDC(0, hdc);
+}
+
+static void test_transformpoints(void)
+{
+    GpStatus status;
+    GpGraphics *graphics = NULL;
+    HDC hdc = GetDC(0);
+    GpPointF ptf[2];
+    GpPoint pt[2];
+
+    status = GdipCreateFromHDC(hdc, &graphics);
+    expect(Ok, status);
+
+    /* NULL arguments */
+    status = GdipTransformPoints(NULL, CoordinateSpacePage, CoordinateSpaceWorld, NULL, 0);
+    expect(InvalidParameter, status);
+    status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, NULL, 0);
+    expect(InvalidParameter, status);
+    status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, ptf, 0);
+    expect(InvalidParameter, status);
+    status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, ptf, -1);
+    expect(InvalidParameter, status);
+
+    ptf[0].X = 1.0;
+    ptf[0].Y = 0.0;
+    ptf[1].X = 0.0;
+    ptf[1].Y = 1.0;
+    status = GdipTransformPoints(graphics, CoordinateSpaceDevice, CoordinateSpaceWorld, ptf, 2);
+    expect(Ok, status);
+    expectf(1.0, ptf[0].X);
+    expectf(0.0, ptf[0].Y);
+    expectf(0.0, ptf[1].X);
+    expectf(1.0, ptf[1].Y);
+
+    status = GdipTranslateWorldTransform(graphics, 5.0, 5.0, MatrixOrderAppend);
+    expect(Ok, status);
+    status = GdipSetPageUnit(graphics, UnitPixel);
+    expect(Ok, status);
+    status = GdipSetPageScale(graphics, 3.0);
+    expect(Ok, status);
+
+    ptf[0].X = 1.0;
+    ptf[0].Y = 0.0;
+    ptf[1].X = 0.0;
+    ptf[1].Y = 1.0;
+    status = GdipTransformPoints(graphics, CoordinateSpaceDevice, CoordinateSpaceWorld, ptf, 2);
+    expect(Ok, status);
+    expectf(18.0, ptf[0].X);
+    expectf(15.0, ptf[0].Y);
+    expectf(15.0, ptf[1].X);
+    expectf(18.0, ptf[1].Y);
+
+    ptf[0].X = 1.0;
+    ptf[0].Y = 0.0;
+    ptf[1].X = 0.0;
+    ptf[1].Y = 1.0;
+    status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, ptf, 2);
+    expect(Ok, status);
+    expectf(6.0, ptf[0].X);
+    expectf(5.0, ptf[0].Y);
+    expectf(5.0, ptf[1].X);
+    expectf(6.0, ptf[1].Y);
+
+    ptf[0].X = 1.0;
+    ptf[0].Y = 0.0;
+    ptf[1].X = 0.0;
+    ptf[1].Y = 1.0;
+    status = GdipTransformPoints(graphics, CoordinateSpaceDevice, CoordinateSpacePage, ptf, 2);
+    expect(Ok, status);
+    expectf(3.0, ptf[0].X);
+    expectf(0.0, ptf[0].Y);
+    expectf(0.0, ptf[1].X);
+    expectf(3.0, ptf[1].Y);
+
+    ptf[0].X = 18.0;
+    ptf[0].Y = 15.0;
+    ptf[1].X = 15.0;
+    ptf[1].Y = 18.0;
+    status = GdipTransformPoints(graphics, CoordinateSpaceWorld, CoordinateSpaceDevice, ptf, 2);
+    expect(Ok, status);
+    expectf(1.0, ptf[0].X);
+    expectf(0.0, ptf[0].Y);
+    expectf(0.0, ptf[1].X);
+    expectf(1.0, ptf[1].Y);
+
+    ptf[0].X = 6.0;
+    ptf[0].Y = 5.0;
+    ptf[1].X = 5.0;
+    ptf[1].Y = 6.0;
+    status = GdipTransformPoints(graphics, CoordinateSpaceWorld, CoordinateSpacePage, ptf, 2);
+    expect(Ok, status);
+    expectf(1.0, ptf[0].X);
+    expectf(0.0, ptf[0].Y);
+    expectf(0.0, ptf[1].X);
+    expectf(1.0, ptf[1].Y);
+
+    ptf[0].X = 3.0;
+    ptf[0].Y = 0.0;
+    ptf[1].X = 0.0;
+    ptf[1].Y = 3.0;
+    status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceDevice, ptf, 2);
+    expect(Ok, status);
+    expectf(1.0, ptf[0].X);
+    expectf(0.0, ptf[0].Y);
+    expectf(0.0, ptf[1].X);
+    expectf(1.0, ptf[1].Y);
+
+    pt[0].X = 1;
+    pt[0].Y = 0;
+    pt[1].X = 0;
+    pt[1].Y = 1;
+    status = GdipTransformPointsI(graphics, CoordinateSpaceDevice, CoordinateSpaceWorld, pt, 2);
+    expect(Ok, status);
+    expect(18, pt[0].X);
+    expect(15, pt[0].Y);
+    expect(15, pt[1].X);
+    expect(18, pt[1].Y);
+
+    GdipDeleteGraphics(graphics);
+    ReleaseDC(0, hdc);
+}
+
+static void test_get_set_clip(void)
+{
+    GpStatus status;
+    GpGraphics *graphics = NULL;
+    HDC hdc = GetDC(0);
+    GpRegion *clip;
+    GpRectF rect;
+    BOOL res;
+
+    status = GdipCreateFromHDC(hdc, &graphics);
+    expect(Ok, status);
+
+    rect.X = rect.Y = 0.0;
+    rect.Height = rect.Width = 100.0;
+
+    status = GdipCreateRegionRect(&rect, &clip);
+
+    /* NULL arguments */
+    status = GdipGetClip(NULL, NULL);
+    expect(InvalidParameter, status);
+    status = GdipGetClip(graphics, NULL);
+    expect(InvalidParameter, status);
+    status = GdipGetClip(NULL, clip);
+    expect(InvalidParameter, status);
+
+    status = GdipSetClipRegion(NULL, NULL, CombineModeReplace);
+    expect(InvalidParameter, status);
+    status = GdipSetClipRegion(graphics, NULL, CombineModeReplace);
+    expect(InvalidParameter, status);
+
+    status = GdipSetClipPath(NULL, NULL, CombineModeReplace);
+    expect(InvalidParameter, status);
+    status = GdipSetClipPath(graphics, NULL, CombineModeReplace);
+    expect(InvalidParameter, status);
+
+    res = FALSE;
+    status = GdipGetClip(graphics, clip);
+    expect(Ok, status);
+    status = GdipIsInfiniteRegion(clip, graphics, &res);
+    expect(Ok, status);
+    expect(TRUE, res);
+
+    /* remains infinite after reset */
+    res = FALSE;
+    status = GdipResetClip(graphics);
+    expect(Ok, status);
+    status = GdipGetClip(graphics, clip);
+    expect(Ok, status);
+    status = GdipIsInfiniteRegion(clip, graphics, &res);
+    expect(Ok, status);
+    expect(TRUE, res);
+
+    /* set to empty and then reset to infinite */
+    status = GdipSetEmpty(clip);
+    expect(Ok, status);
+    status = GdipSetClipRegion(graphics, clip, CombineModeReplace);
+    expect(Ok, status);
+
+    status = GdipGetClip(graphics, clip);
+    expect(Ok, status);
+    res = FALSE;
+    status = GdipIsEmptyRegion(clip, graphics, &res);
+    expect(Ok, status);
+    expect(TRUE, res);
+    status = GdipResetClip(graphics);
+    expect(Ok, status);
+    status = GdipGetClip(graphics, clip);
+    expect(Ok, status);
+    res = FALSE;
+    status = GdipIsInfiniteRegion(clip, graphics, &res);
+    expect(Ok, status);
+    expect(TRUE, res);
+
+    GdipDeleteRegion(clip);
+
+    GdipDeleteGraphics(graphics);
+    ReleaseDC(0, hdc);
+}
+
+static void test_isempty(void)
+{
+    GpStatus status;
+    GpGraphics *graphics = NULL;
+    HDC hdc = GetDC(0);
+    GpRegion *clip;
+    BOOL res;
+
+    status = GdipCreateFromHDC(hdc, &graphics);
+    expect(Ok, status);
+
+    status = GdipCreateRegion(&clip);
+    expect(Ok, status);
+
+    /* NULL */
+    status = GdipIsClipEmpty(NULL, NULL);
+    expect(InvalidParameter, status);
+    status = GdipIsClipEmpty(graphics, NULL);
+    expect(InvalidParameter, status);
+    status = GdipIsClipEmpty(NULL, &res);
+    expect(InvalidParameter, status);
+
+    /* default is infinite */
+    res = TRUE;
+    status = GdipIsClipEmpty(graphics, &res);
+    expect(Ok, status);
+    expect(FALSE, res);
+
+    GdipDeleteRegion(clip);
+
+    GdipDeleteGraphics(graphics);
     ReleaseDC(0, hdc);
 }
 
+static void test_clear(void)
+{
+    GpStatus status;
+
+    status = GdipGraphicsClear(NULL, 0xdeadbeef);
+    expect(InvalidParameter, status);
+}
+
+static void test_textcontrast(void)
+{
+    GpStatus status;
+    HDC hdc = GetDC(0);
+    GpGraphics *graphics;
+    UINT contrast;
+
+    status = GdipGetTextContrast(NULL, NULL);
+    expect(InvalidParameter, status);
+
+    status = GdipCreateFromHDC(hdc, &graphics);
+    expect(Ok, status);
+
+    status = GdipGetTextContrast(graphics, NULL);
+    expect(InvalidParameter, status);
+    status = GdipGetTextContrast(graphics, &contrast);
+    expect(4, contrast);
+
+    GdipDeleteGraphics(graphics);
+    ReleaseDC(0, hdc);
+}
+
+static void test_GdipDrawString(void)
+{
+    GpStatus status;
+    GpGraphics *graphics = NULL;
+    GpFont *fnt = NULL;
+    RectF  rect;
+    GpStringFormat *format;
+    GpBrush *brush;
+    LOGFONTA logfont;
+    HDC hdc = GetDC(0);
+    static const WCHAR string[] = {'T','e','s','t',0};
+
+    memset(&logfont,0,sizeof(logfont));
+    strcpy(logfont.lfFaceName,"Arial");
+    logfont.lfHeight = 12;
+    logfont.lfCharSet = DEFAULT_CHARSET;
+
+    status = GdipCreateFromHDC(hdc, &graphics);
+    expect(Ok, status);
+
+    status = GdipCreateFontFromLogfontA(hdc, &logfont, &fnt);
+    if (status == FileNotFound)
+    {
+        skip("Arial not installed.\n");
+        return;
+    }
+    expect(Ok, status);
+
+    status = GdipCreateSolidFill((ARGB)0xdeadbeef, (GpSolidFill**)&brush);
+    expect(Ok, status);
+
+    status = GdipCreateStringFormat(0,0,&format);
+    expect(Ok, status);
+
+    rect.X = 0;
+    rect.Y = 0;
+    rect.Width = 0;
+    rect.Height = 12;
+
+    status = GdipDrawString(graphics, string, 4, fnt, &rect, format, brush);
+    expect(Ok, status);
+
+    GdipDeleteGraphics(graphics);
+    GdipDeleteBrush(brush);
+    GdipDeleteFont(fnt);
+    GdipDeleteStringFormat(format);
+
+    ReleaseDC(0, hdc);
+}
+
+
 START_TEST(graphics)
 {
     struct GdiplusStartupInput gdiplusStartupInput;
@@ -471,6 +1097,13 @@ START_TEST(graphics)
     test_GdipDrawArcI();
     test_GdipDrawLineI();
     test_GdipDrawLinesI();
+    test_GdipDrawString();
+    test_Get_Release_DC();
+    test_transformpoints();
+    test_get_set_clip();
+    test_isempty();
+    test_clear();
+    test_textcontrast();
 
     GdiplusShutdown(gdiplusToken);
 }