gdiplus: Add metafile test for FillRectangles.

This commit is contained in:
Vincent Povirk 2013-11-20 16:07:26 -06:00 committed by Alexandre Julliard
parent 681cd545ea
commit 68b60c0ddd
1 changed files with 109 additions and 0 deletions

View File

@ -601,6 +601,114 @@ static void test_emfonly(void)
ok(ret != 0, "Failed to delete enhmetafile %p\n", hemf);
}
static const emfplus_record fillrect_records[] = {
{0, EMR_HEADER},
{0, EmfPlusRecordTypeHeader},
{0, EmfPlusRecordTypeFillRects},
{0, EmfPlusRecordTypeEndOfFile},
{0, EMR_EOF},
{0}
};
static void test_fillrect(void)
{
GpStatus stat;
GpMetafile *metafile;
GpGraphics *graphics;
HDC hdc;
HENHMETAFILE hemf;
static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
static const GpPointF dst_points_half[3] = {{0.0,0.0},{50.0,0.0},{0.0,50.0}};
static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
GpBitmap *bitmap;
ARGB color;
GpBrush *brush;
hdc = CreateCompatibleDC(0);
stat = GdipRecordMetafile(hdc, EmfTypeEmfPlusOnly, &frame, MetafileFrameUnitPixel, description, &metafile);
expect(Ok, stat);
DeleteDC(hdc);
if (stat != Ok)
return;
stat = GdipGetHemfFromMetafile(metafile, &hemf);
expect(InvalidParameter, stat);
stat = GdipGetImageGraphicsContext((GpImage*)metafile, &graphics);
expect(Ok, stat);
stat = GdipCreateSolidFill((ARGB)0xff0000ff, (GpSolidFill**)&brush);
expect(Ok, stat);
stat = GdipFillRectangleI(graphics, brush, 25, 25, 75, 75);
expect(Ok, stat);
stat = GdipDeleteBrush(brush);
expect(Ok, stat);
stat = GdipDeleteGraphics(graphics);
expect(Ok, stat);
check_metafile(metafile, fillrect_records, "fillrect metafile", dst_points, &frame, UnitPixel);
stat = GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB, NULL, &bitmap);
expect(Ok, stat);
stat = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
expect(Ok, stat);
play_metafile(metafile, graphics, fillrect_records, "fillrect playback", dst_points, &frame, UnitPixel);
stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
expect(Ok, stat);
expect(0, color);
stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
expect(Ok, stat);
expect(0xff0000ff, color);
stat = GdipBitmapSetPixel(bitmap, 50, 50, 0);
expect(Ok, stat);
play_metafile(metafile, graphics, fillrect_records, "fillrect playback", dst_points_half, &frame, UnitPixel);
stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
expect(Ok, stat);
expect(0xff0000ff, color);
stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
expect(Ok, stat);
expect(0, color);
stat = GdipBitmapSetPixel(bitmap, 15, 15, 0);
expect(Ok, stat);
stat = GdipDrawImagePointsRect(graphics, (GpImage*)metafile, dst_points, 3,
0.0, 0.0, 100.0, 100.0, UnitPixel, NULL, NULL, NULL);
expect(Ok, stat);
stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
expect(Ok, stat);
expect(0, color);
stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
expect(Ok, stat);
expect(0xff0000ff, color);
stat = GdipDeleteGraphics(graphics);
expect(Ok, stat);
stat = GdipDisposeImage((GpImage*)bitmap);
expect(Ok, stat);
stat = GdipDisposeImage((GpImage*)metafile);
expect(Ok, stat);
}
START_TEST(metafile)
{
struct GdiplusStartupInput gdiplusStartupInput;
@ -616,6 +724,7 @@ START_TEST(metafile)
test_empty();
test_getdc();
test_emfonly();
test_fillrect();
GdiplusShutdown(gdiplusToken);
}