From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/uiautomationcore/tests/uiautomation.c | 35 +++++++++----------- dlls/uiautomationcore/uia_client.c | 38 ++++++++++++++++++++-- 2 files changed, 52 insertions(+), 21 deletions(-)
diff --git a/dlls/uiautomationcore/tests/uiautomation.c b/dlls/uiautomationcore/tests/uiautomation.c index 19cebf79143..7a79ea2a4a5 100644 --- a/dlls/uiautomationcore/tests/uiautomation.c +++ b/dlls/uiautomationcore/tests/uiautomation.c @@ -6927,7 +6927,7 @@ static const struct prov_method_sequence cache_req_seq4[] = { /* Sequence for non-matching property condition. */ static const struct prov_method_sequence cache_req_seq5[] = { { &Provider, PROV_GET_PROPERTY_VALUE }, /* Dependent upon property condition. */ - { &Provider, PROV_GET_PROPERTY_VALUE }, /* Dependent upon property condition. */ + { &Provider, PROV_GET_PROPERTY_VALUE, METHOD_TODO }, /* Dependent upon property condition. */ /* Only done on Win10v1507 and below. */ { &Provider, FRAG_NAVIGATE, METHOD_OPTIONAL }, /* NavigateDirection_Parent */ { 0 } @@ -7343,21 +7343,19 @@ static void test_UiaGetUpdatedCache(void) tree_struct = NULL; out_req = NULL;
hr = UiaGetUpdatedCache(node, &cache_req, NormalizeState_View, NULL, &out_req, &tree_struct); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine ok(!!out_req, "out_req == NULL\n"); - todo_wine ok(!!tree_struct, "tree_struct == NULL\n"); - if (out_req) - { - exp_lbound[0] = exp_lbound[1] = 0; - exp_elems[0] = exp_elems[1] = 1; - test_cache_req_sa(out_req, exp_lbound, exp_elems, exp_node_desc); - ok(!wcscmp(tree_struct, L"P)"), "tree structure %s\n", debugstr_w(tree_struct)); - ok_method_sequence(cache_req_seq4, NULL); - } + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!!out_req, "out_req == NULL\n"); + ok(!!tree_struct, "tree_struct == NULL\n"); + + exp_lbound[0] = exp_lbound[1] = 0; + exp_elems[0] = exp_elems[1] = 1; + test_cache_req_sa(out_req, exp_lbound, exp_elems, exp_node_desc); + ok(!wcscmp(tree_struct, L"P)"), "tree structure %s\n", debugstr_w(tree_struct)); + ok_method_sequence(cache_req_seq4, NULL);
SafeArrayDestroy(out_req); SysFreeString(tree_struct); - VariantClear(&prop_cond.Value); + VariantClear(&v);
/* * Provider now returns VARIANT_TRUE for UIA_IsControlElementPropertyId, @@ -7377,13 +7375,12 @@ static void test_UiaGetUpdatedCache(void) tree_struct = NULL; out_req = NULL;
hr = UiaGetUpdatedCache(node, &cache_req, NormalizeState_View, NULL, &out_req, &tree_struct); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - if (SUCCEEDED(hr)) - ok_method_sequence(cache_req_seq5, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok_method_sequence(cache_req_seq5, NULL); ok(!out_req, "out_req != NULL\n"); - todo_wine ok(!!tree_struct, "tree_struct == NULL\n"); - if (tree_struct) - ok(!wcscmp(tree_struct, L""), "tree structure %s\n", debugstr_w(tree_struct)); + ok(!!tree_struct, "tree_struct == NULL\n"); + ok(!wcscmp(tree_struct, L""), "tree structure %s\n", debugstr_w(tree_struct)); + SysFreeString(tree_struct); VariantClear(&v);
diff --git a/dlls/uiautomationcore/uia_client.c b/dlls/uiautomationcore/uia_client.c index 4d3037b212c..328afa7acb2 100644 --- a/dlls/uiautomationcore/uia_client.c +++ b/dlls/uiautomationcore/uia_client.c @@ -1920,6 +1920,41 @@ static BOOL uia_condition_matched(HRESULT hr) return TRUE; }
+static HRESULT uia_property_condition_check(HUIANODE node, struct UiaPropertyCondition *prop_cond) +{ + const struct uia_prop_info *prop_info = uia_prop_info_from_id(prop_cond->PropertyId); + HRESULT hr; + VARIANT v; + + if (!prop_info) + return E_INVALIDARG; + + switch (prop_info->type) + { + case UIAutomationType_Bool: + hr = UiaGetPropertyValue(node, prop_info->prop_id, &v); + if (FAILED(hr) || V_VT(&v) == VT_UNKNOWN) + { + hr = S_FALSE; + break; + } + + if ((V_VT(&v) == V_VT(&prop_cond->Value)) && (V_BOOL(&v) == V_BOOL(&prop_cond->Value))) + hr = S_OK; + else + hr = S_FALSE; + + break; + + default: + FIXME("PropertyCondition comparison unimplemented for type %#x\n", prop_info->type); + return E_NOTIMPL; + } + + VariantClear(&v); + return hr; +} + static HRESULT uia_condition_check(HUIANODE node, struct UiaCondition *condition) { HRESULT hr; @@ -1971,8 +2006,7 @@ static HRESULT uia_condition_check(HUIANODE node, struct UiaCondition *condition }
case ConditionType_Property: - FIXME("Unhandled condition type %d\n", condition->ConditionType); - return E_NOTIMPL; + return uia_property_condition_check(node, (struct UiaPropertyCondition *)condition);
default: WARN("Invalid condition type %d\n", condition->ConditionType);