From ba2fe8af6e2106b88a24d5d97f81ac6eb69ce6b2 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Tue, 10 Feb 2009 11:53:08 -0600 Subject: [PATCH] gdiplus: add a drawing test for GdipFillRectangleI --- dlls/gdiplus/tests/Makefile.in | 1 + dlls/gdiplus/tests/drawing.c | 69 ++++++++++++++++++++++++++++++++++++++++ dlls/gdiplus/tests/drawing.h | 38 ++++++++++++++++++++++ dlls/gdiplus/tests/graphics.c | 35 ++++++++++++++++++++ 4 files changed, 143 insertions(+), 0 deletions(-) create mode 100644 dlls/gdiplus/tests/drawing.c create mode 100644 dlls/gdiplus/tests/drawing.h diff --git a/dlls/gdiplus/tests/Makefile.in b/dlls/gdiplus/tests/Makefile.in index ac5589d..1ad9098 100644 --- a/dlls/gdiplus/tests/Makefile.in +++ b/dlls/gdiplus/tests/Makefile.in @@ -8,6 +8,7 @@ IMPORTS = gdiplus ole32 user32 gdi32 kernel32 CTESTS = \ brush.c \ customlinecap.c \ + drawing.c \ font.c \ graphics.c \ graphicspath.c \ diff --git a/dlls/gdiplus/tests/drawing.c b/dlls/gdiplus/tests/drawing.c new file mode 100644 index 0000000..00bb0fd --- /dev/null +++ b/dlls/gdiplus/tests/drawing.c @@ -0,0 +1,69 @@ +/* Drawing Test Code + * + * Copyright (C) 2009 Vincent Povirk for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "windows.h" +#include "gdiplus.h" +#include "wingdi.h" +#include "wine/test.h" +#include "drawing.h" + +void create_canvas(CANVAS *c, int width, int height) +{ + c->hdc = CreateCompatibleDC(NULL); + + c->hbitmap = CreateBitmap(width, height, 1, 32, NULL); + + SelectObject(c->hdc, c->hbitmap); + + GdipCreateFromHDC(c->hdc, &(c->graphics)); + + c->width = width; + + c->height = height; +} + +void clear_canvas(CANVAS *c) +{ + HBRUSH hbrush; + RECT rc; + + hbrush = CreateSolidBrush(RGB(0,0,0)); + + rc.left = 0; + rc.top = 0; + rc.right = c->width; + rc.bottom = c->height; + + FillRect(c->hdc, &rc, hbrush); + + DeleteObject(hbrush); +} + +void delete_canvas(CANVAS *c) +{ + GdipDeleteGraphics(c->graphics); + + DeleteObject(c->hbitmap); + DeleteDC(c->hdc); +} + +START_TEST(drawing) +{ +} + diff --git a/dlls/gdiplus/tests/drawing.h b/dlls/gdiplus/tests/drawing.h new file mode 100644 index 0000000..b134b9f --- /dev/null +++ b/dlls/gdiplus/tests/drawing.h @@ -0,0 +1,38 @@ +/* Drawing Test Code + * + * Copyright (C) 2009 Vincent Povirk for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +typedef struct _CANVAS { + HDC hdc; + HBITMAP hbitmap; + GpGraphics *graphics; + int width; + int height; +} CANVAS; + +void create_canvas(CANVAS *c, int width, int height); + +void clear_canvas(CANVAS *c); + +void delete_canvas(CANVAS *c); + +#define expect_pixel(hdc, x, y, r, g, b) do { \ + COLORREF _c = GetPixel(hdc, x, y); \ + ok(_c == RGB(r, g, b), "expected %x, got %x at (%i,%i)\n", RGB(r, g, b), _c, x, y); \ + } while (0) + diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c index 8091a9a..758bd03 100644 --- a/dlls/gdiplus/tests/graphics.c +++ b/dlls/gdiplus/tests/graphics.c @@ -22,6 +22,7 @@ #include "gdiplus.h" #include "wingdi.h" #include "wine/test.h" +#include "drawing.h" #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got) #define TABLE_LEN (23) @@ -935,6 +936,39 @@ static void test_textcontrast(void) ReleaseDC(0, hdc); } + +static void test_fillrect(void) +{ + CANVAS c; + GpStatus stat; + GpBrush *brush; + int x, y; + + create_canvas(&c, 3, 3); + + stat = GdipCreateSolidFill(0xFFFFFFFF, (GpSolidFill**)&brush); + expect(Ok, stat); + + clear_canvas(&c); + + + stat = GdipFillRectangleI(c.graphics, brush, 1, 1, 1, 1); + expect(Ok, stat); + + for (x=0; x<3; x++) + for (y=0; y<3; y++) + if (x == 1 && y == 1) + expect_pixel(c.hdc, x, y, 0xff,0xff,0xff); + else + expect_pixel(c.hdc, x, y, 0,0,0); + + + stat = GdipDeleteBrush(brush); + expect(Ok, stat); + + delete_canvas(&c); +} + START_TEST(graphics) { struct GdiplusStartupInput gdiplusStartupInput; @@ -960,6 +994,7 @@ START_TEST(graphics) test_isempty(); test_clear(); test_textcontrast(); + test_fillrect(); GdiplusShutdown(gdiplusToken); } -- 1.5.4.3