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

This commit is contained in:
Alexandre Julliard 2011-11-16 18:08:12 +01:00
parent f7a4cabb46
commit 3bbb208f8e
2 changed files with 31 additions and 14 deletions

View file

@ -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 );

View file

@ -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);