Zhiyi Zhang : uxtheme/tests: Test more WM_CTLCOLOR* messages for dialog theming.
Alexandre Julliard
julliard at winehq.org
Wed Feb 9 16:03:48 CST 2022
Module: wine
Branch: master
Commit: f0e6cfbc0b677bc543604a8824c8b2c3c3d4ee26
URL: https://source.winehq.org/git/wine.git/?a=commit;h=f0e6cfbc0b677bc543604a8824c8b2c3c3d4ee26
Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date: Wed Feb 9 16:44:25 2022 +0800
uxtheme/tests: Test more WM_CTLCOLOR* messages for dialog theming.
Test that some WM_CTLCOLOR* other than WM_CTLCOLORSTATIC also use tab background as dialog texture.
Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/uxtheme/tests/system.c | 150 +++++++++++++++++++++++++++-----------------
1 file changed, 94 insertions(+), 56 deletions(-)
diff --git a/dlls/uxtheme/tests/system.c b/dlls/uxtheme/tests/system.c
index 980676f9e57..77a12f3fa44 100644
--- a/dlls/uxtheme/tests/system.c
+++ b/dlls/uxtheme/tests/system.c
@@ -1617,6 +1617,7 @@ static void test_EnableThemeDialogTexture(void)
LRESULT lr;
POINT org;
SIZE size;
+ UINT msg;
BOOL ret;
struct
@@ -1822,74 +1823,111 @@ static void test_EnableThemeDialogTexture(void)
GetSysColorBrush(COLOR_MENU), brush);
handle_WM_CTLCOLORSTATIC = FALSE;
- /* Test that WM_CTLCOLORSTATIC changes brush origin when dialog texture is on */
- ret = SetBrushOrgEx(child_hdc, 0, 0, NULL);
- ok(ret, "SetBrushOrgEx failed, error %u.\n", GetLastError());
- SendMessageW(dialog, WM_CTLCOLORSTATIC, (WPARAM)child_hdc, (LPARAM)child);
- ret = GetBrushOrgEx(child_hdc, &org);
- ok(ret, "GetBrushOrgEx failed, error %u.\n", GetLastError());
- ok(org.x == -1 && org.y == -2, "Expected (-1,-2), got %s.\n", wine_dbgstr_point(&org));
-
- /* Test that WM_CTLCOLORSTATIC changes background mode when dialog texture is on */
- old_mode = SetBkMode(child_hdc, OPAQUE);
- ok(old_mode != 0, "SetBkMode failed.\n");
- SendMessageW(dialog, WM_CTLCOLORSTATIC, (WPARAM)child_hdc, (LPARAM)child);
- mode = SetBkMode(child_hdc, old_mode);
- ok(mode == TRANSPARENT, "Expected mode %#x, got %#x.\n", TRANSPARENT, mode);
-
- /* Test that WM_CTLCOLORSTATIC changes background color when dialog texture is on */
- old_color = SetBkColor(child_hdc, 0xaa5511);
- ok(old_color != CLR_INVALID, "SetBkColor failed.\n");
- SendMessageW(dialog, WM_CTLCOLORSTATIC, (WPARAM)child_hdc, (LPARAM)child);
- color = SetBkColor(child_hdc, old_color);
- ok(color == GetSysColor(COLOR_BTNFACE), "Expected background color %#x, got %#x.\n",
- GetSysColor(COLOR_BTNFACE), color);
-
/* Test that dialog doesn't have theme handle opened for itself */
ok(GetWindowTheme(dialog) == NULL, "Expected NULL theme handle.\n");
- /* Test that the returned brush is a pattern brush created from the tab body */
- brush = (HBRUSH)SendMessageW(dialog, WM_CTLCOLORSTATIC, (WPARAM)child_hdc, (LPARAM)child);
- memset(&log_brush, 0, sizeof(log_brush));
- count = GetObjectA(brush, sizeof(log_brush), &log_brush);
- ok(count == sizeof(log_brush), "GetObjectA failed, error %u.\n", GetLastError());
- ok(log_brush.lbColor == 0, "Expected brush color %#x, got %#x.\n", 0, log_brush.lbColor);
- ok(log_brush.lbStyle == BS_PATTERN, "Expected brush style %#x, got %#x.\n", BS_PATTERN,
- log_brush.lbStyle);
-
- memset(&bmp, 0, sizeof(bmp));
- count = GetObjectA((HBITMAP)log_brush.lbHatch, sizeof(bmp), &bmp);
- ok(count == sizeof(bmp), "GetObjectA failed, error %u.\n", GetLastError());
-
theme = OpenThemeData(NULL, L"Tab");
ok(theme != NULL, "OpenThemeData failed.\n");
-
size.cx = 0;
size.cy = 0;
hr = GetThemePartSize(theme, NULL, TABP_BODY, 0, NULL, TS_TRUE, &size);
ok(hr == S_OK, "GetThemePartSize failed, hr %#x.\n", hr);
- ok(bmp.bmWidth == size.cx, "Expected width %d, got %d.\n", size.cx, bmp.bmWidth);
- ok(bmp.bmHeight == size.cy, "Expected height %d, got %d.\n", size.cy, bmp.bmHeight);
-
CloseThemeData(theme);
- /* Test that DefDlgProcA/W() are hooked for WM_CTLCOLORSTATIC */
- brush = (HBRUSH)SendMessageW(dialog, WM_CTLCOLORSTATIC, (WPARAM)child_hdc, (LPARAM)child);
- ok(brush != GetSysColorBrush(COLOR_BTNFACE), "Expected a different brush.\n");
- brush2 = (HBRUSH)DefDlgProcW(dialog, WM_CTLCOLORSTATIC, (WPARAM)child_hdc, (LPARAM)child);
- ok(brush2 == brush, "Expected the same brush.\n");
- brush2 = (HBRUSH)DefDlgProcA(dialog, WM_CTLCOLORSTATIC, (WPARAM)child_hdc, (LPARAM)child);
- ok(brush2 == brush, "Expected the same brush.\n");
+ /* Test which WM_CTLCOLOR* message uses tab background as dialog texture */
+ for (msg = WM_CTLCOLORMSGBOX; msg <= WM_CTLCOLORSTATIC; ++msg)
+ {
+ winetest_push_context("msg %#x", msg);
+
+ /* Test that some WM_CTLCOLOR* messages change brush origin when dialog texture is on */
+ ret = SetBrushOrgEx(child_hdc, 0, 0, NULL);
+ ok(ret, "SetBrushOrgEx failed, error %u.\n", GetLastError());
+ SendMessageW(dialog, msg, (WPARAM)child_hdc, (LPARAM)child);
+ ret = GetBrushOrgEx(child_hdc, &org);
+ ok(ret, "GetBrushOrgEx failed, error %u.\n", GetLastError());
+ /* WM_CTLCOLOREDIT, WM_CTLCOLORLISTBOX and WM_CTLCOLORSCROLLBAR don't use tab background */
+ if (msg == WM_CTLCOLOREDIT || msg == WM_CTLCOLORLISTBOX || msg == WM_CTLCOLORSCROLLBAR)
+ {
+ ok(org.x == 0 && org.y == 0, "Expected (0,0), got %s.\n", wine_dbgstr_point(&org));
+ winetest_pop_context();
+ continue;
+ }
+ else
+ {
+ todo_wine_if(msg != WM_CTLCOLORSTATIC)
+ ok(org.x == -1 && org.y == -2, "Expected (-1,-2), got %s.\n", wine_dbgstr_point(&org));
+ }
- /* Test that DefWindowProcA/W() are also hooked for WM_CTLCOLORSTATIC */
- brush = (HBRUSH)SendMessageW(dialog, WM_CTLCOLORSTATIC, (WPARAM)child_hdc, (LPARAM)child);
- ok(brush != GetSysColorBrush(COLOR_BTNFACE), "Expected a different brush.\n");
- brush2 = (HBRUSH)DefWindowProcW(dialog, WM_CTLCOLORSTATIC, (WPARAM)child_hdc, (LPARAM)child);
- todo_wine
- ok(brush2 == brush, "Expected the same brush.\n");
- brush2 = (HBRUSH)DefWindowProcA(dialog, WM_CTLCOLORSTATIC, (WPARAM)child_hdc, (LPARAM)child);
- todo_wine
- ok(brush2 == brush, "Expected the same brush.\n");
+ /* Test that some WM_CTLCOLOR* messages change background mode when dialog texture is on */
+ old_mode = SetBkMode(child_hdc, OPAQUE);
+ ok(old_mode != 0, "SetBkMode failed.\n");
+ SendMessageW(dialog, msg, (WPARAM)child_hdc, (LPARAM)child);
+ mode = SetBkMode(child_hdc, old_mode);
+ todo_wine_if(msg != WM_CTLCOLORSTATIC)
+ ok(mode == TRANSPARENT, "Expected mode %#x, got %#x.\n", TRANSPARENT, mode);
+
+ /* Test that some WM_CTLCOLOR* messages change background color when dialog texture is on */
+ old_color = SetBkColor(child_hdc, 0xaa5511);
+ ok(old_color != CLR_INVALID, "SetBkColor failed.\n");
+ SendMessageW(dialog, msg, (WPARAM)child_hdc, (LPARAM)child);
+ color = SetBkColor(child_hdc, old_color);
+ ok(color == GetSysColor(COLOR_BTNFACE), "Expected background color %#x, got %#x.\n",
+ GetSysColor(COLOR_BTNFACE), color);
+
+ /* Test that the returned brush is a pattern brush created from the tab body */
+ brush = (HBRUSH)SendMessageW(dialog, msg, (WPARAM)child_hdc, (LPARAM)child);
+ memset(&log_brush, 0, sizeof(log_brush));
+ count = GetObjectA(brush, sizeof(log_brush), &log_brush);
+ ok(count == sizeof(log_brush), "GetObjectA failed, error %u.\n", GetLastError());
+ todo_wine_if(msg != WM_CTLCOLORSTATIC)
+ ok(log_brush.lbColor == 0, "Expected brush color %#x, got %#x.\n", 0, log_brush.lbColor);
+ todo_wine_if(msg != WM_CTLCOLORSTATIC)
+ ok(log_brush.lbStyle == BS_PATTERN, "Expected brush style %#x, got %#x.\n", BS_PATTERN,
+ log_brush.lbStyle);
+
+ memset(&bmp, 0, sizeof(bmp));
+ count = GetObjectA((HBITMAP)log_brush.lbHatch, sizeof(bmp), &bmp);
+ todo_wine_if(msg != WM_CTLCOLORSTATIC)
+ ok(count == sizeof(bmp), "GetObjectA failed, error %u.\n", GetLastError());
+ todo_wine_if(msg != WM_CTLCOLORSTATIC)
+ ok(bmp.bmWidth == size.cx, "Expected width %d, got %d.\n", size.cx, bmp.bmWidth);
+ todo_wine_if(msg != WM_CTLCOLORSTATIC)
+ ok(bmp.bmHeight == size.cy, "Expected height %d, got %d.\n", size.cy, bmp.bmHeight);
+
+ /* Test that DefDlgProcA/W() are hooked for some WM_CTLCOLOR* messages */
+ brush = (HBRUSH)SendMessageW(dialog, msg, (WPARAM)child_hdc, (LPARAM)child);
+ todo_wine_if(msg != WM_CTLCOLORSTATIC)
+ ok(brush != GetSysColorBrush(COLOR_BTNFACE), "Expected a different brush.\n");
+ brush2 = (HBRUSH)DefDlgProcW(dialog, msg, (WPARAM)child_hdc, (LPARAM)child);
+ ok(brush2 == brush, "Expected the same brush.\n");
+ brush2 = (HBRUSH)DefDlgProcA(dialog, msg, (WPARAM)child_hdc, (LPARAM)child);
+ ok(brush2 == brush, "Expected the same brush.\n");
+
+ /* Test that DefWindowProcA/W() are also hooked for some WM_CTLCOLOR* messages */
+ brush = (HBRUSH)SendMessageW(dialog, msg, (WPARAM)child_hdc, (LPARAM)child);
+ todo_wine_if(msg != WM_CTLCOLORSTATIC)
+ ok(brush != GetSysColorBrush(COLOR_BTNFACE), "Expected a different brush.\n");
+ if (msg != WM_CTLCOLORDLG)
+ {
+ brush2 = (HBRUSH)DefWindowProcW(dialog, msg, (WPARAM)child_hdc, (LPARAM)child);
+ todo_wine_if(msg == WM_CTLCOLORSTATIC)
+ ok(brush2 == brush, "Expected the same brush.\n");
+ brush2 = (HBRUSH)DefWindowProcA(dialog, msg, (WPARAM)child_hdc, (LPARAM)child);
+ todo_wine_if(msg == WM_CTLCOLORSTATIC)
+ ok(brush2 == brush, "Expected the same brush.\n");
+ }
+ else
+ {
+ brush2 = (HBRUSH)DefWindowProcW(dialog, msg, (WPARAM)child_hdc, (LPARAM)child);
+ todo_wine
+ ok(brush2 != brush, "Expected a different brush.\n");
+ brush2 = (HBRUSH)DefWindowProcA(dialog, msg, (WPARAM)child_hdc, (LPARAM)child);
+ todo_wine
+ ok(brush2 != brush, "Expected a different brush.\n");
+ }
+
+ winetest_pop_context();
+ }
/* Test that DefWindowProcA/W() are not hooked for WM_ERASEBKGND. So the background is still
* drawn with hbrBackground, which in this case, is GRAY_BRUSH.
More information about the wine-cvs
mailing list