gdiplus: Add tests for GdipDrawString.
authorVincent Povirk <vincent@codeweavers.com>
Tue, 30 Mar 2010 15:24:06 +0000 (10:24 -0500)
committerAlexandre Julliard <julliard@winehq.org>
Wed, 31 Mar 2010 09:37:45 +0000 (11:37 +0200)
dlls/gdiplus/tests/graphics.c

index e33ff5f610a3e1a48d2c0e5e560acd57e0df27a4..058532104d9fe43a39e5fe819995d858fa7c2b32 100644 (file)
@@ -2400,6 +2400,73 @@ static void test_GdipGetNearestColor(void)
     ReleaseDC(hwnd, hdc);
 }
 
+static void test_string_functions(void)
+{
+    GpStatus status;
+    GpGraphics *graphics;
+    GpFontFamily *family;
+    GpFont *font;
+    RectF rc;
+    GpBrush *brush;
+    ARGB color = 0xff000000;
+    HDC hdc = GetDC( hwnd );
+    const WCHAR fontname[] = {'C','o','u','r','i','e','r',' ','N','e','w',0};
+    const WCHAR fontname2[] = {'C','o','u','r','i','e','r',0};
+    const WCHAR teststring[] = {'o','o',' ','o','\n','o',0};
+
+    ok(hdc != NULL, "Expected HDC to be initialized\n");
+    status = GdipCreateFromHDC(hdc, &graphics);
+    expect(Ok, status);
+    ok(graphics != NULL, "Expected graphics to be initialized\n");
+
+    status = GdipCreateFontFamilyFromName(fontname, NULL, &family);
+
+    if (status != Ok)
+    {
+        /* Wine doesn't have Courier New? */
+        todo_wine expect(Ok, status);
+        status = GdipCreateFontFamilyFromName(fontname2, NULL, &family);
+    }
+
+    expect(Ok, status);
+
+    status = GdipCreateFont(family, 10.0, FontStyleRegular, UnitPixel, &font);
+    expect(Ok, status);
+
+    status = GdipCreateSolidFill(color, (GpSolidFill**)&brush);
+    expect(Ok, status);
+
+    rc.X = 0;
+    rc.Y = 0;
+    rc.Width = 100.0;
+    rc.Height = 100.0;
+
+    status = GdipDrawString(NULL, teststring, 6, font, &rc, NULL, brush);
+    expect(InvalidParameter, status);
+
+    status = GdipDrawString(graphics, NULL, 6, font, &rc, NULL, brush);
+    expect(InvalidParameter, status);
+
+    status = GdipDrawString(graphics, teststring, 6, NULL, &rc, NULL, brush);
+    expect(InvalidParameter, status);
+
+    status = GdipDrawString(graphics, teststring, 6, font, NULL, NULL, brush);
+    expect(InvalidParameter, status);
+
+    status = GdipDrawString(graphics, teststring, 6, font, &rc, NULL, NULL);
+    expect(InvalidParameter, status);
+
+    status = GdipDrawString(graphics, teststring, 6, font, &rc, NULL, brush);
+    expect(Ok, status);
+
+    GdipDeleteBrush(brush);
+    GdipDeleteFont(font);
+    GdipDeleteFontFamily(family);
+    GdipDeleteGraphics(graphics);
+
+    ReleaseDC(hwnd, hdc);
+}
+
 START_TEST(graphics)
 {
     struct GdiplusStartupInput gdiplusStartupInput;
@@ -2452,6 +2519,7 @@ START_TEST(graphics)
     test_clear();
     test_textcontrast();
     test_fromMemoryBitmap();
+    test_string_functions();
 
     GdiplusShutdown(gdiplusToken);
     DestroyWindow( hwnd );