Signed-off-by: Fabian Maurer dark.shadow4@web.de --- dlls/user32/tests/cursoricon.c | 84 ++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+)
diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c index f84312f3ea2..dbe2b3a57f0 100644 --- a/dlls/user32/tests/cursoricon.c +++ b/dlls/user32/tests/cursoricon.c @@ -3094,6 +3094,89 @@ static void test_copy_image(void) } }
+/* The test the logic for the same function in user32 */ +static HBITMAP create_masked_bitmap( int width, int height, const void *and, const void *xor ) +{ + HDC dc = CreateCompatibleDC( 0 ); + HBITMAP bitmap; + int line_size = width/8; + const char* and2 = (const char*)and; + const char* xor2 = (const char*)xor; + char buffer[sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 2] = {0}; + + BITMAPINFO *bitmap_info = (BITMAPINFO*)buffer; + bitmap_info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bitmap_info->bmiHeader.biWidth = width; + bitmap_info->bmiHeader.biHeight = height * 2; + bitmap_info->bmiHeader.biPlanes = 1; + bitmap_info->bmiHeader.biBitCount = 1; + bitmap_info->bmiColors[1].rgbRed = 255; + bitmap_info->bmiColors[1].rgbGreen = 255; + bitmap_info->bmiColors[1].rgbBlue = 255; + + bitmap = CreateBitmap( width, height * 2, 1, 1, NULL ); + + for (int i = 0; i < height; i++) + { + SetDIBits( dc, bitmap, height - i - 1, 1, &xor2[i*line_size], bitmap_info, FALSE ); + SetDIBits( dc, bitmap, 2*height - i - 1, 1, &and2[i*line_size], bitmap_info, FALSE ); + } + DeleteDC( dc ); + return bitmap; +} + +static void check_monochrome_icon(HICON icon, int draw_flag, int line, BOOL todo) +{ + HDC dc = CreateCompatibleDC(0); + HBITMAP canvas = CreateCompatibleBitmap(dc, 32, 32); + + SelectObject(dc, canvas); + + DrawIconEx(dc, 0, 0, icon, 16, 16, 0, NULL, draw_flag); + + for (int i = 0; i < 16; i++) + { + COLORREF color = GetPixel(dc, i, 8); + int expect = i % 2 == 0 ? 0 : 0xFFFFFF; + todo_wine_if(todo && (i%2 != 0)) + ok_(__FILE__,line)(color == expect, "At index %d got %x\n", i, color); + } + DeleteObject(canvas); + DeleteDC(dc); +} + +static void test_monochrome_icon_creation(void) +{ + HCURSOR cursor; + HICON icon; + ICONINFO iconinfo = {0}; + static const unsigned char monochrome_bits[] = + { + 0xFF, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x55, 0x55, 0x00, 0x00, 0xAA, 0xAA, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xAA, 0xAA, 0x00, 0x00, + 0x55, 0x55, 0x00, 0x00, 0xAA, 0xAA, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + }; + + iconinfo.fIcon = 1; + iconinfo.hbmMask = create_masked_bitmap(16, 16, monochrome_bits, &monochrome_bits[32]); + + cursor = CreateCursor(0, 8, 8, 16, 16, monochrome_bits, &monochrome_bits[32]); + ok(cursor != NULL, "CreateCursor failed\n"); + check_monochrome_icon(cursor, DI_NORMAL, __LINE__, TRUE); + DestroyCursor(cursor); + + icon = CreateIcon(0, 16, 16, 1, 1, monochrome_bits, &monochrome_bits[32]); + ok(icon != NULL, "CreateIcon failed\n"); + check_monochrome_icon(icon, DI_NORMAL, __LINE__, TRUE); + DestroyIcon(icon); + + icon = CreateIconIndirect(&iconinfo); + ok(icon != NULL, "CreateIconIndirect failed\n"); + check_monochrome_icon(icon, DI_NORMAL, __LINE__, FALSE); + DestroyIcon(icon); +} + START_TEST(cursoricon) { pGetCursorInfo = (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetCursorInfo" ); @@ -3130,6 +3213,7 @@ START_TEST(cursoricon) test_DestroyCursor(); test_PrivateExtractIcons(); test_monochrome_icon(); + test_monochrome_icon_creation(); do_parent(); test_child_process(); finish_child_process(); -- 2.33.0
This fixes a regression from db2b266c57b73e1a16785213ce923b749c84400e. Multiple things here: 1) We must use a color table to avoid undefined behavior 2) We must set the bitmap line by line, in reverse
The same function is already used and tested in the previous patch.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51296 Signed-off-by: Fabian Maurer dark.shadow4@web.de --- dlls/user32/cursoricon.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c index 7ad0a04a551..605cd6a3f61 100644 --- a/dlls/user32/cursoricon.c +++ b/dlls/user32/cursoricon.c @@ -1574,19 +1574,28 @@ static HBITMAP create_masked_bitmap( int width, int height, const void *and, con { HDC dc = CreateCompatibleDC( 0 ); HBITMAP bitmap; - - const BITMAPINFO bitmap_info = - { - .bmiHeader.biSize = sizeof(BITMAPINFOHEADER), - .bmiHeader.biWidth = width, - .bmiHeader.biHeight = height * 2, - .bmiHeader.biPlanes = 1, - .bmiHeader.biBitCount = 1, - }; + int line_size = width/8; + const char* and2 = (const char*)and; + const char* xor2 = (const char*)xor; + char buffer[sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 2] = {0}; + + BITMAPINFO *bitmap_info = (BITMAPINFO*)buffer; + bitmap_info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bitmap_info->bmiHeader.biWidth = width; + bitmap_info->bmiHeader.biHeight = height * 2; + bitmap_info->bmiHeader.biPlanes = 1; + bitmap_info->bmiHeader.biBitCount = 1; + bitmap_info->bmiColors[1].rgbRed = 255; + bitmap_info->bmiColors[1].rgbGreen = 255; + bitmap_info->bmiColors[1].rgbBlue = 255;
bitmap = CreateBitmap( width, height * 2, 1, 1, NULL ); - SetDIBits( dc, bitmap, 0, height, and, &bitmap_info, FALSE ); - SetDIBits( dc, bitmap, height, height, xor, &bitmap_info, FALSE ); + + for (int i = 0; i < height; i++) + { + SetDIBits( dc, bitmap, height - i - 1, 1, &xor2[i*line_size], bitmap_info, FALSE ); + SetDIBits( dc, bitmap, 2*height - i - 1, 1, &and2[i*line_size], bitmap_info, FALSE ); + } DeleteDC( dc ); return bitmap; } -- 2.33.0
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=96063
Your paranoid android.
=== debiant2 (32 bit report) ===
user32: cursoricon.c:3166: Test succeeded inside todo block: At index 1 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 3 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 5 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 7 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 9 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 11 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 13 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 15 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 1 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 3 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 5 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 7 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 9 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 11 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 13 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 15 got ffffff
=== debiant2 (32 bit Chinese:China report) ===
user32: cursoricon.c:3166: Test succeeded inside todo block: At index 1 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 3 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 5 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 7 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 9 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 11 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 13 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 15 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 1 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 3 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 5 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 7 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 9 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 11 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 13 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 15 got ffffff
=== debiant2 (32 bit WoW report) ===
user32: cursoricon.c:3166: Test succeeded inside todo block: At index 1 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 3 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 5 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 7 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 9 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 11 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 13 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 15 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 1 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 3 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 5 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 7 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 9 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 11 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 13 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 15 got ffffff
=== debiant2 (64 bit WoW report) ===
user32: cursoricon.c:3166: Test succeeded inside todo block: At index 1 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 3 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 5 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 7 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 9 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 11 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 13 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 15 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 1 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 3 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 5 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 7 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 9 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 11 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 13 got ffffff cursoricon.c:3171: Test succeeded inside todo block: At index 15 got ffffff
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=96062
Your paranoid android.
=== w1064v1507 (32 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w1064v1809 (32 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w1064 (32 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w1064v1507 (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w1064v1809 (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w1064 (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w1064_2qxl (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w10pro64 (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w10pro64_ar (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w10pro64_he (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w10pro64_ja (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== w10pro64_zh_CN (64 bit report) ===
user32: cursoricon.c:2506: Test failed: cursor not shown in info cursoricon.c:2530: Test failed: cursor not shown in info cursoricon.c:2583: Test failed: cursor not shown in info cursoricon.c:2595: Test failed: cursor not shown in info
=== debiant2 (32 bit report) ===
user32: cursoricon.c:3166: Test failed: At index 0 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 1 got ffffff cursoricon.c:3166: Test failed: At index 2 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 3 got ffffff cursoricon.c:3166: Test failed: At index 4 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 5 got ffffff cursoricon.c:3166: Test failed: At index 6 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 7 got ffffff cursoricon.c:3166: Test failed: At index 8 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 9 got ffffff cursoricon.c:3166: Test failed: At index 10 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 11 got ffffff cursoricon.c:3166: Test failed: At index 12 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 13 got ffffff cursoricon.c:3166: Test failed: At index 14 got ffffff cursoricon.c:3166: Test succeeded inside todo block: At index 15 got ffffff