[PATCH] Fix ::get_hPal() behaviour for certain picture types

Nikolay Sivov nsivov at codeweavers.com
Tue Aug 24 13:45:34 CDT 2010


---
 dlls/oleaut32/olepicture.c       |    9 +---
 dlls/oleaut32/tests/olepicture.c |   80 ++++++++++++++++++++++++++++---------
 2 files changed, 63 insertions(+), 26 deletions(-)

diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c
index aaab2a1..2c29280 100644
--- a/dlls/oleaut32/olepicture.c
+++ b/dlls/oleaut32/olepicture.c
@@ -543,18 +543,15 @@ static HRESULT WINAPI OLEPictureImpl_get_hPal(IPicture *iface,
     return E_POINTER;
 
   switch (This->desc.picType) {
-    case (UINT)PICTYPE_UNINITIALIZED:
+    case PICTYPE_UNINITIALIZED:
     case PICTYPE_NONE:
-      *phandle = 0;
-      hres = S_FALSE;
+    case PICTYPE_METAFILE:
+      hres = E_FAIL;
       break;
     case PICTYPE_BITMAP:
       *phandle = HandleToUlong(This->desc.u.bmp.hpal);
       hres = S_OK;
       break;
-    case PICTYPE_METAFILE:
-      hres = E_FAIL;
-      break;
     case PICTYPE_ICON:
     case PICTYPE_ENHMETAFILE:
     default:
diff --git a/dlls/oleaut32/tests/olepicture.c b/dlls/oleaut32/tests/olepicture.c
index 03d47db..faa502a 100644
--- a/dlls/oleaut32/tests/olepicture.c
+++ b/dlls/oleaut32/tests/olepicture.c
@@ -740,6 +740,45 @@ static void test_get_Handle(void)
     IPicture_Release(pic);
 }
 
+static void test_get_hPal(void)
+{
+    IPicture *pic;
+    HRESULT hr;
+    SHORT type;
+    OLE_HANDLE handle;
+    PICTDESC desc;
+
+    hr = OleCreatePictureIndirect(NULL, &IID_IPicture, TRUE, (void**)&pic);
+    ole_expect(hr, S_OK);
+
+    hr = IPicture_get_hPal(pic, NULL);
+    ole_expect(hr, E_POINTER);
+
+    type = PICTYPE_NONE;
+    hr = IPicture_get_Type(pic, &type);
+    ole_expect(hr, S_OK);
+    ok(type == PICTYPE_UNINITIALIZED, "got %d\n", type);
+
+    handle = 0xdeadbeef;
+    hr = IPicture_get_hPal(pic, &handle);
+    ole_expect(hr, E_FAIL);
+    ok(handle == 0xdeadbeef, "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_hPal(pic, &handle);
+    ole_expect(hr, E_FAIL);
+    ok(handle == 0xdeadbeef, "got %x\n", handle);
+
+    IPicture_Release(pic);
+}
+
 static void test_get_Type(void)
 {
     IPicture *pic;
@@ -968,33 +1007,34 @@ static void test_himetric(void)
 
 START_TEST(olepicture)
 {
-	hOleaut32 = GetModuleHandleA("oleaut32.dll");
-	pOleLoadPicture = (void*)GetProcAddress(hOleaut32, "OleLoadPicture");
-	pOleCreatePictureIndirect = (void*)GetProcAddress(hOleaut32, "OleCreatePictureIndirect");
-	if (!pOleLoadPicture)
-	{
-	    win_skip("OleLoadPicture is not available\n");
-	    return;
-	}
+    hOleaut32 = GetModuleHandleA("oleaut32.dll");
+    pOleLoadPicture = (void*)GetProcAddress(hOleaut32, "OleLoadPicture");
+    pOleCreatePictureIndirect = (void*)GetProcAddress(hOleaut32, "OleCreatePictureIndirect");
+    if (!pOleLoadPicture)
+    {
+        win_skip("OleLoadPicture is not available\n");
+        return;
+    }
 
-	/* Test regular 1x1 pixel images of gif, jpg, bmp type */
-        test_pic(gifimage, sizeof(gifimage));
-	test_pic(jpgimage, sizeof(jpgimage));
-	test_pic(bmpimage, sizeof(bmpimage));
-        test_pic(gif4pixel, sizeof(gif4pixel));
-	/* FIXME: No PNG support in Windows... */
-	if (0) test_pic(pngimage, sizeof(pngimage));
-	test_empty_image();
-	test_empty_image_2();
-        test_apm();
-        test_metafile();
-        test_enhmetafile();
+    /* Test regular 1x1 pixel images of gif, jpg, bmp type */
+    test_pic(gifimage, sizeof(gifimage));
+    test_pic(jpgimage, sizeof(jpgimage));
+    test_pic(bmpimage, sizeof(bmpimage));
+    test_pic(gif4pixel, sizeof(gif4pixel));
+    /* FIXME: No PNG support in Windows... */
+    if (0) test_pic(pngimage, sizeof(pngimage));
+    test_empty_image();
+    test_empty_image_2();
+    test_apm();
+    test_metafile();
+    test_enhmetafile();
 
     test_Invoke();
     test_OleCreatePictureIndirect();
     test_Render();
     test_get_Attributes();
     test_get_Handle();
+    test_get_hPal();
     test_get_Type();
     test_OleLoadPicturePath();
     test_himetric();
-- 
1.5.6.5



--------------040601040906010309080003--



More information about the wine-patches mailing list