uiautomationcore: Add basic UiaCondition support to UiaGetUpdatedCache.

Add support for ConditionType_{True/False}.

Signed-off-by: Connor McAdams <cmcadams@codeweavers.com>
This commit is contained in:
Connor McAdams 2022-10-24 10:59:17 -04:00 committed by Alexandre Julliard
parent 272c4a59b0
commit d13d704f11
2 changed files with 90 additions and 36 deletions

View file

@ -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);

View file

@ -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,18 +1965,44 @@ HRESULT WINAPI UiaGetUpdatedCache(HUIANODE huianode, struct UiaCacheRequest *cac
*tree_struct = NULL;
*out_req = NULL;
if (normalize_state != NormalizeState_None)
{
FIXME("Unsupported NormalizeState %d\n", normalize_state);
return E_NOTIMPL;
}
if (cache_req->Scope != TreeScope_Element)
{
FIXME("Unsupported cache request scope %#x\n", cache_req->Scope);
return E_NOTIMPL;
}
switch (normalize_state)
{
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;
sabound[0].lLbound = sabound[1].lLbound = 0;
if (!(sa = SafeArrayCreate(VT_VARIANT, 2, sabound)))