gdiplus: Add tests for GetMetafileHeader functions.
Vincent Povirk
madewokherd at gmail.com
Tue Jan 28 15:17:14 CST 2014
-------------- next part --------------
From c552ff4098e647b65d97cad4291fd3dff78dfad7 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Tue, 28 Jan 2014 15:12:56 -0600
Subject: [PATCH 2/2] gdiplus: Add tests for GetMetafileHeader functions.
---
dlls/gdiplus/tests/metafile.c | 63 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 62 insertions(+), 1 deletion(-)
diff --git a/dlls/gdiplus/tests/metafile.c b/dlls/gdiplus/tests/metafile.c
index f9a5092..bd1aa0e 100644
--- a/dlls/gdiplus/tests/metafile.c
+++ b/dlls/gdiplus/tests/metafile.c
@@ -25,7 +25,8 @@
#include "wine/test.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 %f, got %f\n", (expected), (got))
+#define expectf_(expected, got, precision) ok(fabs((expected) - (got)) <= (precision), "Expected %f, got %f\n", (expected), (got))
+#define expectf(expected, got) expectf_((expected), (got), 0.001)
static BOOL save_metafiles;
@@ -292,6 +293,10 @@ static void test_empty(void)
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 WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
+ MetafileHeader header;
+ UINT size;
+ ENHMETAHEADER emfheader;
+ INT dpix, dpiy;
hdc = CreateCompatibleDC(0);
@@ -316,11 +321,31 @@ static void test_empty(void)
stat = GdipRecordMetafile(hdc, EmfTypeEmfPlusOnly, &frame, MetafileFrameUnitPixel, description, &metafile);
expect(Ok, stat);
+ dpix = GetDeviceCaps(hdc, LOGPIXELSX);
+ dpiy = GetDeviceCaps(hdc, LOGPIXELSY);
+
DeleteDC(hdc);
if (stat != Ok)
return;
+ stat = GdipGetMetafileHeaderFromMetafile(metafile, &header);
+ expect(Ok, stat);
+ todo_wine expect(MetafileTypeEmfPlusOnly, header.Type);
+ expect(0, header.Size);
+ todo_wine ok(header.Version == 0xdbc01001 || header.Version == 0xdbc01002, "got %x\n", header.Version);
+ todo_wine expect(GDIP_EMFPLUSFLAGS_DISPLAY, header.EmfPlusFlags);
+ todo_wine expectf_(dpix * 0.75, header.DpiX, 0.4);
+ todo_wine expectf_(dpiy * 0.75, header.DpiY, 0.4);
+ todo_wine expect(dpix, header.LogicalDpiX);
+ todo_wine expect(dpiy, header.LogicalDpiX);
+ todo_wine ok(header.DpiY != 0, "got %f\n", header.DpiY);
+ expect(0, header.X);
+ expect(0, header.Y);
+ expect(0, header.Width);
+ expect(0, header.Height);
+ todo_wine expect(28, header.EmfPlusHeaderSize);
+
stat = GdipGetHemfFromMetafile(metafile, &hemf);
expect(InvalidParameter, stat);
@@ -337,6 +362,23 @@ static void test_empty(void)
save_metafile(metafile, "empty.emf");
+ stat = GdipGetMetafileHeaderFromMetafile(metafile, &header);
+ expect(Ok, stat);
+ todo_wine expect(MetafileTypeEmfPlusOnly, header.Type);
+ todo_wine ok(header.Size != 0, "got size %d\n", header.Size);
+ size = header.Size;
+ todo_wine ok(header.Version == 0xdbc01001 || header.Version == 0xdbc01002, "got %x\n", header.Version);
+ todo_wine expect(GDIP_EMFPLUSFLAGS_DISPLAY, header.EmfPlusFlags);
+ todo_wine expectf_(dpix * 0.75, header.DpiX, 0.4);
+ todo_wine expectf_(dpiy * 0.75, header.DpiY, 0.4);
+ todo_wine expect(dpix, header.LogicalDpiX);
+ todo_wine expect(dpiy, header.LogicalDpiX);
+ expect(0, header.X);
+ expect(0, header.Y);
+ todo_wine expect(100, header.Width);
+ todo_wine expect(100, header.Height);
+ todo_wine expect(28, header.EmfPlusHeaderSize);
+
stat = GdipGetHemfFromMetafile(metafile, &hemf);
expect(Ok, stat);
@@ -348,6 +390,25 @@ static void test_empty(void)
check_emfplus(hemf, empty_records, "empty emf");
+ stat = GdipGetMetafileHeaderFromEmf(hemf, &header);
+ expect(Ok, stat);
+ todo_wine expect(MetafileTypeEmfPlusOnly, header.Type);
+ expect(size, header.Size);
+ todo_wine ok(header.Version == 0xdbc01001 || header.Version == 0xdbc01002, "got %x\n", header.Version);
+ todo_wine expect(GDIP_EMFPLUSFLAGS_DISPLAY, header.EmfPlusFlags);
+ todo_wine expectf_(dpix * 0.75, header.DpiX, 0.4);
+ todo_wine expectf_(dpiy * 0.75, header.DpiY, 0.4);
+ todo_wine expect(dpix, header.LogicalDpiX);
+ todo_wine expect(dpiy, header.LogicalDpiX);
+ expect(0, header.X);
+ expect(0, header.Y);
+ todo_wine expect(100, header.Width);
+ todo_wine expect(100, header.Height);
+ todo_wine expect(28, header.EmfPlusHeaderSize);
+
+ GetEnhMetaFileHeader(hemf, sizeof(emfheader), &emfheader);
+ todo_wine expect(size, emfheader.nBytes);
+
ret = DeleteEnhMetaFile(hemf);
ok(ret != 0, "Failed to delete enhmetafile %p\n", hemf);
}
--
1.8.1.2
More information about the wine-patches
mailing list