From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/uiautomationcore/tests/uiautomation.c | 44 ++++++++++------------ dlls/uiautomationcore/uia_client.c | 43 ++++++++++----------- 2 files changed, 42 insertions(+), 45 deletions(-)
diff --git a/dlls/uiautomationcore/tests/uiautomation.c b/dlls/uiautomationcore/tests/uiautomation.c index f9e232d6fc3..5c15c9344c9 100644 --- a/dlls/uiautomationcore/tests/uiautomation.c +++ b/dlls/uiautomationcore/tests/uiautomation.c @@ -8791,35 +8791,31 @@ static void test_UiaFind(void) AutomationElementMode_Full); set_find_params(&find_params, 1, TRUE, TRUE, (struct UiaCondition *)&UiaTrueCondition); hr = UiaFind(node, &find_params, &cache_req, &out_req, &offsets, &tree_structs); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine ok(Provider_child.ref == 2, "Unexpected refcnt %ld\n", Provider_child.ref); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(Provider_child.ref == 2, "Unexpected refcnt %ld\n", Provider_child.ref);
- node2 = NULL; - if (SUCCEEDED(hr)) - { - add_provider_desc(&exp_node_desc[0], L"Main", L"Provider_child", TRUE); - exp_lbound[0] = exp_lbound[1] = 0; - exp_elems[0] = exp_elems[1] = 1; + add_provider_desc(&exp_node_desc[0], L"Main", L"Provider_child", TRUE); + exp_lbound[0] = exp_lbound[1] = 0; + exp_elems[0] = exp_elems[1] = 1;
- idx[0] = idx[1] = 0; - hr = SafeArrayGetElement(out_req, idx, &v); - ok(hr == S_OK, "Unexpected hr %#lx\n", hr); + idx[0] = idx[1] = 0; + hr = SafeArrayGetElement(out_req, idx, &v); + ok(hr == S_OK, "Unexpected hr %#lx\n", hr);
- /* node2 is now set as Provider_child. */ - hr = UiaHUiaNodeFromVariant(&v, &node2); - ok(hr == S_OK, "Unexpected hr %#lx\n", hr); - IUnknown_AddRef((IUnknown *)node2); + /* node2 is now set as Provider_child. */ + hr = UiaHUiaNodeFromVariant(&v, &node2); + ok(hr == S_OK, "Unexpected hr %#lx\n", hr); + IUnknown_AddRef((IUnknown *)node2);
- test_cache_req_sa(out_req, exp_lbound, exp_elems, exp_node_desc); + test_cache_req_sa(out_req, exp_lbound, exp_elems, exp_node_desc);
- for (i = 0; i < exp_elems[0]; i++) - { - exp_offset[i] = i; - exp_tree_struct[i] = L"P)"; - } - test_find_sa_results(tree_structs, offsets, exp_elems[0], exp_tree_struct, exp_offset); - ok_method_sequence(find_seq4, "find_seq4"); + for (i = 0; i < exp_elems[0]; i++) + { + exp_offset[i] = i; + exp_tree_struct[i] = L"P)"; } + test_find_sa_results(tree_structs, offsets, exp_elems[0], exp_tree_struct, exp_offset); + ok_method_sequence(find_seq4, "find_seq4");
SafeArrayDestroy(out_req); SafeArrayDestroy(offsets); @@ -8901,7 +8897,7 @@ static void test_UiaFind(void) SafeArrayDestroy(offsets); SafeArrayDestroy(tree_structs);
- todo_wine ok(UiaNodeRelease(node2), "UiaNodeRelease returned FALSE\n"); + ok(UiaNodeRelease(node2), "UiaNodeRelease returned FALSE\n"); ok(Provider_child.ref == 1, "Unexpected refcnt %ld\n", Provider_child.ref);
initialize_provider_tree(); diff --git a/dlls/uiautomationcore/uia_client.c b/dlls/uiautomationcore/uia_client.c index e553ea6b5e2..70c3488c8a9 100644 --- a/dlls/uiautomationcore/uia_client.c +++ b/dlls/uiautomationcore/uia_client.c @@ -927,8 +927,8 @@ exit: }
static HRESULT find_uia_node(HUIANODE huianode, struct UiaCondition *view_cond, struct UiaCondition *match_cond, - struct UiaCondition *sibling_stop_cond, int traversal_opts, BOOL recursive_call, int max_depth, int *cur_depth, - HUIANODE *out_node) + struct UiaCondition *sibling_stop_cond, int traversal_opts, BOOL recursive_call, BOOL exclude_root, + BOOL *root_found, int max_depth, int *cur_depth, HUIANODE *out_node) { struct uia_node *node = unsafe_impl_from_IWineUiaNode((IWineUiaNode *)huianode); BOOL incr_depth = FALSE; @@ -942,17 +942,22 @@ static HRESULT find_uia_node(HUIANODE huianode, struct UiaCondition *view_cond, if (uia_condition_matched(hr)) { incr_depth = TRUE; - hr = uia_condition_check(huianode, match_cond); - if (FAILED(hr)) - goto exit;
- if (uia_condition_matched(hr)) + if (!(exclude_root && !(*root_found))) { - IWineUiaNode_AddRef((IWineUiaNode *)huianode); - *out_node = huianode; - hr = S_FALSE; - goto exit; + hr = uia_condition_check(huianode, match_cond); + if (FAILED(hr)) + goto exit; + + if (uia_condition_matched(hr)) + { + IWineUiaNode_AddRef((IWineUiaNode *)huianode); + *out_node = huianode; + hr = S_FALSE; + goto exit; + } } + *root_found = TRUE; }
if (incr_depth) @@ -967,8 +972,8 @@ static HRESULT find_uia_node(HUIANODE huianode, struct UiaCondition *view_cond, hr = navigate_uia_node(node, NavigateDirection_FirstChild, &node2);
if (SUCCEEDED(hr) && node2) - hr = find_uia_node(node2, view_cond, match_cond, sibling_stop_cond, traversal_opts, TRUE, max_depth, - cur_depth, out_node); + hr = find_uia_node(node2, view_cond, match_cond, sibling_stop_cond, traversal_opts, TRUE, exclude_root, + root_found, max_depth, cur_depth, out_node);
if (FAILED(hr) || hr == S_FALSE) goto exit; @@ -992,8 +997,8 @@ static HRESULT find_uia_node(HUIANODE huianode, struct UiaCondition *view_cond, hr = get_tree_sibling_node(huianode, view_cond, NavigateDirection_NextSibling, !recursive_call, &node2);
if (SUCCEEDED(hr) && node2) - hr = find_uia_node(node2, view_cond, match_cond, sibling_stop_cond, traversal_opts, recursive_call, max_depth, - cur_depth, out_node); + hr = find_uia_node(node2, view_cond, match_cond, sibling_stop_cond, traversal_opts, recursive_call, exclude_root, + root_found, max_depth, cur_depth, out_node);
exit: UiaNodeRelease(huianode); @@ -2698,6 +2703,7 @@ HRESULT WINAPI UiaFind(HUIANODE huianode, struct UiaFindParams *find_params, str struct uia_node *node = unsafe_impl_from_IWineUiaNode((IWineUiaNode *)huianode); SAFEARRAY *runtime_id, *req, *offsets, *tree_structs; struct UiaCondition *sibling_stop_cond; + BOOL root_found = FALSE; int cur_depth = 0; BSTR tree_struct; HUIANODE node2; @@ -2717,12 +2723,6 @@ HRESULT WINAPI UiaFind(HUIANODE huianode, struct UiaFindParams *find_params, str return E_NOTIMPL; }
- if (find_params->ExcludeRoot) - { - FIXME("ExcludeRoot currently unimplemented.\n"); - return E_NOTIMPL; - } - /* * If the initial node has a runtime ID, we'll use it as a stop * condition. @@ -2740,7 +2740,8 @@ HRESULT WINAPI UiaFind(HUIANODE huianode, struct UiaFindParams *find_params, str node2 = NULL; IWineUiaNode_AddRef(&node->IWineUiaNode_iface); hr = find_uia_node(huianode, cache_req->pViewCondition, find_params->pFindCondition, sibling_stop_cond, - TreeTraversalOptions_Default, FALSE, find_params->MaxDepth, &cur_depth, &node2); + TreeTraversalOptions_Default, FALSE, find_params->ExcludeRoot, &root_found, find_params->MaxDepth, + &cur_depth, &node2); if (FAILED(hr) || !node2) goto exit;