Module: wine Branch: master Commit: 2f3673ca7b50fe260c1715d39abcbce1954515a1 URL: https://gitlab.winehq.org/wine/wine/-/commit/2f3673ca7b50fe260c1715d39abcbce...
Author: Connor McAdams cmcadams@codeweavers.com Date: Thu Feb 23 11:48:02 2023 -0500
uiautomationcore: Implement UIA_NamePropertyId for default HWND provider.
Signed-off-by: Connor McAdams cmcadams@codeweavers.com
---
dlls/uiautomationcore/tests/uiautomation.c | 5 ++-- dlls/uiautomationcore/uia_provider.c | 42 ++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 5 deletions(-)
diff --git a/dlls/uiautomationcore/tests/uiautomation.c b/dlls/uiautomationcore/tests/uiautomation.c index beb34fb400f..ddeb3f3f055 100644 --- a/dlls/uiautomationcore/tests/uiautomation.c +++ b/dlls/uiautomationcore/tests/uiautomation.c @@ -12336,9 +12336,8 @@ static void test_node_hwnd_provider_(HUIANODE node, HWND hwnd, const char *file, SendMessageW(hwnd, WM_GETTEXT, ARRAY_SIZE(buf), (LPARAM)buf); hr = UiaGetPropertyValue(node, UIA_NamePropertyId, &v); ok_(file, line)(hr == S_OK, "Unexpected hr %#lx\n", hr); - todo_wine ok_(file, line)(V_VT(&v) == VT_BSTR, "Unexpected VT %d\n", V_VT(&v)); - if (V_VT(&v) == VT_BSTR) - ok(!lstrcmpW(V_BSTR(&v), buf), "Unexpected BSTR %s\n", wine_dbgstr_w(V_BSTR(&v))); + ok_(file, line)(V_VT(&v) == VT_BSTR, "Unexpected VT %d\n", V_VT(&v)); + ok(!lstrcmpW(V_BSTR(&v), buf), "Unexpected BSTR %s\n", wine_dbgstr_w(V_BSTR(&v))); VariantClear(&v); winetest_pop_context();
diff --git a/dlls/uiautomationcore/uia_provider.c b/dlls/uiautomationcore/uia_provider.c index 9c9ad2a426e..ed00abaf33b 100644 --- a/dlls/uiautomationcore/uia_provider.c +++ b/dlls/uiautomationcore/uia_provider.c @@ -1206,10 +1206,27 @@ static HRESULT uia_get_hr_for_last_error(void) { DWORD last_err = GetLastError();
- if (last_err == ERROR_INVALID_WINDOW_HANDLE) + switch (last_err) + { + case ERROR_INVALID_WINDOW_HANDLE: return UIA_E_ELEMENTNOTAVAILABLE;
- return E_FAIL; + case ERROR_TIMEOUT: + return UIA_E_TIMEOUT; + + default: + return E_FAIL; + } +} + +#define UIA_DEFAULT_MSG_TIMEOUT 10000 +static HRESULT uia_send_message_timeout(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, UINT timeout, LRESULT *lres) +{ + *lres = 0; + if (!SendMessageTimeoutW(hwnd, msg, wparam, lparam, SMTO_NORMAL, timeout, (PDWORD_PTR)lres)) + return uia_get_hr_for_last_error(); + + return S_OK; }
/* @@ -1328,6 +1345,27 @@ static HRESULT WINAPI base_hwnd_provider_GetPropertyValue(IRawElementProviderSim break; }
+ case UIA_NamePropertyId: + { + LRESULT lres; + + V_VT(ret_val) = VT_BSTR; + V_BSTR(ret_val) = SysAllocString(L""); + hr = uia_send_message_timeout(base_hwnd_prov->hwnd, WM_GETTEXTLENGTH, 0, 0, UIA_DEFAULT_MSG_TIMEOUT, &lres); + if (FAILED(hr) || !lres) + break; + + if (!SysReAllocStringLen(&V_BSTR(ret_val), NULL, lres)) + { + hr = E_OUTOFMEMORY; + break; + } + + hr = uia_send_message_timeout(base_hwnd_prov->hwnd, WM_GETTEXT, SysStringLen(V_BSTR(ret_val)) + 1, + (LPARAM)V_BSTR(ret_val), UIA_DEFAULT_MSG_TIMEOUT, &lres); + break; + } + default: break; }