Commit 59007aae authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

uxtheme/tests: Add GetThemeTransitionDuration() tests.

parent 36ed40e9
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment