Module: wine Branch: master Commit: c31e5313184380e1ec31a06ee62d2c9ae971b215 URL: https://gitlab.winehq.org/wine/wine/-/commit/c31e5313184380e1ec31a06ee62d2c9...
Author: Connor McAdams cmcadams@codeweavers.com Date: Fri Feb 3 09:36:10 2023 -0500
uiautomationcore: Implement IUIAutomationElement::get_CurrentName.
Signed-off-by: Connor McAdams cmcadams@codeweavers.com
---
dlls/uiautomationcore/tests/uiautomation.c | 20 ++++++++++++++++++++ dlls/uiautomationcore/uia_com_client.c | 17 +++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/dlls/uiautomationcore/tests/uiautomation.c b/dlls/uiautomationcore/tests/uiautomation.c index a5b15726c21..1fd25a49441 100644 --- a/dlls/uiautomationcore/tests/uiautomation.c +++ b/dlls/uiautomationcore/tests/uiautomation.c @@ -9796,6 +9796,7 @@ static void test_Element_GetPropertyValue(IUIAutomation *uia_iface) IUIAutomationElement *element; int i, prop_id, tmp_int; IUnknown *unk_ns; + BSTR tmp_bstr; HRESULT hr; VARIANT v;
@@ -9885,6 +9886,25 @@ static void test_Element_GetPropertyValue(IUIAutomation *uia_iface) set_provider_prop_override(&Provider, NULL, 0); ok_method_sequence(get_prop_seq, NULL);
+ /* + * IUIAutomationElement_get_CurrentName tests. + */ + tmp_bstr = NULL; + hr = IUIAutomationElement_get_CurrentName(element, &tmp_bstr); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!lstrcmpW(tmp_bstr, uia_bstr_prop_str), "Unexpected BSTR %s\n", wine_dbgstr_w(tmp_bstr)); + SysFreeString(tmp_bstr); + ok_method_sequence(get_prop_seq, NULL); + + tmp_bstr = NULL; + Provider.ret_invalid_prop_type = TRUE; + hr = IUIAutomationElement_get_CurrentName(element, &tmp_bstr); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!lstrcmpW(tmp_bstr, L""), "Unexpected BSTR %s\n", wine_dbgstr_w(tmp_bstr)); + SysFreeString(tmp_bstr); + Provider.ret_invalid_prop_type = FALSE; + ok_method_sequence(get_prop_invalid_type_seq, NULL); + IUIAutomationElement_Release(element); ok(Provider.ref == 1, "Unexpected refcnt %ld\n", Provider.ref);
diff --git a/dlls/uiautomationcore/uia_com_client.c b/dlls/uiautomationcore/uia_com_client.c index dad5938a760..8cc39a9342f 100644 --- a/dlls/uiautomationcore/uia_com_client.c +++ b/dlls/uiautomationcore/uia_com_client.c @@ -269,8 +269,21 @@ static HRESULT WINAPI uia_element_get_CurrentLocalizedControlType(IUIAutomationE
static HRESULT WINAPI uia_element_get_CurrentName(IUIAutomationElement9 *iface, BSTR *ret_val) { - FIXME("%p: stub\n", iface); - return E_NOTIMPL; + struct uia_element *element = impl_from_IUIAutomationElement9(iface); + HRESULT hr; + VARIANT v; + + TRACE("%p, %p\n", iface, ret_val); + + VariantInit(&v); + hr = UiaGetPropertyValue(element->node, UIA_NamePropertyId, &v); + if (SUCCEEDED(hr) && V_VT(&v) == VT_BSTR && V_BSTR(&v)) + *ret_val = SysAllocString(V_BSTR(&v)); + else + *ret_val = SysAllocString(L""); + + VariantClear(&v); + return hr; }
static HRESULT WINAPI uia_element_get_CurrentAcceleratorKey(IUIAutomationElement9 *iface, BSTR *ret_val)