Dmitry Timoshkov : user32/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: f5906a5cfb22db07a22e6ac7b4a1afcd907c0af1
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=f5906a5cfb22db07a22e6ac7b4a1afcd907c0af1

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

user32/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/user32/tests/bmp1x1_32bpp.bmp | Bin 0 -> 58 bytes
 dlls/user32/tests/resource.rc      |   3 ++
 dlls/user32/tests/static.c         |  60 +++++++++++++++++++++++++++++++++++++
 3 files changed, 63 insertions(+)

diff --git a/dlls/user32/tests/bmp1x1_32bpp.bmp b/dlls/user32/tests/bmp1x1_32bpp.bmp
new file mode 100644
index 0000000000..3b565be8c2
Binary files /dev/null and b/dlls/user32/tests/bmp1x1_32bpp.bmp differ
diff --git a/dlls/user32/tests/resource.rc b/dlls/user32/tests/resource.rc
index 4301af6d68..89aaf5a61c 100644
--- a/dlls/user32/tests/resource.rc
+++ b/dlls/user32/tests/resource.rc
@@ -249,6 +249,9 @@ FONT 8, "MS Shell Dlg"
 /* @makedep: test_mono.bmp */
 100 BITMAP test_mono.bmp
 
+/* @makedep: bmp1x1_32bpp.bmp */
+101 BITMAP bmp1x1_32bpp.bmp
+
 1 MENU
 {
     POPUP "&File"
diff --git a/dlls/user32/tests/static.c b/dlls/user32/tests/static.c
index 8776c3a9e0..0c453d08a6 100644
--- a/dlls/user32/tests/static.c
+++ b/dlls/user32/tests/static.c
@@ -130,6 +130,65 @@ static void test_set_text(void)
     DestroyWindow(hStatic);
 }
 
+static void test_image(HBITMAP image)
+{
+    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);
+    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);
+
+    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 = build_static(SS_BITMAP);
+    HBITMAP bmp, image;
+
+    image = LoadImageW(GetModuleHandleW(NULL), MAKEINTRESOURCEW(101), IMAGE_BITMAP, 0, 0, 0);
+    ok(image != NULL, "LoadImage failed\n");
+
+    test_image(image);
+
+    bmp = (HBITMAP)SendMessageW(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)image);
+    ok(bmp == NULL, "got not NULL\n");
+
+    bmp = (HBITMAP)SendMessageW(hwnd, STM_GETIMAGE, IMAGE_BITMAP, 0);
+    ok(bmp != NULL, "got NULL\n");
+    ok(bmp == image, "bmp != image\n");
+
+    bmp = (HBITMAP)SendMessageW(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)image);
+    ok(bmp != NULL, "got NULL\n");
+    ok(bmp == image, "bmp != image\n");
+    test_image(image);
+
+    DestroyWindow(hwnd);
+    DeleteObject(image);
+}
+
 START_TEST(static)
 {
     static const char szClassName[] = "testclass";
@@ -162,6 +221,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