7#include <UIAutomationClient.h>
8#include <UIAutomationCoreApi.h>
20#include "flutter/fml/logging.h"
21#include "flutter/fml/platform/win/wstring_conversion.h"
23using Microsoft::WRL::ComPtr;
28#define EXPECT_UIA_INVALIDOPERATION(expr) \
29 EXPECT_EQ(static_cast<HRESULT>(UIA_E_INVALIDOPERATION), (expr))
30#define EXPECT_INVALIDARG(expr) \
31 EXPECT_EQ(static_cast<HRESULT>(E_INVALIDARG), (expr))
44 ITextRangeProvider* destination_range) {
45 ComPtr<ITextRangeProvider> destination_provider = destination_range;
46 ComPtr<AXPlatformNodeTextRangeProviderWin> destination_provider_interal;
48 destination_provider->QueryInterface(
49 IID_PPV_ARGS(&destination_provider_interal));
50 destination_provider_interal->SetOwnerForTesting(owner);
53 const AXPlatformNodeTextProviderWin* text_provider) {
54 return text_provider->owner_.Get();
57 const AXPlatformNodeTextRangeProviderWin* text_range) {
58 return text_range->start();
61 const AXPlatformNodeTextRangeProviderWin* text_range) {
62 return text_range->end();
70 text1_data.
SetName(
"some text");
75 text2_data.
SetName(
"more text");
91 update.tree_data = tree_data;
92 update.has_tree_data =
true;
94 update.nodes = {root_data, link_data, text1_data, text2_data};
97 AXNode* root_node = GetRootAsAXNode();
100 AXPlatformNodeWin* owner =
101 static_cast<AXPlatformNodeWin*
>(AXPlatformNodeFromNode(root_node));
104 ComPtr<IRawElementProviderSimple> root_node_raw =
105 QueryInterfaceFromNode<IRawElementProviderSimple>(root_node);
106 ComPtr<IRawElementProviderSimple> link_node_raw =
107 QueryInterfaceFromNode<IRawElementProviderSimple>(link_node);
108 ComPtr<IRawElementProviderSimple> text2_node_raw =
109 QueryInterfaceFromNode<IRawElementProviderSimple>(text2_node);
111 ComPtr<AXPlatformNodeWin> root_platform_node;
112 EXPECT_HRESULT_SUCCEEDED(
113 root_node_raw->QueryInterface(IID_PPV_ARGS(&root_platform_node)));
114 ComPtr<AXPlatformNodeWin> link_platform_node;
115 EXPECT_HRESULT_SUCCEEDED(
116 link_node_raw->QueryInterface(IID_PPV_ARGS(&link_platform_node)));
117 ComPtr<AXPlatformNodeWin> text2_platform_node;
118 EXPECT_HRESULT_SUCCEEDED(
119 text2_node_raw->QueryInterface(IID_PPV_ARGS(&text2_platform_node)));
123 ComPtr<ITextRangeProvider> text_range_provider =
124 AXPlatformNodeTextProviderWin::CreateDegenerateRangeAtStart(
125 root_platform_node.Get());
126 SetOwner(owner, text_range_provider.Get());
128 EXPECT_HRESULT_SUCCEEDED(
129 text_range_provider->GetText(-1, text_content.
Receive()));
130 EXPECT_EQ(0, wcscmp(text_content.
Get(),
L""));
132 ComPtr<AXPlatformNodeTextRangeProviderWin> actual_range;
133 text_range_provider->QueryInterface(IID_PPV_ARGS(&actual_range));
135 expected_start = root_platform_node->GetDelegate()->CreateTextPositionAt(0);
136 expected_end = expected_start->Clone();
137 EXPECT_EQ(*GetStart(actual_range.Get()), *expected_start);
138 EXPECT_EQ(*GetEnd(actual_range.Get()), *expected_end);
143 text_range_provider =
144 AXPlatformNodeTextProviderWin::CreateDegenerateRangeAtStart(
145 link_platform_node.Get());
146 SetOwner(owner, text_range_provider.Get());
147 EXPECT_HRESULT_SUCCEEDED(
148 text_range_provider->GetText(-1, text_content.
Receive()));
149 EXPECT_EQ(0, wcscmp(text_content.
Get(),
L""));
150 text_range_provider->QueryInterface(IID_PPV_ARGS(&actual_range));
151 EXPECT_EQ(*GetStart(actual_range.Get()), *expected_start);
152 EXPECT_EQ(*GetEnd(actual_range.Get()), *expected_end);
157 text_range_provider =
158 AXPlatformNodeTextProviderWin::CreateDegenerateRangeAtStart(
159 text2_platform_node.Get());
160 SetOwner(owner, text_range_provider.Get());
161 EXPECT_HRESULT_SUCCEEDED(
162 text_range_provider->GetText(-1, text_content.
Receive()));
163 EXPECT_EQ(0, wcscmp(text_content.
Get(),
L""));
164 text_range_provider->QueryInterface(IID_PPV_ARGS(&actual_range));
165 expected_start = text2_platform_node->GetDelegate()->CreateTextPositionAt(0);
166 expected_end = expected_start->Clone();
167 EXPECT_EQ(*GetStart(actual_range.Get()), *expected_start);
168 EXPECT_EQ(*GetEnd(actual_range.Get()), *expected_end);
176 text_data.
SetName(
"some text");
179 empty_text_data.
id = 3;
192 update.tree_data = tree_data;
193 update.has_tree_data =
true;
195 update.nodes.push_back(root_data);
196 update.nodes.push_back(text_data);
197 update.nodes.push_back(empty_text_data);
201 AXNode* root_node = GetRootAsAXNode();
204 AXPlatformNodeWin* owner =
205 static_cast<AXPlatformNodeWin*
>(AXPlatformNodeFromNode(root_node));
208 ComPtr<IRawElementProviderSimple> root_node_raw =
209 QueryInterfaceFromNode<IRawElementProviderSimple>(root_node);
210 ComPtr<IRawElementProviderSimple> text_node_raw =
211 QueryInterfaceFromNode<IRawElementProviderSimple>(text_node);
212 ComPtr<IRawElementProviderSimple> empty_text_node_raw =
213 QueryInterfaceFromNode<IRawElementProviderSimple>(empty_text_node);
216 ComPtr<ITextProvider> text_provider;
217 EXPECT_HRESULT_SUCCEEDED(
218 root_node_raw->GetPatternProvider(UIA_TextPatternId, &text_provider));
220 ComPtr<ITextRangeProvider> text_range_provider;
221 EXPECT_HRESULT_SUCCEEDED(
222 text_provider->RangeFromChild(text_node_raw.Get(), &text_range_provider));
223 SetOwner(owner, text_range_provider.Get());
226 EXPECT_HRESULT_SUCCEEDED(
227 text_range_provider->GetText(-1, text_content.
Receive()));
228 EXPECT_EQ(0, wcscmp(text_content.
Get(),
L"some text"));
232 EXPECT_HRESULT_SUCCEEDED(
233 text_node_raw->GetPatternProvider(UIA_TextPatternId, &text_provider));
236 text_provider->RangeFromChild(root_node_raw.Get(), &text_range_provider));
239 EXPECT_HRESULT_SUCCEEDED(
240 root_node_raw->GetPatternProvider(UIA_TextPatternId, &text_provider));
242 EXPECT_HRESULT_SUCCEEDED(text_provider->RangeFromChild(
243 empty_text_node_raw.Get(), &text_range_provider));
244 SetOwner(owner, text_range_provider.Get());
247 EXPECT_HRESULT_SUCCEEDED(
248 text_range_provider->GetText(-1, empty_text_content.
Receive()));
249 EXPECT_EQ(0, wcscmp(empty_text_content.
Get(),
L""));
254 ComPtr<IRawElementProviderSimple> other_root_node_raw;
256 &other_root_node_raw);
258 EXPECT_HRESULT_SUCCEEDED(
259 root_node_raw->GetPatternProvider(UIA_TextPatternId, &text_provider));
262 other_root_node_raw.Get(), &text_range_provider));
266 ITextProviderRangeFromChildMultipleChildren) {
267 const int ROOT_ID = 1;
268 const int DIALOG_ID = 2;
269 const int DIALOG_LABEL_ID = 3;
270 const int DIALOG_DESCRIPTION_ID = 4;
271 const int BUTTON_ID = 5;
272 const int BUTTON_IMG_ID = 6;
273 const int BUTTON_TEXT_ID = 7;
274 const int DIALOG_DETAIL_ID = 8;
279 root.SetName(
"Document");
280 root.child_ids = {DIALOG_ID};
283 dialog.
id = DIALOG_ID;
285 dialog.
child_ids = {DIALOG_LABEL_ID, DIALOG_DESCRIPTION_ID, BUTTON_ID,
289 dialog_label.
id = DIALOG_LABEL_ID;
291 dialog_label.
SetName(
"Dialog label.");
294 dialog_description.
id = DIALOG_DESCRIPTION_ID;
296 dialog_description.
SetName(
"Dialog description.");
299 button.
id = BUTTON_ID;
301 button.
child_ids = {BUTTON_IMG_ID, BUTTON_TEXT_ID};
304 button_img.
id = BUTTON_IMG_ID;
308 button_text.
id = BUTTON_TEXT_ID;
313 dialog_detail.
id = DIALOG_DETAIL_ID;
315 dialog_detail.
SetName(
"Some more detail about dialog.");
320 update.tree_data = tree_data;
321 update.has_tree_data =
true;
323 update.nodes = {
root, dialog, dialog_label, dialog_description,
324 button, button_img, button_text, dialog_detail};
328 AXNode* root_node = GetRootAsAXNode();
330 AXPlatformNodeWin* owner =
331 static_cast<AXPlatformNodeWin*
>(AXPlatformNodeFromNode(root_node));
334 ComPtr<IRawElementProviderSimple> root_node_raw =
335 QueryInterfaceFromNode<IRawElementProviderSimple>(root_node);
336 ComPtr<IRawElementProviderSimple> dialog_node_raw =
337 QueryInterfaceFromNode<IRawElementProviderSimple>(dialog_node);
340 ComPtr<ITextProvider> text_provider;
341 EXPECT_HRESULT_SUCCEEDED(
342 root_node_raw->GetPatternProvider(UIA_TextPatternId, &text_provider));
344 ComPtr<ITextRangeProvider> text_range_provider;
345 EXPECT_HRESULT_SUCCEEDED(text_provider->RangeFromChild(dialog_node_raw.Get(),
346 &text_range_provider));
347 SetOwner(owner, text_range_provider.Get());
350 EXPECT_HRESULT_SUCCEEDED(
351 text_range_provider->GetText(-1, text_content.
Receive()));
353 u
"Dialog label.Dialog description." + kEmbeddedCharacterAsString +
354 u
"ok.Some more detail " + u
"about dialog.");
358 ComPtr<IRawElementProviderSimple> enclosing_element;
359 EXPECT_HRESULT_SUCCEEDED(
360 text_range_provider->GetEnclosingElement(&enclosing_element));
361 EXPECT_EQ(enclosing_element.Get(), dialog_node_raw.Get());
379 Init(root_data, text_data);
381 AXNode* root_node = GetRootAsAXNode();
384 struct NearestTextIndexTestData {
386 struct point_offset_expected_index_pair {
390 std::vector<point_offset_expected_index_pair> test_data;
392 NearestTextIndexTestData nodes[] = {
394 {{0, 0}, {2, 0}, {3, 1}, {4, 1}, {5, 2}, {8, 2}, {9, 3}, {10, 3}}},
396 {{0, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {8, 0}, {9, 0}, {10, 0}}}};
397 for (
auto data : nodes) {
398 if (!
data.node->IsText() && !
data.node->data().IsTextField()) {
401 ComPtr<IRawElementProviderSimple> element_provider =
402 QueryInterfaceFromNode<IRawElementProviderSimple>(
data.node);
403 ComPtr<ITextProvider> text_provider;
404 EXPECT_HRESULT_SUCCEEDED(element_provider->GetPatternProvider(
405 UIA_TextPatternId, &text_provider));
407 ComPtr<AXPlatformNodeTextProviderWin> platform_text_provider;
408 EXPECT_HRESULT_SUCCEEDED(
409 text_provider->QueryInterface(IID_PPV_ARGS(&platform_text_provider)));
411 ComPtr<AXPlatformNodeWin> platform_node;
412 EXPECT_HRESULT_SUCCEEDED(
413 element_provider->QueryInterface(IID_PPV_ARGS(&platform_node)));
415 for (
auto pair :
data.test_data) {
416 EXPECT_EQ(pair.expected_index, platform_node->NearestTextIndexToPoint(
426 text_data.
SetName(
"some text");
434 Init(root_data, text_data);
436 ComPtr<IRawElementProviderSimple> root_node =
437 GetRootIRawElementProviderSimple();
439 ComPtr<ITextProvider> text_provider;
440 EXPECT_HRESULT_SUCCEEDED(
441 root_node->GetPatternProvider(UIA_TextPatternId, &text_provider));
443 ComPtr<ITextRangeProvider> text_range_provider;
444 EXPECT_HRESULT_SUCCEEDED(
445 text_provider->get_DocumentRange(&text_range_provider));
449 DISABLED_ITextProviderDocumentRangeTrailingIgnored) {
471 static_text_3.
id = 3;
474 static_text_6.
id = 6;
477 static_text_9_ignored.
id = 9;
489 static_text_3.
SetName(
"Hello");
507 gc_8_ignored.
child_ids = {static_text_9_ignored.
id};
511 static_text_9_ignored.
SetName(
"ignored");
517 update.tree_data = tree_data;
518 update.has_tree_data =
true;
520 update.nodes = {root_1, gc_2, static_text_3,
521 gc_4, gc_5, static_text_6,
522 gc_7_ignored, gc_8_ignored, static_text_9_ignored};
526 ComPtr<IRawElementProviderSimple> root_node =
527 GetRootIRawElementProviderSimple();
529 ComPtr<ITextProvider> text_provider;
530 EXPECT_HRESULT_SUCCEEDED(
531 root_node->GetPatternProvider(UIA_TextPatternId, &text_provider));
533 ComPtr<ITextRangeProvider> text_range_provider;
534 EXPECT_HRESULT_SUCCEEDED(
535 text_provider->get_DocumentRange(&text_range_provider));
537 ComPtr<AXPlatformNodeTextRangeProviderWin> text_range;
538 text_range_provider->QueryInterface(IID_PPV_ARGS(&text_range));
540 ComPtr<ITextProvider> root_text_provider;
541 EXPECT_HRESULT_SUCCEEDED(
542 root_node->GetPatternProvider(UIA_TextPatternId, &root_text_provider));
543 ComPtr<AXPlatformNodeTextProviderWin> root_platform_node;
544 root_text_provider->QueryInterface(IID_PPV_ARGS(&root_platform_node));
545 AXPlatformNodeWin* owner = GetOwner(root_platform_node.Get());
548 owner->GetDelegate()->CreateTextPositionAt(0)->AsLeafTextPosition();
551 ->CreateTextPositionAt(0)
552 ->CreatePositionAtEndOfAnchor();
553 expected_end = expected_end->AsLeafTextPosition();
554 EXPECT_EQ(*GetStart(text_range.Get()), *expected_start);
555 EXPECT_EQ(*GetEnd(text_range.Get()), *expected_end);
562 text_data.
SetName(
"some text");
565 paragraph_data.
id = 2;
575 Init(root_data, paragraph_data, text_data);
577 ComPtr<IRawElementProviderSimple> root_node =
578 GetRootIRawElementProviderSimple();
580 ComPtr<ITextProvider> text_provider;
581 EXPECT_HRESULT_SUCCEEDED(
582 root_node->GetPatternProvider(UIA_TextPatternId, &text_provider));
584 ComPtr<ITextRangeProvider> text_range_provider;
585 EXPECT_HRESULT_SUCCEEDED(
586 text_provider->get_DocumentRange(&text_range_provider));
593 text_data.
SetName(
"some text");
601 Init(root_data, text_data);
603 ComPtr<IRawElementProviderSimple> root_node =
604 GetRootIRawElementProviderSimple();
606 ComPtr<ITextProvider> text_provider;
607 EXPECT_HRESULT_SUCCEEDED(
608 root_node->GetPatternProvider(UIA_TextPatternId, &text_provider));
610 SupportedTextSelection text_selection_mode;
611 EXPECT_HRESULT_SUCCEEDED(
612 text_provider->get_SupportedTextSelection(&text_selection_mode));
613 EXPECT_EQ(text_selection_mode, SupportedTextSelection_Single);
620 text_data.
SetName(
"some text");
625 textbox_data.
SetName(
"textbox text");
629 nonatomic_textfield_data.
id = 4;
631 nonatomic_textfield_data.
child_ids = {5};
634 text_child_data.
id = 5;
636 text_child_data.
SetName(
"text");
647 update.tree_data = tree_data;
648 update.has_tree_data =
true;
650 update.nodes = {root_data, text_data, textbox_data, nonatomic_textfield_data,
654 ComPtr<IRawElementProviderSimple> root_node =
655 GetRootIRawElementProviderSimple();
657 ComPtr<ITextProvider> root_text_provider;
658 EXPECT_HRESULT_SUCCEEDED(
659 root_node->GetPatternProvider(UIA_TextPatternId, &root_text_provider));
662 root_text_provider->GetSelection(selections.
Receive());
663 ASSERT_EQ(
nullptr, selections.
Get());
665 ComPtr<AXPlatformNodeTextProviderWin> root_platform_node;
666 root_text_provider->QueryInterface(IID_PPV_ARGS(&root_platform_node));
668 AXPlatformNodeWin* owner = GetOwner(root_platform_node.Get());
670 const_cast<AXTreeData&
>(owner->GetDelegate()->GetTreeData());
676 root_text_provider->GetSelection(selections.
Receive());
677 ASSERT_NE(
nullptr, selections.
Get());
680 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetUBound(selections.
Get(), 1, &ubound));
681 EXPECT_EQ(0, ubound);
683 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetLBound(selections.
Get(), 1, &lbound));
684 EXPECT_EQ(0, lbound);
687 ComPtr<ITextRangeProvider> text_range_provider;
688 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetElement(
689 selections.
Get(), &index,
static_cast<void**
>(&text_range_provider)));
690 SetOwner(owner, text_range_provider.Get());
693 EXPECT_HRESULT_SUCCEEDED(
694 text_range_provider->GetText(-1, text_content.
Receive()));
695 EXPECT_EQ(0, wcscmp(text_content.
Get(),
L"some"));
696 text_content.
Reset();
698 text_range_provider.Reset();
707 root_text_provider->GetSelection(selections.
Receive());
708 ASSERT_NE(
nullptr, selections.
Get());
710 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetUBound(selections.
Get(), 1, &ubound));
711 EXPECT_EQ(0, ubound);
712 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetLBound(selections.
Get(), 1, &lbound));
713 EXPECT_EQ(0, lbound);
715 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetElement(
716 selections.
Get(), &index,
static_cast<void**
>(&text_range_provider)));
717 SetOwner(owner, text_range_provider.Get());
719 EXPECT_HRESULT_SUCCEEDED(
720 text_range_provider->GetText(-1, text_content.
Receive()));
721 EXPECT_EQ(0, wcscmp(text_content.
Get(),
L"some"));
722 text_content.
Reset();
724 text_range_provider.Reset();
735 ComPtr<IRawElementProviderSimple> text_edit_com =
736 QueryInterfaceFromNode<IRawElementProviderSimple>(text_edit_node);
738 ComPtr<ITextProvider> text_edit_provider;
739 EXPECT_HRESULT_SUCCEEDED(text_edit_com->GetPatternProvider(
740 UIA_TextPatternId, &text_edit_provider));
743 EXPECT_HRESULT_SUCCEEDED(
744 text_edit_provider->GetSelection(selections.
Receive()));
745 EXPECT_NE(
nullptr, selections.
Get());
747 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetUBound(selections.
Get(), 1, &ubound));
748 EXPECT_EQ(0, ubound);
749 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetLBound(selections.
Get(), 1, &lbound));
750 EXPECT_EQ(0, lbound);
752 ComPtr<ITextRangeProvider> text_edit_range_provider;
753 EXPECT_HRESULT_SUCCEEDED(
754 SafeArrayGetElement(selections.
Get(), &index,
755 static_cast<void**
>(&text_edit_range_provider)));
756 SetOwner(owner, text_edit_range_provider.Get());
757 EXPECT_HRESULT_SUCCEEDED(
758 text_edit_range_provider->GetText(-1, text_content.
Receive()));
759 EXPECT_EQ(0
U, text_content.
Length());
760 text_content.
Reset();
762 text_edit_range_provider.Reset();
770 root_text_provider->GetSelection(selections.
Receive());
771 ASSERT_NE(
nullptr, selections.
Get());
773 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetUBound(selections.
Get(), 1, &ubound));
774 EXPECT_EQ(0, ubound);
775 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetLBound(selections.
Get(), 1, &lbound));
776 EXPECT_EQ(0, lbound);
778 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetElement(
779 selections.
Get(), &index,
static_cast<void**
>(&text_range_provider)));
781 SetOwner(owner, text_range_provider.Get());
782 EXPECT_HRESULT_SUCCEEDED(
783 text_range_provider->GetText(-1, text_content.
Receive()));
784 EXPECT_EQ(0, wcscmp(text_content.
Get(),
L"some texttextbox text"));
785 text_content.
Reset();
787 text_range_provider.Reset();
795 root_text_provider->GetSelection(selections.
Receive());
796 ASSERT_NE(
nullptr, selections.
Get());
798 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetUBound(selections.
Get(), 1, &ubound));
799 EXPECT_EQ(0, ubound);
800 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetLBound(selections.
Get(), 1, &lbound));
801 EXPECT_EQ(0, lbound);
803 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetElement(
804 selections.
Get(), &index,
static_cast<void**
>(&text_range_provider)));
806 SetOwner(owner, text_range_provider.Get());
807 EXPECT_HRESULT_SUCCEEDED(
808 text_range_provider->GetText(-1, text_content.
Receive()));
809 EXPECT_EQ(0, wcscmp(text_content.
Get(),
L""));
810 text_content.
Reset();
812 text_range_provider.Reset();
822 EXPECT_EQ(
static_cast<HRESULT
>(UIA_E_ELEMENTNOTAVAILABLE),
823 text_edit_provider->GetSelection(selections.
Receive()));
830 text_data.
SetName(
"some text");
841 update.tree_data = tree_data;
842 update.has_tree_data =
true;
844 update.nodes.push_back(root_data);
845 update.nodes.push_back(text_data);
848 ComPtr<IRawElementProviderSimple> root_node =
849 GetRootIRawElementProviderSimple();
851 ComPtr<ITextProvider> root_text_provider;
852 EXPECT_HRESULT_SUCCEEDED(
853 root_node->GetPatternProvider(UIA_TextPatternId, &root_text_provider));
855 ComPtr<ITextEditProvider> root_text_edit_provider;
856 EXPECT_HRESULT_SUCCEEDED(root_node->GetPatternProvider(
857 UIA_TextEditPatternId, &root_text_edit_provider));
859 ComPtr<ITextRangeProvider> text_range_provider;
860 root_text_edit_provider->GetActiveComposition(&text_range_provider);
861 ASSERT_EQ(
nullptr, text_range_provider);
863 ComPtr<AXPlatformNodeTextProviderWin> root_platform_node;
864 root_text_provider->QueryInterface(IID_PPV_ARGS(&root_platform_node));
869 AXPlatformNodeWin* owner = GetOwner(root_platform_node.Get());
870 owner->GetDelegate()->AccessibilityPerformAction(action_data);
871 const std::u16string active_composition_text = u
"a";
872 owner->OnActiveComposition(
gfx::Range(0, 1), active_composition_text,
false);
874 root_text_edit_provider->GetActiveComposition(&text_range_provider);
875 ASSERT_NE(
nullptr, text_range_provider);
876 ComPtr<AXPlatformNodeTextRangeProviderWin> actual_range;
878 owner->GetDelegate()->CreateTextPositionAt(0);
880 owner->GetDelegate()->CreateTextPositionAt(1);
881 text_range_provider->QueryInterface(IID_PPV_ARGS(&actual_range));
882 EXPECT_EQ(*GetStart(actual_range.Get()), *expected_start);
883 EXPECT_EQ(*GetEnd(actual_range.Get()), *expected_end);
890 text_data.
SetName(
"some text");
901 update.tree_data = tree_data;
902 update.has_tree_data =
true;
904 update.nodes.push_back(root_data);
905 update.nodes.push_back(text_data);
908 ComPtr<IRawElementProviderSimple> root_node =
909 GetRootIRawElementProviderSimple();
911 ComPtr<ITextProvider> root_text_provider;
912 EXPECT_HRESULT_SUCCEEDED(
913 root_node->GetPatternProvider(UIA_TextPatternId, &root_text_provider));
915 ComPtr<ITextEditProvider> root_text_edit_provider;
916 EXPECT_HRESULT_SUCCEEDED(root_node->GetPatternProvider(
917 UIA_TextEditPatternId, &root_text_edit_provider));
919 ComPtr<ITextRangeProvider> text_range_provider;
920 root_text_edit_provider->GetConversionTarget(&text_range_provider);
921 ASSERT_EQ(
nullptr, text_range_provider);
923 ComPtr<AXPlatformNodeTextProviderWin> root_platform_node;
924 root_text_provider->QueryInterface(IID_PPV_ARGS(&root_platform_node));
929 AXPlatformNodeWin* owner = GetOwner(root_platform_node.Get());
930 owner->GetDelegate()->AccessibilityPerformAction(action_data);
931 const std::u16string active_composition_text = u
"a";
932 owner->OnActiveComposition(
gfx::Range(0, 1), active_composition_text,
false);
934 root_text_edit_provider->GetConversionTarget(&text_range_provider);
935 ASSERT_NE(
nullptr, text_range_provider);
936 ComPtr<AXPlatformNodeTextRangeProviderWin> actual_range;
938 owner->GetDelegate()->CreateTextPositionAt(0);
940 owner->GetDelegate()->CreateTextPositionAt(1);
941 text_range_provider->QueryInterface(IID_PPV_ARGS(&actual_range));
942 EXPECT_EQ(*GetStart(actual_range.Get()), *expected_start);
943 EXPECT_EQ(*GetEnd(actual_range.Get()), *expected_end);
#define EXPECT_UIA_INVALIDOPERATION(expr)
#define EXPECT_INVALIDARG(expr)
void Reset(BSTR bstr=nullptr)
void Reset(SAFEARRAY *safearray=nullptr)
const std::vector< AXNode * > & children() const
const AXNodePosition::AXPositionInstance & GetEnd(const AXPlatformNodeTextRangeProviderWin *text_range)
AXPlatformNodeTextProviderTest & operator=(const AXPlatformNodeTextProviderTest &)=delete
AXPlatformNodeTextProviderTest()=default
~AXPlatformNodeTextProviderTest() override=default
void SetOwner(AXPlatformNodeWin *owner, ITextRangeProvider *destination_range)
AXPlatformNodeTextProviderTest(const AXPlatformNodeTextProviderTest &)=delete
const AXNodePosition::AXPositionInstance & GetStart(const AXPlatformNodeTextRangeProviderWin *text_range)
AXPlatformNodeWin * GetOwner(const AXPlatformNodeTextProviderWin *text_provider)
std::unique_ptr< AXPosition< AXNodePosition, AXNode > > AXPositionInstance
static AXTreeID CreateNewAXTreeID()
static HRESULT CreateMockIRawElementProviderSimple(IRawElementProviderSimple **provider)
std::u16string WideStringToUtf16(const std::wstring_view str)
TEST_F(AXPositionTest, Clone)
AXRelativeBounds relative_bounds
void AddIntListAttribute(ax::mojom::IntListAttribute attribute, const std::vector< int32_t > &value)
void AddState(ax::mojom::State state)
std::vector< int32_t > child_ids
void SetName(const std::string &name)
AXNode::AXID sel_anchor_object_id
AXNode::AXID sel_focus_object_id
int32_t sel_anchor_offset
std::shared_ptr< const fml::Mapping > data
#define BASE_DCHECK(condition)