gdiplus: Add test cases for GdipDrawCurve

Paul Vriens paul.vriens.wine at gmail.com
Wed Jun 3 01:02:35 CDT 2009


Andrew Eikum wrote:
> Vincent Povirk wrote:
>> +    /* make a graphics object and pen object */
>>
>> +    status = GdipCreateFromHDC(hdc, &graphics);
>>
>> +    expect(Ok, status);
>>
>> +    ok(hdc != NULL, "Expected HDC to be initialized\n");
>>
>> +
>>
>> +    status = GdipCreateFromHDC(hdc, &graphics);
>>
>> +    expect(Ok, status);
>>
>> +    ok(graphics != NULL, "Expected graphics to be initialized\n");
>>
>>
>> You're creating two graphics objects here and leaking the first one.
>>
>> Vincent Povirk
>>
>>
>>
>> On Tue, Jun 2, 2009 at 10:39 PM, Andrew
>> Eikum<andrew at brightnightgames.com> wrote:
>>  
>>> Tested on WinXP Professional SP3 and Win7 Ultimate RC1, all pass.
>>>
>>> ---
>>>  dlls/gdiplus/tests/graphics.c |   64 
>>> +++++++++++++++++++++++++++++++++++++++++
>>>  1 files changed, 64 insertions(+), 0 deletions(-)
>>>
>>>
>>>
>>>
>>>     
> You're right.  I copied that code from the test_GdipDrawBezierI test, 
> which has the same problem.  Would removing the first two non-comment 
> lines of the quoted section resolve the problem?
> 
> Also, how should one handle critical errors in tests?  For example, if 
> hdc is null, the rest of the test cannot continue.  Should this be 
> detected and exit early?  Or just let the test crash?
> 
Hi Andrew,

Tests should never crash (on any platform). I think in this particular
case we can safely assume that GetDC(0) returns a handle.

There are several ways to handle critical errors:

- do a test and bail out if the behavior is not expected:
    hdc = GetDC(0);
    ok(hdc != NULL, "Expected hdc to be initialized\n");
    if (!hdc)
    {
       cleanup if needed;
       return;
    }
    rest_of_the_tests_that_use_hdc();

- if behavior is expected (on any platform including Wine) we can use skip:
    hdc = GetDC(0);
    if (!hdc && GetLastError() == SOME_VALID_ERROR)
    {
       skip("Some message that we skip tests for a known reason\");
       cleanup if needed;
       return;
    }
    rest_of_the_tests_that_use_hdc();

- if behavior is expected on a particular Windows platform but not on Wine:
    hdc = GetDC(0);
    if (!hdc && GetLastError() == SOME_VALID_ERROR)
    {
       win_skip("Some message that we skip tests for a known reason\");
       cleanup if needed;
       return;
    }
    rest_of_the_tests_that_use_hdc();

These examples are not exhaustive but should give you an idea how to
handle errors.

Bottom line is that we don't want crashes and we don't want test
failures on any platform. That last one is a challenge as you can see on
  http://test.winehq.org.

-- 
Cheers,

Paul.





More information about the wine-devel mailing list