[PATCH 1/3] gdiplus/test: Add GdipGetNearestColor test [Try 4]

Justin Chevrier jchevrier at gmail.com
Thu Feb 25 19:41:02 CST 2010


Thanks to Vincent Povirk for testing and coding for Win7 cases.
---
 dlls/gdiplus/tests/graphics.c |  153 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 153 insertions(+), 0 deletions(-)

diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c
index 45bd9f7..32d115e 100644
--- a/dlls/gdiplus/tests/graphics.c
+++ b/dlls/gdiplus/tests/graphics.c
@@ -2270,6 +2270,158 @@ static void test_GdipIsVisibleRect(void)
     ReleaseDC(0, hdc);
 }
 
+static void test_GdipGetNearestColor(void)
+{
+    GpStatus status;
+    GpGraphics *graphics;
+    GpBitmap *bitmap;
+    ARGB color = 0xdeadbeef;
+    HDC hdc = GetDC(0);
+
+    /* 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);
+    GdipDeleteGraphics(graphics);
+
+    status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat1bppIndexed, NULL, &bitmap);
+    expect(Ok, status);
+    status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
+    ok(broken(status == OutOfMemory) /* winver < Win7 */ || status == Ok, "status=%u\n", status);
+    if (status == Ok)
+    {
+        status = GdipGetNearestColor(graphics, &color);
+        todo_wine expect(Ok, status);
+        expect(0xdeadbeef, color);
+        GdipDeleteGraphics(graphics);
+    }
+    GdipDisposeImage((GpImage*)bitmap);
+
+    status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat4bppIndexed, NULL, &bitmap);
+    expect(Ok, status);
+    status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
+    ok(broken(status == OutOfMemory) /* winver < Win7 */ || status == Ok, "status=%u\n", status);
+    if (status == Ok)
+    {
+        status = GdipGetNearestColor(graphics, &color);
+        todo_wine expect(Ok, status);
+        expect(0xdeadbeef, color);
+        GdipDeleteGraphics(graphics);
+    }
+    GdipDisposeImage((GpImage*)bitmap);
+
+    status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat8bppIndexed, NULL, &bitmap);
+    expect(Ok, status);
+    status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
+    ok(broken(status == OutOfMemory) /* winver < Win7 */ || status == Ok, "status=%u\n", status);
+    if (status == Ok)
+    {
+        status = GdipGetNearestColor(graphics, &color);
+        todo_wine expect(Ok, status);
+        expect(0xdeadbeef, color);
+        GdipDeleteGraphics(graphics);
+    }
+    GdipDisposeImage((GpImage*)bitmap);
+
+    status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppGrayScale, NULL, &bitmap);
+    expect(Ok, status);
+    status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
+    todo_wine expect(OutOfMemory, status);
+    if (status == Ok)
+        GdipDeleteGraphics(graphics);
+    GdipDisposeImage((GpImage*)bitmap);
+
+    status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB, NULL, &bitmap);
+    expect(Ok, status);
+    status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
+    expect(Ok, status);
+    status = GdipGetNearestColor(graphics, &color);
+    todo_wine expect(Ok, status);
+    expect(0xdeadbeef, color);
+    GdipDeleteGraphics(graphics);
+    GdipDisposeImage((GpImage*)bitmap);
+
+    status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppRGB, NULL, &bitmap);
+    expect(Ok, status);
+    status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
+    expect(Ok, status);
+    status = GdipGetNearestColor(graphics, &color);
+    todo_wine expect(Ok, status);
+    expect(0xdeadbeef, color);
+    GdipDeleteGraphics(graphics);
+    GdipDisposeImage((GpImage*)bitmap);
+
+    status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppARGB, NULL, &bitmap);
+    expect(Ok, status);
+    status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
+    expect(Ok, status);
+    status = GdipGetNearestColor(graphics, &color);
+    todo_wine expect(Ok, status);
+    expect(0xdeadbeef, color);
+    GdipDeleteGraphics(graphics);
+    GdipDisposeImage((GpImage*)bitmap);
+
+    status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB, NULL, &bitmap);
+    expect(Ok, status);
+    status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
+    expect(Ok, status);
+    status = GdipGetNearestColor(graphics, &color);
+    todo_wine expect(Ok, status);
+    expect(0xdeadbeef, color);
+    GdipDeleteGraphics(graphics);
+    GdipDisposeImage((GpImage*)bitmap);
+
+    status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB, NULL, &bitmap);
+    expect(Ok, status);
+    status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
+    expect(Ok, status);
+    status = GdipGetNearestColor(graphics, &color);
+    todo_wine expect(Ok, status);
+    expect(0xdeadbeef, color);
+    GdipDeleteGraphics(graphics);
+    GdipDisposeImage((GpImage*)bitmap);
+
+    status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB, NULL, &bitmap);
+    expect(Ok, status);
+    status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
+    expect(Ok, status);
+    status = GdipGetNearestColor(graphics, &color);
+    todo_wine expect(Ok, status);
+    expect(0xdeadbeef, color);
+    GdipDeleteGraphics(graphics);
+    GdipDisposeImage((GpImage*)bitmap);
+
+    status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565, NULL, &bitmap);
+    expect(Ok, status);
+    status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
+    expect(Ok, status);
+    status = GdipGetNearestColor(graphics, &color);
+    todo_wine expect(Ok, status);
+    todo_wine expect(0xffa8bce8, color);
+    GdipDeleteGraphics(graphics);
+    GdipDisposeImage((GpImage*)bitmap);
+
+    status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB555, NULL, &bitmap);
+    expect(Ok, status);
+    status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
+    expect(Ok, status);
+    status = GdipGetNearestColor(graphics, &color);
+    todo_wine expect(Ok, status);
+    todo_wine expect(0xffa8b8e8, color);
+    GdipDeleteGraphics(graphics);
+    GdipDisposeImage((GpImage*)bitmap);
+
+    ReleaseDC(0, hdc);
+}
+
 START_TEST(graphics)
 {
     struct GdiplusStartupInput gdiplusStartupInput;
@@ -2296,6 +2448,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-patches mailing list