Commit 15f098c3 authored by Connor McAdams's avatar Connor McAdams Committed by Alexandre Julliard

uiautomationcore: Implement IUIAutomationElement::get_CachedControlType.

parent 6d0047ad
......@@ -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);
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment