[GDIPLUS_WINETEST]
authorAmine Khaldi <amine.khaldi@reactos.org>
Sat, 27 Sep 2014 12:59:19 +0000 (12:59 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sat, 27 Sep 2014 12:59:19 +0000 (12:59 +0000)
* Sync with Wine 1.7.27.
CORE-8540

svn path=/trunk/; revision=64341

rostests/winetests/gdiplus/font.c
rostests/winetests/gdiplus/graphics.c
rostests/winetests/gdiplus/image.c

index 09b8eba..c4f7dbe 100644 (file)
 
 static const WCHAR nonexistent[] = {'T','h','i','s','F','o','n','t','s','h','o','u','l','d','N','o','t','E','x','i','s','t','\0'};
 static const WCHAR MSSansSerif[] = {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'};
-static const WCHAR MicrosoftSansSerif[] = {'M','i','c','r','o','s','o','f','t',' ','S','a','n','s',' ','S','e','r','i','f','\0'};
 static const WCHAR TimesNewRoman[] = {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n','\0'};
-static const WCHAR CourierNew[] = {'C','o','u','r','i','e','r',' ','N','e','w','\0'};
 static const WCHAR Tahoma[] = {'T','a','h','o','m','a',0};
-static const WCHAR LiberationSerif[] = {'L','i','b','e','r','a','t','i','o','n',' ','S','e','r','i','f',0};
 
 static void set_rect_empty(RectF *rc)
 {
@@ -809,17 +806,23 @@ static void test_font_substitution(void)
     lf.lfWeight = 0;
     lf.lfCharSet = 0;
     lstrcpyA(lf.lfFaceName, "ThisFontShouldNotExist");
+    font = NULL;
     status = GdipCreateFontFromLogfontA(hdc, &lf, &font);
 todo_wine
     ok(status == NotTrueTypeFont || broken(status == FileNotFound), /* before XP */
        "expected NotTrueTypeFont, got %d\n", status);
+    /* FIXME: remove when wine is fixed */
+    if (font) GdipDeleteFont(font);
 
     /* empty FaceName */
     lf.lfFaceName[0] = 0;
+    font = NULL;
     status = GdipCreateFontFromLogfontA(hdc, &lf, &font);
 todo_wine
     ok(status == NotTrueTypeFont || broken(status == FileNotFound), /* before XP */
        "expected NotTrueTypeFont, got %d\n", status);
+    /* FIXME: remove when wine is fixed */
+    if (font) GdipDeleteFont(font);
 
     GdipDeleteGraphics(graphics);
     DeleteDC(hdc);
index 20cc699..fca7720 100644 (file)
@@ -98,7 +98,7 @@ static REAL units_scale(GpUnit from, GpUnit to, REAL dpi)
     return pixels_to_units(pixels, to, dpi);
 }
 
-static GpGraphics *create_graphics(REAL res_x, REAL res_y, GpUnit unit, REAL scale)
+static GpGraphics *create_graphics(REAL res_x, REAL res_y, GpUnit unit, REAL scale, GpImage **image)
 {
     GpStatus status;
     union
@@ -123,11 +123,8 @@ static GpGraphics *create_graphics(REAL res_x, REAL res_y, GpUnit unit, REAL sca
 
     status = GdipGetImageGraphicsContext(u.image, &graphics);
     expect(Ok, status);
-    /* image is intentionally leaked to make sure that there is no
-       side effects after its destruction.
-    status = GdipDisposeImage(u.image);
-    expect(Ok, status);
-    */
+
+    *image = u.image;
 
     status = GdipGetDpiX(graphics, &res);
     expect(Ok, status);
@@ -3527,7 +3524,9 @@ static void test_GdipMeasureString(void)
 
     for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
     {
-        graphics = create_graphics(td[i].res_x, td[i].res_y, td[i].unit, td[i].page_scale);
+        GpImage *image;
+
+        graphics = create_graphics(td[i].res_x, td[i].res_y, td[i].unit, td[i].page_scale, &image);
 
         lf.lfHeight = 0xdeadbeef;
         status = GdipGetLogFontW(font, graphics, &lf);
@@ -3578,6 +3577,9 @@ todo_wine
 
         status = GdipDeleteGraphics(graphics);
         expect(Ok, status);
+
+        status = GdipDisposeImage(image);
+        expect(Ok, status);
     }
 
     GdipDeleteFont(font);
@@ -3601,8 +3603,9 @@ todo_wine
         for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
         {
             REAL unit_scale;
+            GpImage *image;
 
-            graphics = create_graphics(td[i].res_x, td[i].res_y, td[i].unit, td[i].page_scale);
+            graphics = create_graphics(td[i].res_x, td[i].res_y, td[i].unit, td[i].page_scale, &image);
 
             lf.lfHeight = 0xdeadbeef;
             status = GdipGetLogFontW(font, graphics, &lf);
@@ -3672,6 +3675,9 @@ todo_wine
 
             status = GdipDeleteGraphics(graphics);
             expect(Ok, status);
+
+            status = GdipDisposeImage(image);
+            expect(Ok, status);
         }
 
         GdipDeleteFont(font);
@@ -3709,12 +3715,13 @@ static void test_transform(void)
     };
     GpStatus status;
     GpGraphics *graphics;
+    GpImage *image;
     GpPointF ptf[2];
     UINT i;
 
     for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
     {
-        graphics = create_graphics(td[i].res_x, td[i].res_y, td[i].unit, td[i].scale);
+        graphics = create_graphics(td[i].res_x, td[i].res_y, td[i].unit, td[i].scale, &image);
         ptf[0].X = td[i].in[0].X;
         ptf[0].Y = td[i].in[0].Y;
         ptf[1].X = td[i].in[1].X;
@@ -3733,6 +3740,8 @@ static void test_transform(void)
         expectf(td[i].in[1].Y, ptf[1].Y);
         status = GdipDeleteGraphics(graphics);
         expect(Ok, status);
+        status = GdipDisposeImage(image);
+        expect(Ok, status);
     }
 }
 
index 1bb749b..b08f425 100644 (file)
@@ -381,24 +381,48 @@ static void test_GdipImageGetFrameDimensionsCount(void)
 static void test_LoadingImages(void)
 {
     GpStatus stat;
+    GpBitmap *bm;
+    GpImage *img;
+    static const WCHAR nonexistentW[] = {'n','o','n','e','x','i','s','t','e','n','t',0};
 
     stat = GdipCreateBitmapFromFile(0, 0);
     expect(InvalidParameter, stat);
 
-    stat = GdipCreateBitmapFromFile(0, (GpBitmap**)0xdeadbeef);
+    bm = (GpBitmap *)0xdeadbeef;
+    stat = GdipCreateBitmapFromFile(0, &bm);
     expect(InvalidParameter, stat);
+    ok(bm == (GpBitmap *)0xdeadbeef, "returned %p\n", bm);
+
+    bm = (GpBitmap *)0xdeadbeef;
+    stat = GdipCreateBitmapFromFile(nonexistentW, &bm);
+    todo_wine expect(InvalidParameter, stat);
+    ok(!bm, "returned %p\n", bm);
 
     stat = GdipLoadImageFromFile(0, 0);
     expect(InvalidParameter, stat);
 
-    stat = GdipLoadImageFromFile(0, (GpImage**)0xdeadbeef);
+    img = (GpImage *)0xdeadbeef;
+    stat = GdipLoadImageFromFile(0, &img);
     expect(InvalidParameter, stat);
+    ok(img == (GpImage *)0xdeadbeef, "returned %p\n", img);
+
+    img = (GpImage *)0xdeadbeef;
+    stat = GdipLoadImageFromFile(nonexistentW, &img);
+    todo_wine expect(OutOfMemory, stat);
+    ok(!img, "returned %p\n", img);
 
     stat = GdipLoadImageFromFileICM(0, 0);
     expect(InvalidParameter, stat);
 
-    stat = GdipLoadImageFromFileICM(0, (GpImage**)0xdeadbeef);
+    img = (GpImage *)0xdeadbeef;
+    stat = GdipLoadImageFromFileICM(0, &img);
     expect(InvalidParameter, stat);
+    ok(img == (GpImage *)0xdeadbeef, "returned %p\n", img);
+
+    img = (GpImage *)0xdeadbeef;
+    stat = GdipLoadImageFromFileICM(nonexistentW, &img);
+    todo_wine expect(OutOfMemory, stat);
+    ok(!img, "returned %p\n", img);
 }
 
 static void test_SavingImages(void)