Dmitry Timoshkov : gdiplus: Add a test to show that GdipCloneImage is not supposed to increase refcount of the source image .

Alexandre Julliard julliard at winehq.org
Mon Jul 2 13:22:00 CDT 2012


Module: wine
Branch: master
Commit: c7ea378f6a26e50766de52d80f01fab9a77534dc
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c7ea378f6a26e50766de52d80f01fab9a77534dc

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Mon Jul  2 12:57:30 2012 +0900

gdiplus: Add a test to show that GdipCloneImage is not supposed to increase refcount of the source image.

---

 dlls/gdiplus/tests/image.c |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c
index 8c972ee..b6cc322 100644
--- a/dlls/gdiplus/tests/image.c
+++ b/dlls/gdiplus/tests/image.c
@@ -2674,9 +2674,9 @@ static GpImage *load_image(const BYTE *image_data, UINT image_size)
     BYTE *data;
     HRESULT hr;
     GpStatus status;
-    GpImage *image = NULL;
+    GpImage *image = NULL, *clone;
     ImageType image_type;
-    LONG refcount;
+    LONG refcount, old_refcount;
 
     hmem = GlobalAlloc(0, image_size);
     data = GlobalLock(hmem);
@@ -2696,6 +2696,22 @@ static GpImage *load_image(const BYTE *image_data, UINT image_size)
     status = GdipGetImageType(image, &image_type);
     ok(status == Ok, "GdipGetImageType error %d\n", status);
 
+    refcount = obj_refcount(stream);
+    if (image_type == ImageTypeBitmap)
+        ok(refcount > 1, "expected stream refcount > 1, got %d\n", refcount);
+    else
+        ok(refcount == 1, "expected stream refcount 1, got %d\n", refcount);
+    old_refcount = refcount;
+
+    status = GdipCloneImage(image, &clone);
+    ok(status == Ok, "GdipCloneImage error %d\n", status);
+    refcount = obj_refcount(stream);
+    ok(refcount == old_refcount, "expected stream refcount %d, got %d\n", old_refcount, refcount);
+    status = GdipDisposeImage(clone);
+    ok(status == Ok, "GdipDisposeImage error %d\n", status);
+    refcount = obj_refcount(stream);
+    ok(refcount == old_refcount, "expected stream refcount %d, got %d\n", old_refcount, refcount);
+
     refcount = IStream_Release(stream);
     if (image_type == ImageTypeBitmap)
         ok(refcount >= 1, "expected stream refcount != 0\n");




More information about the wine-cvs mailing list