[PATCH v2 0/1] MR4531: uxtheme/tests: Add some tests for OpenThemeFile.
The tests show that the first argument must not be null, that the handle returned via the fourth argument is not an HTHEME, and that that handle can be passed to CloseThemeFile without error. -- v2: uxtheme/tests: Add some tests for OpenThemeFile. https://gitlab.winehq.org/wine/wine/-/merge_requests/4531
From: Alex Henrie <alexhenrie24(a)gmail.com> The tests show that the first argument must not be null, that the handle returned via the fourth argument is not an HTHEME, and that that handle can be passed to CloseThemeFile without error. --- dlls/uxtheme/tests/system.c | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/dlls/uxtheme/tests/system.c b/dlls/uxtheme/tests/system.c index c79a6c85a35..36740fe2664 100644 --- a/dlls/uxtheme/tests/system.c +++ b/dlls/uxtheme/tests/system.c @@ -38,6 +38,8 @@ static HTHEME (WINAPI * pOpenThemeDataEx)(HWND, LPCWSTR, DWORD); static HTHEME (WINAPI *pOpenThemeDataForDpi)(HWND, LPCWSTR, UINT); +static HRESULT (WINAPI *pOpenThemeFile)(const WCHAR *, const WCHAR *, const WCHAR *, HANDLE, DWORD); +static HRESULT (WINAPI *pCloseThemeFile)(HANDLE); static HPAINTBUFFER (WINAPI *pBeginBufferedPaint)(HDC, const RECT *, BP_BUFFERFORMAT, BP_PAINTPARAMS *, HDC *); static HRESULT (WINAPI *pBufferedPaintClear)(HPAINTBUFFER, const RECT *); static HRESULT (WINAPI *pDrawThemeBackgroundEx)(HTHEME, HDC, int, int, const RECT *, const DTBGOPTS *); @@ -76,6 +78,8 @@ static void init_funcs(void) HMODULE gdi32 = GetModuleHandleA("gdi32.dll"); HMODULE uxtheme = GetModuleHandleA("uxtheme.dll"); + pOpenThemeFile = (void *)GetProcAddress(uxtheme, MAKEINTRESOURCEA(2)); + pCloseThemeFile = (void *)GetProcAddress(uxtheme, MAKEINTRESOURCEA(3)); pShouldSystemUseDarkMode = (void *)GetProcAddress(uxtheme, MAKEINTRESOURCEA(138)); pShouldAppsUseDarkMode = (void *)GetProcAddress(uxtheme, MAKEINTRESOURCEA(132)); @@ -874,6 +878,48 @@ static void test_CloseThemeData(void) ok(hRes == E_HANDLE, "Expected E_HANDLE, got 0x%08lx\n", hRes); } +static void test_OpenThemeFile(void) +{ + WCHAR currentThemePath[MAX_PATH]; + DWORD pathSize = sizeof(currentThemePath); + HANDLE htf; + LSTATUS ls; + HRESULT hr; + SIZE partSize; + + if (!pOpenThemeFile) + { + win_skip("OpenThemeFile is unavailable.\n"); + return; + } + + ls = RegGetValueW(HKEY_CURRENT_USER, + L"Software\\Microsoft\\Windows\\CurrentVersion\\ThemeManager", L"DllName", + RRF_RT_REG_SZ, NULL, currentThemePath, &pathSize); + if (ls == ERROR_FILE_NOT_FOUND) + { + win_skip("DllName registry value not found.\n"); + return; + } + ok(ls == ERROR_SUCCESS, "RegGetValueW failed: %ld\n", ls); + + htf = (void *)0xdeadbeef; + hr = pOpenThemeFile(NULL, NULL, NULL, &htf, 0); + todo_wine ok(hr == E_POINTER, "Expected E_POINTER, got 0x%08lx\n", hr); + ok(!htf, "Expected NULL, got %p\n", htf); + + htf = (void *)0xdeadbeef; + hr = pOpenThemeFile(currentThemePath, NULL, NULL, &htf, 0); + ok(hr == S_OK, "Expected S_OK, got 0x%08lx\n", hr); + ok(htf != (void *)0xdeadbeef && htf != NULL && htf != INVALID_HANDLE_VALUE, "got %p\n", htf); + + hr = GetThemePartSize(htf, NULL, BP_CHECKBOX, CBS_CHECKEDNORMAL, NULL, TS_DRAW, &partSize); + todo_wine ok(hr == E_HANDLE, "Expected E_HANDLE, got 0x%08lx\n", hr); + + hr = pCloseThemeFile(htf); + ok(hr == S_OK, "Expected S_OK, got 0x%08lx\n", hr); +} + static void test_buffer_dc_props(HDC hdc, const RECT *rect) { static const XFORM ident = { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f }; @@ -2704,6 +2750,7 @@ START_TEST(system) test_OpenThemeData(); test_OpenThemeDataEx(); test_OpenThemeDataForDpi(); + test_OpenThemeFile(); test_GetCurrentThemeName(); test_GetThemePartSize(); test_CloseThemeData(); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4531
On Thu Nov 30 07:03:48 2023 +0000, Alex Henrie wrote:
changed this line in [version 2 of the diff](/wine/wine/-/merge_requests/4531/diffs?diff_id=86985&start_sha=dd9878c552841e6f9415ac3d667dd4510724d8f3#978755c9bd8ab45c22e7b177eb90b114a460dfdf_897_897) Fixed, thanks
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/4531#note_54353
On Thu Nov 30 04:09:34 2023 +0000, Zhiyi Zhang wrote:
Are you going to send a fix or it's just the test? Because if you have a fix then it's better to send it together. I haven't tried to fix it yet. I wrote the tests to reassure myself that I understand this function well enough to not break it.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/4531#note_54354
This merge request was approved by Zhiyi Zhang. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4531
participants (3)
-
Alex Henrie -
Alex Henrie (@alexhenrie) -
Zhiyi Zhang (@zhiyi)