Module: wine Branch: master Commit: 59007aaeef4ae39ed04b358aafeef2004ecd3522 URL: https://source.winehq.org/git/wine.git/?a=commit;h=59007aaeef4ae39ed04b358aa...
Author: Zhiyi Zhang zzhang@codeweavers.com Date: Tue Nov 2 14:27:59 2021 +0800
uxtheme/tests: Add GetThemeTransitionDuration() tests.
Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/uxtheme/tests/system.c | 154 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+)
diff --git a/dlls/uxtheme/tests/system.c b/dlls/uxtheme/tests/system.c index 541d46deeaa..57901e6affb 100644 --- a/dlls/uxtheme/tests/system.c +++ b/dlls/uxtheme/tests/system.c @@ -43,6 +43,7 @@ static HDC (WINAPI *pGetBufferedPaintDC)(HPAINTBUFFER); static HDC (WINAPI *pGetBufferedPaintTargetDC)(HPAINTBUFFER); static HRESULT (WINAPI *pGetBufferedPaintTargetRect)(HPAINTBUFFER, RECT *); static HRESULT (WINAPI *pGetThemeIntList)(HTHEME, int, int, int, INTLIST *); +static HRESULT (WINAPI *pGetThemeTransitionDuration)(HTHEME, int, int, int, int, DWORD *);
static LONG (WINAPI *pDisplayConfigGetDeviceInfo)(DISPLAYCONFIG_DEVICE_INFO_HEADER *); static LONG (WINAPI *pDisplayConfigSetDeviceInfo)(DISPLAYCONFIG_DEVICE_INFO_HEADER *); @@ -81,6 +82,7 @@ static void init_funcs(void) GET_PROC(uxtheme, GetBufferedPaintTargetDC) GET_PROC(uxtheme, GetBufferedPaintTargetRect) GET_PROC(uxtheme, GetThemeIntList) + GET_PROC(uxtheme, GetThemeTransitionDuration) GET_PROC(uxtheme, OpenThemeDataEx) GET_PROC(uxtheme, OpenThemeDataForDpi)
@@ -1299,6 +1301,157 @@ static void test_GetThemeIntList(void) DestroyWindow(hwnd); }
+static void test_GetThemeTransitionDuration(void) +{ + int from_state, to_state, expected; + INTLIST intlist; + DWORD duration; + HTHEME theme; + HRESULT hr; + HWND hwnd; + + if (!pGetThemeTransitionDuration || !pGetThemeIntList) + { + win_skip("GetThemeTransitionDuration or GetThemeIntList is unavailable.\n"); + return; + } + + hwnd = CreateWindowA("static", "", WS_POPUP, 0, 0, 100, 100, 0, 0, 0, NULL); + theme = OpenThemeData(hwnd, L"Button"); + if (!theme) + { + skip("Theming is not active.\n"); + DestroyWindow(hwnd); + return; + } + + /* Invalid parameter tests */ + duration = 0xdeadbeef; + hr = pGetThemeTransitionDuration(NULL, BP_PUSHBUTTON, PBS_NORMAL, PBS_DEFAULTED_ANIMATING, + TMT_TRANSITIONDURATIONS, &duration); + todo_wine + ok(hr == E_HANDLE, "GetThemeTransitionDuration failed, hr %#x.\n", hr); + ok(duration == 0xdeadbeef, "Expected duration %#x, got %#x.\n", 0xdeadbeef, duration); + + duration = 0xdeadbeef; + hr = pGetThemeTransitionDuration((HTHEME)0xdeadbeef, BP_PUSHBUTTON, PBS_NORMAL, + PBS_DEFAULTED_ANIMATING, TMT_TRANSITIONDURATIONS, &duration); + todo_wine + ok(hr == E_HANDLE, "GetThemeTransitionDuration failed, hr %#x.\n", hr); + ok(duration == 0xdeadbeef, "Expected duration %#x, got %#x.\n", 0xdeadbeef, duration); + + duration = 0xdeadbeef; + hr = pGetThemeTransitionDuration(theme, 0xdeadbeef, PBS_NORMAL, PBS_DEFAULTED_ANIMATING, + TMT_TRANSITIONDURATIONS, &duration); + todo_wine + ok(hr == E_PROP_ID_UNSUPPORTED, "GetThemeTransitionDuration failed, hr %#x.\n", hr); + todo_wine + ok(duration == 0, "Expected duration %#x, got %#x.\n", 0, duration); + + duration = 0xdeadbeef; + hr = pGetThemeTransitionDuration(theme, BP_PUSHBUTTON, PBS_NORMAL - 1, PBS_DEFAULTED_ANIMATING, + TMT_TRANSITIONDURATIONS, &duration); + todo_wine + ok(hr == E_INVALIDARG, "GetThemeTransitionDuration failed, hr %#x.\n", hr); + ok(duration == 0xdeadbeef, "Expected duration %#x, got %#x.\n", 0xdeadbeef, duration); + + duration = 0xdeadbeef; + hr = pGetThemeTransitionDuration(theme, BP_PUSHBUTTON, PBS_DEFAULTED_ANIMATING + 1, + PBS_DEFAULTED_ANIMATING, TMT_TRANSITIONDURATIONS, &duration); + todo_wine + ok(hr == E_INVALIDARG, "GetThemeTransitionDuration failed, hr %#x.\n", hr); + todo_wine + ok(duration == 0, "Expected duration %#x, got %#x.\n", 0, duration); + + duration = 0xdeadbeef; + hr = pGetThemeTransitionDuration(theme, BP_PUSHBUTTON, PBS_NORMAL, PBS_NORMAL - 1, + TMT_TRANSITIONDURATIONS, &duration); + todo_wine + ok(hr == E_INVALIDARG, "GetThemeTransitionDuration failed, hr %#x.\n", hr); + ok(duration == 0xdeadbeef, "Expected duration %#x, got %#x.\n", 0xdeadbeef, duration); + + duration = 0xdeadbeef; + hr = pGetThemeTransitionDuration(theme, BP_PUSHBUTTON, PBS_NORMAL, PBS_DEFAULTED_ANIMATING + 1, + TMT_TRANSITIONDURATIONS, &duration); + todo_wine + ok(hr == E_INVALIDARG, "GetThemeTransitionDuration failed, hr %#x.\n", hr); + todo_wine + ok(duration == 0, "Expected duration %#x, got %#x.\n", 0, duration); + + duration = 0xdeadbeef; + hr = pGetThemeTransitionDuration(theme, BP_PUSHBUTTON, PBS_NORMAL, PBS_DEFAULTED_ANIMATING, + TMT_BACKGROUND, &duration); + todo_wine + ok(hr == E_PROP_ID_UNSUPPORTED, "GetThemeTransitionDuration failed, hr %#x.\n", hr); + todo_wine + ok(duration == 0, "Expected duration %#x, got %#x.\n", 0, duration); + + duration = 0xdeadbeef; + hr = pGetThemeTransitionDuration(theme, BP_PUSHBUTTON, PBS_NORMAL, PBS_DEFAULTED_ANIMATING, + 0xdeadbeef, &duration); + todo_wine + ok(hr == E_PROP_ID_UNSUPPORTED, "GetThemeTransitionDuration failed, hr %#x.\n", hr); + todo_wine + ok(duration == 0, "Expected duration %#x, got %#x.\n", 0, duration); + + hr = pGetThemeTransitionDuration(theme, BP_PUSHBUTTON, PBS_NORMAL, PBS_DEFAULTED_ANIMATING, + TMT_TRANSITIONDURATIONS, NULL); + todo_wine + ok(hr == E_INVALIDARG, "GetThemeTransitionDuration failed, hr %#x.\n", hr); + + /* Parts that don't have TMT_TRANSITIONDURATIONS */ + hr = GetThemeIntList(theme, BP_GROUPBOX, GBS_NORMAL, TMT_TRANSITIONDURATIONS, &intlist); + ok(hr == E_PROP_ID_UNSUPPORTED, "GetThemeIntList failed, hr %#x.\n", hr); + + duration = 0xdeadbeef; + hr = pGetThemeTransitionDuration(theme, BP_GROUPBOX, GBS_NORMAL, GBS_DISABLED, + TMT_TRANSITIONDURATIONS, &duration); + todo_wine + ok(hr == E_PROP_ID_UNSUPPORTED, "GetThemeTransitionDuration failed, hr %#x.\n", hr); + todo_wine + ok(duration == 0, "Expected duration %#x, got %#x.\n", 0, duration); + + /* Test parsing TMT_TRANSITIONDURATIONS property. TMT_TRANSITIONDURATIONS is a vista+ property */ + if (LOBYTE(LOWORD(GetVersion())) < 6) + goto done; + + hr = pGetThemeIntList(theme, BP_PUSHBUTTON, PBS_NORMAL, TMT_TRANSITIONDURATIONS, &intlist); + ok(hr == S_OK, "GetThemeIntList failed, hr %#x.\n", hr); + /* The first value is the theme part state count. The following are the values from every state + * to every state. So the total value count should be 1 + state ^ 2 */ + expected = PBS_DEFAULTED_ANIMATING - PBS_NORMAL + 1; + ok(intlist.iValues[0] == expected, "Expected the first value %d, got %d.\n", expected, + intlist.iValues[0]); + expected = 1 + intlist.iValues[0] * intlist.iValues[0]; + ok(intlist.iValueCount == expected, "Expected value count %d, got %d.\n", expected, + intlist.iValueCount); + if (hr == S_OK) + { + for (from_state = PBS_NORMAL; from_state <= PBS_DEFAULTED_ANIMATING; ++from_state) + { + for (to_state = PBS_NORMAL; to_state <= PBS_DEFAULTED_ANIMATING; ++to_state) + { + winetest_push_context("from state %d to %d", from_state, to_state); + + duration = 0xdeadbeef; + hr = pGetThemeTransitionDuration(theme, BP_PUSHBUTTON, from_state, to_state, + TMT_TRANSITIONDURATIONS, &duration); + todo_wine + ok(hr == S_OK, "GetThemeTransitionDuration failed, hr %#x.\n", hr); + expected = intlist.iValues[1 + intlist.iValues[0] * (from_state - 1) + (to_state - 1)]; + todo_wine + ok(duration == expected, "Expected duration %d, got %d.\n", expected, duration); + + winetest_pop_context(); + } + } + } + +done: + CloseThemeData(theme); + DestroyWindow(hwnd); +} + START_TEST(system) { init_funcs(); @@ -1319,6 +1472,7 @@ START_TEST(system) test_CloseThemeData(); test_buffered_paint(); test_GetThemeIntList(); + test_GetThemeTransitionDuration();
/* Test EnableTheming() in the end because it may disable theming */ test_EnableTheming();