Alexandre Julliard : user32/tests: Add tests for small sizes of cursor bitmaps.

Alexandre Julliard julliard at winehq.org
Wed Nov 16 12:46:47 CST 2011


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Nov 16 18:08:12 2011 +0100

user32/tests: Add tests for small sizes of cursor bitmaps.

---

 dlls/user32/cursoricon.c       |    2 +-
 dlls/user32/tests/cursoricon.c |   43 +++++++++++++++++++++++++++------------
 2 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c
index 7475ecab..4ae7098 100644
--- a/dlls/user32/cursoricon.c
+++ b/dlls/user32/cursoricon.c
@@ -2116,7 +2116,7 @@ HICON WINAPI CreateIconIndirect(PICONINFO iconinfo)
 
         width = bmpXor.bmWidth;
         height = bmpXor.bmHeight;
-        if (bmpXor.bmPlanes * bmpXor.bmBitsPixel != 1)
+        if (bmpXor.bmPlanes * bmpXor.bmBitsPixel != 1 || bmpAnd.bmPlanes * bmpAnd.bmBitsPixel != 1)
         {
             color = CreateCompatibleBitmap( screen_dc, width, height );
             mask = CreateBitmap( width, height, 1, 1, NULL );
diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c
index 8a0d7c3..4a570ae 100644
--- a/dlls/user32/tests/cursoricon.c
+++ b/dlls/user32/tests/cursoricon.c
@@ -696,7 +696,7 @@ static void test_initial_cursor(void)
     ok(error == 0xdeadbeef, "Last error: 0x%08x\n", error);
 }
 
-static void test_icon_info_dbg(HICON hIcon, UINT exp_cx, UINT exp_cy, UINT exp_bpp, int line)
+static void test_icon_info_dbg(HICON hIcon, UINT exp_cx, UINT exp_cy, UINT exp_mask_cy, UINT exp_bpp, int line)
 {
     ICONINFO info;
     DWORD ret;
@@ -736,13 +736,13 @@ static void test_icon_info_dbg(HICON hIcon, UINT exp_cx, UINT exp_cy, UINT exp_b
 
         ok_(__FILE__, line)(bmMask.bmBitsPixel == 1, "bmMask.bmBitsPixel = %d\n", bmMask.bmBitsPixel);
         ok_(__FILE__, line)(bmMask.bmWidth == exp_cx, "bmMask.bmWidth = %d\n", bmMask.bmWidth);
-        ok_(__FILE__, line)(bmMask.bmHeight == exp_cy, "bmMask.bmHeight = %d\n", bmMask.bmHeight);
+        ok_(__FILE__, line)(bmMask.bmHeight == exp_mask_cy, "bmMask.bmHeight = %d\n", bmMask.bmHeight);
     }
     else
     {
         ok_(__FILE__, line)(bmMask.bmBitsPixel == 1, "bmMask.bmBitsPixel = %d\n", bmMask.bmBitsPixel);
         ok_(__FILE__, line)(bmMask.bmWidth == exp_cx, "bmMask.bmWidth = %d\n", bmMask.bmWidth);
-        ok_(__FILE__, line)(bmMask.bmHeight == exp_cy * 2, "bmMask.bmHeight = %d\n", bmMask.bmHeight);
+        ok_(__FILE__, line)(bmMask.bmHeight == exp_mask_cy, "bmMask.bmHeight = %d\n", bmMask.bmHeight);
     }
     if (pGetIconInfoExA)
     {
@@ -777,7 +777,7 @@ static void test_icon_info_dbg(HICON hIcon, UINT exp_cx, UINT exp_cy, UINT exp_b
     }
 }
 
-#define test_icon_info(a,b,c,d) test_icon_info_dbg((a),(b),(c),(d),__LINE__)
+#define test_icon_info(a,b,c,d,e) test_icon_info_dbg((a),(b),(c),(d),(e),__LINE__)
 
 static void test_CreateIcon(void)
 {
@@ -789,6 +789,7 @@ static void test_CreateIcon(void)
     HDC hdc;
     void *bits;
     UINT display_bpp;
+    int i;
 
     hdc = GetDC(0);
     display_bpp = GetDeviceCaps(hdc, BITSPIXEL);
@@ -800,12 +801,12 @@ static void test_CreateIcon(void)
 
     hIcon = CreateIcon(0, 16, 16, 1, 1, bmp_bits, bmp_bits);
     ok(hIcon != 0, "CreateIcon failed\n");
-    test_icon_info(hIcon, 16, 16, 1);
+    test_icon_info(hIcon, 16, 16, 32, 1);
     DestroyIcon(hIcon);
 
     hIcon = CreateIcon(0, 16, 16, 1, display_bpp, bmp_bits, bmp_bits);
     ok(hIcon != 0, "CreateIcon failed\n");
-    test_icon_info(hIcon, 16, 16, display_bpp);
+    test_icon_info(hIcon, 16, 16, 16, display_bpp);
     DestroyIcon(hIcon);
 
     hbmMask = CreateBitmap(16, 16, 1, 1, bmp_bits);
@@ -840,7 +841,7 @@ static void test_CreateIcon(void)
     info.hbmColor = hbmColor;
     hIcon = CreateIconIndirect(&info);
     ok(hIcon != 0, "CreateIconIndirect failed\n");
-    test_icon_info(hIcon, 16, 16, display_bpp);
+    test_icon_info(hIcon, 16, 16, 16, display_bpp);
     DestroyIcon(hIcon);
 
     DeleteObject(hbmMask);
@@ -857,11 +858,27 @@ static void test_CreateIcon(void)
     SetLastError(0xdeadbeaf);
     hIcon = CreateIconIndirect(&info);
     ok(hIcon != 0, "CreateIconIndirect failed\n");
-    test_icon_info(hIcon, 16, 16, 1);
+    test_icon_info(hIcon, 16, 16, 32, 1);
     DestroyIcon(hIcon);
-
     DeleteObject(hbmMask);
-    DeleteObject(hbmColor);
+
+    for (i = 0; i <= 4; i++)
+    {
+        hbmMask = CreateBitmap(1, i, 1, 1, bmp_bits);
+        ok(hbmMask != 0, "CreateBitmap failed\n");
+
+        info.fIcon = TRUE;
+        info.xHotspot = 0;
+        info.yHotspot = 0;
+        info.hbmMask = hbmMask;
+        info.hbmColor = 0;
+        SetLastError(0xdeadbeaf);
+        hIcon = CreateIconIndirect(&info);
+        ok(hIcon != 0, "CreateIconIndirect failed\n");
+        test_icon_info(hIcon, 1, i / 2, max(i,1), 1);
+        DestroyIcon(hIcon);
+        DeleteObject(hbmMask);
+    }
 
     /* test creating an icon from a DIB section */
 
@@ -890,7 +907,7 @@ static void test_CreateIcon(void)
     SetLastError(0xdeadbeaf);
     hIcon = CreateIconIndirect(&info);
     ok(hIcon != 0, "CreateIconIndirect failed\n");
-    test_icon_info(hIcon, 32, 32, 8);
+    test_icon_info(hIcon, 32, 32, 32, 8);
     DestroyIcon(hIcon);
     DeleteObject(hbmColor);
 
@@ -908,7 +925,7 @@ static void test_CreateIcon(void)
     SetLastError(0xdeadbeaf);
     hIcon = CreateIconIndirect(&info);
     ok(hIcon != 0, "CreateIconIndirect failed\n");
-    test_icon_info(hIcon, 32, 32, 8);
+    test_icon_info(hIcon, 32, 32, 32, 8);
     DestroyIcon(hIcon);
     DeleteObject(hbmColor);
 
@@ -926,7 +943,7 @@ static void test_CreateIcon(void)
     SetLastError(0xdeadbeaf);
     hIcon = CreateIconIndirect(&info);
     ok(hIcon != 0, "CreateIconIndirect failed\n");
-    test_icon_info(hIcon, 32, 32, 8);
+    test_icon_info(hIcon, 32, 32, 32, 8);
     DestroyIcon(hIcon);
 
     DeleteObject(hbmMask);




More information about the wine-cvs mailing list