From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/uxtheme/tests/system.c | 140 ++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+)
diff --git a/dlls/uxtheme/tests/system.c b/dlls/uxtheme/tests/system.c index debc712a73c..f0f51a68009 100644 --- a/dlls/uxtheme/tests/system.c +++ b/dlls/uxtheme/tests/system.c @@ -2550,6 +2550,144 @@ static void test_GetThemeBackgroundRegion(void) DestroyWindow(hwnd); }
+static const struct message wm_ctlcolorscrollbar_seq[] = +{ + {WM_CTLCOLORSCROLLBAR, sent}, + {WM_CTLCOLORSCROLLBAR, sent | optional}, + {0} +}; + +static LRESULT WINAPI TestScrollBarParentProcA(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) +{ + static LONG defwndproc_counter; + static HBRUSH red_brush; + struct message message = {0}; + LRESULT ret; + + message.message = msg; + message.flags = sent | wparam | lparam; + if (defwndproc_counter) + message.flags |= defwinproc; + message.wParam = wp; + message.lParam = lp; + add_message(sequences, PARENT_SEQ_INDEX, &message); + + switch (msg) + { + case WM_CREATE: + red_brush = CreateSolidBrush(RGB(255, 0, 0)); + break; + case WM_CLOSE: + DeleteObject(red_brush); + PostQuitMessage(0); + return 0; + case WM_CTLCOLORSCROLLBAR: + return (INT_PTR)red_brush; + } + + InterlockedIncrement(&defwndproc_counter); + ret = DefWindowProcA(hwnd, msg, wp, lp); + InterlockedDecrement(&defwndproc_counter); + return ret; +} + +static void test_scrollbar(void) +{ + WNDCLASSA cls = {0}; + BOOL transparent; + HWND hwnd, child; + COLORREF color; + HTHEME htheme; + HRESULT hr; + HDC hdc; + + /* Test that scrollbar arrow parts are transparent */ + hwnd = CreateWindowA(WC_STATICA, "", WS_POPUP, 0, 0, 1, 1, 0, 0, 0, NULL); + ok(!!hwnd, "CreateWindowA failed, error %#lx.\n", GetLastError()); + htheme = OpenThemeData(hwnd, L"ScrollBar"); + if (htheme) + { + transparent = FALSE; + hr = GetThemeBool(htheme, SBP_ARROWBTN, 0, TMT_TRANSPARENT, &transparent); + /* XP does use opaque scrollbar arrow parts and TMT_TRANSPARENT is FALSE */ + if (LOBYTE(LOWORD(GetVersion())) < 6) + { + ok(hr == E_PROP_ID_UNSUPPORTED, "Got unexpected hr %#lx.\n", hr); + + transparent = IsThemeBackgroundPartiallyTransparent(htheme, SBP_ARROWBTN, 0); + ok(!transparent, "Expected opaque.\n"); + } + /* > XP use opaque scrollbar arrow parts, but TMT_TRANSPARENT is TRUE */ + else + { + ok(hr == S_OK, "Got unexpected hr %#lx,\n", hr); + ok(transparent, "Expected transparent.\n"); + + transparent = IsThemeBackgroundPartiallyTransparent(htheme, SBP_ARROWBTN, 0); + ok(transparent, "Expected transparent.\n"); + } + + CloseThemeData(htheme); + } + else + { + skip("Theming is inactive.\n"); + } + DestroyWindow(hwnd); + + cls.hInstance = GetModuleHandleA(0); + cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); + cls.hbrBackground = GetStockObject(WHITE_BRUSH); + cls.lpfnWndProc = TestScrollBarParentProcA; + cls.lpszClassName = "TestScrollBarParentClass"; + RegisterClassA(&cls); + + cls.lpfnWndProc = DefWindowProcA; + cls.lpszClassName = "TestScrollBarChildClass"; + RegisterClassA(&cls); + + hwnd = CreateWindowA("TestScrollBarParentClass", "parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE, + 100, 100, 300, 300, 0, 0, 0, NULL); + ok(!!hwnd, "Failed to create a parent window.\n"); + child = CreateWindowA("ScrollBar", "child", WS_CHILD | WS_VISIBLE | SBS_VERT, 0, 0, 20, 100, + hwnd, 0, 0, NULL); + ok(!!child, "Failed to create a child window.\n"); + flush_events(); + flush_sequences(sequences, NUM_MSG_SEQUENCES); + + /* Test that themed scrollbars don't paint parent background for arrows even if arrow parts are + * reported to be transparent. Note that there is no WM_PRINTCLIENT in wm_ctlcolorscrollbar_seq. + * If DrawThemeParentBackground() is called then WM_PRINTCLIENT must be present */ + RedrawWindow(child, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ERASENOW | RDW_FRAME); + ok_sequence(sequences, PARENT_SEQ_INDEX, wm_ctlcolorscrollbar_seq, "SB_CTL scrollbar paint", + IsThemeActive()); + + hdc = GetDC(child); + color = GetPixel(hdc, 10, 10); + ok(color != RGB(255, 0, 0), "Got unexpected color %#08lx.\n", color); + + /* The brush from WM_CTLCOLORSCROLLBAR is used to fill the lower and upper track if present */ + color = GetPixel(hdc, 10, 60); + todo_wine_if(IsThemeActive()) + ok(color == RGB(255, 0, 0) || broken(color == CLR_INVALID), /* Win7 on TestBots */ + "Got unexpected color %#08lx.\n", color); + ReleaseDC(child, hdc); + + DestroyWindow(child); + child = CreateWindowA("TestScrollBarChildClass", "child", WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL, + 0, 0, 100, 100, hwnd, 0, 0, NULL); + ok(!!child, "Failed to create a child window.\n"); + flush_events(); + flush_sequences(sequences, NUM_MSG_SEQUENCES); + + RedrawWindow(child, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ERASENOW | RDW_FRAME); + ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "SB_HORZ and SB_VERT scrollbar paint", FALSE); + + DestroyWindow(hwnd); + UnregisterClassA("TestScrollBarChildClass", GetModuleHandleA(0)); + UnregisterClassA("TestScrollBarParentClass", GetModuleHandleA(0)); +} + START_TEST(system) { ULONG_PTR ctx_cookie; @@ -2574,10 +2712,12 @@ START_TEST(system) test_DrawThemeParentBackground(); test_DrawThemeBackgroundEx(); test_GetThemeBackgroundRegion(); + test_scrollbar();
if (load_v6_module(&ctx_cookie, &ctx)) { test_EnableThemeDialogTexture(); + test_scrollbar();
unload_v6_module(ctx_cookie, ctx); }