gdiplus: Add a test to show that GdipCloneImage is not supposed to increase refcount of the source image stream, but clone it instead.

Dmitry Timoshkov dmitry at baikal.ru
Thu Jun 28 21:23:58 CDT 2012


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

diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c
index c373f13..a1394a0 100644
--- a/dlls/gdiplus/tests/image.c
+++ b/dlls/gdiplus/tests/image.c
@@ -2672,9 +2672,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);
@@ -2694,6 +2694,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");
-- 
1.7.11.1




More information about the wine-patches mailing list