Module: wine Branch: master Commit: 15f098c34e183d0e6e71187ef47972ceba79eb47 URL: https://gitlab.winehq.org/wine/wine/-/commit/15f098c34e183d0e6e71187ef47972c...
Author: Connor McAdams cmcadams@codeweavers.com Date: Thu Sep 21 06:53:16 2023 -0400
uiautomationcore: Implement IUIAutomationElement::get_CachedControlType.
Signed-off-by: Connor McAdams cmcadams@codeweavers.com
---
dlls/uiautomationcore/tests/uiautomation.c | 12 ++++----- dlls/uiautomationcore/uia_com_client.c | 43 +++++++++++++++++++++--------- 2 files changed, 37 insertions(+), 18 deletions(-)
diff --git a/dlls/uiautomationcore/tests/uiautomation.c b/dlls/uiautomationcore/tests/uiautomation.c index 1fd734bff65..4a5bca74b6a 100644 --- a/dlls/uiautomationcore/tests/uiautomation.c +++ b/dlls/uiautomationcore/tests/uiautomation.c @@ -13658,22 +13658,22 @@ static void test_Element_cache_methods(IUIAutomation *uia_iface)
/* Cached UIA_ControlTypePropertyId. */ hr = IUIAutomationElement_get_CachedControlType(element, NULL); - todo_wine ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
tmp_int = 0xdeadbeef; hr = IUIAutomationElement_get_CachedControlType(element, &tmp_int); - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); ok(tmp_int == 0xdeadbeef, "Unexpected control type %#x\n", tmp_int);
tmp_int = 0; hr = IUIAutomationElement_get_CachedControlType(element2, &tmp_int); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine ok(tmp_int == UIA_CustomControlTypeId, "Unexpected control type %#x\n", tmp_int); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(tmp_int == UIA_CustomControlTypeId, "Unexpected control type %#x\n", tmp_int);
tmp_int = 0; hr = IUIAutomationElement_get_CachedControlType(element3, &tmp_int); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine ok(tmp_int == UIA_HyperlinkControlTypeId, "Unexpected control type %#x\n", tmp_int); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(tmp_int == UIA_HyperlinkControlTypeId, "Unexpected control type %#x\n", tmp_int);
/* Cached UIA_BoundingRectanglePropertyId helper. */ hr = IUIAutomationElement_get_CachedBoundingRectangle(element, NULL); diff --git a/dlls/uiautomationcore/uia_com_client.c b/dlls/uiautomationcore/uia_com_client.c index d138d4ed919..e47c64c479b 100644 --- a/dlls/uiautomationcore/uia_com_client.c +++ b/dlls/uiautomationcore/uia_com_client.c @@ -2143,27 +2143,33 @@ static HRESULT WINAPI uia_element_get_CurrentProcessId(IUIAutomationElement9 *if return E_NOTIMPL; }
+static void uia_elem_get_control_type(VARIANT *v, CONTROLTYPEID *ret_val) +{ + const struct uia_control_type_info *info = NULL; + + *ret_val = UIA_CustomControlTypeId; + if (V_VT(v) != VT_I4) + return; + + if ((info = uia_control_type_info_from_id(V_I4(v)))) + *ret_val = info->control_type_id; + else + WARN("Provider returned invalid control type ID %ld\n", V_I4(v)); +} + static HRESULT WINAPI uia_element_get_CurrentControlType(IUIAutomationElement9 *iface, CONTROLTYPEID *ret_val) { struct uia_element *element = impl_from_IUIAutomationElement9(iface); - const struct uia_control_type_info *control_type_info = NULL; HRESULT hr; VARIANT v;
TRACE("%p, %p\n", iface, ret_val);
VariantInit(&v); - *ret_val = UIA_CustomControlTypeId; hr = UiaGetPropertyValue(element->node, UIA_ControlTypePropertyId, &v); - if (SUCCEEDED(hr) && V_VT(&v) == VT_I4) - { - if ((control_type_info = uia_control_type_info_from_id(V_I4(&v)))) - *ret_val = control_type_info->control_type_id; - else - WARN("Provider returned invalid control type ID %ld\n", V_I4(&v)); - } - + uia_elem_get_control_type(&v, ret_val); VariantClear(&v); + return hr; }
@@ -2393,8 +2399,21 @@ static HRESULT WINAPI uia_element_get_CachedProcessId(IUIAutomationElement9 *ifa
static HRESULT WINAPI uia_element_get_CachedControlType(IUIAutomationElement9 *iface, CONTROLTYPEID *ret_val) { - FIXME("%p: stub\n", iface); - return E_NOTIMPL; + struct uia_element *element = impl_from_IUIAutomationElement9(iface); + const int prop_id = UIA_ControlTypePropertyId; + struct uia_cache_property *cache_prop = NULL; + + TRACE("%p, %p\n", iface, ret_val); + + if (!ret_val) + return E_POINTER; + + if (!(cache_prop = bsearch(&prop_id, element->cached_props, element->cached_props_count, sizeof(*cache_prop), + uia_cached_property_id_compare))) + return E_INVALIDARG; + + uia_elem_get_control_type(&cache_prop->prop_val, ret_val); + return S_OK; }
static HRESULT WINAPI uia_element_get_CachedLocalizedControlType(IUIAutomationElement9 *iface, BSTR *ret_val)