Module: wine Branch: master Commit: ab091b28cb4bb3b654e673f3b0e2d648b42cc65e URL: https://gitlab.winehq.org/wine/wine/-/commit/ab091b28cb4bb3b654e673f3b0e2d64...
Author: Zhiyi Zhang zzhang@codeweavers.com Date: Thu Apr 18 10:28:13 2024 +0800
uxtheme/tests: Test that scrollbar parts should have very few #ffffff pixels.
---
dlls/uxtheme/tests/system.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-)
diff --git a/dlls/uxtheme/tests/system.c b/dlls/uxtheme/tests/system.c index 30c5fbce161..c2da0af7853 100644 --- a/dlls/uxtheme/tests/system.c +++ b/dlls/uxtheme/tests/system.c @@ -2633,12 +2633,15 @@ static void test_GetThemeBackgroundRegion(void) DestroyWindow(hwnd); }
-static void test_theme(void) +static void test_theme(BOOL v6) { + static const int scrollbar_width = 200, scrollbar_height = 50; + int x, y, white_count = 0, white_percent; BOOL transparent; HTHEME htheme; HRESULT hr; HWND hwnd; + HDC hdc;
if (!IsThemeActive()) { @@ -2675,6 +2678,34 @@ static void test_theme(void) CloseThemeData(htheme);
DestroyWindow(hwnd); + + /* Test that scrollbar parts should have very few #ffffff pixels */ + hwnd = CreateWindowA(WC_SCROLLBARA, "scrollbar", WS_POPUP | WS_VISIBLE, 0, 0, scrollbar_width, + scrollbar_height, 0, 0, 0, NULL); + ok(!!hwnd, "CreateWindowA failed, error %#lx.\n", GetLastError()); + flush_events(); + hdc = GetDC(hwnd); + + for (y = 0; y < scrollbar_height; y++) + { + for (x = 0; x < scrollbar_width; x++) + { + COLORREF color = GetPixel(hdc, x, y); + ok(color != CLR_INVALID, "GetPixel failed.\n"); + if (color == 0xffffff) + white_count++; + } + } + + white_percent = white_count * 100 / (scrollbar_width * scrollbar_height); + if (v6) + todo_wine + ok(white_percent < 4, "Expected #ffffff pixels less than 4%%.\n"); + else + ok(white_percent < 50, "Expected #ffffff pixels less than 50%%.\n"); + + ReleaseDC(hwnd, hdc); + DestroyWindow(hwnd); }
static void test_ShouldSystemUseDarkMode(void) @@ -2760,13 +2791,14 @@ START_TEST(system) test_DrawThemeParentBackground(); test_DrawThemeBackgroundEx(); test_GetThemeBackgroundRegion(); - test_theme(); + test_theme(FALSE); test_ShouldSystemUseDarkMode(); test_ShouldAppsUseDarkMode();
if (load_v6_module(&ctx_cookie, &ctx)) { test_EnableThemeDialogTexture(); + test_theme(TRUE);
unload_v6_module(ctx_cookie, ctx); }