[PATCH 1/2] gdiplus/test: Add GdipGetNearestColor test [try 2]

Justin Chevrier jchevrier at gmail.com
Wed Feb 24 18:29:16 CST 2010


Thanks for reviewing the patch Vincent!

I'm reworking the test to use bitmaps but I've run into a problem.
I'm using GdipGetImageGraphicsContext to convert from a bitmap
to a graphic, this works fine at 16bpp and higher, but below that it
returns OutOfMemory on Window (seems that this function doesn't
accept palettized images). Thoughts on how to test at these
color depths?

Justin

On Tue, Feb 23, 2010 at 10:55 PM, Vincent Povirk
<madewokherd+8cd9 at gmail.com> wrote:
> You should probably use a Bitmap object rather than the display for
> this, since the pixel format is important. That should make it
> possible to test other depths, even though they can't yet be
> implemented properly in Wine.
>
> Also, you should mark tests that fail in wine with todo_wine and
> remove the todo_wine in any subsequent patches that fix them.
>
> On Tue, Feb 23, 2010 at 8:56 PM, Justin Chevrier <jchevrier at gmail.com> wrote:
>> ---
>>  dlls/gdiplus/tests/graphics.c |   45 +++++++++++++++++++++++++++++++++++++++++
>>  1 files changed, 45 insertions(+), 0 deletions(-)
>>
>> diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c
>> index 45bd9f7..97c520d 100644
>> --- a/dlls/gdiplus/tests/graphics.c
>> +++ b/dlls/gdiplus/tests/graphics.c
>> @@ -21,6 +21,7 @@
>>  #include "windows.h"
>>  #include "gdiplus.h"
>>  #include "wingdi.h"
>> +#include "winuser.h"
>>  #include "wine/test.h"
>>  #include <math.h>
>>
>> @@ -2270,6 +2271,49 @@ static void test_GdipIsVisibleRect(void)
>>     ReleaseDC(0, hdc);
>>  }
>>
>> +static void test_GdipGetNearestColor(void)
>> +{
>> +    GpStatus status;
>> +    GpGraphics *graphics = NULL;
>> +    ARGB color = 0xdeadbeef;
>> +    HDC hdc = GetDC(0);
>> +    DEVMODEA dmA;
>> +    BOOL ret;
>> +
>> +    /* create a graphics object */
>> +    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");
>> +
>> +    status = GdipGetNearestColor(graphics, NULL);
>> +    expect(InvalidParameter, status);
>> +
>> +    status = GdipGetNearestColor(NULL, &color);
>> +    expect(InvalidParameter, status);
>> +
>> +    ret = EnumDisplaySettingsA(NULL, ENUM_CURRENT_SETTINGS, &dmA);
>> +    if (!ret)
>> +    {
>> +        skip("Could not determine color depth\n");
>> +        goto end;
>> +    }
>> +
>> +    if (dmA.dmBitsPerPel >= 24)
>> +    {
>> +        status = GdipGetNearestColor(graphics, &color);
>> +        expect(Ok, status);
>> +        ok(color == 0xdeadbeef, "expected 0xdeadbeef, got: 0x%08x\n", color);
>> +    }
>> +    else
>> +        skip("Color depth less than 24bpp.\n");
>> +
>> +    end:
>> +    GdipDeleteGraphics(graphics);
>> +    ReleaseDC(0, hdc);
>> +}
>> +
>>  START_TEST(graphics)
>>  {
>>     struct GdiplusStartupInput gdiplusStartupInput;
>> @@ -2296,6 +2340,7 @@ START_TEST(graphics)
>>     test_GdipDrawLineI();
>>     test_GdipDrawLinesI();
>>     test_GdipDrawString();
>> +    test_GdipGetNearestColor();
>>     test_GdipGetVisibleClipBounds();
>>     test_GdipIsVisiblePoint();
>>     test_GdipIsVisibleRect();
>> --
>> 1.6.5.rc1
>>
>>
>>
>>
>
>
>



More information about the wine-devel mailing list