Dmitry Timoshkov : gdiplus: Add a test for image stream refcount.
Alexandre Julliard
julliard at winehq.org
Thu Jun 28 13:55:15 CDT 2012
Module: wine
Branch: master
Commit: 55f160db347759b0c23a5d307e5e6b824f6f4345
URL: http://source.winehq.org/git/wine.git/?a=commit;h=55f160db347759b0c23a5d307e5e6b824f6f4345
Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date: Wed Jun 27 14:27:04 2012 +0900
gdiplus: Add a test for image stream refcount.
---
dlls/gdiplus/tests/image.c | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c
index b930b99..0285879 100644
--- a/dlls/gdiplus/tests/image.c
+++ b/dlls/gdiplus/tests/image.c
@@ -2656,6 +2656,12 @@ static void test_dispose(void)
expect(ObjectBusy, stat);
}
+static LONG obj_refcount(void *obj)
+{
+ IUnknown_AddRef((IUnknown *)obj);
+ return IUnknown_Release((IUnknown *)obj);
+}
+
static GpImage *load_image(const BYTE *image_data, UINT image_size)
{
IStream *stream;
@@ -2664,6 +2670,8 @@ static GpImage *load_image(const BYTE *image_data, UINT image_size)
HRESULT hr;
GpStatus status;
GpImage *image = NULL;
+ ImageType image_type;
+ LONG refcount;
hmem = GlobalAlloc(0, image_size);
data = GlobalLock(hmem);
@@ -2674,10 +2682,20 @@ static GpImage *load_image(const BYTE *image_data, UINT image_size)
ok(hr == S_OK, "CreateStreamOnHGlobal error %#x\n", hr);
if (hr != S_OK) return NULL;
+ refcount = obj_refcount(stream);
+ ok(refcount == 1, "expected stream refcount 1, got %d\n", refcount);
+
status = GdipLoadImageFromStream(stream, &image);
ok(status == Ok, "GdipLoadImageFromStream error %d\n", status);
- IStream_Release(stream);
+ status = GdipGetImageType(image, &image_type);
+ ok(status == Ok, "GdipGetImageType error %d\n", status);
+
+ refcount = IStream_Release(stream);
+ if (image_type == ImageTypeBitmap)
+ todo_wine ok(refcount >= 1, "expected stream refcount != 0\n");
+ else
+ ok(refcount == 0, "expected stream refcount 0, got %d\n", refcount);
return image;
}
More information about the wine-cvs
mailing list