[2/2] gdiplus: Add option to save metafile tests to files.

Vincent Povirk madewokherd at gmail.com
Fri Jan 24 16:27:31 CST 2014


This makes it possible to verify that the Wine and Windows
implementations can play emf's generated by the other.
-------------- next part --------------
From 9b4717c7ef013335de7fc32b58363a37f1e9e1f7 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Fri, 24 Jan 2014 16:22:58 -0600
Subject: [PATCH 2/3] gdiplus: Add option to save metafile tests to files.

---
 dlls/gdiplus/tests/metafile.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/dlls/gdiplus/tests/metafile.c b/dlls/gdiplus/tests/metafile.c
index 16c440b..f9a5092 100644
--- a/dlls/gdiplus/tests/metafile.c
+++ b/dlls/gdiplus/tests/metafile.c
@@ -27,6 +27,8 @@
 #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))
 
+static BOOL save_metafiles;
+
 typedef struct emfplus_record
 {
     BOOL  todo;
@@ -248,6 +250,29 @@ static void play_metafile(GpMetafile *metafile, GpGraphics *graphics, const emfp
     expect(Ok, stat);
 }
 
+static void save_metafile(GpMetafile *metafile, const char *filename)
+{
+    if (save_metafiles)
+    {
+        GpMetafile *clone;
+        HENHMETAFILE hemf;
+        GpStatus stat;
+
+        stat = GdipCloneImage((GpImage*)metafile, (GpImage**)&clone);
+        expect(Ok, stat);
+
+        stat = GdipGetHemfFromMetafile(clone, &hemf);
+        expect(Ok, stat);
+
+        DeleteEnhMetaFile(CopyEnhMetaFileA(hemf, filename));
+
+        DeleteEnhMetaFile(hemf);
+
+        stat = GdipDisposeImage((GpImage*)clone);
+        expect(Ok, stat);
+    }
+}
+
 static const emfplus_record empty_records[] = {
     {0, EMR_HEADER},
     {0, EmfPlusRecordTypeHeader},
@@ -310,6 +335,8 @@ static void test_empty(void)
 
     check_metafile(metafile, empty_records, "empty metafile", dst_points, &frame, UnitPixel);
 
+    save_metafile(metafile, "empty.emf");
+
     stat = GdipGetHemfFromMetafile(metafile, &hemf);
     expect(Ok, stat);
 
@@ -399,6 +426,8 @@ static void test_getdc(void)
 
     check_metafile(metafile, getdc_records, "getdc metafile", dst_points, &frame, UnitPixel);
 
+    save_metafile(metafile, "getdc.emf");
+
     stat = GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB, NULL, &bitmap);
     expect(Ok, stat);
 
@@ -532,6 +561,8 @@ static void test_emfonly(void)
 
     check_metafile(metafile, emfonly_records, "emfonly metafile", dst_points, &frame, UnitPixel);
 
+    save_metafile(metafile, "emfonly.emf");
+
     stat = GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB, NULL, &bitmap);
     expect(Ok, stat);
 
@@ -658,6 +689,8 @@ static void test_fillrect(void)
 
     check_metafile(metafile, fillrect_records, "fillrect metafile", dst_points, &frame, UnitPixel);
 
+    save_metafile(metafile, "fillrect.emf");
+
     stat = GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB, NULL, &bitmap);
     expect(Ok, stat);
 
@@ -869,6 +902,8 @@ static void test_pagetransform(void)
 
     check_metafile(metafile, pagetransform_records, "pagetransform metafile", dst_points, &frame, UnitPixel);
 
+    save_metafile(metafile, "pagetransform.emf");
+
     stat = GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB, NULL, &bitmap);
     expect(Ok, stat);
 
@@ -915,6 +950,8 @@ START_TEST(metafile)
 {
     struct GdiplusStartupInput gdiplusStartupInput;
     ULONG_PTR gdiplusToken;
+    int myARGC;
+    char **myARGV;
 
     gdiplusStartupInput.GdiplusVersion              = 1;
     gdiplusStartupInput.DebugEventCallback          = NULL;
@@ -923,6 +960,11 @@ START_TEST(metafile)
 
     GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
 
+    myARGC = winetest_get_mainargs( &myARGV );
+
+    if (myARGC >= 3 && !strcmp(myARGV[2], "save"))
+        save_metafiles = TRUE;
+
     test_empty();
     test_getdc();
     test_emfonly();
-- 
1.8.1.2



More information about the wine-patches mailing list