1
0
Fork 0
mirror of synced 2025-03-07 03:53:26 +01:00

uiautomationcore: Implement IUIAutomationElement::get_CachedControlType.

Signed-off-by: Connor McAdams <cmcadams@codeweavers.com>
This commit is contained in:
Connor McAdams 2023-09-21 06:53:16 -04:00 committed by Alexandre Julliard
parent 6d0047ad66
commit 15f098c34e
2 changed files with 37 additions and 18 deletions

View file

@ -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);

View file

@ -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)