From ed1ed6aeb36ec31333e29b829c19c83d07e523b2 Mon Sep 17 00:00:00 2001 From: Connor McAdams Date: Fri, 3 Feb 2023 10:20:12 -0500 Subject: [PATCH] uiautomationcore: Add support for UIA_NamePropertyId to MSAA providers. Signed-off-by: Connor McAdams --- dlls/uiautomationcore/tests/uiautomation.c | 28 ++++++++++++++++++++++ dlls/uiautomationcore/uia_provider.c | 13 ++++++++++ 2 files changed, 41 insertions(+) diff --git a/dlls/uiautomationcore/tests/uiautomation.c b/dlls/uiautomationcore/tests/uiautomation.c index b30e592555c..f0112cd2ffb 100644 --- a/dlls/uiautomationcore/tests/uiautomation.c +++ b/dlls/uiautomationcore/tests/uiautomation.c @@ -3434,6 +3434,34 @@ static void test_uia_prov_from_acc_properties(void) IRawElementProviderSimple_Release(elprov); ok(Accessible.ref == 1, "Unexpected refcnt %ld\n", Accessible.ref); + + /* UIA_NamePropertyId tests. */ + set_accessible_props(&Accessible, 0, 0, 0, L"Accessible", 0, 0, 0, 0); + hr = pUiaProviderFromIAccessible(&Accessible.IAccessible_iface, CHILDID_SELF, UIA_PFIA_DEFAULT, &elprov); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(Accessible.ref == 2, "Unexpected refcnt %ld\n", Accessible.ref); + + SET_EXPECT(Accessible_get_accName); + VariantInit(&v); + hr = IRawElementProviderSimple_GetPropertyValue(elprov, UIA_NamePropertyId, &v); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(V_VT(&v) == VT_BSTR, "Unexpected VT %d\n", V_VT(&v)); + ok(!lstrcmpW(V_BSTR(&v), Accessible.name), "Unexpected BSTR %s\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + CHECK_CALLED(Accessible_get_accName); + + /* Name is not cached. */ + set_accessible_props(&Accessible, 0, 0, 0, L"Accessible2", 0, 0, 0, 0); + SET_EXPECT(Accessible_get_accName); + hr = IRawElementProviderSimple_GetPropertyValue(elprov, UIA_NamePropertyId, &v); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(V_VT(&v) == VT_BSTR, "Unexpected VT %d\n", V_VT(&v)); + ok(!lstrcmpW(V_BSTR(&v), Accessible.name), "Unexpected BSTR %s\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + CHECK_CALLED(Accessible_get_accName); + + IRawElementProviderSimple_Release(elprov); + ok(Accessible.ref == 1, "Unexpected refcnt %ld\n", Accessible.ref); } static void test_UiaProviderFromIAccessible(void) diff --git a/dlls/uiautomationcore/uia_provider.c b/dlls/uiautomationcore/uia_provider.c index c4fbd181ada..58d1db9bae8 100644 --- a/dlls/uiautomationcore/uia_provider.c +++ b/dlls/uiautomationcore/uia_provider.c @@ -664,6 +664,19 @@ HRESULT WINAPI msaa_provider_GetPropertyValue(IRawElementProviderSimple *iface, STATE_SYSTEM_PROTECTED)); break; + case UIA_NamePropertyId: + { + BSTR name; + + hr = IAccessible_get_accName(msaa_prov->acc, msaa_prov->cid, &name); + if (SUCCEEDED(hr) && name) + { + V_VT(ret_val) = VT_BSTR; + V_BSTR(ret_val) = name; + } + break; + } + default: FIXME("Unimplemented propertyId %d\n", prop_id); break;