Francois Gouget : gdi32/tests: Dynamically load GdiAlphaBlend() so the test runs on Win9x.

Alexandre Julliard julliard at winehq.org
Fri Nov 9 07:44:26 CST 2007


Module: wine
Branch: master
Commit: 2bbfc931d10c073658b41e2f2091c232d57ebb7e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2bbfc931d10c073658b41e2f2091c232d57ebb7e

Author: Francois Gouget <fgouget at free.fr>
Date:   Fri Nov  9 12:39:19 2007 +0100

gdi32/tests: Dynamically load GdiAlphaBlend() so the test runs on Win9x.

---

 dlls/gdi32/tests/bitmap.c |   45 +++++++++++++++++++++++++++++++--------------
 1 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c
index e1e4437..6f87e29 100644
--- a/dlls/gdi32/tests/bitmap.c
+++ b/dlls/gdi32/tests/bitmap.c
@@ -31,6 +31,8 @@
 
 #include "wine/test.h"
 
+static BOOL (WINAPI *pGdiAlphaBlend)(HDC,int,int,int,int,HDC,int,int,int,int,BLENDFUNCTION);
+
 #define expect_eq(expr, value, type, format) { type ret = (expr); ok((value) == ret, #expr " expected " format " got " format "\n", value, ret); }
 
 static BOOL is_win9x;
@@ -1836,20 +1838,31 @@ static void test_get16dibits(void)
 void test_GdiAlphaBlend()
 {
     /* test out-of-bound parameters for GdiAlphaBlend */
-    HDC hdcNull = GetDC(NULL);
+    HDC hdcNull;
 
-    HDC hdcDst = CreateCompatibleDC(hdcNull);
-    HBITMAP bmpDst = CreateCompatibleBitmap(hdcNull, 100, 100);
+    HDC hdcDst;
+    HBITMAP bmpDst;
     HBITMAP oldDst;
 
     BITMAPINFO bmi;
-    HDC hdcSrc = CreateCompatibleDC(hdcNull);
+    HDC hdcSrc;
     HBITMAP bmpSrc;
     HBITMAP oldSrc;
     LPVOID bits;
 
     BLENDFUNCTION blend;
 
+    if (!pGdiAlphaBlend)
+    {
+        skip("GdiAlphaBlend() is not implemented\n");
+        return;
+    }
+
+    hdcNull = GetDC(NULL);
+    hdcDst = CreateCompatibleDC(hdcNull);
+    bmpDst = CreateCompatibleBitmap(hdcNull, 100, 100);
+    hdcSrc = CreateCompatibleDC(hdcNull);
+
     memset(&bmi, 0, sizeof(bmi));  /* as of Wine 0.9.44 we require the src to be a DIB section */
     bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
     bmi.bmiHeader.biHeight = 20;
@@ -1868,22 +1881,22 @@ void test_GdiAlphaBlend()
     blend.SourceConstantAlpha = 128;
     blend.AlphaFormat = 0;
 
-    expect_eq(GdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, 0, 20, 20, blend), TRUE, BOOL, "%d");
+    expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, 0, 20, 20, blend), TRUE, BOOL, "%d");
     SetLastError(0xdeadbeef);
-    expect_eq(GdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, -1, 0, 10, 10, blend), FALSE, BOOL, "%d");
+    expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, -1, 0, 10, 10, blend), FALSE, BOOL, "%d");
     expect_eq(GetLastError(), ERROR_INVALID_PARAMETER, int, "%d");
-    expect_eq(GdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, -1, 10, 10, blend), FALSE, BOOL, "%d");
-    expect_eq(GdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 15, 0, 10, 10, blend), FALSE, BOOL, "%d");
-    expect_eq(GdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 10, 10, -2, 3, blend), FALSE, BOOL, "%d");
-    expect_eq(GdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 10, 10, -2, 3, blend), FALSE, BOOL, "%d");
+    expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, -1, 10, 10, blend), FALSE, BOOL, "%d");
+    expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 15, 0, 10, 10, blend), FALSE, BOOL, "%d");
+    expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 10, 10, -2, 3, blend), FALSE, BOOL, "%d");
+    expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 10, 10, -2, 3, blend), FALSE, BOOL, "%d");
 
     SetWindowOrgEx(hdcSrc, -10, -10, NULL);
-    expect_eq(GdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, -1, 0, 10, 10, blend), TRUE, BOOL, "%d");
-    expect_eq(GdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, -1, 10, 10, blend), TRUE, BOOL, "%d");
+    expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, -1, 0, 10, 10, blend), TRUE, BOOL, "%d");
+    expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, -1, 10, 10, blend), TRUE, BOOL, "%d");
     SetMapMode(hdcSrc, MM_ANISOTROPIC);
     ScaleWindowExtEx(hdcSrc, 10, 1, 10, 1, NULL);
-    expect_eq(GdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, -1, 0, 30, 30, blend), TRUE, BOOL, "%d");
-    expect_eq(GdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, -1, 30, 30, blend), TRUE, BOOL, "%d");
+    expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, -1, 0, 30, 30, blend), TRUE, BOOL, "%d");
+    expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, -1, 30, 30, blend), TRUE, BOOL, "%d");
 
     SelectObject(hdcDst, oldDst);
     SelectObject(hdcSrc, oldSrc);
@@ -1898,8 +1911,12 @@ void test_GdiAlphaBlend()
 
 START_TEST(bitmap)
 {
+    HMODULE hdll;
     is_win9x = GetWindowLongPtrW(GetDesktopWindow(), GWLP_WNDPROC) == 0;
 
+    hdll = GetModuleHandle("gdi32.dll");
+    pGdiAlphaBlend = (void*)GetProcAddress(hdll, "GdiAlphaBlend");
+
     test_createdibitmap();
     test_dibsections();
     test_mono_dibsection();




More information about the wine-cvs mailing list