Dmitry Timoshkov : comctl32/tests: Add some tests for Static/SS_BITMAP control.

Alexandre Julliard julliard at winehq.org
Fri Feb 7 15:41:09 CST 2020


Module: wine
Branch: master
Commit: f909d18baf1d97831c55a1d47610427ac2084ca3
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=f909d18baf1d97831c55a1d47610427ac2084ca3

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Thu Feb  6 17:31:16 2020 +0800

comctl32/tests: Add some tests for Static/SS_BITMAP control.

Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/comctl32/tests/bmp1x1_32bpp.bmp | Bin 0 -> 58 bytes
 dlls/comctl32/tests/resources.h      |   1 +
 dlls/comctl32/tests/rsrc.rc          |   3 ++
 dlls/comctl32/tests/static.c         |  92 +++++++++++++++++++++++++++++++++++
 4 files changed, 96 insertions(+)

diff --git a/dlls/comctl32/tests/bmp1x1_32bpp.bmp b/dlls/comctl32/tests/bmp1x1_32bpp.bmp
new file mode 100644
index 0000000000..3b565be8c2
Binary files /dev/null and b/dlls/comctl32/tests/bmp1x1_32bpp.bmp differ
diff --git a/dlls/comctl32/tests/resources.h b/dlls/comctl32/tests/resources.h
index 53522c0a09..c4692654ae 100644
--- a/dlls/comctl32/tests/resources.h
+++ b/dlls/comctl32/tests/resources.h
@@ -23,6 +23,7 @@
 
 #define IDB_BITMAP_128x15       10
 #define IDB_BITMAP_80x15        11
+#define IDB_BITMAP_1x1_32BPP    12
 
 #define IDS_TBADD1      16
 #define IDS_TBADD2      17
diff --git a/dlls/comctl32/tests/rsrc.rc b/dlls/comctl32/tests/rsrc.rc
index 6eb4fe8a0a..df22053d4c 100644
--- a/dlls/comctl32/tests/rsrc.rc
+++ b/dlls/comctl32/tests/rsrc.rc
@@ -101,6 +101,9 @@ IDB_BITMAP_128x15 BITMAP bmp128x15.bmp
 /* @makedep: bmp80x15.bmp */
 IDB_BITMAP_80x15 BITMAP bmp80x15.bmp
 
+/* @makedep: bmp1x1_32bpp.bmp */
+IDB_BITMAP_1x1_32BPP BITMAP bmp1x1_32bpp.bmp
+
 IDD_PROP_PAGE_WITH_CUSTOM_DEFAULT_BUTTON DIALOG  5, 43, 227, 215
 STYLE WS_CHILD | WS_DISABLED
 FONT 8, "MS Shell Dlg"
diff --git a/dlls/comctl32/tests/static.c b/dlls/comctl32/tests/static.c
index a65e352728..0e44c4ed7a 100644
--- a/dlls/comctl32/tests/static.c
+++ b/dlls/comctl32/tests/static.c
@@ -24,6 +24,7 @@
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include "commctrl.h"
+#include "resources.h"
 
 #include "wine/test.h"
 
@@ -133,6 +134,96 @@ static void test_set_text(void)
     DestroyWindow(hStatic);
 }
 
+static void test_image(HBITMAP image, BOOL is_dib, BOOL is_premult)
+{
+    BITMAP bm;
+    HDC hdc;
+    BITMAPINFO info;
+    BYTE bits[4];
+
+    GetObjectW(image, sizeof(bm), &bm);
+    ok(bm.bmWidth == 1, "got %d\n", bm.bmWidth);
+    ok(bm.bmHeight == 1, "got %d\n", bm.bmHeight);
+    ok(bm.bmBitsPixel == 32, "got %d\n", bm.bmBitsPixel);
+    if (is_dib)
+    {
+todo_wine
+        ok(bm.bmBits != NULL, "bmBits is NULL\n");
+if (bm.bmBits)
+{
+        memcpy(bits, bm.bmBits, 4);
+        if (is_premult)
+            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
+            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(bm.bmBits == NULL, "bmBits is not NULL\n");
+
+    info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+    info.bmiHeader.biWidth = bm.bmWidth;
+    info.bmiHeader.biHeight = bm.bmHeight;
+    info.bmiHeader.biPlanes = 1;
+    info.bmiHeader.biBitCount = 32;
+    info.bmiHeader.biCompression = BI_RGB;
+    info.bmiHeader.biSizeImage = 4;
+    info.bmiHeader.biXPelsPerMeter = 0;
+    info.bmiHeader.biYPelsPerMeter = 0;
+    info.bmiHeader.biClrUsed = 0;
+    info.bmiHeader.biClrImportant = 0;
+
+    hdc = CreateCompatibleDC(0);
+    GetDIBits(hdc, image, 0, bm.bmHeight, bits, &info, DIB_RGB_COLORS);
+    DeleteDC(hdc);
+
+    if (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
+        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]);
+}
+
+static void test_set_image(void)
+{
+    HWND hwnd = create_static(SS_BITMAP);
+    HBITMAP bmp1, bmp2, image;
+
+    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);
+
+    bmp1 = (HBITMAP)SendMessageW(hwnd, STM_GETIMAGE, IMAGE_BITMAP, 0);
+    ok(bmp1 == NULL, "got not NULL\n");
+
+    bmp1 = (HBITMAP)SendMessageW(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)image);
+    ok(bmp1 == NULL, "got not NULL\n");
+
+    bmp1 = (HBITMAP)SendMessageW(hwnd, STM_GETIMAGE, IMAGE_BITMAP, 0);
+    ok(bmp1 != NULL, "got NULL\n");
+todo_wine
+    ok(bmp1 != image, "bmp == image\n");
+    test_image(bmp1, TRUE, TRUE);
+
+    bmp2 = (HBITMAP)SendMessageW(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)image);
+    ok(bmp2 != NULL, "got NULL\n");
+todo_wine
+    ok(bmp2 != image, "bmp == image\n");
+    ok(bmp1 == bmp2, "bmp1 != bmp2\n");
+    test_image(bmp2, TRUE, TRUE);
+
+    DestroyWindow(hwnd);
+
+    test_image(bmp2, TRUE, TRUE);
+
+    DeleteObject(image);
+}
+
 START_TEST(static)
 {
     static const char classname[] = "testclass";
@@ -171,6 +262,7 @@ START_TEST(static)
     test_updates(SS_ETCHEDHORZ, TODO_COUNT);
     test_updates(SS_ETCHEDVERT, TODO_COUNT);
     test_set_text();
+    test_set_image();
 
     DestroyWindow(hMainWnd);
 




More information about the wine-cvs mailing list