Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
ui::AXPlatformNodeTextRangeProviderTest Class Reference
Inheritance diagram for ui::AXPlatformNodeTextRangeProviderTest:
ui::AXPlatformNodeWinTest ui::AXPlatformNodeTest ui::TestAXTreeManager ui::AXTreeManager

Public Member Functions

const AXNodePosition::AXPositionInstanceGetStart (const AXPlatformNodeTextRangeProviderWin *text_range)
 
const AXNodePosition::AXPositionInstanceGetEnd (const AXPlatformNodeTextRangeProviderWin *text_range)
 
ui::AXPlatformNodeWin * GetOwner (const AXPlatformNodeTextRangeProviderWin *text_range)
 
void CopyOwnerToClone (ITextRangeProvider *source_range, ITextRangeProvider *destination_range)
 
void SetOwner (AXPlatformNodeWin *owner, ITextRangeProvider *destination_range)
 
void NormalizeTextRange (AXPlatformNodeTextRangeProviderWin *text_range, AXNodePosition::AXPositionInstance &start, AXNodePosition::AXPositionInstance &end)
 
void GetTextRangeProviderFromTextNode (ComPtr< ITextRangeProvider > &text_range_provider, ui::AXNode *text_node)
 
void CreateTextRangeProviderWin (ComPtr< AXPlatformNodeTextRangeProviderWin > &text_range_provider_win, AXPlatformNodeWin *owner, const AXNode *start_anchor, int start_offset, ax::mojom::TextAffinity start_affinity, const AXNode *end_anchor, int end_offset, ax::mojom::TextAffinity end_affinity)
 
void ComputeWordBoundariesOffsets (const std::string &text, std::vector< int > &word_start_offsets, std::vector< int > &word_end_offsets)
 
AXTreeUpdate BuildTextDocument (const std::vector< std::string > &text_nodes_content, bool build_word_boundaries_offsets=false, bool place_text_on_one_line=false)
 
ui::AXTreeUpdate BuildAXTreeForBoundingRectangles ()
 
ui::AXTreeUpdate BuildAXTreeForMove ()
 
AXTreeUpdate BuildAXTreeForMoveByFormat ()
 
void ExpectPositionsEqual (const AXNodePosition::AXPositionInstance &a, const AXNodePosition::AXPositionInstance &b)
 
- Public Member Functions inherited from ui::AXPlatformNodeWinTest
 AXPlatformNodeWinTest ()
 
 ~AXPlatformNodeWinTest () override
 
void SetUp () override
 
void TearDown () override
 
template<typename T >
ComPtr< TQueryInterfaceFromNodeId (AXNode::AXID id)
 
template<typename T >
ComPtr< TQueryInterfaceFromNode (AXNode *node)
 
- Public Member Functions inherited from ui::AXPlatformNodeTest
 AXPlatformNodeTest ()
 
 ~AXPlatformNodeTest () override
 
 AXPlatformNodeTest (const AXPlatformNodeTest &)=delete
 
AXPlatformNodeTestoperator= (const AXPlatformNodeTest &)=delete
 
- Public Member Functions inherited from ui::TestAXTreeManager
 TestAXTreeManager ()
 
 TestAXTreeManager (std::unique_ptr< AXTree > tree)
 
virtual ~TestAXTreeManager ()
 
 TestAXTreeManager (const TestAXTreeManager &manager)=delete
 
TestAXTreeManageroperator= (const TestAXTreeManager &manager)=delete
 
void DestroyTree ()
 
AXTreeGetTree () const
 
void SetTree (std::unique_ptr< AXTree > tree)
 
AXNodeGetNodeFromTree (const AXTreeID tree_id, const AXNode::AXID node_id) const override
 
AXNodeGetNodeFromTree (const AXNode::AXID node_id) const override
 
AXTreeID GetTreeID () const override
 
AXTreeID GetParentTreeID () const override
 
AXNodeGetRootAsAXNode () const override
 
AXNodeGetParentNodeFromParentTreeAsAXNode () const override
 
- Public Member Functions inherited from ui::AXTreeManager
virtual ~AXTreeManager ()=default
 

Public Attributes

const std::wstring tree_for_move_full_text
 

Additional Inherited Members

- Protected Types inherited from ui::AXPlatformNodeWinTest
using PatternSet = std::unordered_set< LONG >
 
- Protected Member Functions inherited from ui::AXPlatformNodeWinTest
AXPlatformNodeAXPlatformNodeFromNode (AXNode *node)
 
template<typename T >
Microsoft::WRL::ComPtr< TQueryInterfaceFromNodeId (AXNode::AXID id)
 
template<typename T >
Microsoft::WRL::ComPtr< TQueryInterfaceFromNode (AXNode *node)
 
Microsoft::WRL::ComPtr< IRawElementProviderSimple > GetRootIRawElementProviderSimple ()
 
Microsoft::WRL::ComPtr< IRawElementProviderSimple > GetIRawElementProviderSimpleFromChildIndex (int child_index)
 
Microsoft::WRL::ComPtr< IRawElementProviderSimple > GetIRawElementProviderSimpleFromTree (const ui::AXTreeID tree_id, const AXNode::AXID node_id)
 
Microsoft::WRL::ComPtr< IRawElementProviderFragment > GetRootIRawElementProviderFragment ()
 
Microsoft::WRL::ComPtr< IRawElementProviderFragment > IRawElementProviderFragmentFromNode (AXNode *node)
 
Microsoft::WRL::ComPtr< IAccessible > IAccessibleFromNode (AXNode *node)
 
Microsoft::WRL::ComPtr< IAccessible > GetRootIAccessible ()
 
void CheckVariantHasName (const base::win::ScopedVariant &variant, const wchar_t *expected_name)
 
void CheckIUnknownHasName (Microsoft::WRL::ComPtr< IUnknown > unknown, const wchar_t *expected_name)
 
Microsoft::WRL::ComPtr< IAccessibleTableCell > GetCellInTable ()
 
void InitFragmentRoot ()
 
AXFragmentRootWinInitNodeAsFragmentRoot (AXNode *node, TestFragmentRootDelegate *delegate)
 
Microsoft::WRL::ComPtr< IRawElementProviderFragmentRoot > GetFragmentRoot ()
 
PatternSet GetSupportedPatternsFromNodeId (AXNode::AXID id)
 
- Protected Member Functions inherited from ui::AXPlatformNodeTest
void Init (const AXTreeUpdate &initial_state)
 
void Init (const ui::AXNodeData &node1, const ui::AXNodeData &node2=ui::AXNodeData(), const ui::AXNodeData &node3=ui::AXNodeData(), const ui::AXNodeData &node4=ui::AXNodeData(), const ui::AXNodeData &node5=ui::AXNodeData(), const ui::AXNodeData &node6=ui::AXNodeData(), const ui::AXNodeData &node7=ui::AXNodeData(), const ui::AXNodeData &node8=ui::AXNodeData(), const ui::AXNodeData &node9=ui::AXNodeData(), const ui::AXNodeData &node10=ui::AXNodeData(), const ui::AXNodeData &node11=ui::AXNodeData(), const ui::AXNodeData &node12=ui::AXNodeData())
 
AXTreeUpdate BuildTextField ()
 
AXTreeUpdate BuildTextFieldWithSelectionRange (int32_t start, int32_t stop)
 
AXTreeUpdate BuildContentEditable ()
 
AXTreeUpdate BuildContentEditableWithSelectionRange (int32_t start, int32_t end)
 
AXTreeUpdate Build3X3Table ()
 
AXTreeUpdate BuildAriaColumnAndRowCountGrids ()
 
AXTreeUpdate BuildListBox (bool option_1_is_selected, bool option_2_is_selected, bool option_3_is_selected, const std::vector< ax::mojom::State > &additional_state)
 
- Protected Attributes inherited from ui::AXPlatformNodeWinTest
std::unique_ptr< AXFragmentRootWinax_fragment_root_
 
std::unique_ptr< TestFragmentRootDelegatetest_fragment_root_delegate_
 
- Static Protected Attributes inherited from ui::AXPlatformNodeWinTest
static const std::u16string kEmbeddedCharacterAsString
 

Detailed Description

Definition at line 233 of file ax_platform_node_textrangeprovider_win_unittest.cc.

Member Function Documentation

◆ BuildAXTreeForBoundingRectangles()

ui::AXTreeUpdate ui::AXPlatformNodeTextRangeProviderTest::BuildAXTreeForBoundingRectangles ( )
inline

Definition at line 408 of file ax_platform_node_textrangeprovider_win_unittest.cc.

408 {
409 // AXTree content:
410 // <button>Button</button><input type="checkbox">Line 1<br>Line 2
412 ui::AXNodeData button;
413 ui::AXNodeData check_box;
414 ui::AXNodeData text_field;
415 ui::AXNodeData static_text1;
416 ui::AXNodeData line_break;
417 ui::AXNodeData static_text2;
418 ui::AXNodeData inline_box1;
419 ui::AXNodeData inline_box2;
420 ui::AXNodeData inline_box_line_break;
421
422 const int ROOT_ID = 1;
423 const int BUTTON_ID = 2;
424 const int CHECK_BOX_ID = 3;
425 const int TEXT_FIELD_ID = 4;
426 const int STATIC_TEXT1_ID = 5;
427 const int INLINE_BOX1_ID = 6;
428 const int LINE_BREAK_ID = 7;
429 const int INLINE_BOX_LINE_BREAK_ID = 8;
430 const int STATIC_TEXT2_ID = 9;
431 const int INLINE_BOX2_ID = 10;
432
433 root.id = ROOT_ID;
434 button.id = BUTTON_ID;
435 check_box.id = CHECK_BOX_ID;
436 text_field.id = TEXT_FIELD_ID;
437 static_text1.id = STATIC_TEXT1_ID;
438 inline_box1.id = INLINE_BOX1_ID;
439 line_break.id = LINE_BREAK_ID;
440 inline_box_line_break.id = INLINE_BOX_LINE_BREAK_ID;
441 static_text2.id = STATIC_TEXT2_ID;
442 inline_box2.id = INLINE_BOX2_ID;
443
444 std::string LINE_1_TEXT = "Line 1";
445 std::string LINE_2_TEXT = "Line 2";
446 std::string LINE_BREAK_TEXT = "\n";
447 std::string ALL_TEXT = LINE_1_TEXT + LINE_BREAK_TEXT + LINE_2_TEXT;
448 std::string BUTTON_TEXT = "Button";
449 std::string CHECKBOX_TEXT = "Check box";
450
452
455 button.SetName(BUTTON_TEXT);
456 button.SetValue(BUTTON_TEXT);
457 button.relative_bounds.bounds = gfx::RectF(20, 20, 200, 30);
459 check_box.id);
460 root.child_ids.push_back(button.id);
461
464 check_box.SetName(CHECKBOX_TEXT);
465 check_box.relative_bounds.bounds = gfx::RectF(20, 50, 200, 30);
467 button.id);
468 root.child_ids.push_back(check_box.id);
469
473 "input");
475 "text");
476 text_field.SetValue(ALL_TEXT);
477 text_field.AddIntListAttribute(
479 std::vector<int32_t>{0, 7});
480 text_field.child_ids.push_back(static_text1.id);
481 text_field.child_ids.push_back(line_break.id);
482 text_field.child_ids.push_back(static_text2.id);
483 root.child_ids.push_back(text_field.id);
484
485 static_text1.role = ax::mojom::Role::kStaticText;
487 static_text1.SetName(LINE_1_TEXT);
488 static_text1.child_ids.push_back(inline_box1.id);
489
492 inline_box1.SetName(LINE_1_TEXT);
493 inline_box1.relative_bounds.bounds = gfx::RectF(220, 20, 100, 30);
494 std::vector<int32_t> character_offsets1;
495 // The width of each character is 5px.
496 character_offsets1.push_back(225); // "L" {220, 20, 5x30}
497 character_offsets1.push_back(230); // "i" {225, 20, 5x30}
498 character_offsets1.push_back(235); // "n" {230, 20, 5x30}
499 character_offsets1.push_back(240); // "e" {235, 20, 5x30}
500 character_offsets1.push_back(245); // " " {240, 20, 5x30}
501 character_offsets1.push_back(250); // "1" {245, 20, 5x30}
502 inline_box1.AddIntListAttribute(
505 std::vector<int32_t>{0, 5});
507 std::vector<int32_t>{4, 6});
509 line_break.id);
510
513 line_break.SetName(LINE_BREAK_TEXT);
514 line_break.relative_bounds.bounds = gfx::RectF(250, 20, 0, 30);
516 inline_box1.id);
517 line_break.child_ids.push_back(inline_box_line_break.id);
518
519 inline_box_line_break.role = ax::mojom::Role::kInlineTextBox;
520 inline_box_line_break.AddBoolAttribute(
522 inline_box_line_break.SetName(LINE_BREAK_TEXT);
523 inline_box_line_break.relative_bounds.bounds = gfx::RectF(250, 20, 0, 30);
524 inline_box_line_break.AddIntListAttribute(
526 inline_box_line_break.AddIntListAttribute(
527 ax::mojom::IntListAttribute::kWordStarts, std::vector<int32_t>{0});
528 inline_box_line_break.AddIntListAttribute(
529 ax::mojom::IntListAttribute::kWordEnds, std::vector<int32_t>{0});
530
531 static_text2.role = ax::mojom::Role::kStaticText;
533 static_text2.SetName(LINE_2_TEXT);
534 static_text2.child_ids.push_back(inline_box2.id);
535
538 inline_box2.SetName(LINE_2_TEXT);
539 inline_box2.relative_bounds.bounds = gfx::RectF(220, 50, 100, 30);
540 std::vector<int32_t> character_offsets2;
541 // The width of each character is 7 px.
542 character_offsets2.push_back(227); // "L" {220, 50, 7x30}
543 character_offsets2.push_back(234); // "i" {227, 50, 7x30}
544 character_offsets2.push_back(241); // "n" {234, 50, 7x30}
545 character_offsets2.push_back(248); // "e" {241, 50, 7x30}
546 character_offsets2.push_back(255); // " " {248, 50, 7x30}
547 character_offsets2.push_back(262); // "2" {255, 50, 7x30}
548 inline_box2.AddIntListAttribute(
551 std::vector<int32_t>{0, 5});
553 std::vector<int32_t>{4, 6});
554
556 update.has_tree_data = true;
557 update.root_id = ROOT_ID;
558 update.nodes = {
559 root, button, check_box, text_field,
560 static_text1, inline_box1, line_break, inline_box_line_break,
561 static_text2, inline_box2};
562 update.tree_data.tree_id = ui::AXTreeID::CreateNewAXTreeID();
563 return update;
564 }
static AXTreeID CreateNewAXTreeID()
Definition ax_tree_id.cc:47
AXTreeUpdateBase< AXNodeData, AXTreeData > AXTreeUpdate
AXRelativeBounds relative_bounds
void AddIntListAttribute(ax::mojom::IntListAttribute attribute, const std::vector< int32_t > &value)
void AddState(ax::mojom::State state)
void AddIntAttribute(ax::mojom::IntAttribute attribute, int32_t value)
std::vector< int32_t > child_ids
void SetValue(const std::string &value)
void SetHasPopup(ax::mojom::HasPopup has_popup)
void SetName(const std::string &name)
void AddStringAttribute(ax::mojom::StringAttribute attribute, const std::string &value)
void AddBoolAttribute(ax::mojom::BoolAttribute attribute, bool value)
ax::mojom::Role role
void SetCheckedState(ax::mojom::CheckedState checked_state)

◆ BuildAXTreeForMove()

ui::AXTreeUpdate ui::AXPlatformNodeTextRangeProviderTest::BuildAXTreeForMove ( )
inline

Definition at line 570 of file ax_platform_node_textrangeprovider_win_unittest.cc.

570 {
571 ui::AXNodeData group1_data;
572 group1_data.id = 2;
574 group1_data.AddBoolAttribute(
576
577 ui::AXNodeData text_data;
578 text_data.id = 3;
580 std::string text_content = "First line of text";
581 text_data.SetName(text_content);
582 std::vector<int> word_end_offsets;
583 std::vector<int> word_start_offsets;
584 ComputeWordBoundariesOffsets(text_content, word_start_offsets,
585 word_end_offsets);
587 word_start_offsets);
589 word_end_offsets);
590 group1_data.child_ids = {text_data.id};
591
592 ui::AXNodeData group2_data;
593 group2_data.id = 4;
595
596 ui::AXNodeData line_break1_data;
597 line_break1_data.id = 5;
598 line_break1_data.role = ax::mojom::Role::kLineBreak;
599 line_break1_data.AddBoolAttribute(
601 line_break1_data.SetName("\n");
602
603 ui::AXNodeData standalone_text_data;
604 standalone_text_data.id = 6;
605 standalone_text_data.role = ax::mojom::Role::kStaticText;
606 text_content = "Standalone line";
607 standalone_text_data.SetName(text_content);
608 ComputeWordBoundariesOffsets(text_content, word_start_offsets,
609 word_end_offsets);
610 standalone_text_data.AddIntListAttribute(
611 ax::mojom::IntListAttribute::kWordStarts, word_start_offsets);
612 standalone_text_data.AddIntListAttribute(
614
615 ui::AXNodeData line_break2_data;
616 line_break2_data.id = 7;
617 line_break2_data.role = ax::mojom::Role::kLineBreak;
618 line_break2_data.AddBoolAttribute(
620 line_break2_data.SetName("\n");
621
622 group2_data.child_ids = {line_break1_data.id, standalone_text_data.id,
623 line_break2_data.id};
625 line_break2_data.id);
627 standalone_text_data.id);
628
629 ui::AXNodeData bold_text_data;
630 bold_text_data.id = 8;
631 bold_text_data.role = ax::mojom::Role::kStaticText;
632 bold_text_data.AddIntAttribute(
634 static_cast<int32_t>(ax::mojom::TextStyle::kBold));
635 text_content = "bold text";
636 bold_text_data.SetName(text_content);
637 ComputeWordBoundariesOffsets(text_content, word_start_offsets,
638 word_end_offsets);
640 word_start_offsets);
642 word_end_offsets);
643
644 ui::AXNodeData paragraph1_data;
645 paragraph1_data.id = 9;
646 paragraph1_data.role = ax::mojom::Role::kParagraph;
647 paragraph1_data.AddBoolAttribute(
649
650 ui::AXNodeData paragraph1_text_data;
651 paragraph1_text_data.id = 10;
652 paragraph1_text_data.role = ax::mojom::Role::kStaticText;
653 text_content = "Paragraph 1";
654 paragraph1_text_data.SetName(text_content);
655 ComputeWordBoundariesOffsets(text_content, word_start_offsets,
656 word_end_offsets);
657 paragraph1_text_data.AddIntListAttribute(
658 ax::mojom::IntListAttribute::kWordStarts, word_start_offsets);
659 paragraph1_text_data.AddIntListAttribute(
661 paragraph1_data.AddBoolAttribute(
663
664 ui::AXNodeData ignored_text_data;
665 ignored_text_data.id = 11;
666 ignored_text_data.role = ax::mojom::Role::kStaticText;
667 ignored_text_data.AddState(ax::mojom::State::kIgnored);
668 text_content = "ignored text";
669 ignored_text_data.SetName(text_content);
670
671 paragraph1_data.child_ids = {paragraph1_text_data.id, ignored_text_data.id};
672
673 ui::AXNodeData paragraph2_data;
674 paragraph2_data.id = 12;
675 paragraph2_data.role = ax::mojom::Role::kParagraph;
676 paragraph2_data.AddBoolAttribute(
678
679 ui::AXNodeData paragraph2_text_data;
680 paragraph2_text_data.id = 13;
681 paragraph2_text_data.role = ax::mojom::Role::kStaticText;
682 text_content = "Paragraph 2";
683 paragraph2_text_data.SetName(text_content);
684 ComputeWordBoundariesOffsets(text_content, word_start_offsets,
685 word_end_offsets);
686 paragraph2_text_data.AddIntListAttribute(
687 ax::mojom::IntListAttribute::kWordStarts, word_start_offsets);
688 paragraph2_text_data.AddIntListAttribute(
690 paragraph1_data.AddBoolAttribute(
692 paragraph2_data.child_ids = {paragraph2_text_data.id};
693
694 ui::AXNodeData root_data;
695 root_data.id = 1;
697 root_data.child_ids = {group1_data.id, group2_data.id, bold_text_data.id,
698 paragraph1_data.id, paragraph2_data.id};
699
701 update.has_tree_data = true;
702 update.root_id = root_data.id;
703 update.nodes = {root_data, group1_data,
704 text_data, group2_data,
705 line_break1_data, standalone_text_data,
706 line_break2_data, bold_text_data,
707 paragraph1_data, paragraph1_text_data,
708 ignored_text_data, paragraph2_data,
709 paragraph2_text_data};
710 update.tree_data.tree_id = ui::AXTreeID::CreateNewAXTreeID();
711 return update;
712 }
void ComputeWordBoundariesOffsets(const std::string &text, std::vector< int > &word_start_offsets, std::vector< int > &word_end_offsets)

◆ BuildAXTreeForMoveByFormat()

AXTreeUpdate ui::AXPlatformNodeTextRangeProviderTest::BuildAXTreeForMoveByFormat ( )
inline

Definition at line 714 of file ax_platform_node_textrangeprovider_win_unittest.cc.

714 {
715 // 1
716 // |
717 // -------------------------------------
718 // | | | | | | |
719 // 2 4 8 10 12 14 16
720 // | | | | | | |
721 // | --------- | | | | |
722 // | | | | | | | | |
723 // 3 5 6 7 9 11 13 15 17
724
725 AXNodeData group1_data;
726 group1_data.id = 2;
727 group1_data.role = ax::mojom::Role::kGenericContainer;
728 group1_data.AddStringAttribute(ax::mojom::StringAttribute::kFontFamily,
729 "test font");
730 group1_data.AddBoolAttribute(
732
733 AXNodeData text_data;
734 text_data.id = 3;
735 text_data.role = ax::mojom::Role::kStaticText;
736 text_data.SetName("Text with formatting");
737 group1_data.child_ids = {text_data.id};
738
739 AXNodeData group2_data;
740 group2_data.id = 4;
741 group2_data.role = ax::mojom::Role::kGenericContainer;
742 group2_data.AddBoolAttribute(
744
745 AXNodeData line_break1_data;
746 line_break1_data.id = 5;
747 line_break1_data.role = ax::mojom::Role::kLineBreak;
748 line_break1_data.SetName("\n");
749
750 AXNodeData standalone_text_data;
751 standalone_text_data.id = 6;
752 standalone_text_data.role = ax::mojom::Role::kStaticText;
753 standalone_text_data.SetName("Standalone line with no formatting");
754
755 AXNodeData line_break2_data;
756 line_break2_data.id = 7;
757 line_break2_data.role = ax::mojom::Role::kLineBreak;
758 line_break2_data.SetName("\n");
759
760 group2_data.child_ids = {line_break1_data.id, standalone_text_data.id,
761 line_break2_data.id};
762
763 AXNodeData group3_data;
764 group3_data.id = 8;
765 group3_data.role = ax::mojom::Role::kGenericContainer;
766 group3_data.AddIntAttribute(
768 static_cast<int32_t>(ax::mojom::TextStyle::kBold));
769 group3_data.AddBoolAttribute(
771
772 AXNodeData bold_text_data;
773 bold_text_data.id = 9;
774 bold_text_data.role = ax::mojom::Role::kStaticText;
775 bold_text_data.SetName("bold text");
776 group3_data.child_ids = {bold_text_data.id};
777
778 AXNodeData paragraph1_data;
779 paragraph1_data.id = 10;
780 paragraph1_data.role = ax::mojom::Role::kParagraph;
781 paragraph1_data.AddIntAttribute(ax::mojom::IntAttribute::kColor, 100);
782 paragraph1_data.AddBoolAttribute(
784
785 AXNodeData paragraph1_text_data;
786 paragraph1_text_data.id = 11;
787 paragraph1_text_data.role = ax::mojom::Role::kStaticText;
788 paragraph1_text_data.SetName("Paragraph 1");
789 paragraph1_data.child_ids = {paragraph1_text_data.id};
790
791 AXNodeData paragraph2_data;
792 paragraph2_data.id = 12;
793 paragraph2_data.role = ax::mojom::Role::kParagraph;
794 paragraph2_data.AddFloatAttribute(ax::mojom::FloatAttribute::kFontSize,
795 1.0f);
796 paragraph2_data.AddBoolAttribute(
798
799 AXNodeData paragraph2_text_data;
800 paragraph2_text_data.id = 13;
801 paragraph2_text_data.role = ax::mojom::Role::kStaticText;
802 paragraph2_text_data.SetName("Paragraph 2");
803 paragraph2_data.child_ids = {paragraph2_text_data.id};
804
805 AXNodeData paragraph3_data;
806 paragraph3_data.id = 14;
807 paragraph3_data.role = ax::mojom::Role::kParagraph;
808 paragraph3_data.AddFloatAttribute(ax::mojom::FloatAttribute::kFontSize,
809 1.0f);
810 paragraph3_data.AddBoolAttribute(
812
813 AXNodeData paragraph3_text_data;
814 paragraph3_text_data.id = 15;
815 paragraph3_text_data.role = ax::mojom::Role::kStaticText;
816 paragraph3_text_data.SetName("Paragraph 3");
817 paragraph3_data.child_ids = {paragraph3_text_data.id};
818
819 AXNodeData paragraph4_data;
820 paragraph4_data.id = 16;
821 paragraph4_data.role = ax::mojom::Role::kParagraph;
822 paragraph4_data.AddFloatAttribute(ax::mojom::FloatAttribute::kFontSize,
823 2.0f);
824 paragraph4_data.AddBoolAttribute(
826
827 AXNodeData paragraph4_text_data;
828 paragraph4_text_data.id = 17;
829 paragraph4_text_data.role = ax::mojom::Role::kStaticText;
830 paragraph4_text_data.SetName("Paragraph 4");
831 paragraph4_data.child_ids = {paragraph4_text_data.id};
832
833 AXNodeData root_data;
834 root_data.id = 1;
835 root_data.role = ax::mojom::Role::kRootWebArea;
836 root_data.child_ids = {group1_data.id, group2_data.id,
837 group3_data.id, paragraph1_data.id,
838 paragraph2_data.id, paragraph3_data.id,
839 paragraph4_data.id};
840
842 update.has_tree_data = true;
843 update.root_id = root_data.id;
844 update.nodes = {root_data,
845 group1_data,
846 text_data,
847 group2_data,
848 line_break1_data,
849 standalone_text_data,
850 line_break2_data,
851 group3_data,
852 bold_text_data,
853 paragraph1_data,
854 paragraph1_text_data,
855 paragraph2_data,
856 paragraph2_text_data,
857 paragraph3_data,
858 paragraph3_text_data,
859 paragraph4_data,
860 paragraph4_text_data};
861 update.tree_data.tree_id = ui::AXTreeID::CreateNewAXTreeID();
862 return update;
863 }

◆ BuildTextDocument()

AXTreeUpdate ui::AXPlatformNodeTextRangeProviderTest::BuildTextDocument ( const std::vector< std::string > &  text_nodes_content,
bool  build_word_boundaries_offsets = false,
bool  place_text_on_one_line = false 
)
inline

Definition at line 350 of file ax_platform_node_textrangeprovider_win_unittest.cc.

353 {
354 int current_id = 0;
355 AXNodeData root_data;
356 root_data.id = ++current_id;
357 root_data.role = ax::mojom::Role::kRootWebArea;
358
360 update.tree_data.tree_id = ui::AXTreeID::CreateNewAXTreeID();
361 update.has_tree_data = true;
362
363 for (const std::string& text_content : text_nodes_content) {
364 AXNodeData static_text_data;
365 static_text_data.id = ++current_id;
366 static_text_data.role = ax::mojom::Role::kStaticText;
367 static_text_data.SetName(text_content);
368 root_data.child_ids.push_back(static_text_data.id);
369
370 AXNodeData inline_box_data;
371 inline_box_data.id = ++current_id;
372 inline_box_data.role = ax::mojom::Role::kInlineTextBox;
373 inline_box_data.SetName(text_content);
374 static_text_data.child_ids = {inline_box_data.id};
375
376 if (build_word_boundaries_offsets) {
377 std::vector<int> word_end_offsets;
378 std::vector<int> word_start_offsets;
379 ComputeWordBoundariesOffsets(text_content, word_start_offsets,
380 word_end_offsets);
381 inline_box_data.AddIntListAttribute(
382 ax::mojom::IntListAttribute::kWordStarts, word_start_offsets);
383 inline_box_data.AddIntListAttribute(
385 }
386
387 if (place_text_on_one_line && !update.nodes.empty()) {
388 AXNodeData* previous_inline_box_data = &update.nodes.back();
389 static_text_data.AddIntAttribute(
391 previous_inline_box_data->id);
392 inline_box_data.AddIntAttribute(
394 previous_inline_box_data->id);
395 previous_inline_box_data->AddIntAttribute(
396 ax::mojom::IntAttribute::kNextOnLineId, inline_box_data.id);
397 }
398
399 update.nodes.push_back(static_text_data);
400 update.nodes.push_back(inline_box_data);
401 }
402
403 update.nodes.insert(update.nodes.begin(), root_data);
404 update.root_id = root_data.id;
405 return update;
406 }

◆ ComputeWordBoundariesOffsets()

void ui::AXPlatformNodeTextRangeProviderTest::ComputeWordBoundariesOffsets ( const std::string &  text,
std::vector< int > &  word_start_offsets,
std::vector< int > &  word_end_offsets 
)
inline

Definition at line 329 of file ax_platform_node_textrangeprovider_win_unittest.cc.

331 {
332 char previous_char = ' ';
333 word_start_offsets = std::vector<int>();
334 for (size_t i = 0; i < text.size(); ++i) {
335 if (previous_char == ' ' && text[i] != ' ')
336 word_start_offsets.push_back(i);
337 previous_char = text[i];
338 }
339
340 previous_char = ' ';
341 word_end_offsets = std::vector<int>();
342 for (size_t i = text.size(); i > 0; --i) {
343 if (previous_char == ' ' && text[i - 1] != ' ')
344 word_end_offsets.push_back(i);
345 previous_char = text[i - 1];
346 }
347 std::reverse(word_end_offsets.begin(), word_end_offsets.end());
348 }
std::u16string text

◆ CopyOwnerToClone()

void ui::AXPlatformNodeTextRangeProviderTest::CopyOwnerToClone ( ITextRangeProvider *  source_range,
ITextRangeProvider *  destination_range 
)
inline

Definition at line 250 of file ax_platform_node_textrangeprovider_win_unittest.cc.

251 {
252 ComPtr<ITextRangeProvider> source_provider = source_range;
253 ComPtr<ITextRangeProvider> destination_provider = destination_range;
254
255 ComPtr<AXPlatformNodeTextRangeProviderWin> source_provider_internal;
256 ComPtr<AXPlatformNodeTextRangeProviderWin> destination_provider_internal;
257
258 source_provider->QueryInterface(IID_PPV_ARGS(&source_provider_internal));
259 destination_provider->QueryInterface(
260 IID_PPV_ARGS(&destination_provider_internal));
261 destination_provider_internal->SetOwnerForTesting(
262 source_provider_internal->GetOwner());
263 }

◆ CreateTextRangeProviderWin()

void ui::AXPlatformNodeTextRangeProviderTest::CreateTextRangeProviderWin ( ComPtr< AXPlatformNodeTextRangeProviderWin > &  text_range_provider_win,
AXPlatformNodeWin *  owner,
const AXNode start_anchor,
int  start_offset,
ax::mojom::TextAffinity  start_affinity,
const AXNode end_anchor,
int  end_offset,
ax::mojom::TextAffinity  end_affinity 
)
inline

Definition at line 308 of file ax_platform_node_textrangeprovider_win_unittest.cc.

316 {
318 CreateTextPosition(*start_anchor, start_offset, start_affinity);
320 CreateTextPosition(*end_anchor, end_offset, end_affinity);
321
322 ComPtr<ITextRangeProvider> text_range_provider =
323 AXPlatformNodeTextRangeProviderWin::CreateTextRangeProviderForTesting(
324 owner, std::move(range_start), std::move(range_end));
325
326 text_range_provider->QueryInterface(IID_PPV_ARGS(&text_range_provider_win));
327 }
std::unique_ptr< AXPosition< AXNodePosition, AXNode > > AXPositionInstance
static AXNodePosition::AXPositionInstance CreateTextPosition(const AXNode &anchor, int text_offset, ax::mojom::TextAffinity affinity)

◆ ExpectPositionsEqual()

void ui::AXPlatformNodeTextRangeProviderTest::ExpectPositionsEqual ( const AXNodePosition::AXPositionInstance a,
const AXNodePosition::AXPositionInstance b 
)
inline

Definition at line 865 of file ax_platform_node_textrangeprovider_win_unittest.cc.

866 {
867 EXPECT_EQ(*a, *b);
868 EXPECT_EQ(a->anchor_id(), b->anchor_id());
869 EXPECT_EQ(a->text_offset(), b->text_offset());
870 }
static bool b
struct MyStruct a[10]

◆ GetEnd()

const AXNodePosition::AXPositionInstance & ui::AXPlatformNodeTextRangeProviderTest::GetEnd ( const AXPlatformNodeTextRangeProviderWin *  text_range)
inline

Definition at line 240 of file ax_platform_node_textrangeprovider_win_unittest.cc.

241 {
242 return text_range->end();
243 }

◆ GetOwner()

ui::AXPlatformNodeWin * ui::AXPlatformNodeTextRangeProviderTest::GetOwner ( const AXPlatformNodeTextRangeProviderWin *  text_range)
inline

Definition at line 245 of file ax_platform_node_textrangeprovider_win_unittest.cc.

246 {
247 return text_range->GetOwner();
248 }

◆ GetStart()

const AXNodePosition::AXPositionInstance & ui::AXPlatformNodeTextRangeProviderTest::GetStart ( const AXPlatformNodeTextRangeProviderWin *  text_range)
inline

Definition at line 235 of file ax_platform_node_textrangeprovider_win_unittest.cc.

236 {
237 return text_range->start();
238 }

◆ GetTextRangeProviderFromTextNode()

void ui::AXPlatformNodeTextRangeProviderTest::GetTextRangeProviderFromTextNode ( ComPtr< ITextRangeProvider > &  text_range_provider,
ui::AXNode text_node 
)
inline

Definition at line 283 of file ax_platform_node_textrangeprovider_win_unittest.cc.

285 {
286 ComPtr<IRawElementProviderSimple> provider_simple =
287 QueryInterfaceFromNode<IRawElementProviderSimple>(text_node);
288 ASSERT_NE(nullptr, provider_simple.Get());
289
290 ComPtr<ITextProvider> text_provider;
291 EXPECT_HRESULT_SUCCEEDED(
292 provider_simple->GetPatternProvider(UIA_TextPatternId, &text_provider));
293 ASSERT_NE(nullptr, text_provider.Get());
294
295 EXPECT_HRESULT_SUCCEEDED(
296 text_provider->get_DocumentRange(&text_range_provider));
297 ASSERT_NE(nullptr, text_range_provider.Get());
298
299 ComPtr<AXPlatformNodeTextRangeProviderWin> text_range_provider_interal;
300 EXPECT_HRESULT_SUCCEEDED(text_range_provider->QueryInterface(
301 IID_PPV_ARGS(&text_range_provider_interal)));
302 AXPlatformNode* ax_platform_node = AXPlatformNodeFromNode(text_node);
303 ASSERT_NE(ax_platform_node, nullptr);
304 text_range_provider_interal->SetOwnerForTesting(
305 static_cast<AXPlatformNodeWin*>(ax_platform_node));
306 }
AXPlatformNode * AXPlatformNodeFromNode(AXNode *node)

◆ NormalizeTextRange()

void ui::AXPlatformNodeTextRangeProviderTest::NormalizeTextRange ( AXPlatformNodeTextRangeProviderWin *  text_range,
AXNodePosition::AXPositionInstance start,
AXNodePosition::AXPositionInstance end 
)
inline

Definition at line 275 of file ax_platform_node_textrangeprovider_win_unittest.cc.

277 {
278 DCHECK_EQ(*GetStart(text_range), *start);
279 DCHECK_EQ(*GetEnd(text_range), *end);
280 text_range->NormalizeTextRange(start, end);
281 }
const AXNodePosition::AXPositionInstance & GetEnd(const AXPlatformNodeTextRangeProviderWin *text_range)
const AXNodePosition::AXPositionInstance & GetStart(const AXPlatformNodeTextRangeProviderWin *text_range)
glong glong end

◆ SetOwner()

void ui::AXPlatformNodeTextRangeProviderTest::SetOwner ( AXPlatformNodeWin *  owner,
ITextRangeProvider *  destination_range 
)
inline

Definition at line 265 of file ax_platform_node_textrangeprovider_win_unittest.cc.

266 {
267 ComPtr<AXPlatformNodeTextRangeProviderWin> destination_provider_internal;
268 auto as =
269 static_cast<AXPlatformNodeTextRangeProviderWin*>(destination_range);
270 destination_range->QueryInterface(
271 IID_PPV_ARGS(&destination_provider_internal));
272 destination_provider_internal->SetOwnerForTesting(owner);
273 }

Member Data Documentation

◆ tree_for_move_full_text

const std::wstring ui::AXPlatformNodeTextRangeProviderTest::tree_for_move_full_text
Initial value:
=
L"First line of text\nStandalone line\n"
L"bold text\nParagraph 1\nParagraph 2"

Definition at line 566 of file ax_platform_node_textrangeprovider_win_unittest.cc.


The documentation for this class was generated from the following file: