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

Justin Chevrier jchevrier at gmail.com
Tue Feb 23 20:39:29 CST 2010


---
 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..3c286b7 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%6x\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-patches mailing list