oleaut32: added PICTYPE_NONE and PICTYPE_UNINITIALIZED to IPicture::Render with test (try3)

Nikolay Sivov bunglehead at gmail.com
Wed Dec 10 06:11:43 CST 2008


Paul Vriens wrote:
> Nikolay Sivov wrote:
>> Changelog(try3):
>>     - fixed identation in testlist
>> Changelog(try2):
>>     - added PICTYPE_NONE and PICTYPE_UNINITIALIZED to 
>> IPicture::Render with test
>>     - added test for zero dimensions
>>
>> P.S. Render with this types spotted in traces of bugs 6799 and 10050
>>
>>> From 3386e8674380390c3b60c6247443c605ffe6ff6a Mon Sep 17 00:00:00 2001
>> From: Nikolay Sivov <bunglehead at gmail.com>
>> Date: Wed, 10 Dec 2008 13:41:09 +0300
>> Subject:  added PICTYPE_NONE and PICTYPE_UNINITIALIZED to 
>> IPicture::Render
>>
>> ---
>>  dlls/oleaut32/olepicture.c       |    8 +++++
>>  dlls/oleaut32/tests/olepicture.c |   64 
>> ++++++++++++++++++++++++++++++++++++++
>>  2 files changed, 72 insertions(+), 0 deletions(-)
>>
>> diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c
>> index 498ee53..bdce729 100644
>> --- a/dlls/oleaut32/olepicture.c
>> +++ b/dlls/oleaut32/olepicture.c
>> @@ -637,6 +637,10 @@ static HRESULT WINAPI 
>> OLEPictureImpl_Render(IPicture *iface, HDC hdc,
>>      TRACE("prcWBounds (%d,%d) - (%d,%d)\n", prcWBounds->left, 
>> prcWBounds->top,
>>        prcWBounds->right, prcWBounds->bottom);
>>  
>> +  if(cx == 0 || cy == 0 || cxSrc == 0 || cySrc == 0){
>> +    return CTL_E_INVALIDPROPERTYVALUE;
>> +  }
>> +
>>    /*
>>     * While the documentation suggests this to be here (or after 
>> rendering?)
>>     * it does cause an endless recursion in my sample app. -MM 20010804
>> @@ -644,6 +648,10 @@ static HRESULT WINAPI 
>> OLEPictureImpl_Render(IPicture *iface, HDC hdc,
>>     */
>>  
>>    switch(This->desc.picType) {
>> +  case PICTYPE_UNINITIALIZED:
>> +  case PICTYPE_NONE:
>> +    /* nothing to do */
>> +    return S_OK;
>>    case PICTYPE_BITMAP:
>>      {
>>        HBITMAP hbmpOld;
>> diff --git a/dlls/oleaut32/tests/olepicture.c 
>> b/dlls/oleaut32/tests/olepicture.c
>> index f81c419..9e33121 100644
>> --- a/dlls/oleaut32/tests/olepicture.c
>> +++ b/dlls/oleaut32/tests/olepicture.c
>> @@ -25,6 +25,7 @@
>>  #include <float.h>
>>  
>>  #define COBJMACROS
>> +#define NONAMELESSUNION
>>  
>>  #include "wine/test.h"
>>  #include <windef.h>
>> @@ -587,6 +588,68 @@ static void test_enhmetafile(void)
>>      GlobalFree(hglob);
>>  }
>>  
>> +static void test_Render(void)
>> +{
>> +    IPicture *pic;
>> +    HRESULT hres;
>> +    short type;
>> +    PICTDESC desc;
>> +    HDC hdc = GetDC(0);
>> +
>> +    /* test IPicture::Render return code on uninitialized picture */
>> +    OleCreatePictureIndirect(NULL, &IID_IPicture, TRUE, (VOID**)&pic);
>> +    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_UNINITIALIZED, "Expected type = 
>> PICTYPE_UNINITIALIZED, got = %d\n", type);
>> +    /* zero dimensions */
>> +    hres = IPicture_Render(pic, hdc, 0, 0, 0, 0, 0, 0, 0, 0, NULL);
>> +    ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE);
>> +    hres = IPicture_Render(pic, hdc, 0, 0, 10, 10, 0, 0, 10, 0, NULL);
>> +    ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE);
>> +    hres = IPicture_Render(pic, hdc, 0, 0, 10, 10, 0, 0, 0, 10, NULL);
>> +    ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE);
>> +    hres = IPicture_Render(pic, hdc, 0, 0, 10, 10, 0, 0, 0, 0, NULL);
>> +    ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE);
>> +    hres = IPicture_Render(pic, hdc, 0, 0, 0, 10, 0, 0, 10, 10, NULL);
>> +    ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE);
>> +    hres = IPicture_Render(pic, hdc, 0, 0, 10, 0, 0, 0, 10, 10, NULL);
>> +    ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE);
>> +    hres = IPicture_Render(pic, hdc, 0, 0, 0, 0, 0, 0, 10, 10, NULL);
>> +    ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE);
>> +    /* nonzero dimensions, PICTYPE_UNINITIALIZED */
>> +    hres = IPicture_Render(pic, hdc, 0, 0, 10, 10, 0, 0, 10, 10, NULL);
>> +    ole_expect(hres, S_OK);
>> +    IPicture_Release(pic);
>> +
>> +    desc.cbSizeofstruct = sizeof(PICTDESC);
>> +    desc.picType = PICTYPE_ICON;
>> +    desc.u.icon.hicon = LoadIcon(NULL, IDI_APPLICATION);
>> +    if(!desc.u.icon.hicon){
>> +        win_skip("LoadIcon failed. Skipping...\n");
>
> Shouldn't you also use ReleaseDC() here for consistency sake?
>
>> +        return;
>> +    }
>> +
>> +    OleCreatePictureIndirect(&desc, &IID_IPicture, TRUE, (VOID**)&pic);
>> +    /* zero dimensions, PICTYPE_ICON */
>> +    hres = IPicture_Render(pic, hdc, 0, 0, 0, 0, 0, 0, 0, 0, NULL);
>> +    ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE);
>> +    hres = IPicture_Render(pic, hdc, 0, 0, 10, 10, 0, 0, 10, 0, NULL);
>> +    ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE);
>> +    hres = IPicture_Render(pic, hdc, 0, 0, 10, 10, 0, 0, 0, 10, NULL);
>> +    ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE);
>> +    hres = IPicture_Render(pic, hdc, 0, 0, 10, 10, 0, 0, 0, 0, NULL);
>> +    ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE);
>> +    hres = IPicture_Render(pic, hdc, 0, 0, 0, 10, 0, 0, 10, 10, NULL);
>> +    ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE);
>> +    hres = IPicture_Render(pic, hdc, 0, 0, 10, 0, 0, 0, 10, 10, NULL);
>> +    ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE);
>> +    hres = IPicture_Render(pic, hdc, 0, 0, 0, 0, 0, 0, 10, 10, NULL);
>> +    ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE);
>> +    IPicture_Release(pic);
>> +
>> +    ReleaseDC(NULL, hdc);
>
>
Thank you for spotting this.



More information about the wine-devel mailing list