Dmitry Timoshkov : comctl32/tests: Add more tests for Static/SS_BITMAP control.
Module: wine Branch: master Commit: 2c4f5c0eab4094f13374dc1713eed26fdd91ddc9 URL: https://source.winehq.org/git/wine.git/?a=commit;h=2c4f5c0eab4094f13374dc171... Author: Dmitry Timoshkov <dmitry(a)baikal.ru> Date: Mon Feb 10 16:31:44 2020 +0800 comctl32/tests: Add more tests for Static/SS_BITMAP control. Signed-off-by: Dmitry Timoshkov <dmitry(a)baikal.ru> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/comctl32/tests/static.c | 58 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 7 deletions(-) diff --git a/dlls/comctl32/tests/static.c b/dlls/comctl32/tests/static.c index 0b990d6b39..4efb768579 100644 --- a/dlls/comctl32/tests/static.c +++ b/dlls/comctl32/tests/static.c @@ -134,7 +134,20 @@ static void test_set_text(void) DestroyWindow(hStatic); } -static void test_image(HBITMAP image, BOOL is_dib, BOOL is_premult) +static void remove_alpha(HBITMAP hbitmap) +{ + BITMAP bm; + BYTE *ptr; + int i; + + GetObjectW(hbitmap, sizeof(bm), &bm); + ok(bm.bmBits != NULL, "bmBits is NULL\n"); + + for (i = 0, ptr = bm.bmBits; i < bm.bmWidth * bm.bmHeight; i++, ptr += 4) + ptr[3] = 0; +} + +static void test_image(HBITMAP image, BOOL is_dib, BOOL is_premult, BOOL is_alpha) { BITMAP bm; HDC hdc; @@ -153,9 +166,12 @@ static void test_image(HBITMAP image, BOOL is_dib, BOOL is_premult) todo_wine ok(bits[0] == 0x05 && bits[1] == 0x09 && bits[2] == 0x0e && bits[3] == 0x44, "bits: %02x %02x %02x %02x\n", bits[0], bits[1], bits[2], bits[3]); - else + else if (is_alpha) ok(bits[0] == 0x11 && bits[1] == 0x22 && bits[2] == 0x33 && bits[3] == 0x44, "bits: %02x %02x %02x %02x\n", bits[0], bits[1], bits[2], bits[3]); + else + ok(bits[0] == 0x11 && bits[1] == 0x22 && bits[2] == 0x33 && bits[3] == 0, + "bits: %02x %02x %02x %02x\n", bits[0], bits[1], bits[2], bits[3]); } else ok(bm.bmBits == NULL, "bmBits is not NULL\n"); @@ -180,9 +196,12 @@ todo_wine todo_wine ok(bits[0] == 0x05 && bits[1] == 0x09 && bits[2] == 0x0e && bits[3] == 0x44, "bits: %02x %02x %02x %02x\n", bits[0], bits[1], bits[2], bits[3]); - else + else if (is_alpha) ok(bits[0] == 0x11 && bits[1] == 0x22 && bits[2] == 0x33 && bits[3] == 0x44, "bits: %02x %02x %02x %02x\n", bits[0], bits[1], bits[2], bits[3]); + else + ok(bits[0] == 0x11 && bits[1] == 0x22 && bits[2] == 0x33 && bits[3] == 0, + "bits: %02x %02x %02x %02x\n", bits[0], bits[1], bits[2], bits[3]); } static void test_set_image(void) @@ -193,7 +212,7 @@ static void test_set_image(void) image = LoadImageW(GetModuleHandleW(NULL), MAKEINTRESOURCEW(IDB_BITMAP_1x1_32BPP), IMAGE_BITMAP, 0, 0, 0); ok(image != NULL, "LoadImage failed\n"); - test_image(image, FALSE, FALSE); + test_image(image, FALSE, FALSE, TRUE); bmp1 = (HBITMAP)SendMessageW(hwnd, STM_GETIMAGE, IMAGE_BITMAP, 0); ok(bmp1 == NULL, "got not NULL\n"); @@ -204,17 +223,42 @@ static void test_set_image(void) bmp1 = (HBITMAP)SendMessageW(hwnd, STM_GETIMAGE, IMAGE_BITMAP, 0); ok(bmp1 != NULL, "got NULL\n"); ok(bmp1 != image, "bmp == image\n"); - test_image(bmp1, TRUE, TRUE); + test_image(bmp1, TRUE, TRUE, TRUE); bmp2 = (HBITMAP)SendMessageW(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)image); ok(bmp2 != NULL, "got NULL\n"); ok(bmp2 != image, "bmp == image\n"); ok(bmp1 == bmp2, "bmp1 != bmp2\n"); - test_image(bmp2, TRUE, TRUE); + test_image(bmp2, TRUE, TRUE, TRUE); + + DeleteObject(image); + + image = LoadImageW(GetModuleHandleW(NULL), MAKEINTRESOURCEW(IDB_BITMAP_1x1_32BPP), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); + ok(image != NULL, "LoadImage failed\n"); + + test_image(image, TRUE, FALSE, TRUE); + remove_alpha(image); + test_image(image, TRUE, FALSE, FALSE); + + bmp1 = (HBITMAP)SendMessageW(hwnd, STM_GETIMAGE, IMAGE_BITMAP, 0); + ok(bmp1 != NULL, "got NULL\n"); + ok(bmp1 != image, "bmp == image\n"); + test_image(bmp1, TRUE, TRUE, TRUE); + + bmp2 = (HBITMAP)SendMessageW(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)image); + ok(bmp2 != NULL, "got NULL\n"); + ok(bmp2 != image, "bmp == image\n"); + ok(bmp1 == bmp2, "bmp1 != bmp2\n"); + test_image(bmp1, TRUE, TRUE, FALSE); + + bmp2 = (HBITMAP)SendMessageW(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)image); + ok(bmp2 != NULL, "got NULL\n"); + ok(bmp2 == image, "bmp1 != image\n"); + test_image(bmp2, TRUE, FALSE, FALSE); DestroyWindow(hwnd); - test_image(bmp2, TRUE, TRUE); + test_image(image, TRUE, FALSE, FALSE); DeleteObject(image); }
participants (1)
-
Alexandre Julliard