From 6f2aa68e9fc8d22a7c64a63f70f26237a951e1d4 Mon Sep 17 00:00:00 2001 From: Connor McAdams Date: Tue, 14 Feb 2023 16:17:09 -0500 Subject: [PATCH] uiautomationcore: Implement ILegacyIAccessibleProvider::get_Role for MSAA providers. Signed-off-by: Connor McAdams --- dlls/uiautomationcore/tests/uiautomation.c | 19 +++++++++++++++++++ dlls/uiautomationcore/uia_provider.c | 15 +++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/dlls/uiautomationcore/tests/uiautomation.c b/dlls/uiautomationcore/tests/uiautomation.c index 14195fff8b5..6d2e859a7f6 100644 --- a/dlls/uiautomationcore/tests/uiautomation.c +++ b/dlls/uiautomationcore/tests/uiautomation.c @@ -3556,6 +3556,9 @@ static void test_uia_prov_from_acc_properties(void) for (i = 0; i < ARRAY_SIZE(msaa_role_uia_types); i++) { const struct msaa_role_uia_type *role = &msaa_role_uia_types[i]; + ILegacyIAccessibleProvider *accprov; + DWORD role_val; + IUnknown *unk; /* * Roles get cached once a valid one is mapped, so create a new @@ -3588,6 +3591,22 @@ static void test_uia_prov_from_acc_properties(void) if (!role->uia_control_type) CHECK_CALLED(Accessible_get_accRole); + hr = IRawElementProviderSimple_GetPatternProvider(elprov, UIA_LegacyIAccessiblePatternId, &unk); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!!unk, "unk == NULL\n"); + + hr = IUnknown_QueryInterface(unk, &IID_ILegacyIAccessibleProvider, (void **)&accprov); + IUnknown_Release(unk); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!!accprov, "accprov == NULL\n"); + + SET_EXPECT(Accessible_get_accRole); + hr = ILegacyIAccessibleProvider_get_Role(accprov, &role_val); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(role_val == Accessible.role, "role_val != Accessible.role\n"); + CHECK_CALLED(Accessible_get_accRole); + + ILegacyIAccessibleProvider_Release(accprov); IRawElementProviderSimple_Release(elprov); ok(Accessible.ref == 1, "Unexpected refcnt %ld\n", Accessible.ref); } diff --git a/dlls/uiautomationcore/uia_provider.c b/dlls/uiautomationcore/uia_provider.c index a950df599d8..59be5d3782a 100644 --- a/dlls/uiautomationcore/uia_provider.c +++ b/dlls/uiautomationcore/uia_provider.c @@ -1066,8 +1066,19 @@ static HRESULT WINAPI msaa_acc_provider_get_Description(ILegacyIAccessibleProvid static HRESULT WINAPI msaa_acc_provider_get_Role(ILegacyIAccessibleProvider *iface, DWORD *out_role) { - FIXME("%p, %p: stub!\n", iface, out_role); - return E_NOTIMPL; + struct msaa_provider *msaa_prov = impl_from_msaa_acc_provider(iface); + HRESULT hr; + VARIANT v; + + TRACE("%p, %p\n", iface, out_role); + + *out_role = 0; + VariantInit(&v); + hr = IAccessible_get_accRole(msaa_prov->acc, msaa_prov->cid, &v); + if (SUCCEEDED(hr) && V_VT(&v) == VT_I4) + *out_role = V_I4(&v); + + return S_OK; } static HRESULT WINAPI msaa_acc_provider_get_State(ILegacyIAccessibleProvider *iface, DWORD *out_state)