[PATCH] Some tests for IPicture::get_Handle()

Nikolay Sivov nsivov at codeweavers.com
Tue Aug 24 13:55:10 CDT 2010


---
 dlls/oleaut32/olepicture.c       |    4 +--
 dlls/oleaut32/tests/olepicture.c |   55 +++++++++++++++++++++++++++++--------
 2 files changed, 44 insertions(+), 15 deletions(-)

diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c
index 2c29280..9f44320 100644
--- a/dlls/oleaut32/olepicture.c
+++ b/dlls/oleaut32/olepicture.c
@@ -273,9 +273,7 @@ static OLEPictureImpl* OLEPictureImpl_Construct(LPPICTDESC pictDesc, BOOL fOwn)
    * Allocate space for the object.
    */
   newObject = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(OLEPictureImpl));
-
-  if (newObject==0)
-    return newObject;
+  if (!newObject) return NULL;
 
   /*
    * Initialize the virtual function table.
diff --git a/dlls/oleaut32/tests/olepicture.c b/dlls/oleaut32/tests/olepicture.c
index faa502a..060b77a 100644
--- a/dlls/oleaut32/tests/olepicture.c
+++ b/dlls/oleaut32/tests/olepicture.c
@@ -233,17 +233,17 @@ test_pic_with_stream(LPSTREAM stream, unsigned int imgsize)
 	ok(hres == S_OK,"IPicture_get_Height does not return S_OK, but 0x%08x\n", hres);
 	ok(height != 0, "IPicture_get_Height returns 0, but it should not be 0.\n");
 
-	type = 0;
+	type = PICTYPE_NONE;
 	hres = IPicture_get_Type (pic, &type);
 	ok(hres == S_OK,"IPicture_get_Type does not return S_OK, but 0x%08x\n", hres);
 	ok(type == PICTYPE_BITMAP, "IPicture_get_Type returns %d, but it should be PICTYPE_BITMAP(%d).\n", type, PICTYPE_BITMAP);
 
-	attr = 0;
+	attr = ~0;
 	hres = IPicture_get_Attributes (pic, &attr);
 	ok(hres == S_OK,"IPicture_get_Attributes does not return S_OK, but 0x%08x\n", hres);
 	ok(attr == 0, "IPicture_get_Attributes returns %d, but it should be 0.\n", attr);
 
-	hPal = 0;
+	hPal = 0xdeadbeef;
 	hres = IPicture_get_hPal (pic, &hPal);
 	ok(hres == S_OK,"IPicture_get_hPal does not return S_OK, but 0x%08x\n", hres);
 	/* a single pixel b/w image has no palette */
@@ -520,6 +520,7 @@ static void test_apm(void)
     LPSTREAM stream;
     IPicture *pict;
     HGLOBAL hglob;
+    HRESULT hr;
     LPBYTE *data;
     LONG cxy;
     BOOL keep;
@@ -532,19 +533,29 @@ static void test_apm(void)
     ole_check(CreateStreamOnHGlobal(hglob, TRUE, &stream));
     ole_check(OleLoadPictureEx(stream, sizeof(apmdata), TRUE, &IID_IPicture, 100, 100, 0, (LPVOID *)&pict));
 
-    ole_check(IPicture_get_Handle(pict, &handle));
+    handle = 0;
+    hr = IPicture_get_Handle(pict, &handle);
+    ole_expect(hr, S_OK);
     ok(handle != 0, "handle is null\n");
 
-    ole_check(IPicture_get_Type(pict, &type));
+    type = PICTYPE_NONE;
+    hr = IPicture_get_Type(pict, &type);
+    ole_expect(hr, S_OK);
     expect_eq(type, PICTYPE_METAFILE, short, "%d");
 
-    ole_check(IPicture_get_Height(pict, &cxy));
+    cxy = 0;
+    hr = IPicture_get_Height(pict, &cxy);
+    ole_expect(hr, S_OK);
     expect_eq(cxy,  1667, LONG, "%d");
 
-    ole_check(IPicture_get_Width(pict, &cxy));
+    cxy = 0;
+    hr = IPicture_get_Width(pict, &cxy);
+    ole_expect(hr, S_OK);
     expect_eq(cxy,  1323, LONG, "%d");
 
-    ole_check(IPicture_get_KeepOriginalFormat(pict, &keep));
+    keep = TRUE;
+    hr = IPicture_get_KeepOriginalFormat(pict, &keep);
+    ole_expect(hr, S_OK);
     todo_wine expect_eq(keep, FALSE, LONG, "%d");
 
     ole_expect(IPicture_get_hPal(pict, &handle), E_FAIL);
@@ -729,13 +740,33 @@ static void test_get_Attributes(void)
 
 static void test_get_Handle(void)
 {
+    OLE_HANDLE handle;
+    PICTDESC desc;
     IPicture *pic;
-    HRESULT hres;
+    HRESULT hr;
 
-    OleCreatePictureIndirect(NULL, &IID_IPicture, TRUE, (VOID**)&pic);
+    hr = OleCreatePictureIndirect(NULL, &IID_IPicture, TRUE, (void**)&pic);
+    ole_expect(hr, S_OK);
 
-    hres = IPicture_get_Handle(pic, NULL);
-    ole_expect(hres, E_POINTER);
+    hr = IPicture_get_Handle(pic, NULL);
+    ole_expect(hr, E_POINTER);
+
+    handle = 0xdeadbeef;
+    hr = IPicture_get_Handle(pic, &handle);
+    ole_expect(hr, S_OK);
+    ok(handle == 0, "got %x\n", handle);
+
+    IPicture_Release(pic);
+
+    /* PICTYPE_NONE */
+    desc.picType = PICTYPE_NONE;
+    hr = OleCreatePictureIndirect(&desc, &IID_IPicture, TRUE, (void**)&pic);
+    ole_expect(hr, S_OK);
+
+    handle = 0xdeadbeef;
+    hr = IPicture_get_Handle(pic, &handle);
+    ole_expect(hr, S_OK);
+    ok(handle == 0, "got %x\n", handle);
 
     IPicture_Release(pic);
 }
-- 
1.5.6.5



--------------010408060800050303000309--



More information about the wine-patches mailing list