From 1abc872000d41f76d165d14ff48f615a3d95669e Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Tue, 30 Mar 2010 10:24:06 -0500 Subject: [PATCH 1/8] gdiplus: Add tests for GdipDrawString. --- dlls/gdiplus/tests/graphics.c | 70 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 70 insertions(+), 0 deletions(-) diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c index e33ff5f..a5b8d91 100644 --- a/dlls/gdiplus/tests/graphics.c +++ b/dlls/gdiplus/tests/graphics.c @@ -2400,6 +2400,75 @@ static void test_GdipGetNearestColor(void) ReleaseDC(hwnd, hdc); } +static void test_string_functions(void) +{ + GpStatus status; + GpGraphics *graphics; + GpFontFamily *family; + GpFont *font; + RectF rc, char_bounds, bounds; + 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}; + REAL char_width, char_height; + INT codepointsfitted, linesfilled; + + 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 +2521,7 @@ START_TEST(graphics) test_clear(); test_textcontrast(); test_fromMemoryBitmap(); + test_string_functions(); GdiplusShutdown(gdiplusToken); DestroyWindow( hwnd ); -- 1.6.3.3