From: Connor McAdams cmcadams@codeweavers.com
Add support for ConditionType_{True/False}.
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/uiautomationcore/tests/uiautomation.c | 56 +++++++++--------- dlls/uiautomationcore/uia_client.c | 68 ++++++++++++++++++++-- 2 files changed, 89 insertions(+), 35 deletions(-)
diff --git a/dlls/uiautomationcore/tests/uiautomation.c b/dlls/uiautomationcore/tests/uiautomation.c index 136f5a08dcf..96c2c128906 100644 --- a/dlls/uiautomationcore/tests/uiautomation.c +++ b/dlls/uiautomationcore/tests/uiautomation.c @@ -6949,12 +6949,12 @@ static void test_UiaGetUpdatedCache(void) tree_struct = NULL; out_req = NULL; set_cache_request(&cache_req, (struct UiaCondition *)&UiaFalseCondition, TreeScope_Element, NULL, 0, NULL, 0, AutomationElementMode_Full); hr = UiaGetUpdatedCache(node, &cache_req, NormalizeState_View, NULL, &out_req, &tree_struct); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(!out_req, "out_req != NULL\n"); + /* Empty tree structure string. */ - 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); ok_method_sequence(cache_req_seq2, "cache_req_seq2");
@@ -6965,17 +6965,15 @@ static void test_UiaGetUpdatedCache(void) tree_struct = NULL; out_req = NULL; set_cache_request(&cache_req, (struct UiaCondition *)&UiaTrueCondition, TreeScope_Element, NULL, 0, NULL, 0, AutomationElementMode_Full); 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_seq1, "cache_req_seq1"); - } + 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_seq1, "cache_req_seq1");
SafeArrayDestroy(out_req); SysFreeString(tree_struct); @@ -6987,12 +6985,12 @@ static void test_UiaGetUpdatedCache(void) set_cache_request(&cache_req, (struct UiaCondition *)&UiaTrueCondition, TreeScope_Element, NULL, 0, NULL, 0, AutomationElementMode_Full); tree_struct = NULL; out_req = NULL; hr = UiaGetUpdatedCache(node, &cache_req, NormalizeState_Custom, (struct UiaCondition *)&UiaFalseCondition, &out_req, &tree_struct); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(!out_req, "out_req != NULL\n"); + /* Empty tree structure string. */ - 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);
ok_method_sequence(cache_req_seq2, "cache_req_seq2"); @@ -7004,17 +7002,15 @@ static void test_UiaGetUpdatedCache(void) tree_struct = NULL; out_req = NULL; set_cache_request(&cache_req, (struct UiaCondition *)&UiaTrueCondition, TreeScope_Element, NULL, 0, NULL, 0, AutomationElementMode_Full); hr = UiaGetUpdatedCache(node, &cache_req, NormalizeState_Custom, (struct UiaCondition *)&UiaTrueCondition, &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_seq1, "cache_req_seq1"); - } + 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_seq1, "cache_req_seq1");
SafeArrayDestroy(out_req); SysFreeString(tree_struct); diff --git a/dlls/uiautomationcore/uia_client.c b/dlls/uiautomationcore/uia_client.c index 2bb418e8086..12b53891dcd 100644 --- a/dlls/uiautomationcore/uia_client.c +++ b/dlls/uiautomationcore/uia_client.c @@ -1912,6 +1912,37 @@ void WINAPI UiaRegisterProviderCallback(UiaProviderCallback *callback) uia_provider_callback = default_uia_provider_callback; }
+static BOOL uia_condition_matched(HRESULT hr) +{ + if (hr == S_FALSE) + return FALSE; + else + return TRUE; +} + +static HRESULT uia_condition_check(HUIANODE node, struct UiaCondition *condition) +{ + switch (condition->ConditionType) + { + case ConditionType_True: + return S_OK; + + case ConditionType_False: + return S_FALSE; + + case ConditionType_Property: + case ConditionType_And: + case ConditionType_Or: + case ConditionType_Not: + FIXME("Unhandled condition type %d\n", condition->ConditionType); + return E_NOTIMPL; + + default: + WARN("Invalid condition type %d\n", condition->ConditionType); + return E_INVALIDARG; + } +} + /*********************************************************************** * UiaGetUpdatedCache (uiautomationcore.@) */ @@ -1919,6 +1950,7 @@ HRESULT WINAPI UiaGetUpdatedCache(HUIANODE huianode, struct UiaCacheRequest *cac struct UiaCondition *normalize_cond, SAFEARRAY **out_req, BSTR *tree_struct) { struct uia_node *node = unsafe_impl_from_IWineUiaNode((IWineUiaNode *)huianode); + struct UiaCondition *cond; SAFEARRAYBOUND sabound[2]; SAFEARRAY *sa; LONG idx[2]; @@ -1933,16 +1965,42 @@ HRESULT WINAPI UiaGetUpdatedCache(HUIANODE huianode, struct UiaCacheRequest *cac *tree_struct = NULL; *out_req = NULL;
- if (normalize_state != NormalizeState_None) + if (cache_req->Scope != TreeScope_Element) { - FIXME("Unsupported NormalizeState %d\n", normalize_state); + FIXME("Unsupported cache request scope %#x\n", cache_req->Scope); return E_NOTIMPL; }
- if (cache_req->Scope != TreeScope_Element) + switch (normalize_state) { - FIXME("Unsupported cache request scope %#x\n", cache_req->Scope); - return E_NOTIMPL; + case NormalizeState_None: + cond = NULL; + break; + + case NormalizeState_View: + cond = cache_req->pViewCondition; + break; + + case NormalizeState_Custom: + cond = normalize_cond; + break; + + default: + WARN("Invalid normalize_state %d\n", normalize_state); + return E_INVALIDARG; + } + + if (cond) + { + hr = uia_condition_check(huianode, cond); + if (FAILED(hr)) + return hr; + + if (!uia_condition_matched(hr)) + { + *tree_struct = SysAllocString(L""); + return S_OK; + } }
sabound[0].cElements = sabound[1].cElements = 1;